seomoz/interpol

View on GitHub
example/definitions/add_address.yml

Summary

Maintainability
Test Coverage
---
name: add_contact_address
route: /contacts/:contact_id/address
method: PUT
definitions:
  - message_type: request
    versions: ["1.0"]
    schema:
      description: Adds a new address for a contact.
      type: object
      properties:
        street:
          description: "Street address"
          type: string
        city:
          description: "The City"
          type: string
        state:
          description: "The State"
          type: string
        zip:
          description: "Zip code"
          type: string
    examples:
      - street: 1300 Pine St.
        city: Seattle
        state: WA
        zip: '98111'
  - message_type: request
    versions: ["2.0"]
    schema:
      description: Adds a new address for a contact.
      type: object
      properties:
        street:
          description: "Street address"
          type: string
        apartment:
          description: "Apartment number"
          type: string
          optional: true
        city:
          description: "The City"
          type: string
        state:
          description: "The State"
          type: string
        postal:
          description: "Postal code"
          type: string
    examples:
      - street: 1300 Pine St.
        apartment: 'Suite 400'
        city: Seattle
        state: WA
        postal: '98111'
  - message_type: response
    versions: ["1.0"]
    status_codes: ["2xx"]
    schema:
      description: Successfully added an address for a contact.
      type: object
      properties:
        added_address_id:
          description: "The id of the newly added address"
          type: integer
        contact_address_count:
          description: "The number of addresses for this contact after adding the new one"
          type: integer
    examples:
      - added_address_id: 2185
        contact_address_count: 5
  - message_type: response
    versions: ["1.0"]
    schema:
      description: Error messaging for failure to add the new address for a contact.
      type: object
      properties:
        error_code:
          description: "Error code value for the failure reason"
          type: integer
        error_message:
          description: "Human readable failure message"
          type: string
    examples:
      - error_code: 34
        error_message: Address already exists for this contact