Skip to content

Commit 846b80d

Browse files
fix: Correct exclude handling per {blueprintAction} in model files (#80)
Also add new test data and correct test fixture. Closes #77.
1 parent c407361 commit 846b80d

File tree

3 files changed

+10
-122
lines changed

3 files changed

+10
-122
lines changed

api/models/Pet.js

+8
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@
55
* @docs :: http://sailsjs.org/documentation/concepts/models-and-orm/models
66
*/
77

8+
/**
9+
* @swagger
10+
*
11+
* /create:
12+
* exclude: true
13+
*
14+
*/
15+
816
module.exports = {
917

1018
primaryKey: 'petID',

lib/generators.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,8 @@ export const generatePaths = (routes: SwaggerRouteInfo[], templates: BlueprintAc
376376

377377
if (route.middlewareType === MiddlewareType.BLUEPRINT && route.model) {
378378

379-
if(route.model.swagger?.modelSchema?.exclude === true) {
379+
if (route.model.swagger?.modelSchema?.exclude === true
380+
|| route.model.swagger.actions?.[route.action]?.exclude === true) {
380381
return;
381382
}
382383

test/fixtures/generatedSwagger.json

-121
Original file line numberDiff line numberDiff line change
@@ -989,86 +989,6 @@
989989
}
990990
}
991991
},
992-
"/pet/create": {
993-
"get": {
994-
"summary": "Create Pet *",
995-
"description": "Create a new **Pet** record.\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**)",
996-
"externalDocs": {
997-
"url": "https://sailsjs.com/documentation/reference/blueprint-api/create",
998-
"description": "See https://sailsjs.com/documentation/reference/blueprint-api/create"
999-
},
1000-
"tags": [
1001-
"Pet"
1002-
],
1003-
"parameters": [
1004-
{
1005-
"in": "query",
1006-
"name": "petID",
1007-
"schema": {
1008-
"type": "integer",
1009-
"format": "int64",
1010-
"uniqueItems": true,
1011-
"description": "Note Sails special attributes: autoIncrement",
1012-
"readOnly": true
1013-
},
1014-
"description": "Note Sails special attributes: autoIncrement"
1015-
},
1016-
{
1017-
"in": "query",
1018-
"name": "names",
1019-
"schema": {
1020-
"type": "string",
1021-
"example": "Pet's full name"
1022-
},
1023-
"required": true
1024-
},
1025-
{
1026-
"in": "query",
1027-
"name": "owner",
1028-
"schema": {
1029-
"description": "JSON dictionary representing the **user** instance or FK when creating / updating / not populated",
1030-
"oneOf": [
1031-
{
1032-
"$ref": "#/components/schemas/user"
1033-
}
1034-
]
1035-
},
1036-
"description": "JSON dictionary representing the **user** instance or FK when creating / updating / not populated"
1037-
},
1038-
{
1039-
"in": "query",
1040-
"name": "caredForBy",
1041-
"schema": {
1042-
"description": "JSON dictionary representing the **user** instance or FK when creating / updating / not populated",
1043-
"oneOf": [
1044-
{
1045-
"$ref": "#/components/schemas/user"
1046-
}
1047-
]
1048-
},
1049-
"description": "JSON dictionary representing the **user** instance or FK when creating / updating / not populated"
1050-
}
1051-
],
1052-
"responses": {
1053-
"200": {
1054-
"description": "Responds with a JSON dictionary representing the newly created **Pet** instance",
1055-
"content": {
1056-
"application/json": {
1057-
"schema": {
1058-
"$ref": "#/components/schemas/pet"
1059-
}
1060-
}
1061-
}
1062-
},
1063-
"404": {
1064-
"description": "Resource not found"
1065-
},
1066-
"500": {
1067-
"description": "Internal server error"
1068-
}
1069-
}
1070-
}
1071-
},
1072992
"/pet/update/{_petID}": {
1073993
"get": {
1074994
"summary": "Update Pet *",
@@ -1926,47 +1846,6 @@
19261846
"description": "Internal server error"
19271847
}
19281848
}
1929-
},
1930-
"post": {
1931-
"summary": "Create Pet",
1932-
"description": "Create a new **Pet** record.",
1933-
"externalDocs": {
1934-
"url": "https://sailsjs.com/documentation/reference/blueprint-api/create",
1935-
"description": "See https://sailsjs.com/documentation/reference/blueprint-api/create"
1936-
},
1937-
"tags": [
1938-
"Pet"
1939-
],
1940-
"parameters": [],
1941-
"responses": {
1942-
"200": {
1943-
"description": "Responds with a JSON dictionary representing the newly created **Pet** instance",
1944-
"content": {
1945-
"application/json": {
1946-
"schema": {
1947-
"$ref": "#/components/schemas/pet"
1948-
}
1949-
}
1950-
}
1951-
},
1952-
"404": {
1953-
"description": "Resource not found"
1954-
},
1955-
"500": {
1956-
"description": "Internal server error"
1957-
}
1958-
},
1959-
"requestBody": {
1960-
"description": "JSON dictionary representing the Pet instance to create.",
1961-
"required": true,
1962-
"content": {
1963-
"application/json": {
1964-
"schema": {
1965-
"$ref": "#/components/schemas/pet"
1966-
}
1967-
}
1968-
}
1969-
}
19701849
}
19711850
},
19721851
"/pet/{_petID}": {

0 commit comments

Comments
 (0)