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 in a format compliant with OpenAPI 3.1.0.

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.

Source Distribution

lollipop_jsonschema-0.9.0.tar.gz (11.2 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.9.0-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file lollipop_jsonschema-0.9.0.tar.gz.

File metadata

  • Download URL: lollipop_jsonschema-0.9.0.tar.gz
  • Upload date:
  • Size: 11.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.0

File hashes

Hashes for lollipop_jsonschema-0.9.0.tar.gz
Algorithm Hash digest
SHA256 b2c69280f9cfc677c49b99c4782b9c31cb4f2f3cdbdc24b00f98ef1aad501371
MD5 e133f4f002a4f66b81dd78cc2a1a97e1
BLAKE2b-256 e63acafef31e4e5d349a25fc198bc4ee902f64c80a9eb14187e89ce6dbf3ae71

See more details on using hashes here.

File details

Details for the file lollipop_jsonschema-0.9.0-py3-none-any.whl.

File metadata

File hashes

Hashes for lollipop_jsonschema-0.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 17535a4d19321b64211b2109bf9fc44eea899b34b30424d6bd21dab826abe627
MD5 ddb0d2a047edaf20caf3d7c4ca1a1b19
BLAKE2b-256 64c3666069de9add3ccefdad9b4ee315e8054616d2dadc9b59e9a9bcfcea0f6d

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