# 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.

openapi: 3.0.2
info:
  description: API for managing Currency resources.
  version: 1.0.0
  title: Curerency API
servers:
- url: "https://{APIGEE_HOST}/v1/currencyservices"
security:
  - ApiKeyAuth: [] 
paths:
  /currencies:
    get:
      summary: List 'Currency' objects.
      description: Retrieve a list of 'Currency' objects from the server.
      responses:
        "200":
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Currencies'    
  /convert:
    post:
      summary: Currency conversion
      description: converts a currency
      requestBody:
        description: converts a currency
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ConvertRequest'
      responses:
        "200":
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ConvertResponse'    
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      name: apikey
      in: query
  schemas:
    Currencies:
      type: object
      properties:
        currencycodes:
          type: array
          items:
            type: string
    ConvertRequest:
      type: object
      properties:
        to_code:
          type: string
          example: "GBP"
        from:
          type: object
          properties:
            currency_code: 
              type: string
              example: "USD"
            units: 
              type: string 
              example: "100"
    ConvertResponse:
      type: object
      properties:
        currencyCode:
          type: string
        units:
          type: string
        nanos:
          type: string
