---
swagger: "2.0"
info:
  description: "Backend for URL shortener service."
  version: "1.0.0"
  title: "Zoom"
  contact:
    email: "marc.zych@zoox.com"
host: "zoom.zooxlabs.com"
schemes:
- "http"
paths:
  /links:
    get:
      summary: "Returns all links sorted by name"
      operationId: "zoom.get_all_links"
      produces:
      - "application/json"
      responses:
        200:
          description: "Success"
          schema:
            type: array
            items:
              $ref: "#/definitions/Link"
        404:
          description: "Link not found"
  /links/{name}:
    get:
      summary: "Returns link information by name."
      operationId: "zoom.get_link"
      produces:
      - "application/json"
      parameters:
      - name: "name"
        in: "path"
        description: "Name of Link to retrieve"
        required: true
        type: "string"
      responses:
        200:
          description: "Success"
          schema:
            $ref: "#/definitions/Link"
          examples:
            application/json: { "name": "foo", "link": "http://google.com" }
        404:
          description: "Link not found"
    put:
      summary: "Create a new link or update an existing one."
      operationId: "zoom.create_or_update_link"
      consumes:
      - "application/json"
      produces:
      - "application/json"
      parameters:
      - name: "name"
        in: "path"
        description: "Name of Link to create"
        required: true
        type: "string"
      - in: "body"
        name: "link"
        description: "LinkEdit information to create"
        required: true
        schema:
          $ref: "#/definitions/LinkEdit"
      responses:
        200:
          description: "Success"
          schema:
            $ref: "#/definitions/Link"
        422:
          description: "Validation exception"
          schema:
            $ref: "#/definitions/ValidationErrorResponse"
definitions:
  Link:
    type: "object"
    properties:
      name:
        type: "string"
      url:
        type: "string"
    required:
      - name
      - url
  LinkEdit:
    type: "object"
    properties:
      url:
        type: "string"
        pattern: "^https?://.+"
        enum: ["http://google.com", "http://yahoo.com"]
    required:
      - url
  ValidationErrorResponse:
    type: "object"
    properties:
      message:
        type: "string"
