Closed pm-Egor-Genning closed 3 years ago
Please note that the type
field is missing from the ViberCreationDto
and a few other models. The code is generated without problems if the type
is added to all objects
There are two documents defining the format. JSON schema website mentions that the type
field is optional (https://json-schema.org/):
The most basic schema is a blank JSON object, which constrains nothing, allows anything, and describes nothing:
{}
The OpenAPI spec, in turn, specifies that the type
must be a string (https://swagger.io/specification/#schema-object)
The following properties are taken from the JSON Schema definition but their definitions were adjusted to the OpenAPI Specification. type - Value MUST be a string. Multiple types via an array are not supported.
I would say that the type
should be always specified, what do you think?
please mark as resolved
also tried on 2.0.0-alpha.25 swagger example https://gist.github.com/pm-Egor-Genning/4f00af51d012656dab5f48dfde306c65
Error during generation
yarn generate:api yarn run v1.22.5 $ shx rm -rf ./api/web-admin-backend && ts-node --project ./tsconfig.node.json ./scripts/generate-api.ts [SWAGGER-CODEGEN-TS]: Processing /home/genning_ep/chatbot/web-admin-backend/src/main/resources/api.yaml Error: Received: undefined expected: NonEmptyArray<(ReferenceObject | SchemaObject)> in field oneOf in context: OpenapiObject -> components: Option<ComponentsObject> -> schemas: Option<{ [K in string]: (ReferenceObject | SchemaObject) }> -> ViberCreationDto: (ReferenceObject | SchemaObject) -> 1: SchemaObject -> 5: OneOfSchemaObject -> 1: { oneOf: NonEmptyArray<(ReferenceObject | SchemaObject)> } -> oneOf: NonEmptyArray<(ReferenceObject | SchemaObject)> at /home/genning_ep/chatbot/web-admin-ui/node_modules/@devexperts/swagger-codegen-ts/dist/utils/io-ts.js:15:235 at /home/genning_ep/chatbot/web-admin-ui/node_modules/fp-ts/lib/Option.js:180:68 at Object.pipe (/home/genning_ep/chatbot/web-admin-ui/node_modules/fp-ts/lib/function.js:180:20) at /home/genning_ep/chatbot/web-admin-ui/node_modules/@devexperts/swagger-codegen-ts/dist/utils/io-ts.js:15:109 at /home/genning_ep/chatbot/web-admin-ui/node_modules/fp-ts/lib/Either.js:442:46 at Object.pipe (/home/genning_ep/chatbot/web-admin-ui/node_modules/fp-ts/lib/function.js:180:20) at Object.exports.reportIfFailed (/home/genning_ep/chatbot/web-admin-ui/node_modules/@devexperts/swagger-codegen-ts/dist/utils/io-ts.js:15:53) at /home/genning_ep/chatbot/web-admin-ui/node_modules/@devexperts/swagger-codegen-ts/dist/index.js:49:43 at /home/genning_ep/chatbot/web-admin-ui/node_modules/fp-ts/lib/ReadonlyArray.js:1546:67 at reduceWithIndex_ (/home/genning_ep/chatbot/web-admin-ui/node_modules/fp-ts/lib/ReadonlyArray.js:1229:13) error Command failed with exit code 1.