{
  "openapi": "3.0.0",
  "info": {
    "title": "SchemaNest",
    "description": "API Definition for SchemaNest",
    "contact": {
      "name": "Timo Reymann",
      "url": "https://github.com/timo-reymann/SchemaNest"
    }
  },
  "paths": {
    "/api/schema/json-schema": {
      "get": {
        "summary": "List all available JSON schemas",
        "operationId": "listJSONSchemas",
        "responses": {
          "200": {
            "description": "Successful operation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JsonSchemaDetails"
                }
              }
            }
          }
        }
      }
    },
    "/api/schema/json-schema/{identifier}": {
      "get": {
        "summary": "Get versions of a json schema",
        "parameters": [
          {
            "in": "path",
            "name": "identifier",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Version JSON Schema\"",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JsonSchemaList"
                }
              }
            }
          },
          "404": {
            "description": "JSON Schema with identifier not found"
          }
        }
      }
    },
    "/api/schema/json-schema/{identifier}/latest": {
      "get": {
        "summary": "Get latest version of a JSON schema",
        "parameters": [
          {
            "in": "path",
            "name": "identifier",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Latest JSON Schema definition",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "404": {
            "description": "JSON Schema with identifier not found"
          }
        }
      }
    },
    "/api/schema/json-schema/{identifier}/latest-version": {
      "get": {
        "summary": "Get the version of the latest JSON Schema",
        "parameters": [
          {
            "in": "path",
            "name": "identifier",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Latest JSON schema version",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/VersionParts"
                }
              }
            }
          }
        }
      }
    },
    "/api/schema/json-schema/{identifier}/channel/{channel}": {
      "get": {
        "summary": "Get latest version of a JSON schema for a channel",
        "parameters": [
          {
            "in": "path",
            "name": "identifier",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "in": "path",
            "name": "channel",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Latest JSON Schema definition",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "404": {
            "description": "JSON Schema with identifier not found"
          }
        }
      }
    },
    "/api/schema/json-schema/{identifier}/version/{version}": {
      "get": {
        "summary": "Get latest version of a JSON schema",
        "parameters": [
          {
            "in": "path",
            "name": "identifier",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "in": "path",
            "name": "version",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Latest JSON Schema definition",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "404": {
            "description": "JSON Schema with identifier not found"
          }
        }
      },
      "post": {
        "summary": "Create a new json schema for a version",
        "parameters": [
          {
            "in": "path",
            "name": "identifier",
            "schema": {
              "type": "string"
            },
            "required": true
          },
          {
            "in": "path",
            "name": "version",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created JSON Schema version\""
          },
          "409": {
            "description": "Schema already was uploaded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKeyAuth": []
          },
          {}
        ]
      }
    },
    "/api-spec.yml": {
      "summary": "Get API Specification",
      "get": {
        "responses": {
          "200": {
            "description": "Schema definition"
          }
        }
      }
    },
    "/ui-config": {
      "description": "UI configuration",
      "get": {
        "summary": "Get the UI configuration",
        "responses": {
          "200": {
            "description": "Get UI configuration",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UIConfig"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "JsonSchemaInfo": {
        "type": "object",
        "required": [
          "identifier",
          "description",
          "latestVersion"
        ],
        "properties": {
          "identifier": {
            "type": "string",
            "description": "Identifier for the schema"
          },
          "description": {
            "type": "string",
            "description": "Description for the schema as set by the latest version"
          },
          "latestVersion": {
            "$ref": "#/components/schemas/VersionParts"
          }
        }
      },
      "JsonSchemaList": {
        "type": "array",
        "items": {
          "$ref": "#/components/schemas/JsonSchemaInfo"
        }
      },
      "JsonSchemaDetails": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "versions"
        ],
        "properties": {
          "versions": {
            "$ref": "#/components/schemas/JsonSchemaVersions"
          },
          "description": {
            "type": "string",
            "description": "Description for the"
          }
        }
      },
      "JsonSchemaVersion": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "version"
        ],
        "properties": {
          "version": {
            "type": "string"
          }
        }
      },
      "JsonSchemaVersions": {
        "type": "array",
        "items": {
          "$ref": "#/components/schemas/JsonSchemaVersion"
        }
      },
      "Error": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "string",
            "description": "Error message"
          }
        }
      },
      "VersionParts": {
        "type": "object",
        "description": "Version seperated into its parts",
        "additionalProperties": false,
        "required": [
          "major",
          "minor",
          "patch"
        ],
        "properties": {
          "major": {
            "type": "integer",
            "description": "Semantic major version"
          },
          "minor": {
            "type": "integer",
            "description": "Semantic minor version"
          },
          "patch": {
            "type": "integer",
            "description": "Semantic patch version"
          }
        }
      },
      "UIConfig": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "apiKeyAuthEnabled"
        ],
        "properties": {
          "apiKeyAuthEnabled": {
            "type": "boolean",
            "description": "Whether API Key authentication has been enabled"
          }
        }
      }
    },
    "securitySchemes": {
      "ApiKey": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "API-Key"
      }
    }
  }
}