chancancode / json_expressions

JSON matchmaking for all your API testing needs.
MIT License
414 stars 38 forks source link

Nested schema matching #35

Open a14m opened 8 years ago

a14m commented 8 years ago

working with APIs there are some endpoints that return compound data... for example (just for demonstration... not a real example)

// child schema
{ "name": "Luke Skywalker", "age": 30 }
// parent schema
{ "name": "Darth Vader", "age": 63, "children": [{ "name": "Luke Skywalker", "age": 30 }] }

is there a way to nest the deffinition of the schemas ? so that it's possible to define the parent schema as follows ?

JsonSchema.define :child do
  {
    name: String,
    age: Numeric
  }
end

JsonSchema.define :parent do
  {
    name: String,
    age: Numeric,
    children: [ JsonSchema(:child) ]
  }
end
MiroslavCsonka commented 8 years ago

I also needed to do something similar so I went with this. I was thinking about using FactoryGirl for generation of some schemas.