swagger-parser
swagger-parser copied to clipboard
Bad interaction between additionalProperties and $ref
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.
Can you try changing your definition to the following and see if it helps?
...
definitions:
GenericMap:
type: object
additionalProperties:
type: integer
Container:
type: object
properties:
works:
type: object
additionalProperties:
type: string
breaks:
$ref: "#/definitions/GenericMap"
On each of the three versions of swagger-codegen I had tested, it generates the very same output as the original spec.
Thanks for checking.
is it resolved in the current version of swagger-parser and swagger-codegen?
Has anyone found a solution for this? I'm having the same issue with the typescript-axios vs.
Still broken on Codegen v3.0.31.
Tried it on v3.0.34 and the problem still occurs
Same issue for the version v3.0.36
So is anybody managing this project or what?. People been complaining about this since 2019 and still no answer?.
Any news about this ?
Same issue for the version v3.0.44
Same issue for the version v3.0.50