Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #3257
Closed
Open
Issue created Jul 01, 2019 by Administrator@rootContributor5 of 6 checklist items completed5/6 checklist items

[BUG] [angular-typescript] Unused models not generated

Created by: daniel-sc

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • What's the version of OpenAPI Generator used?
  • Have you search for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Bounty to sponsor the fix (example)
Description

When defining model entities that are not used directly by the resscources these models are not generated with the typescript-angular generator. (see SpecialPet in the example below). This only happens when the model is in a separate file!

This is a problem since our api uses the allOf to extend a base class. The ressource formally returns the base class, but depending on inputs, different acutal responses (subclasses) are returned. It is clear that there needs to be some manual casting, but without the subclass at hand we'd need to manually code it.

openapi-generator version

4.0.2

OpenAPI declaration file content or url

api.yaml:

openapi: 3.0.0
info:
  version: "1.0.0"
  title: "Swagger Petstore"

paths:
  /pet/findByStatus:
    get:
      responses:
        200:
          description: "successful operation"
          content:
            application/json:
              schema:
                type: "array"
                items:
                  $ref: 'types.yaml#/components/schemas/Pet'
        400:
          description: "Invalid status value"

types.yaml:

openapi: 3.0.0
info:
  version: "1.0.0"
  title: "Swagger Petstore"

paths:
  /dummy:
    get:
      responses:
        200:
          description: 'dummy'
  
components:
  schemas:
    Pet:
      type: "object"
      properties:
        id:
          type: "integer"
          format: "int64"
        name:
          type: "string"
          example: "doggie"
    SpecialPet:
      type: "object"
      allOf: 
      - $ref: '#/components/schemas/Pet'
      - type: object
        properties:
          specialType:
            type: string
Command line used for generation

java -jar openapi-generator-cli-4.0.2.jar generate -i api.yaml -g typescript-angular

Steps to reproduce
Related issues/PRs
Suggest a fix

There should be an option to allow generation of unused models.

Alternatively/Additionally secondary input files from which models are generated might as well solve the problem.

Assignee
Assign to
Time tracking