Skip to content

Content-Type text/plain is not respected #312

Closed
@JochenDiekenbrock

Description

@JochenDiekenbrock

Given a path that accepts a put operation with a text/plain body:

info:
  title: Demo
  version: '1.0'
swagger: '2.0'
paths:
  '/agency':
    put:
      consumes:
        - text/plain
      produces:
        - text/plain
      parameters:
        - in: body
          name: agency
          required: true
          schema:
            type: string
            example: "123"
      responses:
        '200':
          description: OK
          schema:
            type: string

The generated client code for axios does not set the Content-Type. The Content-Type header in the http request is not set.

agencyUpdate: (agency: string, params: RequestParams = {}) =>
      this.request<string, any>({
        path: `/agency`,
        method: "PUT",
        body: agency,
        ...params
      })

If in the generated code the type is added manually, the Content-Type header is set as specified:

agencyUpdate: (agency: string, params: RequestParams = {}) =>
      this.request<string, any>({
        path: `/agency`,
        method: "PUT",
        type: "text/plain" as any,
        body: agency,
        ...params
      })

Expected behavior: The type should be set according to the "consumes" definition (and the typing of type should be adapted)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions