Open argos83 opened 7 years ago
Hi, First of all thanks for this great library!
I'm came across a validation issue (unless I'm doing things wrong). Here it is:
Given this swagger specification:
swagger: '2.0' info: version: '0.0.0' title: 'Test' consumes: - 'application/json' definitions: someObject: type: object properties: key: type: string required: - key paths: /a-list: post: parameters: - name: 'body' in: 'body' required: true schema: type: array items: $ref: '#/definitions/someObject' responses: 204: description: 'OK'
And this express app:
const express = require('express'); const swaggerTools = require('swagger-tools'); const yaml = require('yamljs'); const app = express(); const swaggerSpec = yaml.load('./swagger.yml'); swaggerTools.initializeMiddleware(swaggerSpec, (middleware) => { app.use(middleware.swaggerMetadata()); app.use(middleware.swaggerValidator()); app.post('/a-list', function (req, res) { res.status(204).end(); }); app.listen(3000, function () { console.log('Example app listening on port 3000!') }); });
I'm getting the following validation results when POSTing the following payloads to /a-list:
/a-list
[]
[{"key": "a"}]
[{"key": "a"}, {"key": "b"}]
[{"missingKey": "a"}]
{}
{"key": "a"}
This is tested on:
Might be related to this https://github.com/apigee-127/swagger-tools/issues/438
Hi, First of all thanks for this great library!
I'm came across a validation issue (unless I'm doing things wrong). Here it is:
Given this swagger specification:
And this express app:
I'm getting the following validation results when POSTing the following payloads to
/a-list
:[]
-> valid as expected[{"key": "a"}]
-> valid as expected[{"key": "a"}, {"key": "b"}]
-> valid as expected[{"missingKey": "a"}]
-> invalid as expected{}
-> invalid as expected{"key": "a"}
-> should be invalid however validation passesThis is tested on: