openapi: 3.0.0
info:
  title: Bookstore API
  description: API for managing a collection of books with admin functionality
  version: 1.0.0
servers:
  - url: https://api.bookstore.com/v1
paths:
  /books:
    get:
      summary: List all books
      operationId: listBooks
      responses:
        '200':
          description: A list of books
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Book'
    post:
      summary: Add a new book (Admin)
      operationId: addBook
      requestBody:
        description: The book to add
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/NewBook'
      responses:
        '201':
          description: The book was created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Book'
  /books/{bookId}:
    get:
      summary: Get a book by ID
      operationId: getBook
      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: Book not found
    put:
      summary: Update a book by ID (Admin)
      operationId: updateBook
      parameters:
        - name: bookId
          in: path
          required: true
          schema:
            type: string
      requestBody:
        description: The book data to update
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/NewBook'
      responses:
        '200':
          description: The updated book
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Book'
        '404':
          description: Book not found
  /admin/books/{bookId}:
    delete:
      summary: Delete a book by ID (Admin)
      operationId: deleteBook
      parameters:
        - name: bookId
          in: path
          required: true
          schema:
            type: string
      responses:
        '204':
          description: The book was deleted
        '404':
          description: Book not found
components:
  schemas:
    Book:
      type: object
      properties:
        id:
          type: string
        title:
          type: string
        author:
          type: string
        publishedDate:
          type: string
          format: date
        isbn:
          type: string
    NewBook:
      type: object
      properties:
        title:
          type: string
        author:
          type: string
        publishedDate:
          type: string
          format: date
        isbn:
          type: string
