python

package
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 8, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

README

Python

Translates JSON Schema to Python dataclass definitions (.py).

Example

Input (JSON Schema):

{
  "type": "object",
  "properties": {
    "name": { "type": "string" },
    "age": { "type": "integer" }
  }
}

Output (Python):

import dataclasses
from typing import Optional

@dataclasses.dataclass
class UsersSchema:
    name: Optional[str] = None
    age: Optional[int] = None

Supported JSON Schema Features

Type Keywords
  • type
  • enum
  • const
Type Values
  • string
  • integer
  • number
  • boolean
  • array
  • object
  • null
Schema Composition
  • allOf
  • anyOf
  • oneOf
  • not
Object Keywords
  • properties
  • required
  • additionalProperties
  • patternProperties
  • propertyNames
  • minProperties / maxProperties
  • unevaluatedProperties
  • dependentRequired
Array Keywords
  • items
  • prefixItems
  • contains
  • minItems / maxItems
  • uniqueItems
  • unevaluatedItems
  • maxContains / minContains
Numeric Validation
  • minimum / maximum
  • exclusiveMinimum / exclusiveMaximum
  • multipleOf
String Validation
  • minLength / maxLength
  • pattern
References & Definitions
  • $ref
  • $defs
  • $id
  • $anchor
  • $dynamicRef / $dynamicAnchor
String Formats
  • date
  • date-time
  • time
  • duration
  • uuid
  • uri / uri-reference / uri-template
  • iri / iri-reference
  • email / idn-email
  • hostname / idn-hostname
  • ipv4 / ipv6
  • json-pointer / relative-json-pointer
  • regex
Annotations
  • description
  • title
  • default
  • deprecated
  • readOnly / writeOnly
  • examples
Conditional
  • if / then / else
  • dependentSchemas
Content
  • contentEncoding
  • contentMediaType
  • contentSchema

Documentation

Overview

Package python provides Python dataclass schema translation utilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Translator

type Translator struct{}

Translator translates JSON schemas to Python dataclass definitions.

func (*Translator) FileExtension

func (t *Translator) FileExtension() string

FileExtension returns the file extension for Python files.

func (*Translator) Translate

func (t *Translator) Translate(portName string, schema *jsonschema.Schema, _ string) ([]byte, error)

Translate converts a JSON schema to Python dataclass definitions.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL