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.5

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.

Filename, size & hash SHA256 hash help File type Python version Upload date
lollipop_jsonschema-0.8.2-py2.py3-none-any.whl (7.6 kB) Copy SHA256 hash SHA256 Wheel py2.py3
lollipop-jsonschema-0.8.2.tar.gz (10.9 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page