openapi json model, processing & parsing fixes
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
module jsonschema
|
||||
|
||||
import x.json2 { Any }
|
||||
import json
|
||||
|
||||
pub fn decode(data string) !Schema {
|
||||
schema_map := json2.raw_decode(data)!.as_map()
|
||||
mut schema := json2.decode[Schema](data)!
|
||||
mut schema := json.decode(Schema, data)!
|
||||
for key, value in schema_map {
|
||||
if key == 'properties' {
|
||||
schema.properties = decode_schemaref_map(value.as_map())!
|
||||
|
||||
@@ -8,7 +8,7 @@ pub type SchemaRef = Reference | Schema
|
||||
|
||||
pub struct Reference {
|
||||
pub:
|
||||
ref string @[json: 'ref']
|
||||
ref string @[json: '\$ref']
|
||||
}
|
||||
|
||||
pub type Number = int
|
||||
@@ -21,10 +21,10 @@ pub mut:
|
||||
title string @[omitempty]
|
||||
description string @[omitempty]
|
||||
typ string @[json: 'type'; omitempty]
|
||||
properties map[string]SchemaRef @[omitempty]
|
||||
properties map[string]SchemaRef @[json: '-'; omitempty]
|
||||
additional_properties SchemaRef @[json: 'additionalProperties'; omitempty]
|
||||
required []string @[omitempty]
|
||||
items Items @[omitempty]
|
||||
items Items @[json: '-'; omitempty]
|
||||
defs map[string]SchemaRef @[omitempty]
|
||||
one_of []SchemaRef @[json: 'oneOf'; omitempty]
|
||||
format string @[omitempty]
|
||||
|
||||
Reference in New Issue
Block a user