openapi-typescript version
7.10.1
Node.js version
22.20
OS + version
macOS
Description
I'm seeing an issue in the openapi-typescript library that I'm not sure how to get around. Previously this worked fine (without components) but after moving to components I'm seeing a lot of wrongly generated types.
Reproduction
Here's an example:
{
"components": {
"schemas": {
"PipesRequestConfig": {
"type": "object",
"properties": {
"environment": {
"type": "string",
"enum": [
"production",
"sandbox"
],
"default": "production"
},
"widgets": {
"type": "object",
"properties": {
"enabled": {
"type": "boolean",
"default": false
}
},
"default": {
"enabled": false
}
},
"field_definitions": {
"type": "object",
"properties": {
"enabled": {
"type": "boolean"
}
},
"default": {
"enabled": false
},
"required": [
"enabled"
]
},
"transform": {
"type": "object",
"properties": {
"include_fields": {
"type": "string",
"enum": [
"input",
"annotated"
]
}
},
"default": {
"include_fields": "input"
},
"required": [
"include_fields"
]
}
},
"default": {
"environment": "production",
"transform": {
"include_fields": "input"
},
"widgets": {
"enabled": false
},
"field_definitions": {
"enabled": false
}
}
}
}
}
}
But it is turned into the following type:
PipesRequestConfig: {
/**
* @default production
* @enum {string}
*/
environment: "production" | "sandbox";
/** @default {
* "enabled": false
* } */
widgets: {
/** @default false */
enabled: boolean;
};
/** @default {
* "enabled": false
* } */
field_definitions: {
enabled: boolean;
};
/** @default {
* "include_fields": "input"
* } */
transform: {
/** @enum {string} */
include_fields: "input" | "annotated";
};
};
Example: The widgets key is not listed as a required property. But the resulting type has it as required.I've tried explicitly setting the --properties-required-by-default=false but it did not help.
Expected result
Fields like widgets are optional.
Required
Extra
openapi-typescript version
7.10.1
Node.js version
22.20
OS + version
macOS
Description
I'm seeing an issue in the
openapi-typescriptlibrary that I'm not sure how to get around. Previously this worked fine (without components) but after moving to components I'm seeing a lot of wrongly generated types.Reproduction
Here's an example:
{ "components": { "schemas": { "PipesRequestConfig": { "type": "object", "properties": { "environment": { "type": "string", "enum": [ "production", "sandbox" ], "default": "production" }, "widgets": { "type": "object", "properties": { "enabled": { "type": "boolean", "default": false } }, "default": { "enabled": false } }, "field_definitions": { "type": "object", "properties": { "enabled": { "type": "boolean" } }, "default": { "enabled": false }, "required": [ "enabled" ] }, "transform": { "type": "object", "properties": { "include_fields": { "type": "string", "enum": [ "input", "annotated" ] } }, "default": { "include_fields": "input" }, "required": [ "include_fields" ] } }, "default": { "environment": "production", "transform": { "include_fields": "input" }, "widgets": { "enabled": false }, "field_definitions": { "enabled": false } } } } } }But it is turned into the following type:
Example: The
widgetskey is not listed as a required property. But the resulting type has it as required.I've tried explicitly setting the--properties-required-by-default=falsebut it did not help.Expected result
Fields like
widgetsare optional.Required
npx @redocly/cli@latest lint)Extra