Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #14090
Closed
Open
Issue created Nov 22, 2022 by Administrator@rootContributor4 of 6 checklist items completed4/6 checklist items

[BUG][Python] Ranged response codes not working

Created by: Poolmann

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

Ranged HTTP response codes are not recognized in deserialization of the response.

openapi-generator version

Version 6.3.0

OpenAPI declaration file content or url

With a response schema like:

paths:
  /upload:
    post:
      tags: [upload]
      operationId: postUpload
      requestBody:
        $ref: "#/components/requestBodies/UploadRequest"
      responses:
        "2XX":
          $ref: "#/components/responses/UploadResponse"
        "403":
          $ref: "#/components/responses/UploadForbiddenError"
        "413":
          $ref: "#/components/responses/UploadRequestToLargeError"
        "415":
          $ref: "#/components/responses/UploadUnsupportedMediaError"
        "429":
          $ref: "#/components/responses/UploadTooManyRequestsError"
        # General responses
        "400":
          $ref: "#/components/responses/BadRequestError"
        "401":
          $ref: "#/components/responses/UnauthorizedError"
        "500":
          $ref: "#/components/responses/InternalServerError"
        "503":
          $ref: "#/components/responses/ServiceUnavailableError"
Generation Details

java -jar openapi-generator-cli-6.3.0.jar generate -i openapi.yaml -g python

Steps to reproduce
  1. Use ranged response codes in the specification
  2. skip_deserialization should be False (also default)

Expected Result: Deserialized response body Actual Result: <devaice_web_api_client.schemas.Unset object at 0x7fdf7fe177f0>

These are the relevant code snippets regarding the deserialization:

if skip_deserialization:
    api_response = api_client.ApiResponseWithoutDeserialization(response=response)
else:
    response_for_status = _status_code_to_response.get(str(response.status))
    if response_for_status:
        api_response = response_for_status.deserialize(response, self.api_client.configuration)
    else:
        api_response = api_client.ApiResponseWithoutDeserialization(response=response)

and

_status_code_to_response = {
    '403': _response_for_403,
    '413': _response_for_413,
    '415': _response_for_415,
    '429': _response_for_429,
    '400': _response_for_400,
    '401': _response_for_401,
    '500': _response_for_500,
    '503': _response_for_503,
    '2XX': _response_for_2XX,
}

So the response code '200' is not recognized => response_for_status is None and I don't get a deserialized response.

Assignee
Assign to
Time tracking