{
  "components": {
    "schemas": {
      "Context": {
        "items": {
          "type": "string"
        },
        "type": "array"
      },
      "Error": {
        "properties": {
          "message": {
            "example": "An error message",
            "type": "string"
          }
        },
        "type": "object"
      },
      "ResultList": {
        "properties": {
          "context": {
            "$ref": "#/components/schemas/Context"
          },
          "data": {
            "items": {
              "type": "object"
            },
            "type": "array"
          }
        },
        "type": "object"
      },
      "ResultSingleton": {
        "properties": {
          "context": {
            "$ref": "#/components/schemas/Context"
          },
          "data": {
            "type": "object"
          }
        },
        "type": "object"
      }
    },
    "securitySchemes": {
      "bearer": {
        "bearerFormat": "JWT",
        "description": "JWT Authorization header using the Bearer scheme.",
        "scheme": "bearer",
        "type": "http"
      }
    }
  },
  "definitions": {},
  "info": {
    "description": "A sample API for getting started with Couchbase Server and the SDK.",
    "termsOfService": "",
    "title": "Travel Sample API",
    "version": "1.0"
  },
  "openapi": "3.0.3",
  "paths": {
    "/": {
      "get": {
        "responses": {
          "200": {
            "content": {
              "text/html": {
                "example": "<h1> Travel Sample API </h1>"
              }
            },
            "description": "Returns the API index page"
          }
        },
        "summary": "Returns the index page"
      }
    },
    "/api/airports": {
      "get": {
        "parameters": [
          {
            "description": "The airport name/code to search for",
            "example": "SFO",
            "in": "query",
            "name": "search",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "context": [
                    "A description of a N1QL operation"
                  ],
                  "data": [
                    {
                      "airportname": "San Francisco Intl"
                    }
                  ]
                },
                "schema": {
                  "$ref": "#/components/schemas/ResultList"
                }
              }
            },
            "description": "Returns airport data and query context information"
          }
        },
        "summary": "Returns list of matching airports and the source query",
        "tags": [
          "airports"
        ]
      }
    },
    "/api/flightPaths/{fromloc}/{toloc}": {
      "get": {
        "parameters": [
          {
            "description": "Airport name for beginning route",
            "example": "San Francisco Intl",
            "in": "path",
            "name": "fromloc",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Airport name for end route",
            "example": "Los Angeles Intl",
            "in": "path",
            "name": "toloc",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Date of flight departure in `mm/dd/yyyy` format",
            "example": "05/24/2021",
            "in": "query",
            "name": "leave",
            "required": true,
            "schema": {
              "format": "date",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "context": [
                    "N1QL query - scoped to inventory: SELECT faa as fromAirport FROM `travel-sample`.inventory.airport WHERE airportname = $1 UNION SELECT faa as toAirport FROM `travel-sample`.inventory.airport WHERE airportname = $2"
                  ],
                  "data": [
                    {
                      "destinationairport": "LAX",
                      "equipment": "738",
                      "flight": "AA331",
                      "flighttime": 1220,
                      "name": "American Airlines",
                      "price": 152.5,
                      "sourceairport": "SFO",
                      "utc": "16:37:00"
                    }
                  ]
                },
                "schema": {
                  "$ref": "#/components/schemas/ResultList"
                }
              }
            },
            "description": "Returns flight data and query context information"
          }
        },
        "summary": "Return flights information, cost and more for a given flight time and date",
        "tags": [
          "flightPaths"
        ]
      }
    },
    "/api/hotels/{description}/{location}/": {
      "get": {
        "parameters": [
          {
            "description": "Hotel description keywords",
            "example": "pool",
            "in": "path",
            "name": "description",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Hotel location",
            "example": "San Francisco",
            "in": "path",
            "name": "location",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "context": [
                    "FTS search - scoped to: inventory.hotel within fields address,city,state,country,name,description"
                  ],
                  "data": [
                    {
                      "address": "250 Beach St, San Francisco, California, United States",
                      "description": "Nice hotel, centrally located (only two blocks from Pier 39). Heated outdoor swimming pool.",
                      "name": "Radisson Hotel Fisherman's Wharf"
                    },
                    {
                      "address": "121 7th St, San Francisco, California, United States",
                      "description": "Chain motel with a few more amenities than the typical Best Western; outdoor swimming pool, internet access, cafe on-site, pet friendly.",
                      "name": "Best Western Americania"
                    }
                  ]
                },
                "schema": {
                  "$ref": "#/components/schemas/ResultList"
                }
              }
            },
            "description": "Returns hotel data and query context information"
          }
        },
        "summary": "Find hotels using full text search",
        "tags": [
          "hotels"
        ]
      }
    },
    "/api/tenants/{tenant}/user/login": {
      "post": {
        "parameters": [
          {
            "description": "Tenant agent name",
            "example": "tenant_agent_00",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "password": {
                    "example": "password1",
                    "type": "string"
                  },
                  "user": {
                    "example": "user1",
                    "type": "string"
                  }
                },
                "required": [
                  "user",
                  "password"
                ],
                "type": "object"
              }
            }
          }
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "context": [
                    "KV get - scoped to tenant_agent_00.users: for password field in document user1"
                  ],
                  "data": {
                    "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyIjoibXNfdXNlciJ9.GPs8two_vPVBpdqD7cz_yJ4X6J9yDTi6g7r9eWyAwEM"
                  }
                },
                "schema": {
                  "$ref": "#/components/schemas/ResultSingleton"
                }
              }
            },
            "description": "Returns login data and query context information"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Returns an authentication error"
          }
        },
        "summary": "Login an existing user for a given tenant agent",
        "tags": [
          "tenants"
        ]
      }
    },
    "/api/tenants/{tenant}/user/signup": {
      "post": {
        "parameters": [
          {
            "description": "Tenant agent name",
            "example": "tenant_agent_00",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "password": {
                    "example": "password1",
                    "type": "string"
                  },
                  "user": {
                    "example": "user1",
                    "type": "string"
                  }
                },
                "required": [
                  "user",
                  "password"
                ],
                "type": "object"
              }
            }
          }
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "example": {
                  "context": [
                    "KV insert - scoped to tenant_agent_00.users: document user1"
                  ],
                  "data": {
                    "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyIjoibXNfdXNlciJ9.GPs8two_vPVBpdqD7cz_yJ4X6J9yDTi6g7r9eWyAwEM"
                  }
                },
                "schema": {
                  "$ref": "#/components/schemas/ResultSingleton"
                }
              }
            },
            "description": "Returns login data and query context information"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Returns a conflict error"
          }
        },
        "summary": "Signup a new user",
        "tags": [
          "tenants"
        ]
      }
    },
    "/api/tenants/{tenant}/user/{username}/flights": {
      "get": {
        "parameters": [
          {
            "description": "Tenant agent name",
            "example": "tenant_agent_00",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Username",
            "example": "user1",
            "in": "path",
            "name": "username",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "context": [
                    "KV get - scoped to tenant_agent_00.user: for 2 bookings in document user1"
                  ],
                  "data": [
                    {
                      "date": "05/24/2021",
                      "destinationairport": "LAX",
                      "equipment": "738",
                      "flight": "AA655",
                      "flighttime": 5383,
                      "name": "American Airlines",
                      "price": 672.88,
                      "sourceairport": "SFO",
                      "utc": "11:42:00"
                    },
                    {
                      "date": "05/28/2021",
                      "destinationairport": "SFO",
                      "equipment": "738",
                      "flight": "AA344",
                      "flighttime": 6081,
                      "name": "American Airlines",
                      "price": 760.13,
                      "sourceairport": "LAX",
                      "utc": "20:47:00"
                    }
                  ]
                },
                "schema": {
                  "$ref": "#/components/schemas/ResultList"
                }
              }
            },
            "description": "Returns flight data and query context information"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Returns an authentication error"
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "summary": "List the flights that have been reserved by a user",
        "tags": [
          "tenants"
        ]
      },
      "put": {
        "parameters": [
          {
            "description": "Tenant agent name",
            "example": "tenant_agent_00",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Username",
            "example": "user1",
            "in": "path",
            "name": "username",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "flights": {
                    "example": [
                      {
                        "date": "12/12/2020",
                        "destinationairport": "Leonardo Da Vinci International Airport",
                        "flight": "12RF",
                        "name": "boeing",
                        "price": 50.0,
                        "sourceairport": "London (Gatwick)"
                      }
                    ],
                    "format": "string",
                    "type": "array"
                  }
                },
                "type": "object"
              }
            }
          }
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "context": [
                    "KV update - scoped to tenant_agent_00.user: for bookings field in document user1"
                  ],
                  "data": {
                    "added": [
                      {
                        "date": "12/12/2020",
                        "destinationairport": "Leonardo Da Vinci International Airport",
                        "flight": "12RF",
                        "name": "boeing",
                        "price": 50.0,
                        "sourceairport": "London (Gatwick)"
                      }
                    ]
                  }
                },
                "schema": {
                  "$ref": "#/components/schemas/ResultSingleton"
                }
              }
            },
            "description": "Returns flight data and query context information"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Returns an authentication error"
          }
        },
        "security": [
          {
            "bearer": []
          }
        ],
        "summary": "Book a new flight for a user",
        "tags": [
          "tenants"
        ]
      }
    }
  }
}