marshmallow-jsonschema icon indicating copy to clipboard operation
marshmallow-jsonschema copied to clipboard

Provide schema metadata in the "Meta" class

Open MichalKononenko opened this issue 7 years ago • 9 comments

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?

MichalKononenko avatar Aug 02 '17 14:08 MichalKononenko

I think it does already :)

mgd020 avatar Mar 19 '18 10:03 mgd020

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?

LukeMarlin avatar Aug 09 '19 15:08 LukeMarlin

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 as required=True
  • $schema: couldn't find a way to provide this
  • additionalProperties: Recently added, not released yet. Simply provide additional_properties field in a Meta 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?

LukeMarlin avatar Aug 09 '19 15:08 LukeMarlin

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..?

fuhrysteve avatar Aug 09 '19 16:08 fuhrysteve

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?

LukeMarlin avatar Aug 11 '19 14:08 LukeMarlin

Just pushed 0.7.0. Hope that works for you!

fuhrysteve avatar Aug 11 '19 14:08 fuhrysteve

Thank you very much, trying that at work tomorrow :)

LukeMarlin avatar Aug 11 '19 15:08 LukeMarlin

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.

LukeMarlin avatar Aug 12 '19 14:08 LukeMarlin

Bump - please add 'title' and 'description' support.

ksbrar avatar Mar 04 '22 00:03 ksbrar