Skip to main content

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 of 1=a, 2=b or use_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 using use_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

  1. Make your changes
  2. Create ~/.pypirc file for twine
[distutils]
index-servers =
    pypi
    testpypi

[pypi]
username = pypiusername
password = pypipsw

[testpypi]
username = pypiusername
password = pypipsw
  1. make pypitest to deploy to https://test.pypi.org
  2. 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

marshmallow-jsonschema-3-1.0.9.tar.gz (10.5 kB view details)

Uploaded Source

Built Distribution

marshmallow_jsonschema_3-1.0.9-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

Details for the file marshmallow-jsonschema-3-1.0.9.tar.gz.

File metadata

File hashes

Hashes for marshmallow-jsonschema-3-1.0.9.tar.gz
Algorithm Hash digest
SHA256 81dc6625bdafe4f04ca2365317751228ad7f01f521cacef967635da583c4ee38
MD5 8bbba66d6c50eae46b9dfeabb25511d4
BLAKE2b-256 71f351922b552b665d283137b66ed9ea4c674776700521098687244648d85eaf

See more details on using hashes here.

File details

Details for the file marshmallow_jsonschema_3-1.0.9-py3-none-any.whl.

File metadata

File hashes

Hashes for marshmallow_jsonschema_3-1.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 1cff4271ff28f0e85d671cdcdbf9fd8c385fedfec628775c8037848857fcedb1
MD5 36d60b3afe5c8584adca54e81759d27a
BLAKE2b-256 aba9d7c72fc14b750f52e78f2e4642950c553d8f84d42afcc935a6b4de72f247

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page