cyclosproject / ng-openapi-gen

An OpenAPI 3.0 codegen for Angular
MIT License
397 stars 132 forks source link

Referenced models are not generated #124

Closed danbalarin closed 4 years ago

danbalarin commented 4 years ago

Hello,

We've been experiencing weird bug with generation of models. For our large yaml definitions the generator created services and in those services referenced models, but models are not generated. Bellow is minimal, redacted config for reproduction.

Same example on https://editor.swagger.io/ works flawlessly.

Command:

ng-openapi-gen -i ./test.yaml --ignoreUnusedModels false

Result:

Generation from ./test.yaml finished with 0 models and 1 services.

This is just an example, but the structure is the same.

swagger: '2.0'
info:
  version: 1.0.0
  title: 'Foobar'
host: foo.bar.com
basePath: /store/api
schemes:
  - http
consumes:
  - application/json
produces:
  - application/json

paths:
  /v1/search:
    x-summary: Search
    post:
      tags:
        - Crates
      operationId: 'getCrateSearch'
      parameters:
        - in: body
          name: body
          schema:
            $ref: '#/definitions/CratesSearchRequestBody'
      responses:
        200:
          description: OK
          schema:
            $ref: '#/definitions/CratesSearchResponse'

definitions:

  CratesSearchRequestBody:
    type: object
    properties:
      categories:
        type: string

  CratesSearchResponse:
    type: object
    properties:
      pageNumber:
        type: integer
luisfpg commented 4 years ago

Your API definition uses Swagger 2. This project is for OpenApi 3. Use the sibling project instead: https://github.com/cyclosproject/ng-swagger-gen