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

Advanced example for parsing schemas #85

Open
andrewmellinger opened this issue Jun 4, 2021 · 2 comments
Open

Advanced example for parsing schemas #85

andrewmellinger opened this issue Jun 4, 2021 · 2 comments

Comments

@andrewmellinger
Copy link

Greetings! First off, thanks for taking the time to put this together and maintain it. :)

I am trying to build a utility for generating documentation/templates from json schemas as I can't find something out there that works. So I thought I'd try to use the statham parser to generate more outputs. I have been reading through the advanced tutorials on model generation and the API reference but I am having trouble understanding how to iterate (recurse) all the elements. I can't and find the description, default and example properties. Is there any example traverser code or visitor support available?

Thanks!

@jacksmith15
Copy link
Owner

Hi @andrewmellinger

default is exposed on each element returned from the get_children iterator, e.g.

from statham.serializers.orderer import get_children

for child_element in get_children(root_element):
    print(element.default)

Unfortunately description and examples are not currently parsed by statham - see https://statham-schema.readthedocs.io/en/latest/compatibility.html#annotations.

Happy to accept a PR which adds support for those annotations!

@andrewmellinger
Copy link
Author

Awesome! I haven't dug through your source at all. Can you drop a quick pointer where the default is extracted so I can see how hard/complex it is going to be?

Thanks!

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