swagger-api / swagger-api/swagger-codegen

JavaScript: Errornous generation of param types in JSDoc for enum and array typed parameters

Open
#2,925 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Client: JavaScript/Node.js Feature: Documentation help wanted Issue: Bug
Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

This is generated

    /**
     * Массовые операции над объектами клиентов
     * @param {Array.<module:model/Integer>} objectsList Список идентификаторов объектов для массовой операции
     * @param {module:model/String} operation Тип операции
     * data is of type: {Array.<module:model/BatchResults>}
     */

But should be something like this:

    /**
     * Массовые операции над объектами клиентов
     * @param {Number[]} objectsList Список идентификаторов объектов для массовой операции
     * @param {String} operation Тип операции
     * data is of type: {Array.<module:model/BatchResults>}
     */

Source spec for this part is:

  /batch/clients/{operation}:
    put:
      summary: "Массовые операции над объектами клиентов"
      operationId: "batch_clients"
      parameters:
        - name: "objects_list"
          description: "Список идентификаторов объектов для массовой операции"
          required: true
          schema:
            type: "array"
            items:
              type: "integer"
              format: "int64"
              description: "Идентификатор объекта"
          in: "body"
        - name: "operation"
          description: "Тип операции"
          required: true
          type: "string"
          enum:
            - 'reload'
            - 'reboot'
            - 'shutdown'
          in: "path"
      responses:
        200:
          description: ""
          schema:
            type: "array"
            items:
              $ref: BatchResults
Swagger-codegen version

Latest master.

Swagger declaration file content or url

https://gist.github.com/arikon/2f078fcf15aae07984c7e1d35def90bf

Command line used for generation
SWAGGER_JSON=swagger-new.json
SWAGGER_OUTPUT=sandbox-json-api

export JAVA_HOME=$(/usr/libexec/java_home -v 1.7)
export PATH=${JAVA_HOME}/bin:$PATH

java -jar swagger-codegen/modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \
    -i ${SWAGGER_JSON} \
    -l javascript \
    -o ${SWAGGER_OUTPUT} \
    --additional-properties usePromises=true
Steps to reproduce
Related issues
Suggest a Fix

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 JavaScript generation using the linked Swagger declaration, the shown command, and the batch endpoint schema. Compare the generated JSDoc for the array and enum parameters with the expected Number[] and String forms; done means the incorrect param types are corrected without regressing the response type.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.