Skip to content

Consider coercing response codes to strings #422

@zachmullen

Description

@zachmullen

The OpenAPI specification allows responses of the form 2XX, 4XX, etc. Using this library, it's possible in a docstring to write something like this:

responses:
   200:
       content:
           application/json:
               schema: GoodResponseSchema
   4XX:
       content:
           application/json:
               schema: RequestErrorSchema

This causes the following error:

File "/Users/zach/.pyenv/versions/3.6.5/lib/python3.6/json/encoder.py", line 353, in _iterencode_dict
    items = sorted(dct.items(), key=lambda kv: kv[0])
TypeError: '<' not supported between instances of 'str' and 'int'

Which happens because the 200 key is stored as an int, and the 4XX key is stored as a string. A preprocessing step to make them all strings would fix that problem.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions