wolverdude / GenSON

GenSON is a powerful, user-friendly JSON Schema generator built in Python.
MIT License
571 stars 64 forks source link

How to get only content from schema ? #61

Closed Yawan-1 closed 2 years ago

Yawan-1 commented 2 years ago

I am trying to get only content from the schema. But when I try to access it like

builder.to_schema().content

then it keep says

AttributeError: 'str' object has no attribute 'content'

wolverdude commented 2 years ago

Hi Yawan!

to_schema() returns a dict, not an object, so you have to access its data using square brackets (e.g. builder.to_schema()["content"]). But that would still give you an error since there is no content keyword in JSON-Schema that I'm aware of. Perhaps you want to get the schema for the content property in the original object? If so, then you'll need to do something like this:

builder.to_schema()["properties"]["content"]

If that's not what you mean by "content", then please specify. I'll go ahead and close this issue now, since it isn't a problem with GenSON's features.