question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bad interaction between additionalProperties and $ref

See original GitHub issue
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.

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:1
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

6reactions
BrandonWalker88commented, May 19, 2021

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

0reactions
SchiessMaxcommented, May 23, 2022

Tried it on v3.0.34 and the problem still occurs

Read more comments on GitHub >

github_iconTop Results From Across the Web

"additionalProperties" and "allOf", here we go again!
The syntax I've been playng with is basically a "$patch" next to "$ref": ... to referenced types and preserves that relationship in the...
Read more >
oneOf and anyOf validations violate additionalProperties ...
I believe I have identified an issue that causes anyOf and oneOf cases to fail due to the application of additonalProperties: false in...
Read more >
Swagger Resolver error, Could not resolve reference
I'm setting up a new asp.net core 3.1 project, exposing a RESTful API in FHIR format, which is a format extending JSON. I'd...
Read more >
Google Visualization API Reference | Charts
If null is specified, all additional properties of the column will be removed. ... If you want to interact with the chart, and...
Read more >
CWS/7/5 Annex (in English) - WIPO
Processing of Intellectual Property Information using JSON ... It should also noted that earlier drafts of JSON schema may not be completely compatible....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found