{
  "swagger": "2.0",
  "info": { "title": "Pet Store 2.0", "version": "1.0.0" },
  "host": "api.pets.example.com",
  "basePath": "/v2",
  "schemes": ["http", "https"],
  "consumes": ["application/json"],
  "produces": ["application/json"],
  "securityDefinitions": {
    "petstore_auth": {
      "type": "oauth2",
      "flow": "application",
      "tokenUrl": "https://auth.pets.example.com/oauth/token",
      "scopes": {
        "read:pets": "Read pets",
        "write:pets": "Modify pets"
      }
    },
    "api_key": {
      "type": "apiKey",
      "name": "X-Api-Key",
      "in": "header"
    }
  },
  "security": [{ "api_key": [] }],
  "parameters": {
    "PetId": {
      "name": "petId",
      "in": "path",
      "required": true,
      "type": "integer",
      "format": "int64",
      "x-example": 123
    }
  },
  "definitions": {
    "Pet": {
      "type": "object",
      "required": ["name"],
      "properties": {
        "id": { "type": "integer", "format": "int64" },
        "name": { "type": "string" },
        "tag": { "type": "string", "default": "friendly" },
        "status": { "type": "string", "enum": ["available", "pending", "sold"] }
      }
    },
    "Error": {
      "type": "object",
      "properties": { "message": { "type": "string" } }
    }
  },
  "paths": {
    "/pets": {
      "get": {
        "operationId": "listPets",
        "tags": ["pets"],
        "description": "Lists pets, newest first.",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "type": "integer",
            "default": 20,
            "description": "How many pets to return."
          },
          {
            "name": "tags",
            "in": "query",
            "required": false,
            "type": "array",
            "collectionFormat": "csv",
            "items": { "type": "string", "enum": ["cat", "dog"] }
          },
          {
            "name": "X-Tenant-Id",
            "in": "header",
            "required": true,
            "type": "string",
            "x-example": "acme"
          }
        ],
        "responses": {
          "200": {
            "description": "a list of pets",
            "schema": { "type": "array", "items": { "$ref": "#/definitions/Pet" } }
          },
          "default": {
            "description": "error",
            "schema": { "$ref": "#/definitions/Error" }
          }
        }
      },
      "post": {
        "operationId": "createPet",
        "tags": ["pets"],
        "parameters": [
          {
            "name": "body",
            "in": "body",
            "required": true,
            "schema": { "$ref": "#/definitions/Pet" }
          }
        ],
        "responses": {
          "201": { "description": "created", "schema": { "$ref": "#/definitions/Pet" } }
        }
      }
    },
    "/pets/{petId}": {
      "parameters": [{ "$ref": "#/parameters/PetId" }],
      "get": {
        "operationId": "getPet",
        "tags": ["pets"],
        "responses": {
          "200": { "description": "a pet", "schema": { "$ref": "#/definitions/Pet" } }
        }
      },
      "post": {
        "operationId": "uploadPetPhoto",
        "tags": ["pets"],
        "consumes": ["multipart/form-data"],
        "parameters": [
          { "name": "caption", "in": "formData", "required": true, "type": "string" },
          { "name": "photo", "in": "formData", "required": false, "type": "file" }
        ],
        "responses": { "200": { "description": "uploaded" } }
      }
    }
  }
}
