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

[BUG] [PYTHON] Invalid function names based on strings containing # and digits #13942

Closed
5 of 6 tasks
syntaxaire opened this issue Nov 7, 2022 · 2 comments · Fixed by #13985
Closed
5 of 6 tasks

[BUG] [PYTHON] Invalid function names based on strings containing # and digits #13942

syntaxaire opened this issue Nov 7, 2022 · 2 comments · Fixed by #13985

Comments

@syntaxaire
Copy link

syntaxaire commented Nov 7, 2022

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

Invalid function names are generated from enum string values resembling "#367B9C".

openapi-generator version

latest via docker CLI

OpenAPI declaration file content or url

Minimal reproduction: gist, validated with vacuum

Generation Details

docker run --rm -v ${PWD}:/local openapitools/openapi-generator-cli:latest generate --global-property skipFormModel=false -i /local/color-names.json -g python -o /local/openapi-client

Steps to reproduce

After generating, install generated code and run pytest.

Output:

openapi-client\test\test_paths\test_sample_json\test_post.py:15: in <module>
    from openapi_client.paths.sample_json import post  # noqa: E501
E     File "C:\Users\Work\Code\openapi-generator-repros\openapi-client\openapi_client\paths\sample_json\post.py", line 90
E       def 67B9C(cls):
E            ^
E   SyntaxError: invalid decimal literal
@syntaxaire syntaxaire changed the title [BUG] [PYTHON] Invalid class names based on strings containing # and digits [BUG] [PYTHON] Invalid function names based on strings containing # and digits Nov 7, 2022
@spacether
Copy link
Contributor

Sample spec is:

{
  "openapi": "3.0.0",
  "info": {
    "title": "API Documentation",
    "description": "Test documentation",
    "contact": {
      "name": "Support",
      "email": "[email protected]"
    },
    "version": "v4",
    "x-logo": {
      "url": "https://example.com/logo.png"
    }
  },
  "servers": [
    {
      "url": "https://app.example.com/api/v4",
      "description": "Server"
    }
  ],
  "paths": {
    "/sample.json": {
      "post": {
        "tags": [
          "Things"
        ],
        "summary": "Create a new Thing",
        "operationId": "Thing#create",
        "description": "Outlines the parameters and data fields used when creating a new Thing",
        "responses": {
          "200": {
            "description": "Ok",
            "content": {
              "application/json": {}
            }
          }
        },
        "requestBody": {
          "description": "Request Body for Things",
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "data"
                ],
                "properties": {
                  "data": {
                    "type": "object",
                    "properties": {
                      "color": {
                        "type": "string",
                        "enum": [
                          "#367B9C",
                          "#FFA5A4",
                          "#83D17F",
                          "#FFAC7B",
                          "#8E3F64",
                          "#C75300",
                          "#009CEC",
                          "#62D6B1",
                          "#9EEDCB",
                          "#F9A2C4",
                          "#616161",
                          "#BBDA81",
                          "#DFD3F8",
                          "#D6C4A5",
                          "#FFD478",
                          "#6AC9DE",
                          "#EABBB0",
                          "#BFC2E1",
                          "#DADADA",
                          "#CDE2F5"
                        ],
                        "description": "Test description"
                      },
                      "name": {
                        "type": "string",
                        "description": "Another test description"
                      },
                      "source": {
                        "type": "string",
                        "enum": [
                          "web",
                          "mobile"
                        ],
                        "description": "Yet another test description"
                      },
                      "visible": {
                        "type": "boolean",
                        "description": "Nothing to see here"
                      }
                    },
                    "required": [
                      "name"
                    ]
                  }
                }
              }
            }
          },
          "required": false
        }
      }
    }
  },
  "tags": [
    {
      "name": "Things",
      "description": "A bunch of things"
    }
  ]
}

@spacether
Copy link
Contributor

@syntaxaire fixed!

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

Successfully merging a pull request may close this issue.

2 participants