Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Python] Code generator doesn't preserve original case for variables #12505

Open
ShemTovYosef opened this issue Dec 19, 2024 · 0 comments
Open

Comments

@ShemTovYosef
Copy link

ShemTovYosef commented Dec 19, 2024

Description

We are using swagger codegen several years for Java and Node.JS projects and now implemented Python project.
We found codegen for Python doesn't preserve original names for models and variables, and converts them to underscored by default: petId => pet_id and in addition, supports or camel o pascal

But we want to preserve the case as it's working in Java/Javascript/Scala/C# based on CodegenConstants.MODEL_PROPERTY_NAMING_TYPE

Swagger-codegen version

2.4.41

Swagger declaration file content or url
  Repository:
    type: object
    description: A local repo configuration
    properties:
      repoName:
        type: string
        description: The local repo name
      location:
        type: string
        description: The local repo  location
      description:
        type: string
        description: The local repo description

  RepoResults:
    type: object
    description: List of local repositories configuration
    properties:
      RepoConfig:
        type: array
        items:
          $ref: '#/definitions/Repository'
Command line used for generation

Using maven with swagger-codegen-maven-plugin

<plugin>
                <groupId>io.swagger</groupId>
                <artifactId>swagger-codegen-maven-plugin</artifactId>
                <version>2.4.41</version>
                <executions>
                    <execution>
                        <id>python-swagger-client</id>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <inputSpec>${basedir}/target/resources/controlm-services.yaml</inputSpec>
                            <output>${basedir}/target/generated_sources</output>
                            <templateDirectory>${basedir}/templates</templateDirectory>
                            <generateApiTests>false</generateApiTests>
                            <generateModelTests>false</generateModelTests>
                            <language>python</language>
                            <additionalProperties>
                                <property>case=camel</property>
                            </additionalProperties>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
Steps to reproduce
  1. Create a model that can contain variables with different cases
  2. Generate python code
  3. Expects that python can parse JSON payload with original cases
Related issues/PRs

like these PR:
#6305
#8213

Suggest a fix/enhancement

Add support for "original" type for "case" property like done for camel/snake

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant