You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When generating the client, the model classes in the resulting api.ts file are sorted alphabetically. In many cases this is fine and doesn't matter. The problem comes in when you are using inheritance. In TypeScript you cannot put an inherited class before its parent. If for instance you have a parent "Section" and a child "ButtonSection", this will cause the Typescript compilation to fail since the child comes before the parent alphabetically.
openapi-generator version
3.0.2
OpenAPI declaration file content or url
swagger: "2.0"info:
version: "1.0.0"title: Sections ServicebasePath: /#schemes:
- httpconsumes:
- application/jsonproduces:
- application/jsonpaths:
/sections:
x-swagger-router-controller: sectionsget:
description: Retrieves sectionsoperationId: getSectionsparameters:
- name: skipin: querydescription: Number of items to skiprequired: falsetype: integerformat: int64default: 0minimum: 0
- name: takein: querydescription: Number of items to returnrequired: falsetype: integerformat: int64default: 20minimum: 1maximum: 100responses:
200:
description: Successheaders:
X-Total-Count:
description: Total number of sectionstype: integerformat: int64minimum: 0schema:
type: arrayitems:
$ref: "#/definitions/Section"/swagger:
x-swagger-pipe: swagger_rawdefinitions:
Section:
type: objectdiscriminator: typerequired:
- name
- typeproperties:
name:
type: stringtype:
type: stringenum:
- ButtonSectionButtonSection:
type: objectallOf:
- $ref: '#/definitions/Section'
- type: objectrequired:
- buttonsproperties:
buttons:
type: arrayitems:
$ref: '#/definitions/Button'Button:
type: objectrequired:
- index
- labelproperties:
index:
type: integerformat: int64minimum: 0label:
type: string
The CodeGen needs to sort models based on their inheritance tree before outputting. Another solution could be breaking the output out into multiple different files instead of one massive file.
The text was updated successfully, but these errors were encountered:
Description
When generating the client, the model classes in the resulting api.ts file are sorted alphabetically. In many cases this is fine and doesn't matter. The problem comes in when you are using inheritance. In TypeScript you cannot put an inherited class before its parent. If for instance you have a parent "Section" and a child "ButtonSection", this will cause the Typescript compilation to fail since the child comes before the parent alphabetically.
openapi-generator version
3.0.2
OpenAPI declaration file content or url
Command line used for generation
docker run -d --rm -v $WORKSPACE:/input:ro -v $WORKSPACE/output:/output openapitools/openapi-generator-cli generate -i /input/swagger.yaml -g typescript-node -o /output
Steps to reproduce
Run the above command on reference file
Suggest a fix/enhancement
The CodeGen needs to sort models based on their inheritance tree before outputting. Another solution could be breaking the output out into multiple different files instead of one massive file.
The text was updated successfully, but these errors were encountered: