Skip to content

Commit

Permalink
fix: Correct exclude handling per {blueprintAction} in model files (#…
Browse files Browse the repository at this point in the history
…80)

Also add new test data and correct test fixture.

Closes #77.
  • Loading branch information
danielsharvey committed Jun 19, 2020
1 parent c407361 commit 846b80d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 122 deletions.
8 changes: 8 additions & 0 deletions api/models/Pet.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@
* @docs :: http://sailsjs.org/documentation/concepts/models-and-orm/models
*/

/**
* @swagger
*
* /create:
* exclude: true
*
*/

module.exports = {

primaryKey: 'petID',
Expand Down
3 changes: 2 additions & 1 deletion lib/generators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,8 @@ export const generatePaths = (routes: SwaggerRouteInfo[], templates: BlueprintAc

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

if(route.model.swagger?.modelSchema?.exclude === true) {
if (route.model.swagger?.modelSchema?.exclude === true
|| route.model.swagger.actions?.[route.action]?.exclude === true) {
return;
}

Expand Down
121 changes: 0 additions & 121 deletions test/fixtures/generatedSwagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -989,86 +989,6 @@
}
}
},
"/pet/create": {
"get": {
"summary": "Create Pet *",
"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**)",
"externalDocs": {
"url": "https://sailsjs.com/documentation/reference/blueprint-api/create",
"description": "See https://sailsjs.com/documentation/reference/blueprint-api/create"
},
"tags": [
"Pet"
],
"parameters": [
{
"in": "query",
"name": "petID",
"schema": {
"type": "integer",
"format": "int64",
"uniqueItems": true,
"description": "Note Sails special attributes: autoIncrement",
"readOnly": true
},
"description": "Note Sails special attributes: autoIncrement"
},
{
"in": "query",
"name": "names",
"schema": {
"type": "string",
"example": "Pet's full name"
},
"required": true
},
{
"in": "query",
"name": "owner",
"schema": {
"description": "JSON dictionary representing the **user** instance or FK when creating / updating / not populated",
"oneOf": [
{
"$ref": "#/components/schemas/user"
}
]
},
"description": "JSON dictionary representing the **user** instance or FK when creating / updating / not populated"
},
{
"in": "query",
"name": "caredForBy",
"schema": {
"description": "JSON dictionary representing the **user** instance or FK when creating / updating / not populated",
"oneOf": [
{
"$ref": "#/components/schemas/user"
}
]
},
"description": "JSON dictionary representing the **user** instance or FK when creating / updating / not populated"
}
],
"responses": {
"200": {
"description": "Responds with a JSON dictionary representing the newly created **Pet** instance",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/pet"
}
}
}
},
"404": {
"description": "Resource not found"
},
"500": {
"description": "Internal server error"
}
}
}
},
"/pet/update/{_petID}": {
"get": {
"summary": "Update Pet *",
Expand Down Expand Up @@ -1926,47 +1846,6 @@
"description": "Internal server error"
}
}
},
"post": {
"summary": "Create Pet",
"description": "Create a new **Pet** record.",
"externalDocs": {
"url": "https://sailsjs.com/documentation/reference/blueprint-api/create",
"description": "See https://sailsjs.com/documentation/reference/blueprint-api/create"
},
"tags": [
"Pet"
],
"parameters": [],
"responses": {
"200": {
"description": "Responds with a JSON dictionary representing the newly created **Pet** instance",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/pet"
}
}
}
},
"404": {
"description": "Resource not found"
},
"500": {
"description": "Internal server error"
}
},
"requestBody": {
"description": "JSON dictionary representing the Pet instance to create.",
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/pet"
}
}
}
}
}
},
"/pet/{_petID}": {
Expand Down

0 comments on commit 846b80d

Please sign in to comment.