Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bad interaction between additionalProperties and $ref #401

Open
ranma42 opened this issue Feb 23, 2017 · 13 comments
Open

Bad interaction between additionalProperties and $ref #401

ranma42 opened this issue Feb 23, 2017 · 13 comments

Comments

@ranma42
Copy link

ranma42 commented Feb 23, 2017

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 swagger-api/swagger-codegen#4839
@wing328 suggested to report the issue here as it is likely related to some problems with the resolution of the reference.

@webron
Copy link
Contributor

webron commented Feb 23, 2017

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"

@ranma42
Copy link
Author

ranma42 commented Feb 23, 2017

On each of the three versions of swagger-codegen I had tested, it generates the very same output as the original spec.

@webron
Copy link
Contributor

webron commented Feb 23, 2017

Thanks for checking.

@naXa777
Copy link

naXa777 commented Sep 12, 2019

is it resolved in the current version of swagger-parser and swagger-codegen?

@BrandonWalker88
Copy link

Has anyone found a solution for this? I'm having the same issue with the typescript-axios vs.

@twistedpair
Copy link

Still broken on Codegen v3.0.31.

@SchiessMax
Copy link

Tried it on v3.0.34 and the problem still occurs

@mohammedSlimani
Copy link

Same issue for the version v3.0.36

@rofenix2
Copy link

So is anybody managing this project or what?. People been complaining about this since 2019 and still no answer?.

@alois-git
Copy link

Any news about this ?

@skizocell
Copy link

Same issue for the version v3.0.44

@skizocell
Copy link

Same issue for the version v3.0.50

@threydor
Copy link

Still broken for the version v3.0.58

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests