{
  "openapi": "3.0.3",
  "info": {
    "title": "Library catalogue API",
    "version": "1.0.0",
    "description": "Illustrative API contract for the Chiltepin import example. No service is deployed at the example URL."
  },
  "servers": [
    {
      "url": "https://library.example/api"
    }
  ],
  "paths": {
    "/books": {
      "get": {
        "operationId": "listBooks",
        "summary": "Search the catalogue",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": false,
            "description": "Match a title or author. Omit to browse.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 50,
              "default": 20
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Matching books",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Book"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/books/{bookId}": {
      "get": {
        "operationId": "getBook",
        "summary": "Read a book and its availability",
        "parameters": [
          {
            "name": "bookId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The requested book",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Book"
                }
              }
            }
          },
          "404": {
            "description": "No book has this identifier",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/holds": {
      "post": {
        "operationId": "placeHold",
        "summary": "Request a hold at Central Library",
        "description": "This fixture only models the request contract. Authentication and circulation rules belong in the real service specification.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "bookId",
                  "memberId"
                ],
                "properties": {
                  "bookId": {
                    "type": "string"
                  },
                  "memberId": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Hold recorded",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "status"
                  ],
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "requested"
                      ]
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "No copy can currently be held",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Book": {
        "type": "object",
        "required": [
          "id",
          "title",
          "author",
          "availableCopies"
        ],
        "properties": {
          "id": {
            "type": "string",
            "example": "book-001"
          },
          "title": {
            "type": "string",
            "example": "A small garden"
          },
          "author": {
            "type": "string",
            "example": "Lee Morgan"
          },
          "availableCopies": {
            "type": "integer",
            "minimum": 0,
            "example": 2
          }
        }
      },
      "Problem": {
        "type": "object",
        "required": [
          "code",
          "message"
        ],
        "properties": {
          "code": {
            "type": "string"
          },
          "message": {
            "type": "string"
          }
        }
      }
    }
  }
}
