From f2c6e367c0bffce8b77975ae08359ea3705d1c3a Mon Sep 17 00:00:00 2001 From: CoprDistGit Date: Tue, 11 Apr 2023 00:41:16 +0000 Subject: automatic import of python-marshmallow-jsonschema --- .gitignore | 1 + python-marshmallow-jsonschema.spec | 795 +++++++++++++++++++++++++++++++++++++ sources | 1 + 3 files changed, 797 insertions(+) create mode 100644 python-marshmallow-jsonschema.spec create mode 100644 sources diff --git a/.gitignore b/.gitignore index e69de29..050fcb8 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1 @@ +/marshmallow-jsonschema-0.13.0.tar.gz diff --git a/python-marshmallow-jsonschema.spec b/python-marshmallow-jsonschema.spec new file mode 100644 index 0000000..b4355d0 --- /dev/null +++ b/python-marshmallow-jsonschema.spec @@ -0,0 +1,795 @@ +%global _empty_manifest_terminate_build 0 +Name: python-marshmallow-jsonschema +Version: 0.13.0 +Release: 1 +Summary: JSON Schema Draft v7 (http://json-schema.org/) formatting with marshmallow +License: MIT License +URL: https://github.com/fuhrysteve/marshmallow-jsonschema +Source0: https://mirrors.nju.edu.cn/pypi/web/packages/2f/53/109d80013b70b6140d05e521ad31e3014680007b51c3dfac72ad20a2d6ee/marshmallow-jsonschema-0.13.0.tar.gz +BuildArch: noarch + +Requires: python3-marshmallow +Requires: python3-marshmallow-enum +Requires: python3-marshmallow-union + +%description +## marshmallow-jsonschema: JSON Schema formatting with marshmallow + +![Build Status](https://github.com/fuhrysteve/marshmallow-jsonschema/workflows/build/badge.svg) +[![Coverage Status](https://coveralls.io/repos/github/fuhrysteve/marshmallow-jsonschema/badge.svg?branch=master)](https://coveralls.io/github/fuhrysteve/marshmallow-jsonschema?branch=master) +[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/python/black) + + marshmallow-jsonschema translates marshmallow schemas into + JSON Schema Draft v7 compliant jsonschema. See http://json-schema.org/ + +#### Why would I want my schema translated to JSON? + +What are the use cases for this? Let's say you have a +marshmallow schema in python, but you want to render your +schema as a form in another system (for example: a web browser +or mobile device). + +#### Installation + +Requires python>=3.6 and marshmallow>=3.11. (For python 2 & marshmallow 2 support, please use marshmallow-jsonschema<0.11) + +``` +pip install marshmallow-jsonschema +``` + +#### Some Client tools can render forms using JSON Schema + +* [react-jsonschema-form](https://github.com/mozilla-services/react-jsonschema-form) (recommended) + * See below extension for this excellent library! +* https://github.com/brutusin/json-forms +* https://github.com/jdorn/json-editor +* https://github.com/ulion/jsonform + +### Examples + +#### Simple Example + +```python +from marshmallow import Schema, fields +from marshmallow_jsonschema import JSONSchema + +class UserSchema(Schema): + username = fields.String() + age = fields.Integer() + birthday = fields.Date() + +user_schema = UserSchema() + +json_schema = JSONSchema() +json_schema.dump(user_schema) +``` + +Yields: + +```python +{'properties': {'age': {'format': 'integer', + 'title': 'age', + 'type': 'number'}, + 'birthday': {'format': 'date', + 'title': 'birthday', + 'type': 'string'}, + 'username': {'title': 'username', 'type': 'string'}}, + 'required': [], + 'type': 'object'} +``` + +#### Nested Example + +```python +from marshmallow import Schema, fields +from marshmallow_jsonschema import JSONSchema +from tests import UserSchema + + +class Athlete(object): + user_schema = UserSchema() + + def __init__(self): + self.name = 'sam' + + +class AthleteSchema(Schema): + user_schema = fields.Nested(JSONSchema) + name = fields.String() + + +athlete = Athlete() +athlete_schema = AthleteSchema() + +athlete_schema.dump(athlete) +``` + +#### Complete example Flask application using brutisin/json-forms + +![Screenshot](http://i.imgur.com/jJv1wFk.png) + +This example renders a form not dissimilar to how [wtforms](https://github.com/wtforms/wtforms) might render a form. + +However rather than rendering the form in python, the JSON Schema is rendered using the +javascript library [brutusin/json-forms](https://github.com/brutusin/json-forms). + + +```python +from flask import Flask, jsonify +from marshmallow import Schema, fields +from marshmallow_jsonschema import JSONSchema + +app = Flask(__name__) + + +class UserSchema(Schema): + name = fields.String() + address = fields.String() + + +@app.route('/schema') +def schema(): + schema = UserSchema() + return jsonify(JSONSchema().dump(schema)) + + +@app.route('/') +def home(): + return ''' + + + + + + + + +
+ + +''' + + +if __name__ == '__main__': + app.run(host='0.0.0.0', debug=True) + +``` + + +### Advanced usage +#### Custom Type support + +Simply add a `_jsonschema_type_mapping` method to your field +so we know how it ought to get serialized to JSON Schema. + +A common use case for this is creating a dropdown menu using +enum (see Gender below). + + +```python +class Colour(fields.Field): + + def _jsonschema_type_mapping(self): + return { + 'type': 'string', + } + + def _serialize(self, value, attr, obj): + r, g, b = value + r = "%02X" % (r,) + g = "%02X" % (g,) + b = "%02X" % (b,) + return '#' + r + g + b + +class Gender(fields.String): + def _jsonschema_type_mapping(self): + return { + 'type': 'string', + 'enum': ['Male', 'Female'] + } + + +class UserSchema(Schema): + name = fields.String(required=True) + favourite_colour = Colour() + gender = Gender() + +schema = UserSchema() +json_schema = JSONSchema() +json_schema.dump(schema) +``` + + +### React-JSONSchema-Form Extension + +[react-jsonschema-form](https://react-jsonschema-form.readthedocs.io/en/latest/) +is a library for rendering jsonschemas as a form using React. It is very powerful +and full featured.. the catch is that it requires a proprietary +[`uiSchema`](https://react-jsonschema-form.readthedocs.io/en/latest/form-customization/#the-uischema-object) +to provide advanced control how the form is rendered. +[Here's a live playground](https://rjsf-team.github.io/react-jsonschema-form/) + +*(new in version 0.10.0)* + +```python +from marshmallow_jsonschema.extensions import ReactJsonSchemaFormJSONSchema + +class MySchema(Schema): + first_name = fields.String( + metadata={ + 'ui:autofocus': True, + } + ) + last_name = fields.String() + + class Meta: + react_uischema_extra = { + 'ui:order': [ + 'first_name', + 'last_name', + ] + } + + +json_schema_obj = ReactJsonSchemaFormJSONSchema() +schema = MySchema() + +# here's your jsonschema +data = json_schema_obj.dump(schema) + +# ..and here's your uiSchema! +ui_schema_json = json_schema_obj.dump_uischema(schema) + + + + +%package -n python3-marshmallow-jsonschema +Summary: JSON Schema Draft v7 (http://json-schema.org/) formatting with marshmallow +Provides: python-marshmallow-jsonschema +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-marshmallow-jsonschema +## marshmallow-jsonschema: JSON Schema formatting with marshmallow + +![Build Status](https://github.com/fuhrysteve/marshmallow-jsonschema/workflows/build/badge.svg) +[![Coverage Status](https://coveralls.io/repos/github/fuhrysteve/marshmallow-jsonschema/badge.svg?branch=master)](https://coveralls.io/github/fuhrysteve/marshmallow-jsonschema?branch=master) +[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/python/black) + + marshmallow-jsonschema translates marshmallow schemas into + JSON Schema Draft v7 compliant jsonschema. See http://json-schema.org/ + +#### Why would I want my schema translated to JSON? + +What are the use cases for this? Let's say you have a +marshmallow schema in python, but you want to render your +schema as a form in another system (for example: a web browser +or mobile device). + +#### Installation + +Requires python>=3.6 and marshmallow>=3.11. (For python 2 & marshmallow 2 support, please use marshmallow-jsonschema<0.11) + +``` +pip install marshmallow-jsonschema +``` + +#### Some Client tools can render forms using JSON Schema + +* [react-jsonschema-form](https://github.com/mozilla-services/react-jsonschema-form) (recommended) + * See below extension for this excellent library! +* https://github.com/brutusin/json-forms +* https://github.com/jdorn/json-editor +* https://github.com/ulion/jsonform + +### Examples + +#### Simple Example + +```python +from marshmallow import Schema, fields +from marshmallow_jsonschema import JSONSchema + +class UserSchema(Schema): + username = fields.String() + age = fields.Integer() + birthday = fields.Date() + +user_schema = UserSchema() + +json_schema = JSONSchema() +json_schema.dump(user_schema) +``` + +Yields: + +```python +{'properties': {'age': {'format': 'integer', + 'title': 'age', + 'type': 'number'}, + 'birthday': {'format': 'date', + 'title': 'birthday', + 'type': 'string'}, + 'username': {'title': 'username', 'type': 'string'}}, + 'required': [], + 'type': 'object'} +``` + +#### Nested Example + +```python +from marshmallow import Schema, fields +from marshmallow_jsonschema import JSONSchema +from tests import UserSchema + + +class Athlete(object): + user_schema = UserSchema() + + def __init__(self): + self.name = 'sam' + + +class AthleteSchema(Schema): + user_schema = fields.Nested(JSONSchema) + name = fields.String() + + +athlete = Athlete() +athlete_schema = AthleteSchema() + +athlete_schema.dump(athlete) +``` + +#### Complete example Flask application using brutisin/json-forms + +![Screenshot](http://i.imgur.com/jJv1wFk.png) + +This example renders a form not dissimilar to how [wtforms](https://github.com/wtforms/wtforms) might render a form. + +However rather than rendering the form in python, the JSON Schema is rendered using the +javascript library [brutusin/json-forms](https://github.com/brutusin/json-forms). + + +```python +from flask import Flask, jsonify +from marshmallow import Schema, fields +from marshmallow_jsonschema import JSONSchema + +app = Flask(__name__) + + +class UserSchema(Schema): + name = fields.String() + address = fields.String() + + +@app.route('/schema') +def schema(): + schema = UserSchema() + return jsonify(JSONSchema().dump(schema)) + + +@app.route('/') +def home(): + return ''' + + + + + + + + +
+ + +''' + + +if __name__ == '__main__': + app.run(host='0.0.0.0', debug=True) + +``` + + +### Advanced usage +#### Custom Type support + +Simply add a `_jsonschema_type_mapping` method to your field +so we know how it ought to get serialized to JSON Schema. + +A common use case for this is creating a dropdown menu using +enum (see Gender below). + + +```python +class Colour(fields.Field): + + def _jsonschema_type_mapping(self): + return { + 'type': 'string', + } + + def _serialize(self, value, attr, obj): + r, g, b = value + r = "%02X" % (r,) + g = "%02X" % (g,) + b = "%02X" % (b,) + return '#' + r + g + b + +class Gender(fields.String): + def _jsonschema_type_mapping(self): + return { + 'type': 'string', + 'enum': ['Male', 'Female'] + } + + +class UserSchema(Schema): + name = fields.String(required=True) + favourite_colour = Colour() + gender = Gender() + +schema = UserSchema() +json_schema = JSONSchema() +json_schema.dump(schema) +``` + + +### React-JSONSchema-Form Extension + +[react-jsonschema-form](https://react-jsonschema-form.readthedocs.io/en/latest/) +is a library for rendering jsonschemas as a form using React. It is very powerful +and full featured.. the catch is that it requires a proprietary +[`uiSchema`](https://react-jsonschema-form.readthedocs.io/en/latest/form-customization/#the-uischema-object) +to provide advanced control how the form is rendered. +[Here's a live playground](https://rjsf-team.github.io/react-jsonschema-form/) + +*(new in version 0.10.0)* + +```python +from marshmallow_jsonschema.extensions import ReactJsonSchemaFormJSONSchema + +class MySchema(Schema): + first_name = fields.String( + metadata={ + 'ui:autofocus': True, + } + ) + last_name = fields.String() + + class Meta: + react_uischema_extra = { + 'ui:order': [ + 'first_name', + 'last_name', + ] + } + + +json_schema_obj = ReactJsonSchemaFormJSONSchema() +schema = MySchema() + +# here's your jsonschema +data = json_schema_obj.dump(schema) + +# ..and here's your uiSchema! +ui_schema_json = json_schema_obj.dump_uischema(schema) + + + + +%package help +Summary: Development documents and examples for marshmallow-jsonschema +Provides: python3-marshmallow-jsonschema-doc +%description help +## marshmallow-jsonschema: JSON Schema formatting with marshmallow + +![Build Status](https://github.com/fuhrysteve/marshmallow-jsonschema/workflows/build/badge.svg) +[![Coverage Status](https://coveralls.io/repos/github/fuhrysteve/marshmallow-jsonschema/badge.svg?branch=master)](https://coveralls.io/github/fuhrysteve/marshmallow-jsonschema?branch=master) +[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/python/black) + + marshmallow-jsonschema translates marshmallow schemas into + JSON Schema Draft v7 compliant jsonschema. See http://json-schema.org/ + +#### Why would I want my schema translated to JSON? + +What are the use cases for this? Let's say you have a +marshmallow schema in python, but you want to render your +schema as a form in another system (for example: a web browser +or mobile device). + +#### Installation + +Requires python>=3.6 and marshmallow>=3.11. (For python 2 & marshmallow 2 support, please use marshmallow-jsonschema<0.11) + +``` +pip install marshmallow-jsonschema +``` + +#### Some Client tools can render forms using JSON Schema + +* [react-jsonschema-form](https://github.com/mozilla-services/react-jsonschema-form) (recommended) + * See below extension for this excellent library! +* https://github.com/brutusin/json-forms +* https://github.com/jdorn/json-editor +* https://github.com/ulion/jsonform + +### Examples + +#### Simple Example + +```python +from marshmallow import Schema, fields +from marshmallow_jsonschema import JSONSchema + +class UserSchema(Schema): + username = fields.String() + age = fields.Integer() + birthday = fields.Date() + +user_schema = UserSchema() + +json_schema = JSONSchema() +json_schema.dump(user_schema) +``` + +Yields: + +```python +{'properties': {'age': {'format': 'integer', + 'title': 'age', + 'type': 'number'}, + 'birthday': {'format': 'date', + 'title': 'birthday', + 'type': 'string'}, + 'username': {'title': 'username', 'type': 'string'}}, + 'required': [], + 'type': 'object'} +``` + +#### Nested Example + +```python +from marshmallow import Schema, fields +from marshmallow_jsonschema import JSONSchema +from tests import UserSchema + + +class Athlete(object): + user_schema = UserSchema() + + def __init__(self): + self.name = 'sam' + + +class AthleteSchema(Schema): + user_schema = fields.Nested(JSONSchema) + name = fields.String() + + +athlete = Athlete() +athlete_schema = AthleteSchema() + +athlete_schema.dump(athlete) +``` + +#### Complete example Flask application using brutisin/json-forms + +![Screenshot](http://i.imgur.com/jJv1wFk.png) + +This example renders a form not dissimilar to how [wtforms](https://github.com/wtforms/wtforms) might render a form. + +However rather than rendering the form in python, the JSON Schema is rendered using the +javascript library [brutusin/json-forms](https://github.com/brutusin/json-forms). + + +```python +from flask import Flask, jsonify +from marshmallow import Schema, fields +from marshmallow_jsonschema import JSONSchema + +app = Flask(__name__) + + +class UserSchema(Schema): + name = fields.String() + address = fields.String() + + +@app.route('/schema') +def schema(): + schema = UserSchema() + return jsonify(JSONSchema().dump(schema)) + + +@app.route('/') +def home(): + return ''' + + + + + + + + +
+ + +''' + + +if __name__ == '__main__': + app.run(host='0.0.0.0', debug=True) + +``` + + +### Advanced usage +#### Custom Type support + +Simply add a `_jsonschema_type_mapping` method to your field +so we know how it ought to get serialized to JSON Schema. + +A common use case for this is creating a dropdown menu using +enum (see Gender below). + + +```python +class Colour(fields.Field): + + def _jsonschema_type_mapping(self): + return { + 'type': 'string', + } + + def _serialize(self, value, attr, obj): + r, g, b = value + r = "%02X" % (r,) + g = "%02X" % (g,) + b = "%02X" % (b,) + return '#' + r + g + b + +class Gender(fields.String): + def _jsonschema_type_mapping(self): + return { + 'type': 'string', + 'enum': ['Male', 'Female'] + } + + +class UserSchema(Schema): + name = fields.String(required=True) + favourite_colour = Colour() + gender = Gender() + +schema = UserSchema() +json_schema = JSONSchema() +json_schema.dump(schema) +``` + + +### React-JSONSchema-Form Extension + +[react-jsonschema-form](https://react-jsonschema-form.readthedocs.io/en/latest/) +is a library for rendering jsonschemas as a form using React. It is very powerful +and full featured.. the catch is that it requires a proprietary +[`uiSchema`](https://react-jsonschema-form.readthedocs.io/en/latest/form-customization/#the-uischema-object) +to provide advanced control how the form is rendered. +[Here's a live playground](https://rjsf-team.github.io/react-jsonschema-form/) + +*(new in version 0.10.0)* + +```python +from marshmallow_jsonschema.extensions import ReactJsonSchemaFormJSONSchema + +class MySchema(Schema): + first_name = fields.String( + metadata={ + 'ui:autofocus': True, + } + ) + last_name = fields.String() + + class Meta: + react_uischema_extra = { + 'ui:order': [ + 'first_name', + 'last_name', + ] + } + + +json_schema_obj = ReactJsonSchemaFormJSONSchema() +schema = MySchema() + +# here's your jsonschema +data = json_schema_obj.dump(schema) + +# ..and here's your uiSchema! +ui_schema_json = json_schema_obj.dump_uischema(schema) + + + + +%prep +%autosetup -n marshmallow-jsonschema-0.13.0 + +%build +%py3_build + +%install +%py3_install +install -d -m755 %{buildroot}/%{_pkgdocdir} +if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi +if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi +if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi +if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi +pushd %{buildroot} +if [ -d usr/lib ]; then + find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/lib64 ]; then + find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/bin ]; then + find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/sbin ]; then + find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst +fi +touch doclist.lst +if [ -d usr/share/man ]; then + find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst +fi +popd +mv %{buildroot}/filelist.lst . +mv %{buildroot}/doclist.lst . + +%files -n python3-marshmallow-jsonschema -f filelist.lst +%dir %{python3_sitelib}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Tue Apr 11 2023 Python_Bot - 0.13.0-1 +- Package Spec generated diff --git a/sources b/sources new file mode 100644 index 0000000..a24d118 --- /dev/null +++ b/sources @@ -0,0 +1 @@ +cf38c60f67e176f71550d67b0ec068f3 marshmallow-jsonschema-0.13.0.tar.gz -- cgit v1.2.3