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

Provide schema metadata in the "Meta" class #41

Open
MichalKononenko opened this issue Aug 2, 2017 · 9 comments · May be fixed by #99
Open

Provide schema metadata in the "Meta" class #41

MichalKononenko opened this issue Aug 2, 2017 · 9 comments · May be fixed by #99

Comments

@MichalKononenko
Copy link

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?

@mgd020
Copy link

mgd020 commented Mar 19, 2018

I think it does already :)

@LukeMarlin
Copy link
Contributor

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
Copy link
Contributor

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?

@fuhrysteve
Copy link
Owner

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

@LukeMarlin
Copy link
Contributor

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?

@fuhrysteve
Copy link
Owner

Just pushed 0.7.0. Hope that works for you!

@LukeMarlin
Copy link
Contributor

LukeMarlin commented Aug 11, 2019 via email

@LukeMarlin
Copy link
Contributor

LukeMarlin commented Aug 12, 2019

Works nicely on 0.7, thanks ! 🎉
OP was asking for title and description which are still missing, but that cleared my issue at least. 😃

Note: $id might be interesting for some users as well.

LukeMarlin pushed a commit to LukeMarlin/marshmallow-jsonschema that referenced this issue Oct 29, 2019
  - Refactor _resolve_additional_properties to reuse parts of it for
  title and description support
  - Add _get_schema_metadata that retrieves the 3 currently supported
  metadata options on a schema
  - Rename 'cls' params to something less confusing as 'cls' is a python
  keyword
  - Add documentation for title, description and additional_properties
  - Move addtional_properties tests to a new forlder
  "schema_metadata_tests" so they can be gathered in a common place

Closes fuhrysteve#41
LukeMarlin pushed a commit to LukeMarlin/marshmallow-jsonschema that referenced this issue Oct 30, 2019
  - Refactor _resolve_additional_properties to reuse parts of it for
  title and description support
  - Add _get_schema_metadata that retrieves the 3 currently supported
  metadata options on a schema
  - Rename 'cls' params to something less confusing as 'cls' is a python
  keyword
  - Add documentation for title, description and additional_properties
  - Move addtional_properties tests to a new forlder
  "schema_metadata_tests" so they can be gathered in a common place

Closes fuhrysteve#41
LukeMarlin pushed a commit to LukeMarlin/marshmallow-jsonschema that referenced this issue Oct 30, 2019
  - Refactor _resolve_additional_properties to reuse parts of it for
  title and description support
  - Add _get_schema_metadata that retrieves the 3 currently supported
  metadata options on a schema
  - Rename 'cls' params to something less confusing as 'cls' is a python
  keyword
  - Add documentation for title, description and additional_properties
  - Move addtional_properties tests to a new forlder
  "schema_metadata_tests" so they can be gathered in a common place

Closes fuhrysteve#41
LukeMarlin pushed a commit to LukeMarlin/marshmallow-jsonschema that referenced this issue Oct 30, 2019
  - Refactor _resolve_additional_properties to reuse parts of it for
  title and description support
  - Add _get_schema_metadata that retrieves the 3 currently supported
  metadata options on a schema
  - Rename 'cls' params to something less confusing as 'cls' is a python
  keyword
  - Add documentation for title, description and additional_properties
  - Move addtional_properties tests to a new forlder
  "schema_metadata_tests" so they can be gathered in a common place

Closes fuhrysteve#41
@LukeMarlin LukeMarlin linked a pull request Oct 30, 2019 that will close this issue
@ksbrar
Copy link

ksbrar commented Mar 4, 2022

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

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

Successfully merging a pull request may close this issue.

5 participants