Fix schema

This commit is contained in:
1ilit 2024-02-05 14:38:38 +02:00
parent 215bd55b99
commit 1f84e36f8c

View File

@ -49,6 +49,9 @@ function dataURItoBlob(dataUrl) {
} }
function getJsonType(f) { function getJsonType(f) {
if (!sqlDataTypes.includes(f.type)) {
return '{ "type" : "object", additionalProperties : true }';
}
switch (f.type) { switch (f.type) {
case "INT": case "INT":
case "SMALLINT": case "SMALLINT":
@ -76,7 +79,7 @@ function getJsonType(f) {
} }
function generateSchema(type) { function generateSchema(type) {
return `{\n\t\t\t"type": "object",\n\t\t\t"properties": {\n\t\t\t\t${type.fields return `{\n\t\t\t"$schema": "http://json-schema.org/draft-04/schema#",\n\t\t\t"type": "object",\n\t\t\t"properties": {\n\t\t\t\t${type.fields
.map((f) => `"${f.name}" : ${getJsonType(f)}`) .map((f) => `"${f.name}" : ${getJsonType(f)}`)
.join( .join(
",\n\t\t\t\t" ",\n\t\t\t\t"