Skip to content

[C#] Not all referenced models are generated #4285

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

Closed
mpazdnikova opened this issue Nov 29, 2016 · 7 comments
Closed

[C#] Not all referenced models are generated #4285

mpazdnikova opened this issue Nov 29, 2016 · 7 comments

Comments

@mpazdnikova
Copy link

Hi.

I'm using swaggerhub and have difficulties with correct client code generation for C#. When I reference some model from my domain, it is generated fine, but if this model have references to definitions from that domain, that are not referenced in spec, they are not generated in client code.

For example in my spec I have:

  SomeObject:
    type: object
    properties:
      SomeProperty:
        type: array
        items:
          $ref: '[link to domain]#/definitions/InnerModel'

And in domain:

  InnerModel:
    type: object
    properties:
      SomeEnumName:
        $ref: "#/definitions/SomeEnum"

  SomeEnum:
    type: string
    enum: [
      example,
      anotherexample]

Then in C# code there is mention of SomeEnum in InnerModel class, but the SomeEnum class itself is missing.

I am not sure if that's a bug or some mistake from my side, but it would be nice if these transitive models were properly generated.

@wing328
Copy link
Contributor

wing328 commented Nov 30, 2016

@mpazdnikova as a workaround, you can define the enum directly in the property itself.

I would also suggest you to try the latest master, which should support enum as a standalone class.

@wing328
Copy link
Contributor

wing328 commented Nov 30, 2016

(If your company is using Swagger Codegen, please consider adding your company name to this list)

@jimschubert
Copy link
Contributor

@wing328 @mpazdnikova when you say [link to domain] are you talking about external refs? If so, there are open issues #4103 and #4135 for tracking the problem with the parser in JSON and YAML respectively.

@aleksei-saharov
Copy link

@wing328

should support enum as a standalone class.

Do web interface support it?
If yes, where documentation is?

@wing328
Copy link
Contributor

wing328 commented Dec 21, 2016

@aleksei-saharov you may want to build the JAR based on the latest master as there's a new version of swagger parser, which should have addressed the issue you reported.

@pfedotovsky
Copy link

pfedotovsky commented Dec 23, 2016

@wing328, we're not interested in building latest master and we won't do it. Our company has Enterprise Swagger Hub subscription and it's crucial for us to have stable Swagger Web client as our business depends on it.
So please, give us an estimate when we can see this fixed in the Web client.

@wing328
Copy link
Contributor

wing328 commented Feb 17, 2017

We plan to release 2.2.2 release this month (Feb 2017) and then generator.swagger.io (used by editor.swagger.io) will be updated to use 2.2.2 for code generation.

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

No branches or pull requests

5 participants