swagger-api / swagger-api/swagger-codegen

property name "_" results in empty string var name

Open
#12,084 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

https://github.com/swagger-api/swagger-codegen/blob/1a1016381e173f885242e35d4d449ada16433d3a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PythonClientCodegen.java#L442

Consider the following snippet from FireHydrant's spec:

    "postV1PostMortemsReportsReportIdPublish": {
      "type": "object",
      "properties": {
        "_": {
          "type": "string",
          "enum": [
            "true"
          ]
        },

This results in the generated variable name being empty; e.g.,

def __init__(self, =None, user_ids=None, team_ids=None, _configuration=None): # noqa: E501

(Note the empty variable name for the first parameter after self.)

I think the line above is what causes this/where it needs to be protected against, but I'm not positive. (There also may be some more appropriate place to protect against this - I haven't looked up all the places where it is called.)

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

Start in modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PythonClientCodegen.java at line 442, then inspect the places that call the relevant name-generation logic. Reproduce the FireHydrant-style property named "_" and verify that generated Python constructor parameters always have nonempty names, without breaking the other parameters.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.