Skip to main content

wtforms-jsonschema converts WTForms into JSON Schema compatibile representations

Project description

Introduction

wtforms-jsonschema converts WTForms into JSON Schema compatibile representations

Requirements

  • Python 2.6 or later

  • Wtforms

Usage

To convert a form to a JSON Schema:

from wtforms_jsonschema.jsonschema import WTFormToJSONSchema

schema_repr = WTFormToJSONSchema().convert_form(MyForm)

TODO: To embed a JSON Schema as a form field:

from wtforms_jsonschema.forms import JSONSchemaField

#where schema is a python dictionay like schema_repr in the first exmaple

class MyForm(forms.Form):
    subfield = JSONSchemaField(schema=schema)

form = MyForm(data={'subfield':'<json encoded value>'})
form.validate() #will validate the subfield entry against schema
form['subfield'].as_widget() #will render a textarea widget with a data-schemajson attribute

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

wtforms-jsonschema-0.0.7.tar.gz (3.3 kB view details)

Uploaded Source

File details

Details for the file wtforms-jsonschema-0.0.7.tar.gz.

File metadata

File hashes

Hashes for wtforms-jsonschema-0.0.7.tar.gz
Algorithm Hash digest
SHA256 62e1191c66ce81907da55c33319b4c1fca496861e4406f61f653e4b26b8a30a9
MD5 e633445927fc375a2168ae25b81c1d06
BLAKE2b-256 7f81b38800a48a919b63b8ed144f2c5f5aa30f666cc699d653a22cafa646dec1

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page