Lack of default and exmaple properties in SDK schema
Describe the bug For OpenAPI type schema
"MyNumber": {
"minimum": 1,
"type": "integer",
"description": "My number.",
"default": 1,
"example": 2
},
openapi-typescript-codegen --exportSchemas true does not generate default nor example properties in SDK schema (schemas/$MyNumber.ts):
export const $MyNumber = {
type: 'number',
description: `My number.`,
minimum: 1,
} as const;
Schema should include both (expecially default that may be useful for clients).
Thanks for a great tool overall!
I'm seconding this issue. I've been using the --exportSchemas to try and get values to populate forms and client-side validation and I'm missing a few of them:
components:
schemas:
MyObject:
type: object
properties:
clientId:
type: string
format: string
description: client identifier
example: my-example-client-id
nullable: true
pattern: "^[a-zA-Z0-9 -_]*"
keepAlive:
type: integer
format: int32
default: 240
description: keepAlive
maximum: 65535
minimum: 0
and I'm getting this:
export const $MyObject = {
properties: {
clientId: {
type: 'string',
description: `client identifier.`,
isRequired: true,
isNullable: true,
format: 'string',
pattern: '^[a-zA-Z0-9 -_]*',
},
keepAlive: {
type: 'number',
description: `keepAlive`,
isRequired: true,
format: 'int32',
maximum: 65535,
},
defaultis missingexampleis missingminimumis missing if equal to 0 (I guess that can be checked)
also missing patternProperties
I have fixed the issue with minimum missing when equal to 0 (also other min/max schema values will no longer have this bug). Please check out v0.32.1 of our fork @hey-api/openapi-ts. I plan to add default in the near future. If there are any other issues you have please open an issue and we will address as soon as we can!