Skip to main content

A set of utilities to generate JSON Schema from simple JSON objects

Project description

schemautil

A set of utilities to generate JSON Schema from simple JSON objects.

Example

Given the following object schema:

{
  "type": "object",
  "properties": {
    "a": { "type": "string" },
    "b": { "type": "string" }
  },
  "required": ["a", "b"],
  "additionalProperties": false
}

You can generate this schema using:

obj_schema({"a": "string", "b": "string"})

Rules

  • All fields are required and additionalProperties is always set to false.
  • To make a field nullable, add a ? to the end of its name.
    Example: {"a": "string", "b?": "string"} (b is nullable)
  • To define an array, wrap the type in brackets.
    Example: {"a": "string", "b": ["string"]} (b is an array of strings)
    Note: There should be only one type in the array.
  • To define a field that can be one of multiple types, list the types in brackets.
    Example: {"a": "string", "b": ["string", "number"]} (b can be a string or a number)

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

bfg_schemautil-0.1.0.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

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

bfg_schemautil-0.1.0-py3-none-any.whl (2.3 kB view details)

Uploaded Python 3

File details

Details for the file bfg_schemautil-0.1.0.tar.gz.

File metadata

  • Download URL: bfg_schemautil-0.1.0.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.9

File hashes

Hashes for bfg_schemautil-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8d012c6924ee4d1a36b5d108738032f10d5057e19683cf4700a2a4b5478d4657
MD5 9050eec7f915cd8b8f82305f5fd2476c
BLAKE2b-256 a3eb8b9045c5025193e9deb2ae48788caa2d8cc3c2edc48c5fec71b9907bd585

See more details on using hashes here.

File details

Details for the file bfg_schemautil-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for bfg_schemautil-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c3a085478e1a853071363c3c843906caaf6521bc65bc1855f359e79ee49798ec
MD5 a75af6987d8cb0b10fcdf89028ed5eb2
BLAKE2b-256 1b8d9c50bbfda3c554cad9d054c8377dd48d057a1b04bb90e43a3ecbde869c91

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