{
  "$schema": "https://www.pontxapi.com/public/schemas/draft-04.json#",
  "$id": "http://example.com/pontx-schema.json",
  "title": "A JSON Schema for Pontx",
  "type": "object",
  "required": ["name", "definitions", "apis"],
  "additionalProperties": false,
  "properties": {
    "name": {
      "type": "string"
    },
    "info": {
      "type": "object",
      "additionalProperties": true
    },
    "description": {
      "type": "string",
      "title": "元数据描述"
    },
    "pontx": {
      "type": "string",
      "title": "pontx 协议版本"
    },
    "components": {
      "type": "object",
      "properties": {
        "schemas": {
          "type": "object",
          "additionalProperties": {
            "$ref": "#/definitions/schema"
          }
        }
      }
    },
    "definitions": {
      "$ref": "#/definitions/definitions"
    },
    "apis": {
      "type": "object",
      "additionalProperties": {
        "$ref": "#/definitions/api"
      }
    },
    "tags": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "description": {
            "type": "string"
          }
        }
      }
    },
    "servers": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "url": {
            "type": "string"
          },
          "description": {
            "type": "string"
          }
        }
      }
    },
    "ext": {
      "type": "object"
    },
    "security": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": {
          "type": "array",
          "default": [],
          "items": {
            "type": "string"
          }
        }
      }
    },
    "securitySchemes": {
      "type": "object",
      "additionalProperties": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "in": {
            "type": "string"
          },
          "scheme": {
            "type": "string"
          },
          "bearerFormat": {
            "type": "string"
          },
          "flows": {
            "$ref": "#/definitions/OAuthFlowsObject"
          },
          "openIdConnectUrl": {
            "type": "string"
          }
        }
      }
    },
    "title": {
      "type": "string"
    },
    "version": {
      "type": "string"
    },
    "style": {
      "type": "string",
      "enum": ["RPC", "RESTFul", "GraphQL"]
    },
    "envs": {
      "additionalProperties": {
        "$ref": "#"
      }
    }
  },
  "definitions": {
    "api": {
      "type": "object",
      "required": ["parameters", "responses", "name"],
      "default": {
        "name": "createPontx",
        "description": "This is a pontx api",
        "parameters": [
          {
            "name": "name",
            "in": "query",
            "schema": { "type": "string", "title": "名称", "required": true }
          }
        ],
        "responses": {
          "200": {
            "schema": {}
          }
        }
      },
      "properties": {
        "name": {
          "title": "API 标识名称",
          "type": "string"
        },
        "title": {
          "title": "API 标题",
          "type": "string"
        },
        "description": {
          "type": "string",
          "title": "描述"
        },
        "deprecated": {
          "type": "boolean",
          "title": "是否弃用"
        },
        "path": {
          "title": "路径",
          "type": "string"
        },
        "method": {
          "title": "API 方法",
          "type": "string",
          "enum": ["GET", "POST", "DELETE", "PATCH", "PUT", "OPTIONS", "HEAD"]
        },
        "consumes": {
          "description": "A list of MIME types the API can consume.",
          "allOf": [
            {
              "$ref": "#/definitions/mediaTypeList"
            }
          ]
        },
        "produces": {
          "description": "A list of MIME types the API can produce.",
          "allOf": [
            {
              "$ref": "#/definitions/mediaTypeList"
            }
          ]
        },
        "parameters": {
          "title": "请求参数",
          "type": "array",
          "items": {
            "$ref": "#/definitions/parameter"
          }
        },
        "responses": {
          "title": "返回参数",
          "type": "object",
          "additionalProperties": {
            "$ref": "#/definitions/response"
          }
        },
        "security": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": {
              "type": "array",
              "default": [],
              "items": {
                "type": "string"
              }
            }
          }
        },
        "ext": {
          "type": "object"
        }
      }
    },
    "parameter": {
      "type": "object",
      "required": ["name", "in", "schema"],
      "properties": {
        "schema": {
          "$ref": "#/definitions/schema"
        },
        "name": {
          "type": "string"
        },
        "in": {
          "type": "string",
          "enum": ["query", "body", "path", "formData", "header"]
        },
        "required": {
          "type": "boolean"
        }
      }
    },
    "mimeType": {
      "type": "string",
      "description": "The MIME type of the HTTP message."
    },
    "mediaTypeList": {
      "type": "array",
      "items": {
        "$ref": "#/definitions/mimeType"
      },
      "uniqueItems": true
    },
    "response": {
      "type": "object",
      "properties": {
        "schema": {
          "$ref": "#/definitions/schema"
        },
        "headers": {
          "$ref": "https://www.pontxapi.com/public/schemas/oas2.json#/definitions/headers"
        },
        "description": {
          "type": "string"
        }
      },
      "additionalProperties": false
    },
    "definitions": {
      "type": "object",
      "additionalProperties": {
        "$ref": "#/definitions/schema"
      },
      "description": "数据结构定义"
    },
    "OAuthFlowsObject": {
      "type": "object",
      "properties": {
        "implicit": {
          "$ref": "#/definitions/OAuthFlowObject",
          "desc": "Configuration for the OAuth Implicit flow"
        },
        "password": {
          "$ref": "#/definitions/OAuthFlowObject",
          "desc": "Configuration for the OAuth Resource Owner Password flow"
        },
        "clientCredentials": {
          "$ref": "#/definitions/OAuthFlowObject",
          "desc": "Configuration for the OAuth Client Credentials flow.  Previously called <code>application</code> in OpenAPI 2.0."
        },
        "authorizationCode": {
          "$ref": "#/definitions/OAuthFlowObject",
          "desc": "Configuration for the OAuth Authorization Code flow.  Previously called <code>accessCode</code> in OpenAPI 2.0."
        }
      }
    },
    "OAuthFlowObject": {
      "type": "object",
      "properties": {
        "authorizationUrl": {
          "type": "string"
        },
        "tokenUrl": {
          "type": "string"
        },
        "refreshUrl": {
          "type": "string"
        },
        "scopes": {
          "type": "object",
          "additionalProperties": {
            "type": "string"
          }
        }
      }
    },
    "schema": {
      "type": "object",
      "description": "A deterministic version of a JSON Schema object.",
      "properties": {
        "$id": {
          "type": "string"
        },
        "$schema": {
          "type": "string"
        },
        "$ref": {
          "type": "string"
        },
        "$comment": {
          "type": "string"
        },
        "title": {
          "$ref": "https://www.pontxapi.com/public/schemas/draft-04.json#/properties/title"
        },
        "description": {
          "$ref": "https://www.pontxapi.com/public/schemas/draft-04.json#/properties/description"
        },
        "default": {
          "$ref": "https://www.pontxapi.com/public/schemas/draft-04.json#/properties/default"
        },
        "readOnly": {
          "type": "boolean"
        },
        "examples": {
          "type": "array",
          "items": {}
        },
        "multipleOf": {
          "$ref": "https://www.pontxapi.com/public/schemas/draft-04.json#/properties/multipleOf"
        },
        "maximum": {
          "$ref": "https://www.pontxapi.com/public/schemas/draft-04.json#/properties/maximum"
        },
        "exclusiveMaximum": {
          "$ref": "https://www.pontxapi.com/public/schemas/draft-04.json#/properties/exclusiveMaximum"
        },
        "minimum": {
          "$ref": "https://www.pontxapi.com/public/schemas/draft-04.json#/properties/minimum"
        },
        "exclusiveMinimum": {
          "$ref": "https://www.pontxapi.com/public/schemas/draft-04.json#/properties/exclusiveMinimum"
        },
        "maxLength": {
          "$ref": "https://www.pontxapi.com/public/schemas/draft-04.json#/definitions/positiveInteger"
        },
        "minLength": {
          "$ref": "https://www.pontxapi.com/public/schemas/draft-04.json#/definitions/positiveIntegerDefault0"
        },
        "pattern": {
          "$ref": "https://www.pontxapi.com/public/schemas/draft-04.json#/properties/pattern"
        },
        "maxItems": {
          "$ref": "https://www.pontxapi.com/public/schemas/draft-04.json#/definitions/positiveInteger"
        },
        "minItems": {
          "$ref": "https://www.pontxapi.com/public/schemas/draft-04.json#/definitions/positiveIntegerDefault0"
        },
        "uniqueItems": {
          "$ref": "https://www.pontxapi.com/public/schemas/draft-04.json#/properties/uniqueItems"
        },
        "contains": {
          "type": "object",
          "additionalProperties": {
            "$ref": "#/definitions/schema"
          }
        },
        "maxProperties": {
          "$ref": "https://www.pontxapi.com/public/schemas/draft-04.json#/definitions/positiveInteger"
        },
        "additionalItems": {
          "anyOf": [
            {
              "$ref": "#/definitions/schema"
            },
            {
              "type": "boolean"
            }
          ],
          "default": {}
        },
        "minProperties": {
          "$ref": "https://www.pontxapi.com/public/schemas/draft-04.json#/definitions/positiveIntegerDefault0"
        },
        "patternProperties": {
          "type": "object",
          "additionalProperties": {
            "$ref": "#/definitions/schema"
          },
          "default": {}
        },
        "dependencies": {
          "additionalProperties": {
            "anyOf": [
              {
                "$ref": "#/definitions/schema"
              },
              {
                "$ref": "https://www.pontxapi.com/public/schemas/draft-04.json#/definitions/stringArray"
              }
            ]
          }
        },
        "propertyNames": {
          "$ref": "#/definitions/schema"
        },
        "const": {},
        "enum": {
          "$ref": "https://www.pontxapi.com/public/schemas/draft-04.json#/properties/enum"
        },
        "type": {
          "anyOf": [
            {
              "enum": [
                "array",
                "boolean",
                "integer",
                "null",
                "number",
                "object",
                "string",
                "void"
              ]
            },
            {
              "type": "array",
              "items": {
                "enum": [
                  "array",
                  "boolean",
                  "integer",
                  "null",
                  "number",
                  "object",
                  "string",
                  "void"
                ]
              },
              "minItems": 1,
              "uniqueItems": true
            }
          ]
        },
        "format": {
          "type": "string"
        },
        "contentMediaType": {
          "type": "string"
        },
        "contentEncoding": {
          "type": "string"
        },
        "if": {
          "$ref": "#/definitions/schema"
        },
        "then": {
          "$ref": "#/definitions/schema"
        },
        "else": {
          "$ref": "#/definitions/schema"
        },
        "allOf": {
          "$ref": "#/definitions/schemaArray"
        },
        "anyOf": {
          "$ref": "#/definitions/schemaArray"
        },
        "oneOf": {
          "$ref": "#/definitions/schemaArray"
        },
        "not": {
          "$ref": "#/definitions/schema"
        },
        "items": {
          "anyOf": [
            {
              "$ref": "#/definitions/schema"
            },
            {
              "$ref": "#/definitions/schemaArray"
            }
          ],
          "default": {}
        },
        "additionalProperties": {
          "anyOf": [
            {
              "$ref": "#/definitions/schema"
            },
            {
              "type": "boolean"
            }
          ],
          "default": {}
        },
        "definitions": {
          "type": "object",
          "additionalProperties": {
            "$ref": "#/definitions/schema"
          },
          "default": {}
        },
        "properties": {
          "type": "object",
          "additionalProperties": {
            "$ref": "#/definitions/schema"
          },
          "default": {}
        },
        "templateIndex": {
          "type": "number",
          "default": -1
        },
        "typeName": {
          "type": "string"
        },
        "templateArgs": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/schema"
          },
          "default": []
        },
        "example": {},
        "required": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "requiredProps": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      },
      "additionalProperties": true
    },
    "schemaArray": {
      "type": "array",
      "minItems": 1,
      "items": {
        "$ref": "#/definitions/schema"
      }
    }
  }
}
