janw / jsonschema-extended

Extended non-draft-compliant version of JSON Schema validation and format checks

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

JSON Schema โ€” Extended ๐ŸŽ†

Maintainability Test Coverage

The jsonschema-extended library (JSE) provides an extended version of JSON Schema functionality as provided by the jsonschema package. JSE by default enables all current and previous format validators (independent of the JSON Schema draft they were introduced or removed for) for the latest draft version, and includes a variety of additional format validators that are not included in the JSON schema spec.

I created JSE to use it in the configuration validation in another project of mine, CleanAB, which requires more "niche" data types to be checked for, as well as default values. The latter is also supported by JSE right out of the box.

What is "extended" about it?

Extensive format checks

  • Format validation is enabled by default
  • Most formats of all JSON schema draft versions are enabled out-of-the-box (independent of what version they were actually specified in), namely:
    • color
    • date: RFC3339 date
    • date-time: RFC3339 date-time
    • duration: RFC3339 duration
    • email
    • hostname
    • idn-email
    • idn-hostname
    • ipv4
    • ipv6
    • json-pointer
    • regex
    • relative-json-pointer
    • time: RFC3339 time
    • uri
    • uri-reference
    • uuid
  • Additonal general purpose formats have been added:
  • Additional niche formats

Planned features

  • Allow generating an end user-friendly representation of a given schema, specifically to document available configuration options with title, description, default, example, etc.
  • Add "type-casting" capability for formats that have a python-native type equivalent but are not part provided by JSON itself (e.g. convert date format properties to datetime.date, or uuid to uuid.UUID, etc.)
  • Add more common formats and build a comprehensive library of possible formats (I'm planning on accepting PRs or issues for new formats regularly after reaching structural maturity for the project)

About

Extended non-draft-compliant version of JSON Schema validation and format checks

License:Apache License 2.0


Languages

Language:Python 100.0%