openapi-generator
openapi-generator copied to clipboard
[BUG] [typescript-axios] Nullable addtional properites are generated as not nullable
Bug Report Checklist
- [x] Have you provided a full/minimal spec to reproduce the issue?
- [x] Have you validated the input using an OpenAPI validator (example)?
- [x] Have you tested with the latest master to confirm the issue still exists?
- [x] Have you searched for related issues/PRs?
- [x] What's the actual output vs expected output?
- [ ] [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
Additional properties with nullable: true in them are generated as not nullable.
openapi-generator version
6.1.1-SNAPSHOT
OpenAPI declaration file content or url
components:
schemas:
MyObject:
type: object
required:
- string
- data
properties:
string:
$ref: '#/components/schemas/MyString'
data:
$ref: '#/components/schemas/MyData'
MyData:
type: object
additionalProperties:
$ref: '#/components/schemas/MyString'
MyString:
type: string
nullable: true
Generation Details
Generated using the latest typescript-axios generator:
docker run --rm -v "${PWD}:/local" openapitools/openapi-generator-cli:latest generate \
-i /local/spec/sample.openapi.yaml \
-g typescript-axios \
-o /local/out/sample
Generator output
export interface MyObject {
'string': string | null;
'data': { [key: string]: string; };
}
As you can see, the regular property is nullable and the additional one is not, even though they're both declared the same way.
Steps to reproduce
Run the typescript-axios generator
Suggest a fix
Make additional properties nullable:
export interface MyObject {
'string': string | null;
'data': { [key: string]: string | null; };
}