Skip to main content

Library to convert Lollipop schema to JSON schema

Project description

License: MIT Build Status PyPI

Library to convert Lollipop schema to JSON schema.

Example

import lollipop.types as lt
import lollipop.validators as lv

EMAIL_REGEXP = r"^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$"

USER = lt.Object({
    'name': lt.String(validate=lv.Length(min=1)),
    'email': lt.String(validate=lv.Regexp(EMAIL_REGEXP)),
    'age': lt.Optional(lt.Integer(validate=lv.Range(min=18))),
}, name='User', description='User information')

from lollipop_jsonschema import json_schema
import json

print json.dumps(json_schema(USER), indent=2)
# {
#   "title": "User",
#   "description": "User information",
#   "type": "object",
#   "properties": {
#     "age": {
#       "type": "integer",
#       "minimum": 18
#     },
#     "name": {
#       "type": "string",
#       "minLength": 1
#     },
#     "email": {
#       "type": "string",
#       "pattern": "^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\\.[a-zA-Z0-9-.]+$"
#     }
#   },
#   "required": [
#     "name",
#     "email"
#   ]
# }

Installation

$ pip install lollipop-jsonschema

Requirements

  • Python >= 2.7 and <= 3.6

  • lollipop >= 1.1.2

License

MIT licensed. See the bundled LICENSE file for more details.

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

lollipop-jsonschema-0.2.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lollipop_jsonschema-0.2-py2.py3-none-any.whl (5.5 kB view details)

Uploaded Python 2Python 3

File details

Details for the file lollipop-jsonschema-0.2.tar.gz.

File metadata

File hashes

Hashes for lollipop-jsonschema-0.2.tar.gz
Algorithm Hash digest
SHA256 2bf828882c8f561c7f871cc3bc11c2ff3c3c2cc4c735be9a7d6ae7f744b31f24
MD5 52a4d9b4f5b708fef417e1096a77cc53
BLAKE2b-256 7f9e600e09ae00da87d73bcfadfd2d12aab2153a43dcfcc55f82b881dd4ee157

See more details on using hashes here.

File details

Details for the file lollipop_jsonschema-0.2-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for lollipop_jsonschema-0.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 e3d9c3bb13dc61dada0dd05bb23d22430ff6882e9aec1dfd314eb5f584129563
MD5 8e2c7d3cc8850f5471daf866dfcc4d3e
BLAKE2b-256 bf72dc84eacd31999dc7ede1b5ccc614b98706d401281f806232ac7805b71526

See more details on using hashes here.

Supported by

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