OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
21.48k stars 6.5k forks source link

[BUG][typescript-axios] Incorrect request body name #9676

Closed epidemia closed 1 month ago

epidemia commented 3 years ago

Bug Report Checklist

Description

Request body name from x-codegen-request-body-name is ignored for composed schema.

openapi-generator version

5.1.1

OpenAPI declaration file content or url
{
  "post": {
    "tags": [
      "entities"
    ],
    "summary": "Creates a new entity",
    "operationId": "createEntity",
    "x-codegen-request-body-name": "body",
    "requestBody": {
      "content": {
        "application/json": {
          "schema": {
            "description": "Input data",
            "oneOf": [
              {
                "$ref": "#/components/schemas/First"
              },
              {
                "$ref": "#/components/schemas/Second"
              },
              {
                "$ref": "#/components/schemas/Third"
              }
            ]
          }
        }
      }
    }
  }
}
Generation Details

openapi-generator-maven-plugin:5.1.1

Expected request param name: body Actual request param name: firstSecondThird

Steps to reproduce

Use the openapi-generator-maven-plugin and typescript-axios template

Related issues/PRs
Suggest a fix
andreiciceu commented 3 years ago

Hello,

This might be related. When using external $ref on requestBody, e.g.

  /contracts/{id}/sign/{tokenId}:
    put:
      tags:
        - Contracts
      description: Update a contract signature as anonymous user
      operationId: updateAsAnonymous
      parameters:
        - name: id
          in: path
          description: ID of the contract to update
          required: true
          schema:
            type: string
            format: uuid
        - name: tokenId
          description: the token ID
          in: path
          required: true
          schema:
            type: string
            format: uuid
      requestBody:
        description: The signature file for the beneficiary
        required: true
        content:
          application/json:
            schema:
              $ref: './whp-common.yaml#/components/schemas/AdditionalFileDTO'

the generated Type name for the body looks like this:

image

and does not exist in the generated file