openapi: 3.0.1
info:
  title: BookInfo API
  description: This is the API of the Istio BookInfo sample application.
  termsOfService: https://istio.io/
  license:
    name: Apache 2.0
    url: http://www.apache.org/licenses/LICENSE-2.0.html
  version: 1.0.0
externalDocs:
  description: Learn more about the Istio BookInfo application
  url: https://istio.io/docs/samples/bookinfo.html
servers:
  - url: http://www.bookinfo.com/api/v1
tags:
  - name: product
    description: Information about a product (in this case a book)
  - name: review
    description: Review information for a product
  - name: rating
    description: Rating information for a product
paths:
  /products:
    get:
      tags:
        - product
      summary: List all products
      description: List all products available in the application with a minimum amount of information.
      operationId: getProducts
      responses:
        200:
          description: successful operation
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Product'
  /products/{id}:
    get:
      tags:
        - product
      summary: Get individual product
      description: Get detailed information about an individual product with the given id.
      operationId: getProduct
      parameters:
        - name: id
          in: path
          description: Product id
          required: true
          schema:
            type: integer
            format: int32
      responses:
        200:
          description: successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProductDetails'
        400:
          description: Invalid product id
          content: {}
  /products/{id}/reviews:
    get:
      tags:
        - review
      summary: Get reviews for a product
      description: Get reviews for a product, including review text and possibly ratings information.
      operationId: getProductReviews
      parameters:
        - name: id
          in: path
          description: Product id
          required: true
          schema:
            type: integer
            format: int32
      responses:
        200:
          description: successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProductReviews'
        400:
          description: Invalid product id
          content: {}
  /products/{id}/ratings:
    get:
      tags:
        - rating
      summary: Get ratings for a product
      description: Get ratings for a product, including stars and their color.
      operationId: getProductRatings
      parameters:
        - name: id
          in: path
          description: Product id
          required: true
          schema:
            type: integer
            format: int32
      responses:
        200:
          description: successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProductRatings'
        400:
          description: Invalid product id
          content: {}
components:
  schemas:
    Product:
      required:
        - descriptionHtml
        - id
        - title
      type: object
      properties:
        id:
          type: integer
          description: Product id
          format: int32
        title:
          type: string
          description: Title of the book
        descriptionHtml:
          type: string
          description: Description of the book - may contain HTML tags
      description: Basic information about a product
    ProductDetails:
      required:
        - ISBN-10
        - ISBN-13
        - author
        - id
        - language
        - pages
        - publisher
        - type
        - year
      type: object
      properties:
        id:
          type: integer
          description: Product id
          format: int32
        publisher:
          type: string
          description: Publisher of the book
        language:
          type: string
          description: Language of the book
        author:
          type: string
          description: Author of the book
        ISBN-10:
          type: string
          description: ISBN-10 of the book
        ISBN-13:
          type: string
          description: ISBN-13 of the book
        year:
          type: integer
          description: Year the book was first published in
          format: int32
        type:
          type: string
          description: Type of the book
          enum:
            - paperback
            - hardcover
        pages:
          type: integer
          description: Number of pages of the book
          format: int32
      description: Detailed information about a product
    ProductReviews:
      required:
        - id
        - reviews
      type: object
      properties:
        id:
          type: integer
          description: Product id
          format: int32
        reviews:
          type: array
          description: List of reviews
          items:
            $ref: '#/components/schemas/Review'
      description: Object containing reviews for a product
    Review:
      required:
        - reviewer
        - text
      type: object
      properties:
        reviewer:
          type: string
          description: Name of the reviewer
        text:
          type: string
          description: Review text
        rating:
          $ref: '#/components/schemas/Rating'
      description: Review of a product
    Rating:
      required:
        - color
        - stars
      type: object
      properties:
        stars:
          maximum: 5
          minimum: 1
          type: integer
          description: Number of stars
          format: int32
        color:
          type: string
          description: Color in which stars should be displayed
          enum:
            - red
            - black
      description: Rating of a product
    ProductRatings:
      required:
        - id
        - ratings
      type: object
      properties:
        id:
          type: integer
          description: Product id
          format: int32
        ratings:
          type: object
          additionalProperties:
            type: string
          description: A hashmap where keys are reviewer names, values are number of stars
      description: Object containing ratings of a product
