Skip to content

Commit c407361

Browse files
fix: Correct merge of custom {blueprintAction} from model files (#78)
Previously, `allActions` custom documentation in model files was correctly merged into the final output, but per-blueprint-action documentation (in either JSDoc or `swagger` element) was missed. Closes #77.
1 parent eafbed4 commit c407361

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

lib/generators.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,10 @@ export const generatePaths = (routes: SwaggerRouteInfo[], templates: BlueprintAc
412412
tags: route.swagger?.tags || route.model.swagger.modelSchema?.tags || route.model.swagger.actions?.allactions?.tags || [route.model.globalId],
413413
parameters,
414414
responses: cloneDeep(defaultsValues.responses || {}),
415-
...cloneDeep(omit(route.model.swagger.actions?.allactions || {}, 'exclude')),
415+
...cloneDeep(omit({
416+
...route.model.swagger.actions?.allactions || {},
417+
...route.model.swagger.actions?.[route.action] || {},
418+
}, 'exclude')),
416419
...cloneDeep(omit(route.swagger || {}, 'exclude')),
417420
};
418421

test/fixtures/generatedSwagger.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@
361361
},
362362
"get": {
363363
"summary": "List User (find where)",
364-
"description": "Find a list of **User** records that match the specified criteria.",
364+
"description": "_Alternate description_: Find a list of **User** records that match the specified criteria.\n",
365365
"externalDocs": {
366366
"url": "https://somewhere.com/yep",
367367
"description": "Refer to these docs for more info"
@@ -1190,7 +1190,7 @@
11901190
"/user/find": {
11911191
"get": {
11921192
"summary": "List User (find where) *",
1193-
"description": "Find a list of **User** records that match the specified criteria.\n\n(\\*) Note that this is a [Sails blueprint shortcut route](https://sailsjs.com/documentation/concepts/blueprints/blueprint-routes#?shortcut-blueprint-routes) (recommended for **development-mode only**)",
1193+
"description": "_Alternate description_: Find a list of **User** records that match the specified criteria.\n\n\n(\\*) Note that this is a [Sails blueprint shortcut route](https://sailsjs.com/documentation/concepts/blueprints/blueprint-routes#?shortcut-blueprint-routes) (recommended for **development-mode only**)",
11941194
"externalDocs": {
11951195
"url": "https://somewhere.com/yep",
11961196
"description": "Refer to these docs for more info"
@@ -1272,7 +1272,7 @@
12721272
"/user/find/{_id}": {
12731273
"get": {
12741274
"summary": "Get User (find one) *",
1275-
"description": "Look up the **User** record with the specified ID.\n\n(\\*) Note that this is a [Sails blueprint shortcut route](https://sailsjs.com/documentation/concepts/blueprints/blueprint-routes#?shortcut-blueprint-routes) (recommended for **development-mode only**)",
1275+
"description": "_Alternate description_: Look up the **User** record with the specified ID.\n\n(\\*) Note that this is a [Sails blueprint shortcut route](https://sailsjs.com/documentation/concepts/blueprints/blueprint-routes#?shortcut-blueprint-routes) (recommended for **development-mode only**)",
12761276
"externalDocs": {
12771277
"url": "https://somewhere.com/yep",
12781278
"description": "Refer to these docs for more info"
@@ -2208,7 +2208,7 @@
22082208
"/user/{_id}": {
22092209
"get": {
22102210
"summary": "Get User (find one)",
2211-
"description": "Look up the **User** record with the specified ID.",
2211+
"description": "_Alternate description_: Look up the **User** record with the specified ID.",
22122212
"externalDocs": {
22132213
"url": "https://somewhere.com/yep",
22142214
"description": "Refer to these docs for more info"

0 commit comments

Comments
 (0)