Updated embedded OAS schemas and fixed UniqueValues

UniqueValues was marked as an integer, not a boolean.

Signed-off-by: Dave Shanley <dave@quobix.com>
This commit is contained in:
Dave Shanley
2023-04-28 18:55:16 -04:00
parent 736fbfd0c3
commit 26e694a5e9
4 changed files with 1224 additions and 1152 deletions

View File

@@ -84,7 +84,7 @@ type Schema struct {
Format string `json:"format,omitempty" yaml:"format,omitempty"` Format string `json:"format,omitempty" yaml:"format,omitempty"`
MaxItems *int64 `json:"maxItems,omitempty" yaml:"maxItems,omitempty"` MaxItems *int64 `json:"maxItems,omitempty" yaml:"maxItems,omitempty"`
MinItems *int64 `json:"minItems,omitempty" yaml:"minItems,omitempty"` MinItems *int64 `json:"minItems,omitempty" yaml:"minItems,omitempty"`
UniqueItems *int64 `json:"uniqueItems,omitempty" yaml:"uniqueItems,omitempty"` UniqueItems *bool `json:"uniqueItems,omitempty" yaml:"uniqueItems,omitempty"`
MaxProperties *int64 `json:"maxProperties,omitempty" yaml:"maxProperties,omitempty"` MaxProperties *int64 `json:"maxProperties,omitempty" yaml:"maxProperties,omitempty"`
MinProperties *int64 `json:"minProperties,omitempty" yaml:"minProperties,omitempty"` MinProperties *int64 `json:"minProperties,omitempty" yaml:"minProperties,omitempty"`
Required []string `json:"required,omitempty" yaml:"required,omitempty"` Required []string `json:"required,omitempty" yaml:"required,omitempty"`
@@ -171,13 +171,15 @@ func NewSchema(schema *base.Schema) *Schema {
if !schema.MinContains.IsEmpty() { if !schema.MinContains.IsEmpty() {
s.MinContains = &schema.MinContains.Value s.MinContains = &schema.MinContains.Value
} }
if !schema.UniqueItems.IsEmpty() {
s.UniqueItems = &schema.UniqueItems.Value
}
if !schema.Contains.IsEmpty() { if !schema.Contains.IsEmpty() {
s.Contains = &SchemaProxy{schema: &lowmodel.NodeReference[*base.SchemaProxy]{ s.Contains = &SchemaProxy{schema: &lowmodel.NodeReference[*base.SchemaProxy]{
ValueNode: schema.Contains.ValueNode, ValueNode: schema.Contains.ValueNode,
Value: schema.Contains.Value, Value: schema.Contains.Value,
}} }}
} }
if !schema.If.IsEmpty() { if !schema.If.IsEmpty() {
s.If = &SchemaProxy{schema: &lowmodel.NodeReference[*base.SchemaProxy]{ s.If = &SchemaProxy{schema: &lowmodel.NodeReference[*base.SchemaProxy]{
ValueNode: schema.If.ValueNode, ValueNode: schema.If.ValueNode,

View File

@@ -103,7 +103,7 @@ type Schema struct {
Format low.NodeReference[string] Format low.NodeReference[string]
MaxItems low.NodeReference[int64] MaxItems low.NodeReference[int64]
MinItems low.NodeReference[int64] MinItems low.NodeReference[int64]
UniqueItems low.NodeReference[int64] UniqueItems low.NodeReference[bool]
MaxProperties low.NodeReference[int64] MaxProperties low.NodeReference[int64]
MinProperties low.NodeReference[int64] MinProperties low.NodeReference[int64]
Required low.NodeReference[[]low.ValueReference[string]] Required low.NodeReference[[]low.ValueReference[string]]

View File

@@ -46,7 +46,8 @@
} }
}, },
"patternProperties": { "patternProperties": {
"^x-": {} "^x-": {
}
}, },
"additionalProperties": false, "additionalProperties": false,
"definitions": { "definitions": {
@@ -90,7 +91,8 @@
} }
}, },
"patternProperties": { "patternProperties": {
"^x-": {} "^x-": {
}
}, },
"additionalProperties": false "additionalProperties": false
}, },
@@ -110,7 +112,8 @@
} }
}, },
"patternProperties": { "patternProperties": {
"^x-": {} "^x-": {
}
}, },
"additionalProperties": false "additionalProperties": false
}, },
@@ -129,7 +132,8 @@
} }
}, },
"patternProperties": { "patternProperties": {
"^x-": {} "^x-": {
}
}, },
"additionalProperties": false "additionalProperties": false
}, },
@@ -153,7 +157,8 @@
} }
}, },
"patternProperties": { "patternProperties": {
"^x-": {} "^x-": {
}
}, },
"additionalProperties": false "additionalProperties": false
}, },
@@ -177,7 +182,8 @@
} }
}, },
"patternProperties": { "patternProperties": {
"^x-": {} "^x-": {
}
}, },
"additionalProperties": false "additionalProperties": false
}, },
@@ -321,7 +327,8 @@
} }
}, },
"patternProperties": { "patternProperties": {
"^x-": {} "^x-": {
}
}, },
"additionalProperties": false "additionalProperties": false
}, },
@@ -395,7 +402,8 @@
}, },
"enum": { "enum": {
"type": "array", "type": "array",
"items": {}, "items": {
},
"minItems": 1, "minItems": 1,
"uniqueItems": false "uniqueItems": false
}, },
@@ -502,7 +510,8 @@
"format": { "format": {
"type": "string" "type": "string"
}, },
"default": {}, "default": {
},
"nullable": { "nullable": {
"type": "boolean", "type": "boolean",
"default": false "default": false
@@ -518,7 +527,8 @@
"type": "boolean", "type": "boolean",
"default": false "default": false
}, },
"example": {}, "example": {
},
"externalDocs": { "externalDocs": {
"$ref": "#/definitions/ExternalDocumentation" "$ref": "#/definitions/ExternalDocumentation"
}, },
@@ -531,7 +541,8 @@
} }
}, },
"patternProperties": { "patternProperties": {
"^x-": {} "^x-": {
}
}, },
"additionalProperties": false "additionalProperties": false
}, },
@@ -575,7 +586,8 @@
} }
}, },
"patternProperties": { "patternProperties": {
"^x-": {} "^x-": {
}
}, },
"additionalProperties": false "additionalProperties": false
}, },
@@ -622,7 +634,8 @@
} }
}, },
"patternProperties": { "patternProperties": {
"^x-": {} "^x-": {
}
}, },
"additionalProperties": false "additionalProperties": false
}, },
@@ -639,7 +652,8 @@
} }
] ]
}, },
"example": {}, "example": {
},
"examples": { "examples": {
"type": "object", "type": "object",
"additionalProperties": { "additionalProperties": {
@@ -661,7 +675,8 @@
} }
}, },
"patternProperties": { "patternProperties": {
"^x-": {} "^x-": {
}
}, },
"additionalProperties": false, "additionalProperties": false,
"allOf": [ "allOf": [
@@ -679,14 +694,16 @@
"description": { "description": {
"type": "string" "type": "string"
}, },
"value": {}, "value": {
},
"externalValue": { "externalValue": {
"type": "string", "type": "string",
"format": "uri-reference" "format": "uri-reference"
} }
}, },
"patternProperties": { "patternProperties": {
"^x-": {} "^x-": {
}
}, },
"additionalProperties": false "additionalProperties": false
}, },
@@ -740,7 +757,8 @@
"minProperties": 1, "minProperties": 1,
"maxProperties": 1 "maxProperties": 1
}, },
"example": {}, "example": {
},
"examples": { "examples": {
"type": "object", "type": "object",
"additionalProperties": { "additionalProperties": {
@@ -756,7 +774,8 @@
} }
}, },
"patternProperties": { "patternProperties": {
"^x-": {} "^x-": {
}
}, },
"additionalProperties": false, "additionalProperties": false,
"allOf": [ "allOf": [
@@ -774,7 +793,8 @@
"^\\/": { "^\\/": {
"$ref": "#/definitions/PathItem" "$ref": "#/definitions/PathItem"
}, },
"^x-": {} "^x-": {
}
}, },
"additionalProperties": false "additionalProperties": false
}, },
@@ -815,7 +835,8 @@
"^(get|put|post|delete|options|head|patch|trace)$": { "^(get|put|post|delete|options|head|patch|trace)$": {
"$ref": "#/definitions/Operation" "$ref": "#/definitions/Operation"
}, },
"^x-": {} "^x-": {
}
}, },
"additionalProperties": false "additionalProperties": false
}, },
@@ -901,7 +922,8 @@
} }
}, },
"patternProperties": { "patternProperties": {
"^x-": {} "^x-": {
}
}, },
"additionalProperties": false "additionalProperties": false
}, },
@@ -930,7 +952,8 @@
} }
] ]
}, },
"^x-": {} "^x-": {
}
}, },
"minProperties": 1, "minProperties": 1,
"additionalProperties": false "additionalProperties": false
@@ -961,7 +984,8 @@
} }
}, },
"patternProperties": { "patternProperties": {
"^x-": {} "^x-": {
}
}, },
"additionalProperties": false "additionalProperties": false
}, },
@@ -980,7 +1004,8 @@
} }
}, },
"patternProperties": { "patternProperties": {
"^x-": {} "^x-": {
}
}, },
"additionalProperties": false "additionalProperties": false
}, },
@@ -1104,7 +1129,8 @@
"minProperties": 1, "minProperties": 1,
"maxProperties": 1 "maxProperties": 1
}, },
"example": {}, "example": {
},
"examples": { "examples": {
"type": "object", "type": "object",
"additionalProperties": { "additionalProperties": {
@@ -1120,7 +1146,8 @@
} }
}, },
"patternProperties": { "patternProperties": {
"^x-": {} "^x-": {
}
}, },
"additionalProperties": false, "additionalProperties": false,
"required": [ "required": [
@@ -1242,7 +1269,8 @@
} }
}, },
"patternProperties": { "patternProperties": {
"^x-": {} "^x-": {
}
}, },
"additionalProperties": false "additionalProperties": false
}, },
@@ -1292,7 +1320,8 @@
} }
}, },
"patternProperties": { "patternProperties": {
"^x-": {} "^x-": {
}
}, },
"additionalProperties": false "additionalProperties": false
}, },
@@ -1320,7 +1349,8 @@
} }
}, },
"patternProperties": { "patternProperties": {
"^x-": {} "^x-": {
}
}, },
"additionalProperties": false, "additionalProperties": false,
"oneOf": [ "oneOf": [
@@ -1372,7 +1402,8 @@
} }
}, },
"patternProperties": { "patternProperties": {
"^x-": {} "^x-": {
}
}, },
"additionalProperties": false "additionalProperties": false
}, },
@@ -1398,7 +1429,8 @@
} }
}, },
"patternProperties": { "patternProperties": {
"^x-": {} "^x-": {
}
}, },
"additionalProperties": false "additionalProperties": false
}, },
@@ -1419,7 +1451,8 @@
} }
}, },
"patternProperties": { "patternProperties": {
"^x-": {} "^x-": {
}
}, },
"additionalProperties": false "additionalProperties": false
}, },
@@ -1446,7 +1479,8 @@
} }
}, },
"patternProperties": { "patternProperties": {
"^x-": {} "^x-": {
}
}, },
"additionalProperties": false "additionalProperties": false
}, },
@@ -1473,7 +1507,8 @@
} }
}, },
"patternProperties": { "patternProperties": {
"^x-": {} "^x-": {
}
}, },
"additionalProperties": false "additionalProperties": false
}, },
@@ -1500,7 +1535,8 @@
} }
}, },
"patternProperties": { "patternProperties": {
"^x-": {} "^x-": {
}
}, },
"additionalProperties": false "additionalProperties": false
}, },
@@ -1532,7 +1568,8 @@
} }
}, },
"patternProperties": { "patternProperties": {
"^x-": {} "^x-": {
}
}, },
"additionalProperties": false "additionalProperties": false
}, },
@@ -1548,9 +1585,11 @@
}, },
"parameters": { "parameters": {
"type": "object", "type": "object",
"additionalProperties": {} "additionalProperties": {
}
},
"requestBody": {
}, },
"requestBody": {},
"description": { "description": {
"type": "string" "type": "string"
}, },
@@ -1559,7 +1598,8 @@
} }
}, },
"patternProperties": { "patternProperties": {
"^x-": {} "^x-": {
}
}, },
"additionalProperties": false, "additionalProperties": false,
"not": { "not": {
@@ -1576,7 +1616,8 @@
"$ref": "#/definitions/PathItem" "$ref": "#/definitions/PathItem"
}, },
"patternProperties": { "patternProperties": {
"^x-": {} "^x-": {
}
} }
}, },
"Encoding": { "Encoding": {

View File

@@ -1,5 +1,5 @@
{ {
"$id": "https://spec.openapis.org/oas/3.1/schema/2022-02-27", "$id": "https://spec.openapis.org/oas/3.1/schema/2022-10-07",
"$schema": "https://json-schema.org/draft/2020-12/schema", "$schema": "https://json-schema.org/draft/2020-12/schema",
"description": "The description of OpenAPI v3.1.x documents without schema validation, as defined by https://spec.openapis.org/oas/v3.1.0", "description": "The description of OpenAPI v3.1.x documents without schema validation, as defined by https://spec.openapis.org/oas/v3.1.0",
"type": "object", "type": "object",
@@ -22,7 +22,9 @@
"$ref": "#/$defs/server" "$ref": "#/$defs/server"
}, },
"default": [ "default": [
{ "url": "/" } {
"url": "/"
}
] ]
}, },
"paths": { "paths": {
@@ -148,18 +150,15 @@
"required": [ "required": [
"name" "name"
], ],
"oneOf": [ "dependentSchemas": {
{ "identifier": {
"required": [ "not": {
"identifier"
]
},
{
"required": [ "required": [
"url" "url"
] ]
} }
], }
},
"$ref": "#/$defs/specification-extensions", "$ref": "#/$defs/specification-extensions",
"unevaluatedProperties": false "unevaluatedProperties": false
}, },
@@ -319,10 +318,29 @@
"items": { "items": {
"$ref": "#/$defs/parameter-or-reference" "$ref": "#/$defs/parameter-or-reference"
} }
}
}, },
"patternProperties": { "get": {
"^(get|put|post|delete|options|head|patch|trace)$": { "$ref": "#/$defs/operation"
},
"put": {
"$ref": "#/$defs/operation"
},
"post": {
"$ref": "#/$defs/operation"
},
"delete": {
"$ref": "#/$defs/operation"
},
"options": {
"$ref": "#/$defs/operation"
},
"head": {
"$ref": "#/$defs/operation"
},
"patch": {
"$ref": "#/$defs/operation"
},
"trace": {
"$ref": "#/$defs/operation" "$ref": "#/$defs/operation"
} }
}, },
@@ -822,7 +840,16 @@
}, },
"minProperties": 1, "minProperties": 1,
"$ref": "#/$defs/specification-extensions", "$ref": "#/$defs/specification-extensions",
"unevaluatedProperties": false "unevaluatedProperties": false,
"if": {
"$comment": "either default, or at least one response code property must exist",
"patternProperties": {
"^[1-5](?:[0-9]{2}|XX)$": false
}
},
"then" : {
"required": [ "default" ]
}
}, },
"response": { "response": {
"$comment": "https://spec.openapis.org/oas/v3.1.0#response-object", "$comment": "https://spec.openapis.org/oas/v3.1.0#response-object",
@@ -936,7 +963,9 @@
"type": "string", "type": "string",
"format": "uri-reference" "format": "uri-reference"
}, },
"operationId": true, "operationId": {
"type": "string"
},
"parameters": { "parameters": {
"$ref": "#/$defs/map-of-strings" "$ref": "#/$defs/map-of-strings"
}, },