Skip to content

Commit

Permalink
fix(cli): generate operation only for the 1st tag to avoid duplicate …
Browse files Browse the repository at this point in the history
…routes

An OpenAPI operation may have more than one tags. Adding the operation to
two controllers produces duplicate routes and it fails the application.
  • Loading branch information
raymondfeng committed Apr 11, 2019
1 parent af20548 commit 4843a1f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/cli/generators/openapi/spec-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,9 @@ function groupOperationsByController(apiSpec) {
let controllers = ['OpenApiController'];
if (op['x-controller-name']) {
controllers = [op['x-controller-name']];
} else if (op.tags) {
controllers = op.tags.map(t => titleCase(t + 'Controller'));
} else if (Array.isArray(op.tags) && op.tags.length) {
// Only add the operation to first tag to avoid duplicate routes
controllers = [titleCase(op.tags[0] + 'Controller')];
}
controllers.forEach((c, index) => {
/**
Expand Down

0 comments on commit 4843a1f

Please sign in to comment.