openapi-generators / openapi-generators/openapi-python-client

Linting error when class has a property with the same name after snake case

Open
#1,117 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
2k
Forks
293
Avg merge
34m
Merged PRs (30d)
1

Description

openapi-python-client: 0.21.4
Python: 3.10
OpenAPI spec version: 3.0.3

In OpenAPI specs where a property has the same name as the snake cased class name (in the example below, the snake casing is the lower case, but if it was, ex, InstagramId, then this would happen with a property named instagram_id) the code generated has a duplicated variable name (see image below).

The suggested fix is that the return variable name should have an underscore _, in this example, email_.

      "Email": {
        "type": "object",
        "properties": {
          "email": {
            "type": "string"
          },
          "verified": {
            "type": "boolean"
          }
        },
        "required": [
          "email",
          "type"
        ]
      },
Monosnap xeal-qa-utils – email py 2024-09-03 18-31-37

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with the supplied OpenAPI 3.0.3 snippet using openapi-python-client 0.21.4 and inspect the generated Email model. Trace the generator path that chooses names for the return variable and the property, then verify that the generated names no longer collide and that the example remains valid Python.

Written by the indexing model from the issue text.

Assessment

Tech stack
openapi, python
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.