---
swagger: '2.0'
info:
  title: bar CRUD API
  version: 4.2.0
schemes:
  - http
basePath: /api
consumes:
  - application/json
produces:
  - application/json
paths:
  /common:
    get:
      operationId: commonGet
      summary: here to test path collisons
      responses:
        '200':
          description: OK
          schema:
            $ref: "#/definitions/bar"
  /bars:
    post:
      operationId: create
      summary: Create a new bar
      parameters:
        - name: info
          in: body
          schema:
            $ref: "#/definitions/bar"
      responses:
        '201':
          description: created
          schema:
            $ref: "#/definitions/barId"
        default:
          description: error
          schema:
            $ref: "#/definitions/error"
  /bars/{barid}:
    get:
      operationId: get
      summary: Get a bar by id
      parameters:
        - $ref: "#/parameters/barid"
      responses:
        '200':
          description: OK
          schema:
            $ref: "#/definitions/bar"
        '401':
          $ref: "#/responses/401"
        '404':
          $ref: "#/responses/404"
        default:
          description: error
          schema:
            $ref: "#/definitions/error"
    delete:
      operationId: delete
      summary: delete a bar by id
      parameters:
        - name: barid
          in: path
          required: true
          type: string
      responses:
        '200':
          description: OK
        '401':
          description: unauthorized
          schema:
            $ref: "#/definitions/error"
        '404':
          description: resource not found
          schema:
            $ref: "#/definitions/error"
        default:
          description: error
          schema:
            $ref: "#/definitions/error"
    post:
      operationId: update
      summary: update a bar by id
      parameters:
        - name: barid
          in: path
          required: true
          type: string
        - name: info
          in: body
          schema:
            $ref: "#/definitions/bar"
      responses:
        '200':
          description: OK
        '401':
          description: unauthorized
          schema:
            $ref: "#/definitions/error"
        '404':
          description: resource not found
          schema:
            $ref: "#/definitions/error"
        default:
          description: error
          schema:
            $ref: "#/definitions/error"

definitions:
  common:
    type: object
    required:
      - id
    properties:
      id:
        type: string
        format: string
        minLength: 1
  bar:
    type: object
    required:
      - name
      - description
    properties:
      id:
        type: string
        format: string
        readOnly: true
      name:
        type: string
        format: string
        minLength: 1
      description:
        type: string
        format: string
        minLength: 1
  barId:
    type: object
    required:
      - id
    properties:
      id:
        type: string
        format: string
        minLength: 1
  error:
    type: object
    required:
       - message
    properties:
      code:
        type: string
        format: string
      message:
        type: string
      fields:
        type: string

parameters:
  common:
    name: common
    in: query
    type: string
  barid:
    name: barid
    in: path
    required: true
    type: string

responses:
  401:
    description: bar unauthorized
    schema:
      $ref: "#/definitions/error"
  404:
    description: bar resource not found
    schema:
      $ref: "#/definitions/error"
