swagger-api / swagger-api/swagger-codegen
Swagger generator doesn't recognize controller
Nobody has claimed this yet.
- 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:

Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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