swagger-api / swagger-api/swagger-codegen

[JavaScript] Missing comma between parameters in documentation

Open
#6,920 0 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

The generated documentation misses commas between the arguments in the examples section, for example:

import Api from 'api';

let apiInstance = new Api.DefaultApi();

let taskId = 56; // Number |

let text = "text_example"; // String |


apiInstance.tasksTaskIdCommentsPost(taskIdtext, (error, data, response) => {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully.');
  }
});

Notice the first argument to apiInstance.tasksTaskIdCommentsPost() being taskIdtext while it should be two parameters: taskId, text.

Swagger-codegen version

Both master and 3.0.0 branches are affected.

Swagger declaration file content or url
swagger: '2.0'
  
info:
  title: API
  version: '1.0'

paths:
  '/tasks/{task_id}/comments/':
    parameters:
      - name: task_id
        in: path
        required: true
        type: integer

    options:
      responses:
        '204':
          description: 'Request fulfilled, nothing follows'
      summary: Check which methods are allowed

    post:
      responses:
        '200':
          description: 'Request fulfilled, document follows'

      summary: Create a new Comment
      parameters:
        - in: formData
          name: text
          required: true
          type: string
      consumes:
        - application/x-www-form-urlencoded
        - multipart/form-data
Command line used for generation
java -jar ./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate -i /tmp/swagger.yaml -l javascript -o /tmp/client
Steps to reproduce
  1. Generate any flavor of JavaScript client

  2. Open ./docs/DefaultApi.md

  3. Notice that there is

    tasksTaskIdCommentsPost(taskIdtext, callback)
    

    instead of

    tasksTaskIdCommentsPost(taskId, text, callback)
    
Suggest a fix/enhancement

It seems that the issue is not in the template, but probably in the Java code because if I remove the OPTIONS endpoint or merge the path-global parameters down to the method parameters, the issue gets fixed!

/cc @wing328 @xhh

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

Run the documented Java CLI generation command with the supplied Swagger YAML, then inspect ./docs/DefaultApi.md and the generated JavaScript example. Trace whether path-level parameters and the OPTIONS endpoint affect argument rendering; done means the example shows tasksTaskIdCommentsPost(taskId, text, callback) without breaking other generated clients.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.