@trigo/atrix-swagger
Advanced tools
| 'use strict'; | ||
| module.exports = (req, reply) => reply(); |
| 'use strict'; | ||
| module.exports = (req, reply) => reply(req.payload); |
| 'use strict'; | ||
| module.exports = (req, reply) => reply(req.payload); |
| 'use strict'; | ||
| const svc = require('./service.js'); | ||
| const start = async () => { | ||
| await svc.start(); | ||
| }; | ||
| start(); | ||
@@ -117,2 +117,17 @@ 'use strict'; | ||
| let schema; | ||
| /* | ||
| * handle special case: | ||
| * - in: body | ||
| * name: body | ||
| * schema: | ||
| * type: object | ||
| * parameters: | ||
| * # the typeless property creates a "null" value for key "typeless" | ||
| * typeless: | ||
| * ohterprop: | ||
| * decription: has value | ||
| */ | ||
| if (!parameter) { | ||
| return Joi.any(); | ||
| } | ||
| if (parameter.schema) { | ||
@@ -119,0 +134,0 @@ schema = createSchemaValidator(parameter.schema); |
+1
-1
| { | ||
| "name": "@trigo/atrix-swagger", | ||
| "version": "1.5.0", | ||
| "version": "1.5.1", | ||
| "engines": { | ||
@@ -5,0 +5,0 @@ "node": ">=7.6.0" |
@@ -209,2 +209,31 @@ 'use strict'; | ||
| }); | ||
| describe('typeless parameters/schemas', () => { | ||
| ['test', 0, true].forEach((v) => { | ||
| it(`can omit type in main parametes list send ?typless=${typeof v === 'object' ? JSON.stringify(v) : v}`, async () => { | ||
| const res = await svc.test.get(`/prefix/typeless?typeless=${v}`); | ||
| expect(res.statusCode).to.eql(200); | ||
| }); | ||
| }); | ||
| ['test', 0, { test: 'obj' }].forEach((v) => { | ||
| it(`can omit type in body schema send ${typeof v === 'object' ? JSON.stringify(v) : v}`, async () => { | ||
| const res = await svc.test.post('/prefix/typeless').send(v); | ||
| expect(res.statusCode).to.eql(200); | ||
| }); | ||
| }); | ||
| ['test', 0, { test: 'obj' }].forEach((v) => { | ||
| it(`can omit type in body schema send ${typeof v === 'object' ? JSON.stringify(v) : v}`, async () => { | ||
| const res = await svc.test.put('/prefix/typeless').send({ typeless: v, 'typeless-required': 'sdf' }); | ||
| expect(res.statusCode).to.eql(200); | ||
| }); | ||
| it(`Typless parameters ca be marked as required. Sending ${typeof v === 'object' ? JSON.stringify(v) : v}`, async () => { | ||
| const res = await svc.test.put('/prefix/typeless').send({ typeless: v }); | ||
| expect(res.statusCode).to.eql(400); | ||
| expect(res.body.message).to.contain('"typeless-required" is required'); | ||
| }); | ||
| }); | ||
| }); | ||
| }); |
+21
-0
@@ -598,2 +598,23 @@ swagger: "2.0" | ||
| /typeless: | ||
| get: | ||
| parameters: | ||
| - in: query | ||
| name: typeless | ||
| post: | ||
| parameters: | ||
| - in: body | ||
| name: body | ||
| put: | ||
| parameters: | ||
| - in: body | ||
| name: body | ||
| schema: | ||
| type: object | ||
| required: | ||
| - typeless-required | ||
| properties: | ||
| typeless: | ||
| typeless-required: | ||
| securityDefinitions: | ||
@@ -600,0 +621,0 @@ api_key: |
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
176719
1.29%41
10.81%1319
4.1%