Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update openapi types #1174

Merged
merged 1 commit into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@
"lodash.uniqby": "^4.7.0",
"lodash.uniqwith": "^4.5.0",
"micromatch": "^4.0.5",
"openapi-types": "^12.1.3",
"openapi3-ts": "^3.2.0",
"openapi3-ts": "4.2.1",
"swagger2openapi": "^7.0.8"
}
}
2 changes: 1 addition & 1 deletion packages/core/src/generators/component-definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
ReferenceObject,
RequestBodyObject,
ResponseObject,
} from 'openapi3-ts';
} from 'openapi3-ts/oas30';
import { getResReqTypes } from '../getters';
import { ContextSpecs, GeneratorSchema } from '../types';
import { jsDoc, pascal, sanitize } from '../utils';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/generators/interface.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SchemaObject } from 'openapi3-ts';
import { SchemaObject } from 'openapi3-ts/oas30';
import { generalJSTypesWithArray } from '../constants';
import { getScalar } from '../getters';
import { ContextSpecs } from '../types';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/generators/parameter-definition.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ComponentsObject, ParameterObject } from 'openapi3-ts';
import { ComponentsObject, ParameterObject } from 'openapi3-ts/oas30';
import { resolveObject, resolveRef } from '../resolvers';
import { ContextSpecs, GeneratorSchema } from '../types';
import { jsDoc, pascal, sanitize } from '../utils';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/generators/schema-definition.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import isEmpty from 'lodash.isempty';
import { SchemaObject, SchemasObject } from 'openapi3-ts';
import { SchemaObject, SchemasObject } from 'openapi3-ts/oas30';
import { getEnum, resolveDiscriminators } from '../getters';
import { resolveRef, resolveValue } from '../resolvers';
import { ContextSpecs, GeneratorSchema } from '../types';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/generators/verbs-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
ParameterObject,
PathItemObject,
ReferenceObject,
} from 'openapi3-ts';
} from 'openapi3-ts/oas30';
import {
getBody,
getOperationId,
Expand Down
14 changes: 12 additions & 2 deletions packages/core/src/getters/array.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { SchemaObject } from 'openapi3-ts';
import { SchemaObject } from 'openapi3-ts/oas30';
import { SchemaObject as SchemaObject31 } from 'openapi3-ts/oas31';
import { ContextSpecs, ScalarValue } from '../types';
import { resolveObject } from '../resolvers/object';
import { resolveExampleRefs } from '../resolvers';
Expand All @@ -18,6 +19,13 @@ export const getArray = ({
context: ContextSpecs;
}): ScalarValue => {
if (schema.items) {
const schema31 = schema as SchemaObject31;
if (schema31.prefixItems) {
// TODO: https://github.com/anymaniax/orval/issues/890
throw new Error(
`prefixItems is not supported (name=${name}, schema=${JSON.stringify(schema)})`,
);
}
const resolvedObject = resolveObject({
schema: schema.items,
propName: name + context.output.override.components.schemas.itemSuffix,
Expand All @@ -39,6 +47,8 @@ export const getArray = ({
examples: resolveExampleRefs(schema.examples, context),
};
} else {
throw new Error('All arrays must have an `items` key define');
throw new Error(
`All arrays must have an \`items\` key defined (name=${name}, schema=${JSON.stringify(schema)})`,
);
}
};
2 changes: 1 addition & 1 deletion packages/core/src/getters/body.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ReferenceObject, RequestBodyObject } from 'openapi3-ts';
import { ReferenceObject, RequestBodyObject } from 'openapi3-ts/oas30';
import { generalJSTypesWithArray } from '../constants';
import { ContextSpecs, GetterBody, OverrideOutputContentType } from '../types';
import { camel, sanitize } from '../utils';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/getters/combine.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import omit from 'lodash.omit';
import { SchemaObject } from 'openapi3-ts';
import { SchemaObject } from 'openapi3-ts/oas30';
import { resolveExampleRefs, resolveObject } from '../resolvers';
import {
ContextSpecs,
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/getters/discriminators.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SchemasObject } from 'openapi3-ts';
import { SchemasObject } from 'openapi3-ts/oas30';
import { ContextSpecs } from '../types';
import { getRefInfo } from './ref';
import { pascal } from '../utils';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/getters/object.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ReferenceObject, SchemaObject } from 'openapi3-ts';
import { ReferenceObject, SchemaObject } from 'openapi3-ts/oas30';
import { resolveExampleRefs, resolveObject, resolveValue } from '../resolvers';
import { ContextSpecs, ScalarValue, SchemaType } from '../types';
import { isBoolean, isReference, jsDoc, pascal } from '../utils';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/getters/operation.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { OperationObject } from 'openapi3-ts';
import { OperationObject } from 'openapi3-ts/oas30';
import { getOperationId } from './operation';

describe('getOperationId getter', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/getters/operation.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { OperationObject } from 'openapi3-ts';
import { OperationObject } from 'openapi3-ts/oas30';
import { Verbs } from '../types';
import { pascal, sanitize } from '../utils';

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/getters/parameters.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ParameterObject, ReferenceObject } from 'openapi3-ts';
import { ParameterObject, ReferenceObject } from 'openapi3-ts/oas30';
import { resolveRef } from '../resolvers/ref';
import { ContextSpecs, GetterParameters } from '../types';
import { isReference } from '../utils';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/getters/query-params.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ParameterObject } from 'openapi3-ts';
import { ParameterObject } from 'openapi3-ts/oas30';
import { describe, expect, it } from 'vitest';
import { ContextSpecs } from '../types';
import { getQueryParams } from './query-params';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/getters/query-params.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ContentObject, SchemaObject } from 'openapi3-ts';
import { ContentObject, SchemaObject } from 'openapi3-ts/oas30';
import { resolveValue } from '../resolvers';
import {
ContextSpecs,
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/getters/ref.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import get from 'lodash.get';
import { ReferenceObject } from 'openapi3-ts';
import { ReferenceObject } from 'openapi3-ts/oas30';
import { ContextSpecs } from '../types';
import { getFileInfo, isUrl, pascal, upath } from '../utils';

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/getters/res-req-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
RequestBodyObject,
ResponseObject,
SchemaObject,
} from 'openapi3-ts';
} from 'openapi3-ts/oas30';
import { resolveObject } from '../resolvers/object';
import { resolveExampleRefs, resolveRef } from '../resolvers/ref';
import { ContextSpecs, ResReqTypesValue } from '../types';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/getters/response.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ResponsesObject } from 'openapi3-ts';
import { ResponsesObject } from 'openapi3-ts/oas30';
import {
ContextSpecs,
GetterResponse,
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/getters/scalar.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SchemaObject } from 'openapi3-ts';
import { SchemaObject } from 'openapi3-ts/oas30';
import { ContextSpecs, ScalarValue } from '../types';
import { escape, isString } from '../utils';
import { getArray } from './array';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/resolvers/object.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ReferenceObject, SchemaObject } from 'openapi3-ts';
import { ReferenceObject, SchemaObject } from 'openapi3-ts/oas30';
import { getEnum } from '../getters/enum';
import { ContextSpecs, ResolverValue } from '../types';
import { jsDoc } from '../utils';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/resolvers/ref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
RequestBodyObject,
ResponseObject,
SchemaObject,
} from 'openapi3-ts';
} from 'openapi3-ts/oas30';
import { RefInfo, getRefInfo } from '../getters/ref';
import { ContextSpecs, GeneratorImport } from '../types';
import { isReference } from '../utils';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/resolvers/value.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ReferenceObject, SchemaObject } from 'openapi3-ts';
import { ReferenceObject, SchemaObject } from 'openapi3-ts/oas30';
import { getScalar } from '../getters';
import { ContextSpecs, ResolverValue, SchemaType } from '../types';
import { isReference } from '../utils';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
RequestBodyObject,
ResponsesObject,
SchemaObject,
} from 'openapi3-ts';
} from 'openapi3-ts/oas30';
// @ts-ignore // FIXME when running `yarn test` getting `orval:test: ../core/src/types.ts(12,34): error TS7016: Could not find a declaration file for module 'swagger2openapi'. '/home/maxim/orval/node_modules/swagger2openapi/index.js' implicitly has an 'any' type.`
import swagger2openapi from 'swagger2openapi';
import type { allLocales } from '@faker-js/faker';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/utils/assertion.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ReferenceObject, SchemaObject } from 'openapi3-ts';
import { ReferenceObject, SchemaObject } from 'openapi3-ts/oas30';
import { SchemaType, Verbs } from '../types';
import { extname } from './path';

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/utils/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const logError = (err: unknown, tag?: string) =>
chalk.red(
[
'🛑',
tag ? `${tag} - ` : undefined,
tag ? `${tag} -` : undefined,
err instanceof Error ? err.stack : err,
]
.filter(Boolean)
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/utils/open-api-converter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import chalk from 'chalk';
import { OpenAPIObject } from 'openapi3-ts';
import { OpenAPIObject } from 'openapi3-ts/oas30';
import swagger2openapi from 'swagger2openapi';
import { log } from './logger';

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/utils/validator.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { OpenAPIObject } from 'openapi3-ts';
import { OpenAPIObject } from 'openapi3-ts/oas30';
import {
ibmOpenapiValidatorErrors,
ibmOpenapiValidatorWarnings,
Expand Down
2 changes: 1 addition & 1 deletion packages/mock/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
"@orval/core": "6.23.0",
"lodash.get": "^4.4.2",
"lodash.omit": "^4.5.0",
"openapi3-ts": "^3.0.0"
"openapi3-ts": "^4.2.1"
}
}
2 changes: 1 addition & 1 deletion packages/mock/src/faker/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SchemaObject } from 'openapi3-ts';
import { SchemaObject } from 'openapi3-ts/oas30';

export const DEFAULT_FORMAT_MOCK: Record<
Required<SchemaObject>['format'],
Expand Down
2 changes: 1 addition & 1 deletion packages/mock/src/faker/getters/object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
isReference,
MockOptions,
} from '@orval/core';
import { ReferenceObject, SchemaObject } from 'openapi3-ts';
import { ReferenceObject, SchemaObject } from 'openapi3-ts/oas30';
import { resolveMockValue } from '../resolvers/value';
import { MockDefinition, MockSchemaObject } from '../../types';
import { combineSchemasMock } from './combine';
Expand Down
2 changes: 1 addition & 1 deletion packages/mock/src/faker/resolvers/value.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
MockOptions,
} from '@orval/core';
import get from 'lodash.get';
import { SchemaObject } from 'openapi3-ts';
import { SchemaObject } from 'openapi3-ts/oas30';
import { getMockScalar } from '../getters/scalar';
import { MockDefinition, MockSchemaObject } from '../../types';

Expand Down
2 changes: 1 addition & 1 deletion packages/mock/src/msw/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
resolveRef,
stringify,
} from '@orval/core';
import { OpenAPIObject, SchemaObject } from 'openapi3-ts';
import { OpenAPIObject, SchemaObject } from 'openapi3-ts/oas30';
import { getMockScalar } from '../faker/getters';

const getMockPropertiesWithoutFunc = (properties: any, spec: OpenAPIObject) =>
Expand Down
2 changes: 1 addition & 1 deletion packages/mock/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { GeneratorImport } from '@orval/core';
import { SchemaObject } from 'openapi3-ts';
import { SchemaObject } from 'openapi3-ts/oas30';

export interface MockDefinition {
value: string;
Expand Down
3 changes: 1 addition & 2 deletions packages/orval/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@
"find-up": "5.0.0",
"fs-extra": "^11.2.0",
"lodash.uniq": "^4.5.0",
"openapi-types": "^12.1.3",
"openapi3-ts": "^3.2.0",
"openapi3-ts": "4.2.1",
"string-argv": "^0.3.2",
"tsconfck": "^2.0.1"
}
Expand Down
2 changes: 1 addition & 1 deletion packages/orval/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
resolveRef,
} from '@orval/core';
import { generateMockImports } from '@orval/mock';
import { PathItemObject } from 'openapi3-ts';
import { PathItemObject } from 'openapi3-ts/oas30';
import {
generateClientFooter,
generateClientHeader,
Expand Down
2 changes: 1 addition & 1 deletion packages/orval/src/import-open-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
WriteSpecsBuilder,
} from '@orval/core';
import omit from 'lodash.omit';
import { OpenAPIObject, SchemasObject } from 'openapi3-ts';
import { OpenAPIObject, SchemasObject } from 'openapi3-ts/oas30';
import { getApiBuilder } from './api';

export const importOpenApi = async ({
Expand Down
2 changes: 1 addition & 1 deletion packages/orval/src/utils/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
} from '@orval/core';
import { DEFAULT_MOCK_OPTIONS } from '@orval/mock';
import chalk from 'chalk';
import { InfoObject } from 'openapi3-ts';
import { InfoObject } from 'openapi3-ts/oas30';
import pkg from '../../package.json';
import { githubResolver } from './github';
import { loadPackageJson } from './package-json';
Expand Down
2 changes: 1 addition & 1 deletion packages/orval/src/write-specs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import chalk from 'chalk';
import execa from 'execa';
import fs from 'fs-extra';
import uniq from 'lodash.uniq';
import { InfoObject } from 'openapi3-ts';
import { InfoObject } from 'openapi3-ts/oas30';
import { executeHook } from './utils';

const getHeader = (
Expand Down
2 changes: 1 addition & 1 deletion packages/zod/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
RequestBodyObject,
ResponseObject,
SchemaObject,
} from 'openapi3-ts';
} from 'openapi3-ts/oas30';
import {
camel,
ClientBuilder,
Expand Down
Loading