{
  "openapi": "3.0.0",
  "servers": [
    {
      "url": "localhost:3000",
      "description": "Local Metadata Provider"
    }
  ],
  "info": {
    "title": "Custom Metadata Provider",
    "version": "0.1.0",
    "license": {
      "name": "MIT",
      "url": "https://opensource.org/licenses/MIT"
    }
  },
  "security": [
    {
      "api_key": []
    }
  ],
  "paths": {
    "/goodreads/search": {
      "get": {
        "operationId": "searchGoodreads",
        "summary": "Search for books using goodreads",
        "description": "Search for books using goodreads",
        "parameters": [
          {
            "$ref": "#/components/parameters/query"
          },
          {
            "$ref": "#/components/parameters/author"
          }
        ],
        "responses": {
          "200": {
            "$ref": "#/components/responses/200"
          },
          "400": {
            "$ref": "#/components/responses/400"
          },
          "401": {
            "$ref": "#/components/responses/401"
          },
          "500": {
            "$ref": "#/components/responses/500"
          }
        }
      }
    },
    "/kindle/{region}/search": {
      "get": {
        "operationId": "searchKindle",
        "summary": "Search for books using kindle",
        "description": "Search for books using kindle",
        "parameters": [
          {
            "name": "region",
            "in": "path",
            "schema": {
              "type": "string",
              "enum": [
                "au",
                "ca",
                "de",
                "es",
                "fr",
                "in",
                "it",
                "jp",
                "uk",
                "us"
              ]
            }
          },
          {
            "$ref": "#/components/parameters/query"
          },
          {
            "$ref": "#/components/parameters/author"
          }
        ],
        "responses": {
          "200": {
            "$ref": "#/components/responses/200"
          },
          "400": {
            "$ref": "#/components/responses/400"
          },
          "401": {
            "$ref": "#/components/responses/401"
          },
          "500": {
            "$ref": "#/components/responses/500"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "api_key": {
        "type": "apiKey",
        "name": "AUTHORIZATION",
        "in": "header"
      }
    },
    "schemas": {
      "BookMetadata": {
        "type": "object",
        "required": [
          "title"
        ],
        "properties": {
          "title": {
            "type": "string"
          },
          "subtitle": {
            "type": "string"
          },
          "author": {
            "type": "string"
          },
          "narrator": {
            "type": "string"
          },
          "publisher": {
            "type": "string"
          },
          "publishedYear": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "cover": {
            "type": "string",
            "description": "URL to the cover image"
          },
          "isbn": {
            "type": "string",
            "format": "isbn"
          },
          "asin": {
            "type": "string",
            "format": "asin"
          },
          "genres": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "series": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SeriesMetadata"
            }
          },
          "language": {
            "type": "string"
          },
          "duration": {
            "type": "integer",
            "format": "int",
            "description": "Duration in seconds"
          }
        }
      },
      "SeriesMetadata": {
        "type": "object",
        "required": [
          "series"
        ],
        "properties": {
          "series": {
            "type": "string"
          },
          "sequence": {
            "type": "string"
          }
        }
      }
    },
    "parameters": {
      "query": {
        "name": "query",
        "in": "query",
        "required": true,
        "schema": {
          "type": "string"
        }
      },
      "author": {
        "name": "author",
        "in": "query",
        "required": false,
        "schema": {
          "type": "string"
        }
      }
    },
    "responses": {
      "200": {
        "description": "OK",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "matches": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/BookMetadata"
                  }
                }
              }
            }
          }
        }
      },
      "400": {
        "description": "Bad Request",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "error": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "401": {
        "description": "Unauthorized",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "error": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "500": {
        "type": "object",
        "description": "Internal Server Error",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "error": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    }
  }
}