Marshmallow schema to OpenAPI 3.0.x-3.1 spec. Fork of marshmallow-jsonschema by Stephen J. Fuhry.
Project description
marshmallow-jsonschema-3
Transform marshmallow schemas into correct OpenAPI3.0.x-3.1 definitions. Fork of marshmallow-jsonschema by Stephen J. Fuhry.
Why fork?
- Add support for marshmallow fields.Constant (missing in marshmallow-jsonschema 0.13.0)
- Add enum handling for the future? At least not as useless as current
approach. Flags
use_repr_enums=
to convert enums into list of1=a, 2=b
oruse_new_enums=
to create 3.1 suggested enums. - Put schema references into
#/components/schemas/<name>
instead of#/definitions/<name>
source - Add old
nullable: true
attribute usinguse_nullable=
flag.
Installation
pip install marshmallow-jsonschema-3
in >=Python3.8
Usage
from marshmallow import Schema, fields
from marshmallow_jsonschema_3 import JSONSchema
class UserSchema(Schema):
username = fields.String()
age = fields.Integer()
birthday = fields.Date()
user_schema = UserSchema()
json_schema = JSONSchema(use_repr_enums=True, use_nullable=True)
json_schema.dump(user_schema)
Deployment
- Make your changes
- Create
~/.pypirc
file for twine
[distutils]
index-servers =
pypi
testpypi
[pypi]
username = pypiusername
password = pypipsw
[testpypi]
username = pypiusername
password = pypipsw
make pypitest
to deploy to https://test.pypi.org- Use
pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi. org/simple marshmallow-jsonschema-3
to install test package in your projects using real pypi dependencies. The default pip install provided by test.pypi will only look for dependencies in test.pypi, and will fail to find actual versions of dependencies...
Use make pypi
for real pypi and use pip install marshmallow-jsonschema-3
to install
published package.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file marshmallow-jsonschema-3-1.0.9.tar.gz
.
File metadata
- Download URL: marshmallow-jsonschema-3-1.0.9.tar.gz
- Upload date:
- Size: 10.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 81dc6625bdafe4f04ca2365317751228ad7f01f521cacef967635da583c4ee38 |
|
MD5 | 8bbba66d6c50eae46b9dfeabb25511d4 |
|
BLAKE2b-256 | 71f351922b552b665d283137b66ed9ea4c674776700521098687244648d85eaf |
File details
Details for the file marshmallow_jsonschema_3-1.0.9-py3-none-any.whl
.
File metadata
- Download URL: marshmallow_jsonschema_3-1.0.9-py3-none-any.whl
- Upload date:
- Size: 10.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1cff4271ff28f0e85d671cdcdbf9fd8c385fedfec628775c8037848857fcedb1 |
|
MD5 | 36d60b3afe5c8584adca54e81759d27a |
|
BLAKE2b-256 | aba9d7c72fc14b750f52e78f2e4642950c553d8f84d42afcc935a6b4de72f247 |