Skip to content

Handle Default Responses in response generation #124

Description

@bladecoates

Describe the bug
In the specifications, default MAY be used as a default response object for all HTTP codes that are not covered individually by the specification.

response = response_from_data(status_code=int(code), data=response_data)

ValueError: invalid literal for int() with base 10: 'default'

To Reproduce
Sample code from a openapi spec.

      responses:
        "200":
          description: An array of items
          content:
            application/json:
              schema:
                allOf:
                  - $ref: "#/components/schemas/ItemsArrayObj"
        default:
          description: Unknown error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"

Expected behavior
Code should generate a custom ApiResponseError class if default is defined, with content of error being a model of the reference/schema items

OpenAPI Spec File
Sample code from a openapi spec.

      responses:
        "200":
          description: An array of items
          content:
            application/json:
              schema:
                allOf:
                  - $ref: "#/components/schemas/ItemsArrayObj"
        default:
          description: Unknown error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"

Desktop (please complete the following information):

  • OS: Linux Mint
  • Python Version: 3.8.3
  • openapi-python-client version: git main

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions