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. source
- Put schema references into
#/components/schemas/<name>
instead of#/definitions/<name>
source
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()
# OpenAPI 3.0.x output
json_schema = JSONSchema()
# OpenAPI 3.1 output
json_schema = JSONSchema(to_openapi31=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-<something>
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-<something>
.
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
Close
Hashes for marshmallow-jsonschema-3-1.0.4.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 36c21f85c53987d3d9ec7a3a443fe1f8fa0ed6ff475693a580024b3d08ef21aa |
|
MD5 | 084a7894e81258198c4251410e0b73be |
|
BLAKE2b-256 | d643a5d8e0ff4d2beb215efe383dc63a877f708adb6ab7e7e5389d2d82944f97 |
Close
Hashes for marshmallow_jsonschema_3-1.0.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 83d0e37125a1058ae048ef584ff692e3347cd39d4e6ed108e4d1f21372ebcd97 |
|
MD5 | d9cff371603ebeb8ea7e526f86cb3517 |
|
BLAKE2b-256 | a402bb169b3340a4f93937b791eca56c8142a9353d576d7ffa4e36c55ce2caf2 |