Comments (4)
Validation is handled by gavel.js and not by dredd, so this should really be an issue over there.
What happens is that the body is parsed into a representative json schema, and I suspect it's just not generating a schema properly for your case. Support for root-level arrays is the most recent addition to gavel, and I wouldn't be surprised if there isn't coverage for this situation.
Short term solution for you: if you provide your own json schema, it will validate against that instead, so you can manually specify that the number of items is important.
from dredd.
That said, we are still going to look into it in gavel.
from dredd.
OK thanks a lot. I appreciate the replies. Very cool stuff.
from dredd.
I try to replicate it on latest dredd v0.3.7 and it seems to be no longer valid. Gavel generates schema for each member in the array so real response array must contain at least same amount of members as specified in blueprint.
info: Beginning Dredd testing...
127.0.0.1 - - [Tue, 01 Jul 2014 14:07:58 GMT] "GET /machines HTTP/1.1" 200 70 "-" "Dredd/0.3.7 (Darwin 13.2.0; x64)"
fail: GET /machines duration: 11ms
info: Displaying failed tests...
fail: GET /machines duration: 11ms
fail: body: The ‘1’ property is required.
body: The 1 property must be an object (current value is undefined).
body: The ‘1,_id’ property is required.
body: The ‘1,type’ property is required.
body: The ‘1,name’ property is required.
request:
body:
headers:
User-Agent: Dredd/0.3.7 (Darwin 13.2.0; x64)
uri: /machines
method: GET
expected:
headers:
content-type: application/json
body:
[
{
"_id": "52341870ed55224b15ff07ef",
"type": "bulldozer",
"name": "willy"
},
{
"_id": "12345",
"type": "car",
"name": "tommy"
}
]
statusCode: 200
actual:
statusCode: 200
headers:
x-powered-by: Express
content-type: application/json
content-length: 70
date: Tue, 01 Jul 2014 14:07:58 GMT
connection: keep-alive
body:
[
{
"_id": "12345",
"type": "car",
"name": "tommy"
}
]
complete: 0 passing, 1 failing, 0 errors, 0 skipped
complete: Tests took 20ms
from dredd.
Related Issues (20)
- Package dependency triggers NPM advisory (1179) HOT 5
- [Question] How to send form-data (not file, it's string)? HOT 1
- Skipped tests when using square brackets in get parameter name HOT 5
- Package dependency triggers NPM advisory (1696) HOT 1
- [Suggestion] Add timeout
- vulnerability CVE-2020-7598 is introduced by package minimist HOT 1
- dredd init fails when travis ci integration is requested HOT 1
- API description parser error
- oneOf doesn't work as expected
- [Question] Is it possible to split hooks.js?
- Update latest image on Dockerhub
- Add the ability to issue warnings instead of errors for hyphens in Openapi request parameters.
- Dredd doesn't make consistency check between OpenAPI schema and example
- Improved documentation for running dredd in CI / docker
- Empty body with x-www-form-urlencoded
- Multiple status code exclusion in if statement in webhook
- Issues on Paramaeters Example with Swagger.JSON
- Request library is deprecated
- Head type requests not working HOT 1
- Is `dredd` dead? Please don't abandon this amazing project! HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dredd.