-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Description
Description
When generating models from a swagger document, if a model matches a reserved word it appends "Model" at the beginning of the name. This is expected as you can't have a model named "package". However, you should be able to have a model named "Package". Currently this is not allowed and is instead renamed as "ModelPackage" which ends up breaking a few things downstream in our system.
openapi-generator version
3.0.2
OpenAPI declaration file content or url
swagger: "2.0"
info:
version: "1.0.0"
title: Packages Service
basePath: /
schemes:
- http
- https
consumes:
- application/json
produces:
- application/json
paths:
/packages:
x-swagger-router-controller: packages
get:
description: Returns a list of packages
operationId: getPackages
parameters:
- name: skip
in: query
description: Number of items to skip
required: false
type: integer
format: int64
default: 0
minimum: 0
- name: take
in: query
description: Number of items to return
required: false
type: integer
format: int64
default: 20
minimum: 1
maximum: 100
responses:
200:
description: Success
headers:
X-Total-Count:
description: Total number of packages
type: integer
format: int64
minimum: 0
schema:
type: array
items:
$ref: "#/definitions/Package"
/swagger:
x-swagger-pipe: swagger_raw
definitions:
Package:
type: object
properties:
name:
type: string
minLength: 1
maxLength: 80Command 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
We should adjust the DefaultCodeGen to have a case sensitive version of the isReservedWord functionality. Or we can go the route of the C# generator and workd around it:
Line 99 in b594262
| reservedWords.addAll( |