swagger-api / swagger-api/swagger-codegen

Swagger generator doesn't recognize controller

Open
#4,156 4 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

General: Suggestion Server: Nodejs
Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

Swagger generator doesn't recognize controller
http://stackoverflow.com/questions/38295951/swagger-generator-doesnt-recognize-controller

Swagger-codegen version

2.2.1

Swagger declaration file content or url
swagger: '2.0'
info:
  version: 0.0.0
  title: Mac Data API
paths:
  /tasks:
    x-swagger-router-controller: taskController
    get:
      operationId: getTasks
      responses:
        201:
          description: OK
          schema:
            type: "array"
            items:
              $ref: "#/definitions/task"
definitions:
  task:
    type: "object"
    properties:
      title:
        type: string
      date:
        type: string
      status:
        type: string
        default: "todo"
        enum:
        - todo
        - done
    required:
    - title
    - status
Command line used for generation

java -jar "E:\tools\\swagger-codegen-cli-2.2.1.jar" generate -l nodejs-server -o src/api/swagger -i src/api/swagger/swagger.yaml

Steps to reproduce

Just use swagger definition file and command line described above.

I'm confused with solution given in Stackoverflow thread... adding tags to make it works is crappy...

Furthermore, if I add multiple tags to get operation:

  ...
  /tasks:
    get:
      operationId: getTasks
      tags:
      - taskController
      - anotherController
      responses:
      ...

generate command spread the same code over templated controller files:

image

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 issue with the provided swagger.yaml and the Java command using the nodejs-server generator. Compare generation with x-swagger-router-controller alone versus multiple operation tags. Done means the controller is recognized as intended and an operation is not duplicated across templated controller files.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, node.js, openapi
Domain
backend-api-design, 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.