OpenAPITools/openapi-generator

[Python] boolean query parameter capitalization

Geschlossen

#1.260 geöffnet am 17.10.2018

 (16 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)Java (7.516 Forks)batch import
Client: PythonGood First IssueIssue: Bug

Repository-Metriken

Stars
 (26.243 Sterne)
PR-Merge-Metriken
 (Durchschn. Merge 9T 1h) (123 gemergte PRs in 30 T)

Beschreibung

(Copy of https://github.com/swagger-api/swagger-codegen/issues/8433)

Description

The generated python client translates boolean query parameters in Python case - i.e. "True"/"False" rather than "true"/"false".

I am dealing with a case-sensitive API endpoint, which expects a boolean query parameter, and treats anything except "0" and "false" as true - including "False" evaluating to true.

Per RFC 3986, the query part of a URI should be treated as case-sensitive. I suspect many (most?) servers in the wild expect "false", in line with the variable names in most languages.

Is this expected behavior?

Swagger-codegen version

2.4.0-SNAPSHOT

Swagger declaration file content or url

        "parameters": [
          {
            "name": "reverse",
            "in": "query",
            "description": "If true, will sort results newest first.",
            "required": false,
            "default": false,
            "type": "boolean"
          }
        ],

Command line used for generation

java -jar ./swagger-codegen/modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate -i ./swagger.json -l python -o generated/python

Steps to reproduce

# given an API endpoint which accepts a boolean query parameter
>>> foo_list = client.Foo.Foo_get(reverse=True)
>>> foo_list.future.request.prepare()
>>> print(foo_list.url)
http://example.com/api/foo?reverse=True

Suggest a fix/enhancement

Suggestion: instead of "True" or "False", convert to the string "true" or "false".

Contributor Guide