Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] [Python] Response deserealisation is broken, content type #19190

Closed
5 of 6 tasks
genestack-okunitsyn opened this issue Jul 17, 2024 · 1 comment
Closed
5 of 6 tasks

Comments

@genestack-okunitsyn
Copy link
Contributor

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

Response serialisation doesn't support any other text content types but text/plain. In the openapi declaration provided example that contains content-type: text/csv.

openapi-generator version

7.7.0

OpenAPI declaration file content or url
openapi: "3.0.0"
info:
  version: 1.0.0
  title: Swagger Petstore
servers:
  - url: http://petstore.swagger.io/v1
paths:
  /pets:
    get:
      summary: List all pets
      operationId: listPets
      tags:
        - pets
      parameters:
        - name: type
          in: query
          description: Type of pet
          required: false
          schema:
            enum:
              - cat
              - dog
            type: string
      responses:
        '200':
          description: A paged array of pets
          content:
            text/csv:
              schema:
                $ref: "#/components/schemas/Pets"
        default:
          description: unexpected error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
components:
  schemas:
    Pet:
      type: object
      required:
        - id
        - name
      properties:
        id:
          type: integer
          format: int64
        name:
          type: string
        tag:
          type: string
    Pets:
      type: array
      maxItems: 100
      items:
        $ref: "#/components/schemas/Pet"
    Error:
      type: object
      required:
        - code
        - message
      properties:
        code:
          type: integer
          format: int32
        message:
          type: string
Generation Details
openapi-generator generate -i definition.yaml -g python -o openapi
Steps to reproduce

It would require any server implementation that returns a response in text/csv format. I haven't one.
But from other declaration with the very same content type I have got an error:

E   odm_api.exceptions.ApiException: (0)
E   Reason: Unsupported content type: text/csv;charset=UTF-8
Related issues/PRs

6ae8a8f

Suggest a fix

I suppose we can substitute this condition in template:

        elif content_type.startswith("text/plain"):

to more general one:

        elif content_type.startswith("text/"):

Link in the code:

elif content_type.startswith("text/plain"):

@Adrien-LUDWIG
Copy link

Related to #19285 which describes the same problem for json related MIME types.

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

No branches or pull requests

2 participants