Skip to content

Commit

Permalink
feat: add OpenAPI 3.0 schema validation (#348)
Browse files Browse the repository at this point in the history
Co-authored-by: Sergio Moya <[email protected]>
  • Loading branch information
jonaslagoni and smoya authored Mar 14, 2023
1 parent 8e127db commit 48e7b43
Show file tree
Hide file tree
Showing 3 changed files with 401 additions and 0 deletions.
23 changes: 23 additions & 0 deletions definitions/3.0.0/messageObject.json
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,29 @@
}
}
}
},
{
"if": {
"required": [
"schemaFormat"
],
"properties": {
"schemaFormat": {
"enum": [
"application/vnd.oai.openapi;version=3.0.0",
"application/vnd.oai.openapi+json;version=3.0.0",
"application/vnd.oai.openapi+yaml;version=3.0.0"
]
}
}
},
"then": {
"properties": {
"payload": {
"$ref": "http://asyncapi.com/definitions/3.0.0/openapiSchema_3_0.json"
}
}
}
}
],
"$schema": "http://json-schema.org/draft-07/schema#",
Expand Down
288 changes: 288 additions & 0 deletions definitions/3.0.0/openapiSchema_3_0.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,288 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "http://asyncapi.com/definitions/3.0.0/openapiSchema_3_0.json",
"type": "object",
"definitions": {
"ExternalDocumentation": {
"type": "object",
"required": [
"url"
],
"properties": {
"description": {
"type": "string"
},
"url": {
"type": "string",
"format": "uri-reference"
}
},
"patternProperties": {
"^x-": {}
},
"additionalProperties": false
},
"Discriminator": {
"type": "object",
"required": [
"propertyName"
],
"properties": {
"propertyName": {
"type": "string"
},
"mapping": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
}
},
"Reference": {
"type": "object",
"required": [
"$ref"
],
"patternProperties": {
"^\\$ref$": {
"type": "string",
"format": "uri-reference"
}
}
},
"XML": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"namespace": {
"type": "string",
"format": "uri"
},
"prefix": {
"type": "string"
},
"attribute": {
"type": "boolean",
"default": false
},
"wrapped": {
"type": "boolean",
"default": false
}
},
"patternProperties": {
"^x-": {}
},
"additionalProperties": false
}
},
"properties": {
"title": {
"type": "string"
},
"multipleOf": {
"type": "number",
"exclusiveMinimum": 0
},
"maximum": {
"type": "number"
},
"exclusiveMaximum": {
"type": "boolean",
"default": false
},
"minimum": {
"type": "number"
},
"exclusiveMinimum": {
"type": "boolean",
"default": false
},
"maxLength": {
"type": "integer",
"minimum": 0
},
"minLength": {
"type": "integer",
"minimum": 0,
"default": 0
},
"pattern": {
"type": "string",
"format": "regex"
},
"maxItems": {
"type": "integer",
"minimum": 0
},
"minItems": {
"type": "integer",
"minimum": 0,
"default": 0
},
"uniqueItems": {
"type": "boolean",
"default": false
},
"maxProperties": {
"type": "integer",
"minimum": 0
},
"minProperties": {
"type": "integer",
"minimum": 0,
"default": 0
},
"required": {
"type": "array",
"items": {
"type": "string"
},
"minItems": 1,
"uniqueItems": true
},
"enum": {
"type": "array",
"items": true,
"minItems": 1,
"uniqueItems": false
},
"type": {
"type": "string",
"enum": [
"array",
"boolean",
"integer",
"number",
"object",
"string"
]
},
"not": {
"oneOf": [
{
"$ref": "#"
},
{
"$ref": "#/definitions/Reference"
}
]
},
"allOf": {
"type": "array",
"items": {
"oneOf": [
{
"$ref": "#"
},
{
"$ref": "#/definitions/Reference"
}
]
}
},
"oneOf": {
"type": "array",
"items": {
"oneOf": [
{
"$ref": "#"
},
{
"$ref": "#/definitions/Reference"
}
]
}
},
"anyOf": {
"type": "array",
"items": {
"oneOf": [
{
"$ref": "#"
},
{
"$ref": "#/definitions/Reference"
}
]
}
},
"items": {
"oneOf": [
{
"$ref": "#"
},
{
"$ref": "#/definitions/Reference"
}
]
},
"properties": {
"type": "object",
"additionalProperties": {
"oneOf": [
{
"$ref": "#"
},
{
"$ref": "#/definitions/Reference"
}
]
}
},
"additionalProperties": {
"oneOf": [
{
"$ref": "#"
},
{
"$ref": "#/definitions/Reference"
},
{
"type": "boolean"
}
],
"default": true
},
"description": {
"type": "string"
},
"format": {
"type": "string"
},
"default": true,
"nullable": {
"type": "boolean",
"default": false
},
"discriminator": {
"$ref": "#/definitions/Discriminator"
},
"readOnly": {
"type": "boolean",
"default": false
},
"writeOnly": {
"type": "boolean",
"default": false
},
"example": true,
"externalDocs": {
"$ref": "#/definitions/ExternalDocumentation"
},
"deprecated": {
"type": "boolean",
"default": false
},
"xml": {
"$ref": "#/definitions/XML"
}
},
"patternProperties": {
"^x-": true
},
"additionalProperties": false
}
Loading

0 comments on commit 48e7b43

Please sign in to comment.