Skip to content

Commit

Permalink
feat: add OpenAPI 3.0 Schema (#362)
Browse files Browse the repository at this point in the history
Co-authored-by: Lukasz Gornicki <lpgornicki@gmail.com>
  • Loading branch information
jonaslagoni and derberg authored Apr 26, 2023
1 parent 2255c30 commit 73f1f52
Show file tree
Hide file tree
Showing 14 changed files with 2,177 additions and 0 deletions.
23 changes: 23 additions & 0 deletions definitions/2.0.0/message.json
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,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/2.0.0/openapiSchema_3_0.json"
}
}
}
},
{
"if": {
"required": [
Expand Down
288 changes: 288 additions & 0 deletions definitions/2.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/2.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
}
23 changes: 23 additions & 0 deletions definitions/2.1.0/message.json
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,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/2.1.0/openapiSchema_3_0.json"
}
}
}
},
{
"if": {
"required": [
Expand Down
Loading

0 comments on commit 73f1f52

Please sign in to comment.