marshmallow-jsonschema
marshmallow-jsonschema copied to clipboard
Provide schema metadata in the "Meta" class
Marshmallow uses a nested Meta
class in order to hold metadata about things like what fields to serialize. Can we use this schema to hold string fields about title
, description
, and $schema
as defined in the JSON schema standard?
I think it does already :)
Where, how?
I'm quite surprised that this didn't get any reply.
I've tried putting some values in Meta
and it seems pretty much ignored.
Looking at the code and tests, I can see there is a way to provide a field's metadata, but not the schema metadata.
Any pointers?
To add a bit more to the conversation, after checking the code and tests, here is the status for some metas:
-
required
: generated by marking a field asrequired=True
-
$schema
: couldn't find a way to provide this -
additionalProperties
: Recently added, not released yet. Simply provideadditional_properties
field in aMeta
class under the schema
Only remaining issue for me (after the next release), would be $schema
.
Any reason why you don't set it automatically as "http://json-schema.org/draft-07/schema#"?
Would you accept to have a way to set it under the Meta
class in a schema_uri
variable for example?
Hey @LukeMarlin thanks for digging in and pulling out some of those answers.
Looking here it is setting $schema
to "http://json-schema.org/draft-07/schema#".. I wonder if that's simply not in the latest version in pypi..?
Missed that! Given that 0.6 seems to date back to June 16, and that that line was added 22 days ago, that's probably the case.
Is it possible to release a 0.7 in the near future?
Just pushed 0.7.0. Hope that works for you!
Thank you very much, trying that at work tomorrow :)
Works nicely on 0.7, thanks ! :tada:
OP was asking for title
and description
which are still missing, but that cleared my issue at least. :smiley:
Note: $id might be interesting for some users as well.
Bump - please add 'title' and 'description' support.