Skip to content
Snippets Groups Projects
Commit 8129242f authored by Julian's avatar Julian
Browse files

Rename schema to jsonschema

parent b7e13671
No related branches found
No related tags found
No related merge requests found
from django.forms import Form from django.forms import Form
from django_forms_as_jsonschema.schema import Schema from .jsonschema import JSONSchema
class JSONSchemaFormMixin: class JSONSchemaFormMixin:
def as_jsonschema(self: Form) -> str: def as_jsonschema(self: Form) -> dict:
schema = Schema() schema = JSONSchema()
for name, field in self.fields.items(): for name, field in self.fields.items():
schema.add_field(name, field) schema.add_field(name, field)
return schema.schema return schema.schema
...@@ -4,15 +4,14 @@ import json ...@@ -4,15 +4,14 @@ import json
from django import forms from django import forms
class Schema: class JSONSchema:
SCHEMA = {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {},
}
def __init__(self): def __init__(self):
self.schema = copy.deepcopy(self.SCHEMA) self.schema = {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {},
}
# example_json = { # example_json = {
# "type": "object", # "type": "object",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment