OpenAPITools / OpenAPITools/openapi-generator
[BUG] [typescript-axios] Nullable addtional properites are generated as not nullable
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- 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; };
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the typescript-axios generator and reproduce the issue using the provided OpenAPI declaration and Docker command. Compare generated additional-property types with regular nullable properties; done means the generated MyData index signature includes string | null.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100