We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
default
Description
An optional field in the openapi schema that includes the default property is generated as required in typescript
openapi-typescript
7.4.3
18.19
macOS 14.2.1
Reproduction
The following openapi schema is used:
{ "openapi": "3.1.0", "info": { "title": "Config Service", "version": "local" }, "paths": { "/config": { "post": { "summary": "Set Config", "operationId": "set_config_v1_config_post", "parameters": [], "requestBody": { "content": { "application/json": { "schema": { "anyOf": [ { "$ref": "#/components/schemas/ConfigIn" }, { "type": "null" } ], "title": "Params" } } } }, "responses": { "200": { "description": "Successful Response", "content": { "application/json": { "schema": { "type": "null", "title": "Response Set Config Post" } } } } } }, } }, "components": { "schemas": { "ConfigIn": { "properties": { "interval": { "anyOf": [ { "type": "integer" }, { "type": "null" } ], "title": "Interval", "default": 1 }, "start_at": { "anyOf": [ { "type": "string", "format": "date-time" }, { "type": "null" } ], "title": "Start At" } }, "type": "object", "required": [], "title": "ConfigIn" } } } }
Running npx openapi-typescript ./schema.json -o ./types.ts
npx openapi-typescript ./schema.json -o ./types.ts
The following type for ConfigIn is generated:
ConfigIn: { /** * Interval * @default 1 */ interval: number | null; /** Start At */ start_at?: string | null; };
Expected result
I expect interval to be marked optional as well
interval
ConfigIn: { /** * Interval * @default 1 */ interval?: number | null; /** Start At */ start_at?: string | null; };
Checklist
npx @redocly/cli@latest lint
The text was updated successfully, but these errors were encountered:
Possible duplicate of #1957
Sorry, something went wrong.
kerwanp
No branches or pull requests
Description
An optional field in the openapi schema that includes the
default
property is generated as required in typescriptopenapi-typescript
7.4.3
18.19
macOS 14.2.1
Reproduction
The following openapi schema is used:
Running
npx openapi-typescript ./schema.json -o ./types.ts
The following type for ConfigIn is generated:
Expected result
I expect
interval
to be marked optional as wellChecklist
npx @redocly/cli@latest lint
)The text was updated successfully, but these errors were encountered: