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
  • #3920
Closed
Open
Issue created Sep 20, 2019 by Administrator@rootContributor

[BUG][typescript-fetch] cannot handle with application/x-www-form-urlencoded content

Created by: namaozi

Description

In OpenAPI Specification Media Type Object, it says requestBody->content 's key is media type (it includes 'application/x-www-form-urlencoded' ) or media type range.

like this:

paths:
  /memo/{memoId}:
    put:
      summary: update Memo
      tags: 
        - Memos
      operationId: updateMemo
      requestBody:
        content:
          application/x-www-form-urlencoded:
            schema:
              type: object
              required:
              - title 
              properties:
                title:
                ...

It seems that the request body made through by the generated code however always make multipart/form-data request.

like this (in src/apis/Memos.ts):

export class MemosApi extends runtime.BaseAPI {
  async updateMemoRaw(requestParameters: UpdateMemoRequest) {

    // ...
    
    const headerParameters: runtime.HTTPHeaders = {};

    // ...
    
    const formData = new FormData();
    if (requestParameters.title !== undefined) {
        formData.append('title', requestParameters.title as any);
    }

    // and formData is set as body (`body: formData`)
  }
}

It would be appreciated like this:

    const headerParameters: runtime.HTTPHeaders = {};

    headerParameters['Content-Type'] = 'application/x-www-form-urlencoded'; 

    const bodyParams = new URLSearchParams();
    if (requestParameters.title !== undefined) {
        bodyParams.append('title', requestParameters.title as any);
    }

    // and bodyParams is set as body (`body: bodyParams`)
openapi-generator version

v4.1.1

Command line used for generation

openapi-generator generate -i bundle.yml -o ./lib --generator-name typescript-fetch

Assignee
Assign to
Time tracking