Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested schema matching #35

Open
a14m opened this issue May 6, 2016 · 1 comment
Open

Nested schema matching #35

a14m opened this issue May 6, 2016 · 1 comment

Comments

@a14m
Copy link

a14m commented May 6, 2016

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
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants