OpenAPITools/openapi-generator

[Python] boolean query parameter capitalization

已關閉

#1,260 建立於 2018年10月17日

 (16 則留言) (0 個反應) (0 位負責人)Java (7,516 個分叉)batch import
Client: PythonGood First IssueIssue: Bug

倉庫指標

星標
 (26,243 顆星)
PR 合併指標
 (平均合併 9天 1小時) (30 天內合併 123 個 PR)

描述

(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".

貢獻者指南