swagger-api / swagger-api/swagger-parser
Bad interaction between additionalProperties and $ref
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 867
- Forks
- 560
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 7
Description
Description
Compiling the following spec into a TypeScript-Fetch client results in invalid code.
Specifically, the generated code contains
export interface GenericMap extends null<String, number> {
}
which the TypeScript compiler rejects.
Swagger-codegen version
I tested it on swagger-codegen 2.2.1 (latest stable), 2.3.0 (7aebcfa) and master (d11d0f8).
Swagger declaration file content or url
...
definitions:
GenericMap:
additionalProperties:
type: integer
Container:
type: object
properties:
works:
type: object
additionalProperties:
type: string
breaks:
$ref: "#/definitions/GenericMap"
Command line used for generation
swagger-codegen generate -i test.yaml -l typescript-fetch
Steps to reproduce
Compile a swagger API containing the definitions mentioned above into a typescript-fetch client.
Further data
This was originally reported as https://github.com/swagger-api/swagger-codegen/issues/4839
@wing328 suggested to report the issue here as it is likely related to some problems with the resolution of the reference.
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 supplied YAML definition and run swagger-codegen generate -i test.yaml -l typescript-fetch against the reported versions or master. Trace how the $ref to GenericMap is resolved alongside additionalProperties; done means the generated TypeScript-Fetch client no longer contains invalid extends null<String, number> code.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, typescript
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100