swagger-api / swagger-api/swagger-codegen
[Typescript-Fetch] incorrect handling of nullable for additionalProperties
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
It will create same code for additional properties with nullable and non nullable elements.
Generated code:
export interface EnvVars {
works?: { [key: string]: string; };
notworks?: { [key: string]: string; };
}
How I think it should be
export interface EnvVars {
works?: { [key: string]: string | null; };
notworks?: { [key: string]: string | null; };
}
Swagger-codegen version
Latest stable 2.2.3
And latest 3 (Tue Nov 14 06:42:44 UTC 2017)
Swagger declaration file content or url
Try to generate with adding somewhere such definitions
definitions:
envVars:
description: description
type: object
properties:
works:
type: object
additionalProperties:
type: string
x-nullable: false
notworks:
type: object
additionalProperties:
type: string
x-nullable: true
Command line used for generation
java -jar ./swagger-codegen-cli.jar generate -l typescript-fetch -i ./spec/swagger.yml -DnpmName=client-ts -DnpmVersion=0.1.0 -o ts-gen
Steps to reproduce
Try to generate with provided yaml
Related issues/PRs
Can't find same problem.
Suggest a fix/enhancement
Golang not affected.
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 by running the provided java -jar swagger-codegen-cli.jar command with the YAML definition and the typescript-fetch generator, then inspect the generated EnvVars interface. The fix is complete when x-nullable on additionalProperties produces the expected nullable or non-nullable value type instead of identical output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100