swagger-api / swagger-api/swagger-codegen

[Java] Generated javascript client code is invalid

Open
#11,823 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

Defined header attribute with line break the client generated code.

Swagger-codegen version

3.0.34

Swagger declaration file content or url

(for Json code)

{
  "openapi": "3.0.1",
  "info": {
    "title": "Reporting API",
    "version": "v1"
  },
  "paths": {
    "/reporting/HealthCheck": {
      "get": {
        "tags": [
          "HealthCheck"
        ],
        "parameters": [
          {
            "name": "X-Header-Attribute-Id",
            "in": "header",
            "description": "xcxcxcxcx  sdsds-E1B8C520F65A)",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              },
              "application/json": {
                "schema": {
                  "type": "string"
                }
              },
              "text/json": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    }}
Generated client

/**

  • HealthCheckApi - axios parameter creator
  • @export
    /
    export const HealthCheckApiAxiosParamCreator = function (configuration?: Configuration) {
    return {
    /
    *
    *
    * @param {} Please specify header X-Header-Attribute-Id. For Example(ddddd5A)
    * @param {*} [options] Override http request option.
    * @throws {RequiredError}
    */
    healthCheckGet: async (: , options: AxiosRequestConfig = {}): Promise => {
    // verify required parameter '' is not null or undefined
    if ( === null || === undefined) {
    throw new RequiredError('','Required parameter was null or undefined when calling healthCheckGet.');
    }

So first parameter is simply empty, in case I will change the name of header from X-Header-Attribute-Id to XHeaderAttributeId it works.

Suggest a fix/enhancement

Header name no matter what name contains should not break the client code.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the generated JavaScript client from the supplied OpenAPI declaration and inspect the HealthCheckApiAxiosParamCreator output, especially the header parameter with hyphens. Trace the JavaScript client generation template or entry point that produces the empty parameter name. Done means the generated client remains valid and preserves the header parameter name.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
api, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.