Giter Site home page Giter Site logo

Comments (4)

ecordell avatar ecordell commented on May 22, 2024 1

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.

Almad avatar Almad commented on May 22, 2024

That said, we are still going to look into it in gavel.

from dredd.

gaxunil avatar gaxunil commented on May 22, 2024

OK thanks a lot. I appreciate the replies. Very cool stuff.

from dredd.

netmilk avatar netmilk commented on May 22, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.