Skip to content

[BUG] Python generator incorrectly renames valid model names #3428

@rizwansaeed

Description

@rizwansaeed
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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions