openapi-typescript-codegen
openapi-typescript-codegen copied to clipboard
All properties are nullable, even though they are not defined as nullable in swagger file
Hi thank you for grate library. I have one problem, all properties are nullable, even though they are not defined as nullable in swagger file.
"LoginResponse": {
"type": "object",
"additionalProperties": false,
"properties": {
"accessToken": {
"type": "string"
},
"refreshToken": {
"type": "string",
"nullable": true
},
"expireIn": {
"type": "integer",
"format": "int32"
},
"user": {
"$ref": "#/components/schemas/DetailedUserDto"
}
}
},
export type LoginResponse = {
accessToken?: string;
refreshToken?: string | null;
expireIn?: number;
user?: DetailedUserDto;
};
Am I doing something wrong ?
I'd like to see an option to disable the optional aspect of properties for generated models.
In this case, openapi-typescript-codegen
is following the schemas correctly. With such an override, openapi document would be describing different objects than the generated client.
Relevant docs: https://json-schema.org/understanding-json-schema/reference/object#required https://swagger.io/docs/specification/data-models/data-types/#object
Thanks for clarifying @tajnymag