# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
swagger: "2.0"
info:
  version: 1.0.0
  title: Swagger Petstore Regex Protection (x-a127-services array)
  license:
    name: MIT
host: petstore.swagger.io
basePath: /v1
schemes:
  - http
consumes:
  - application/json
produces:
  - application/json
x-a127-services:
  - name: input-validation
    provider: x-input-validation
    apply:
      pipe: request
      endPoint: proxy
    options:
      displayName: Add Input Validation
      continueOnError: 'true'
  - name: raiseInputValidationFault
    provider: x-raiseInputValidationFault
    apply:
      pipe: request
      endPoint: proxy
    options:
      displayName: Raise Input Validation Error
      statusCode: 400
      reasonPhrase: Bad Request
      continueOnError: 'false'
  - name: output-validation
    provider: x-output-validation
    apply:
      pipe: response
      endPoint: proxy
    options:
      displayName: Add Output Validation
      continueOnError: 'true'
  - name: raiseOutputValidationFault
    provider: x-raiseOutputValidationFault
    apply:
      pipe: response
      endPoint: proxy
    options:
      displayName: Raise Output Validation Error
      statusCode: 500
      reasonPhrase: Server Error
      continueOnError: 'false'
  - name: add-headers-x-api-key
    provider: x-headers
    apply:
      pipe: request
      endPoint: target
    options:
      displayName: Add AWS api key header
      headers:
        x-api-key:
          type: string
          default: "random_api_key"
          description: >
            x-api-key header
  - name: add-headers-token
    provider: x-headers
    apply:
      pipe: request
      endPoint: target
    options:
      displayName: Add token header
      headers:
        x-token:
          type: string
          default: "random_token"
          description: >
            token header
  - name: quotaAnil
    provider: volos-quota-memory
    options:
      timeUnit: day
      interval: 2
      allow: 2500
  - name: oauth2
    provider: volos-oauth-apigee
    options:
      tokenLifetime: 300000
      key: apigeeProxyKey
      uri: apigeeProxyUri
      validGrantTypes:
        - client_credentials
        - authorization_code
        - implicit_grant
        - password
      tokenPaths:  # These will be added to your paths section for you
        authorize: /authorize
        token: /accesstoken
        invalidate: /invalidate
        refresh: /refresh
paths:
  /pets:
    get:
      x-a127-apply:
        quotaAnil:
          pipe: request
          endPoint: proxy
      summary: List all pets
      operationId: listPets
      tags:
        - pets
      parameters:
        - name: limit
          in: query
          description: How many items to return at one time (max 100)
          required: false
          type: integer
          format: int32
        - name: param1
          in: query
          required: true
          type: string
        - name: param2
          in: query
          required: true
          type: string
      responses:
        200:
          description: An paged array of pets
          headers:
            x-next:
              type: string
              description: A link to the next page of responses
          schema:
            $ref: Pets
        default:
          description: unexpected error
          schema:
            $ref: Error
    post:
      summary: Create a pet
      operationId: createPets
      tags:
        - pets
      responses:
        201:
          description: Null response
        default:
          description: unexpected error
          schema:
            $ref: Error
  /pets/{petId}:
    get:
      summary: Info for a specific pet
      operationId: showPetById
      security:
        - apiKeyHeader: []
        - oauth2: []
      tags:
        - pets
      parameters:
        - name: petId
          in: path
          required: true
          description: The id of the pet to retrieve
          type: string
        - name: param1
          in: query
          required: true
          type: string
      responses:
        200:
          description: Expected response to a valid request
          schema:
            $ref: Pets
        default:
          description: unexpected error
          schema:
            $ref: Error
definitions:
  Pet:
    required:
      - id
      - name
    properties:
      id:
        type: integer
        format: int64
      name:
        type: string
      tag:
        type: string
  Pets:
    type: array
    items:
      $ref: Pet
  Error:
    required:
      - code
      - message
    properties:
      code:
        type: integer
        format: int32
      message:
        type: string
