# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You 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.0
x-sw-service-name: serviceA-1
x-sw-endpoint-name-match-rule: "<${METHOD}>:${PATH}"
x-sw-endpoint-name-format: "<${METHOD}>:${PATH}"
info:
  description: OpenAPI definition for SkyWalking test.
  version: v1
  title: Customer API

tags:
  - name: customer
    description: customer

paths:
  /customers:
    get:
      tags:
        - customer
      summary: Get all customers list
      description: Get all customers list.
      operationId: getCustomers
      responses:
        "200":
          description: Success
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/Customer"
  /customers/{id}:
    get:
      tags:
        - customer
      summary: Get customer details
      description: Get customer details with the given id.
      operationId: getCustomer
      parameters:
        - name: id
          in: path
          description: Customer id
          required: true
          schema:
            type: integer
            format: int64
      responses:
        "200":
          description: successful operation
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CustomerDetails"
        "400":
          description: Invalid customer id
    post:
      tags:
        - customer
      summary: Update customer details
      description: Update customer details with the given id.
      operationId: updateCustomer
      parameters:
        - name: id
          in: path
          description: Customer id
          required: true
          schema:
            type: integer
            format: int64
        - name: name
          in: query
          description: Customer name
          required: true
          schema:
            type: string
      responses:
        "200":
          description: successful operation
    delete:
      tags:
        - customer
      summary: Delete customer details
      description: Delete customer details with the given id.
      operationId: deleteCustomer
      parameters:
        - name: id
          in: path
          description: Customer id
          required: true
          schema:
            type: integer
            format: int64
      responses:
        "200":
          description: successful operation

  /customer/{region}/{country}:
    get:
      tags:
        - customer
      summary: Get customers regional
      description: Get customers regional with the given id.
      operationId: getCustomersRegional
      parameters:
        - name: region
          in: path
          description: Customers region
          required: true
          schema:
            type: string
        - name: country
          in: path
          description: Customers country
          required: true
          schema:
            type: string
      responses:
        "200":
          description: successful operation
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Customer"
        "400":
          description: Invalid parameters supplied
components:
  schemas:
    Customer:
      type: object
      description: Customer id and name
      properties:
        id:
          type: integer
          format: int64
          description: Customer id
        name:
          type: string
          description: Customer name
      required:
        - id
        - name
    CustomerDetails:
      type: object
      description: Customer details
      properties:
        id:
          type: integer
          format: int64
          description: Customer id
        name:
          type: string
          description: Customer name
        description:
          type: string
          description: Customer description
      required:
        - id
        - name
