# The sample document behind the agent-emitter fixtures (5.mcp-tools.*,
# 6.skill.*). Each case's input.json is this document converted by
# @xyd-js/openapi — regenerate them with
#   XYD_NATIVE=0 bun packages/apitoolchain-openapi/scripts/build-agent-fixture-inputs.ts
# What it exercises:
# - two tagged groups (pets, store) and one untagged operation (health)
# - path, query, header and JSON-body parameters; a root-array body; a body
#   property that shares its name with a path parameter (replaceOrder.id)
# - several responses per operation, a 204 without a body, two deletes
# - string and integer enums, arrays, nested objects three levels deep, oneOf,
#   anyOf, nullable, defaults, examples, minimum/maximum, a deprecated param
# - an operation without an operationId (canonical from its summary) and one
#   with neither (canonical from method + path)
# - x-docs page paths and x-codeSamples
# - hard-wrapped descriptions (literal blocks), one with a setext heading and
#   a fenced code sample, and an "at most N" clause on a `limit` the MCP cap
#   overrides
# - a query parameter named like a path parameter (listOwnerPets.name), an
#   optional request body (shipOrder), a multipart-only body (uploadPetPhoto)
# - abbreviations in a first sentence ("e.g.", "No.") and a nullable string
#   enum with a null member (NewPet.size)
openapi: 3.0.3
info:
  title: Pet Store API
  version: 1.0.0
servers:
  - url: https://api.example.com/v1
tags:
  - name: pets
  - name: store
paths:
  /pets:
    get:
      operationId: listPets
      summary: List pets
      description: |-
        Returns a page of pets, newest
        first. Filters combine with AND.

        Use `cursor` from a previous page to continue:
        - pass `next_cursor` back as `cursor`
        - keep the other filters as they were
      tags: [pets]
      x-docs:
        path: pets/list
      parameters:
        - name: limit
          in: query
          description: |-
            Maximum number of pets to return,
            at most 100.
          schema:
            type: integer
            default: 20
            minimum: 1
            maximum: 100
        - name: status
          in: query
          description: Only pets with this status.
          schema:
            type: string
            enum: [available, pending, sold]
        - name: tag
          in: query
          description: Only pets carrying every one of these tags.
          schema:
            type: array
            items:
              type: string
        - name: cursor
          in: query
          description: The `next_cursor` of the previous page.
          schema:
            type: string
        - name: sort
          in: query
          deprecated: true
          description: Sort order (use `order` instead).
          schema:
            type: string
            deprecated: true
      responses:
        '200':
          description: A page of pets.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PetList'
        '400':
          description: The filters are invalid.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
    post:
      operationId: createPet
      summary: Create pet
      description: Creates a pet. Names need not be unique | pipes are kept.
      tags: [pets]
      x-docs:
        path: pets/create
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/NewPet'
      responses:
        '201':
          description: The pet that was created.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Pet'
        '422':
          description: The pet is invalid.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /pets/search:
    post:
      operationId: searchPets
      summary: Search pets
      description: Searches pets by name. A read-only POST — the query is too rich for a URL.
      tags: [pets]
      x-docs:
        path: pets/search
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [query]
              properties:
                query:
                  type: string
                  description: Text to match against pet names.
                  example: rex
                filters:
                  type: object
                  description: |-
                    Narrow the matches; every
                    filter must hold:
                    - status
                    - tags
                  properties:
                    status:
                      type: string
                      enum: [available, pending, sold]
                    tags:
                      type: array
                      items:
                        type: string
                limit:
                  type: integer
                  description: |-
                    Maximum number of matches, 100 by default and at most
                    5000. Larger values are rejected.
                  default: 100
                  maximum: 5000
      responses:
        '200':
          description: The matching pets.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PetList'
  /pets/{petId}:
    get:
      operationId: getPet
      summary: Retrieve pet
      description: Returns one pet.
      tags: [pets]
      x-docs:
        path: pets/retrieve
      x-codeSamples:
        - lang: javascript
          label: SDK
          source: |-
            const pet = await client.pets.retrieve("pet_123");
      parameters:
        - name: petId
          in: path
          required: true
          description: The pet's ID.
          schema:
            type: string
            example: pet_123
      responses:
        '200':
          description: The pet.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Pet'
        '404':
          description: No pet has this ID.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
    patch:
      operationId: updatePet
      summary: Update pet
      description: Updates the fields given; the others keep their values.
      tags: [pets]
      parameters:
        - name: petId
          in: path
          required: true
          description: The pet's ID.
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  description: The new name.
                status:
                  type: string
                  enum: [available, pending, sold]
                weight:
                  type: number
                  nullable: true
                  description: Weight in kilograms; null clears it.
      responses:
        '200':
          description: The updated pet.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Pet'
    delete:
      operationId: deletePet
      summary: Delete pet
      description: Deletes a pet for good.
      tags: [pets]
      x-docs:
        path: pets/delete
      parameters:
        - name: petId
          in: path
          required: true
          description: The pet's ID.
          schema:
            type: string
      responses:
        '204':
          description: The pet was deleted.
        '404':
          description: No pet has this ID.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /pets/{petId}/tags:
    put:
      operationId: replacePetTags
      summary: Replace pet tags
      description: Replaces every tag of a pet with the list given.
      tags: [pets]
      parameters:
        - name: petId
          in: path
          required: true
          description: The pet's ID.
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: array
              items:
                type: string
      responses:
        '200':
          description: The pet with its new tags.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Pet'
  /owners/{name}/pets:
    get:
      operationId: listOwnerPets
      summary: List owner pets
      description: |-
        Returns the pets of one owner, e.g. the ones a shop assistant looks
        after. Pets come sorted by name.
      tags: [pets]
      parameters:
        - name: name
          in: path
          required: true
          description: The owner's full name.
          schema:
            type: string
        - name: name
          in: query
          description: Only pets with this name.
          schema:
            type: string
  /pets/{petId}/photo:
    post:
      operationId: uploadPetPhoto
      summary: Upload pet photo
      description: Uploads a photo of the pet.
      tags: [pets]
      parameters:
        - name: petId
          in: path
          required: true
          description: The pet's ID.
          schema:
            type: string
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              required: [file]
              properties:
                file:
                  type: string
                  format: binary
                  description: The image.
                caption:
                  type: string
      responses:
        '204':
          description: The photo was stored.
  /store/inventory:
    get:
      summary: Store inventory
      description: Returns pet counts by status.
      tags: [store]
      responses:
        '200':
          description: Counts by status.
          content:
            application/json:
              schema:
                type: object
                additionalProperties:
                  type: integer
  /store/orders:
    post:
      operationId: placeOrder
      summary: Place order
      description: Places an order for a pet.
      tags: [store]
      x-docs:
        path: store/orders/create
      parameters:
        - name: Idempotency-Key
          in: header
          description: Retries with the same key place one order.
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/NewOrder'
      responses:
        '201':
          description: The order that was placed.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Order'
        '409':
          description: The pet is not available.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /store/orders/{id}/ship:
    post:
      operationId: shipOrder
      summary: Ship order
      description: |-
        Ships an order with carrier No. 1 unless told otherwise. A tracking
        code follows by email.
      tags: [store]
      parameters:
        - name: id
          in: path
          required: true
          description: The order's ID.
          schema:
            type: integer
      requestBody:
        content:
          application/json:
            schema:
              type: object
              required: [carrier]
              properties:
                carrier:
                  type: string
                  description: The carrier to use.
                tracking:
                  type: boolean
                  description: Whether to send a tracking code.
      responses:
        '202':
          description: The order is on its way.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Order'
  /store/orders/{id}:
    get:
      operationId: getOrder
      summary: Retrieve order
      description: Returns one order.
      tags: [store]
      parameters:
        - name: id
          in: path
          required: true
          description: The order's ID.
          schema:
            type: integer
        - name: expand
          in: query
          description: Related objects to inline.
          schema:
            type: array
            items:
              type: string
              enum: [pet, owner]
      responses:
        '200':
          description: The order.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Order'
        '404':
          description: No order has this ID.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
    put:
      operationId: replaceOrder
      summary: Replace order
      description: Replaces an order; the body's `id` must match the path.
      tags: [store]
      parameters:
        - name: id
          in: path
          required: true
          description: The order's ID.
          schema:
            type: integer
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Order'
      responses:
        '200':
          description: The replaced order.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Order'
    delete:
      operationId: cancelOrder
      summary: Cancel order
      description: Cancels an order that has not shipped.
      tags: [store]
      parameters:
        - name: id
          in: path
          required: true
          description: The order's ID.
          schema:
            type: integer
      responses:
        '204':
          description: The order was cancelled.
  /health:
    get:
      responses:
        '200':
          description: The service is up.
components:
  schemas:
    Pet:
      type: object
      description: A pet.
      required: [id, name, status]
      properties:
        id:
          type: string
          description: Unique identifier for the pet.
        name:
          type: string
          description: The pet's name.
        status:
          type: string
          enum: [available, pending, sold]
          description: Where the pet is in the sale.
        tags:
          type: array
          items:
            type: string
        owner:
          $ref: '#/components/schemas/Owner'
    NewPet:
      type: object
      required: [name]
      properties:
        name:
          type: string
          description: The pet's name.
          example: Rex
        status:
          type: string
          enum: [available, pending, sold]
          default: available
        tags:
          type: array
          description: Free-form labels.
          items:
            type: string
        owner:
          $ref: '#/components/schemas/Owner'
        vaccinated:
          type: boolean
          default: false
        priority:
          type: integer
          enum: [1, 2, 3]
          description: Listing priority, 1 the highest.
        size:
          type: string
          nullable: true
          enum: [small, medium, large, null]
          description: The pet's size; null when unknown.
        attributes:
          type: object
          additionalProperties: true
          description: |-
            Free-form attributes
            ====================
            Stored as given, for example:
            ```json
            {
              "color": "brown",
              "legs": 4
            }
            ```
            Keys are
            case-sensitive.
    Owner:
      type: object
      description: Who looks after the pet.
      required: [name]
      properties:
        name:
          type: string
          description: The owner's full name.
        contact:
          type: object
          description: How to reach the owner.
          properties:
            email:
              type: string
              description: An email address.
            phone:
              type: string
              nullable: true
    PetList:
      type: object
      required: [data, has_more]
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/Pet'
        has_more:
          type: boolean
          description: Whether another page follows.
        next_cursor:
          type: string
          nullable: true
          description: Pass as `cursor` to fetch the next page.
    NewOrder:
      type: object
      required: [pet_id, payment]
      properties:
        pet_id:
          type: string
          description: The pet to order.
        quantity:
          type: integer
          minimum: 1
          default: 1
        payment:
          description: How the order is paid.
          oneOf:
            - $ref: '#/components/schemas/CardPayment'
            - $ref: '#/components/schemas/TransferPayment'
        note:
          description: A note for the shop.
          anyOf:
            - type: string
            - type: integer
    Order:
      type: object
      required: [id, pet_id, status]
      properties:
        id:
          type: integer
          description: The order's ID.
        pet_id:
          type: string
        status:
          type: string
          enum: [placed, approved, delivered]
        ship_date:
          type: string
          format: date-time
          nullable: true
    CardPayment:
      type: object
      title: Card
      required: [type, token]
      properties:
        type:
          type: string
          enum: [card]
        token:
          type: string
          description: A card token from the payment form.
    TransferPayment:
      type: object
      title: Transfer
      required: [type, iban]
      properties:
        type:
          type: string
          enum: [transfer]
        iban:
          type: string
    Error:
      type: object
      required: [code, message]
      properties:
        code:
          type: string
          description: A machine-readable error code.
        message:
          type: string
          description: A human-readable message.
