Skip to content

[PYTHON] Bug: client applies Content-Type header when no request body is present #10378

Description

@Robweb2000
Description

Requests with no body parameters (ie, no request body) should not include a Content-Type header.
This was acknowledged to be a bug for the Java Feign client (see #6647), and was fixed. I'm asking for parity in the Python client.

Swagger-codegen version

2.3.0

Swagger declaration file content or url
swagger: '2.0'
basePath: /
schemes:
  - http
paths:
  '/toggle':
    post:
      summary: Toggle the switch
      description: If switch is off, toggle to on, and vice versa.
      responses:
        200:
          description: Success
Command line used for generation
swagger-codegen generate -i example.yaml -l python -o $OUTPUT_DIR
Steps to reproduce

Generate a python client using an API spec that includes a POST path with no body parameters. Use the client to make a request, and observe that the request has a "Content-Type" header.

Related issues/PRs

#5613
#6647

Suggest a fix/enhancement

Only add a Content-Type header is body parameters are specified: #6648

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions