Skip to content

Dereference swagger spec instead of parsing it #34

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Dereference swagger spec instead of parsing it #34

wants to merge 1 commit into from

Conversation

YStrauch
Copy link

Hello,

consider the following example API:

swagger: '2.0'
info:
  title: Test
  description: Test
  version: "0.0.1"
paths:
  /test:
    get:
      parameters:
        - $ref: "#/parameters/foobar"
      responses:
        default:
          description: Successful response
          schema:
            title: Bar
            type: string
parameters:
  foobar:
    name: foo
    in: query
    description: Foo
    type: string
    required: true

The important part is how the parameter is referenced.
This is currently not supported by your plugin (it will never be dereferenced and crash in the template).
You are currently using swagger-parser, but you use the method parse. Instead you could call the method dereference (which will internally call parse), which will fix this issue.

@sandorfr
Copy link
Member

Hi, thanks for this :) I'll test tonight !

@YStrauch
Copy link
Author

Okay I just realized that this breaks the interfaces of return types. Damn it I really need this feature.

@sandorfr
Copy link
Member

I have been quite short on time yesterday with yarn I'll try my best to take a look at this. Maybe it will be hard to make it work fine with this version of the generator but easier with the new engine. I guess you need the typescript template?

@YStrauch
Copy link
Author

TypeScript yes, but actually I am using my own templates since I need an Angular2 Service integration with some custom magic.

@sandorfr
Copy link
Member

@YStrauch OK, very interesting, we need to talk :).

@sandorfr
Copy link
Member

sandorfr commented Oct 14, 2016

I think I can document the new version and include the json dereferencing for the beginning of next week, Do you have enough time to migrate your templates and would you like to help with geeklearningio/gl-swagger-generator#3

You can get an idea about what changed by looking at the csharp netstandard template : https://github.com/geeklearningio/gl-swagger-generator/tree/develop/src/node-swagger-generator/templates/csharp/netstandard/1.3

@YStrauch
Copy link
Author

I am sorry but I don't have the time to work on V3, I need to start front end development. I can imagine that if you release V3 I may eventually migrate my templates, and then I can surely push them.

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

Successfully merging this pull request may close these issues.

2 participants