[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.