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

Question: How to define self referential schemas #256

Open
alisaifee opened this issue Mar 28, 2021 · 1 comment
Open

Question: How to define self referential schemas #256

alisaifee opened this issue Mar 28, 2021 · 1 comment

Comments

@alisaifee
Copy link

I have a schema that references itself in a property, and couldn't figure out a way to declare this.

For example:

person = Schema({
   "first_name": str, 
   "last_name": str,
   "age": int,
   "children": [person]
}, name="person")
@lozog
Copy link

lozog commented Aug 27, 2021

hey, we did self-referential schemas this way:

person_defn = dict()
person_defn.update(
    {
        "first_name": str, 
        "last_name": str,
        "age": int,
        "children": [person_defn]
    }
)
person = Schema(person_defn)

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