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 model generation when using reference to another swagger file #258

Open
martinduris opened this issue Mar 11, 2021 · 1 comment
Open

Comments

@martinduris
Copy link

Hi,

when i use in entity reference to entity defined in another swagger file:
(child-api-doc.yaml:)

ChildEntity:
    type: object
    discriminator: 'className'
    properties:
      className:
        type: string
      childEntity:
        $ref: 'parent-api-doc.yaml#/definitions/ChildResponseResponse'
    required:
      - childEntity

and this referenced entity has definition:
(parent-api-doc.yaml:)

ChildEntity:
    type: object
    properties:
      email:
        type: string
      vision:
        $ref: '#/definitions/Translation'
  ChildResponseResponse:
    allOf:
      - $ref: '#/definitions/ChildEntity'
      - type: object
        properties:
          id:
            type: integer
        required:
          - id
 ################################## TRANSLATIONS ##############################
  TranslationLanguage:
    type: string
    enum:
      - GB
      - SK
      - CS
  TranslationContent:
    type: object
    properties:
      language:
        $ref: '#/definitions/TranslationLanguage'
      content:
        type: string
    required:
      - language
      - content
  Translation:
    type: object
    properties:
      defaultLanguage:
        $ref: '#/definitions/TranslationLanguage'
      translations:
        type: array
        minItems: 1
        items:
          $ref: '#/definitions/TranslationContent'
    required:
        - defaultLanguage
        - translations

generated model 'ChildEntity' looks:

/* tslint:disable */
export interface ChildEntity {
  childEntity: {email?: string, vision?: {defaultLanguage: 'GB' | 'SK' | 'CS', translations: Array<{language: DefaultLanguage, content: string}>}} & {id: number};
  className?: string;
}

Problem is here:

translations: Array<{language: DefaultLanguage, content: string}>}}

Interface 'DefaultLanguage' is not existing/not generated
(please notice, that "defaultLanguage: 'GB' | 'SK' | 'CS'" is looking good)


You can try example in this sample repo:
https://github.com/martinduris/ng-swagger-gen-test
... just run npm run swagger

Thanks a lot
Martin

@luisfpg
Copy link
Collaborator

luisfpg commented Jul 16, 2021

Sorry, I don't really have any more time to maintain this project.
Help is appreciated.

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

2 participants