Skip to content

[Typescript-Angular] Not generating models from referenced definition #6817

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
HermenOtter opened this issue Oct 26, 2017 · 2 comments
Open

Comments

@HermenOtter
Copy link

HermenOtter commented Oct 26, 2017

I have been searching for a similiar issue, but the proposed solutions didn't solve my problem.

Description

In swaggerhub we have several api definitions. There is one 'domain' api that contains shared definitions and responses, however when this domain is referenced by one of the api's: models for the definitions in the domain are not generated.

I want to know how I can reference a shared api and generate the models, the proper way.

Swagger-codegen version

2.3.0-SNAPSHOT

Swagger declaration file content or url

https://app.swaggerhub.com/apis/Company/JustAnApi/2.0

This is JustAnApi that references the SharedApi

post:
     ...stuff here...
      parameters:    
        schema:
          ....stuff here....
      responses:
        201:
          .....stuff here......
        400:
         $ref: 'https://api.swaggerhub.com/domains/Company/SharedApi/0.1#/responses/GeneralError'

https://api.swaggerhub.com/domains/Company/SharedApi/0.1
Below the response that is used in the JustAnApi.

Response Example A - not working:

definitions:
  ErrorModel:   
    properties:
      <insert properties here>
responses:
   GeneralError:
     description: General Error
     schema:
      type: "array"
      items:
       $ref: '#definitions/ErrorModel'

The above response references the ErrorModel definition. This approach does not generate the ErrorModel.
The example below does work.

Response example B - working response:

definitions:
  ErrorModel:   
    properties:
      <insert properties here>
responses:
   GeneralError:     
     schema:
      type: "array"
      items:
       $ref: 'https://api.swaggerhub.com/domains/Company/SharedApi/0.1#definitions/ErrorModel'

However a static ref as seen in example B is something we cannot use in our development cycle(it will cause trouble), do you have any idea how to solve this problem?

Command line used for generation

java -jar swagger-codegen-cli-2.3.0.jar generate -i https://api.swaggerhub.com/apis/Centric/Belastingen_Subjecten/0.2.2_codegen -l typescript-angular -o

Thank you for reading,
Hermen

@HermenOtter HermenOtter changed the title [Typescript-Angular] Not generating from model referenced definition. [Typescript-Angular] Not generating models from referenced definition. Oct 26, 2017
@HermenOtter
Copy link
Author

HermenOtter commented Oct 26, 2017

This issue explains a workaround, but I wonder if this issue is going to be fixed or that it can't be fixed?

ps. I appreciate the work being done here and the code generation is great.

@tony-gutierrez
Copy link

Doesnt follow external refs for ruby in the online generator either.

@HermenOtter HermenOtter changed the title [Typescript-Angular] Not generating models from referenced definition. [Typescript-Angular] Not generating models from referenced definition Nov 9, 2017
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

2 participants