OpenAPITools / OpenAPITools/openapi-generator
[BUG] Python generator incorrectly renames valid model names
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Description
The generator is renaming valid model object names. Looking at https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientCodegen.java#L119 it seems that it is ignoring casing which means that valid names such as Property are being renamed to ModelProperty
openapi-generator version
4.1.0-SNAPSHOT
OpenAPI declaration file content or url
swagger: "2.0"
info:
description: "API description"
version: "1.0.0"
title: "Demo API"
license:
name: "Apache 2.0"
url: "http://www.apache.org/licenses/LICENSE-2.0.html"
host: "host.com"
basePath: "/v2"
tags:
- name: "myapi"
description: "do something"
schemes:
- "https"
- "http"
paths:
/myroute:
post:
tags:
- "myapi"
summary: "add something"
description: ""
operationId: "addSomthing"
consumes:
- "application/json"
produces:
- "application/json"
parameters:
- in: "body"
name: "body"
description: "Do Something"
required: true
schema:
$ref: "#/definitions/Property"
responses:
405:
description: "Invalid input"
definitions:
Property:
type: "object"
properties:
id:
type: "integer"
format: "int64"
Command line used for generation
$ docker run --rm -v ${PWD}:/local openapitools/openapi-generator-cli generate -i /local/example.yml -g python -o /local/out/sdk
Suggest a fix
Preserve casing when checking for keywords
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientCodegen.java around line 119, then reproduce the issue with the provided OpenAPI declaration and Docker command. Done means valid model names such as Property retain their casing and are not renamed to ModelProperty.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, python
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100