title: Swagger Nested Array of Objects
body: <p>i was asked to use swagger to describe the API and I struggle to get the more complex situations to work. Imagine you are posting Order with multiple order items</p>
  
  <pre><code>&lt;upload_order&gt;
  &lt;token&gt;d6a91238b0f17b49d49fbdcbba773d71&lt;/token&gt;
  &lt;order&gt;
      &lt;order_id&gt;10006&lt;/order_id&gt;
      &lt;item_value&gt;48.50&lt;/item_value&gt;
      &lt;postage_value&gt;5.00&lt;/postage_value&gt;
      &lt;gross_value&gt;A43.50&lt;/gross_value&gt;
      &lt;discount_value&gt;10.00&lt;/discount_value&gt;
      &lt;delivery_date&gt;2016-10-32&lt;/delivery_date&gt;
      &lt;customer_name&gt;Tom H&lt;/customer_name&gt;
      &lt;business_name&gt;Toysorry&lt;/business_name&gt;
      &lt;address_line_1&gt;Adderss Line 1&lt;/address_line_1&gt;
      &lt;address_line_2&gt;Adderss Line 1&lt;/address_line_2&gt;
      &lt;town&gt;Town&lt;/town&gt;
      &lt;county&gt;County&lt;/county&gt;
      &lt;postcode&gt;PO123ST&lt;/postcode&gt;
      &lt;email&gt;email@email.com&lt;/email&gt;
      &lt;telephone&gt;0787878787878&lt;/telephone&gt;
      &lt;delivery_instructions&gt;Garage&lt;/delivery_instructions&gt;
      &lt;delivery_method&gt;PRE12&lt;/delivery_method&gt;
      &lt;items&gt;
          &lt;item&gt;
              &lt;id&gt;1&lt;/id&gt;
              &lt;sku&gt;BLABLA&lt;/sku&gt;
              &lt;qty&gt;A&lt;/qty&gt;
              &lt;product_name&gt;A Product&lt;/product_name&gt;
              &lt;unit_price&gt;1.50&lt;/unit_price&gt;
          &lt;/item&gt;
          &lt;item&gt;
              &lt;id&gt;2&lt;/id&gt;
              &lt;sku&gt;HAHAHA&lt;/sku&gt;
              &lt;qty&gt;2&lt;/qty&gt;
              &lt;product_name&gt;WINTER BUNDLE&lt;/product_name&gt;
              &lt;unit_price&gt;22.00&lt;/unit_price&gt;
          &lt;/item&gt;
      &lt;/items&gt;
  &lt;/order&gt;
  </code></pre>
  
  <p></p>
  
  <p>how can i describe it in swagger, since usage of array in this way does not seem to play</p>
  
  <pre><code>/upload_order:
  post:
    description: create order
    operationId: upload_order
    produces:
      - application/xml
    parameters:
      - name: upload_order
        in: body
        description: upload order
        required: true
        schema:
          $ref: '#/definitions/newOrder'
    responses:
      '200':
        description: response
        schema:
          $ref: '#/definitions/token_response'
      default:
        description: unexpected error
        schema:
          $ref: '#/definitions/errorModel'
  
  
  
  newOrder:
      type: object
      required:
        - token
        - order_id
        - item_value
        - postage_value
        - gross_value
        - discount_value
        - delivery_date
        - customer_name
        - business_name
        - address_line_1
        - address_line_2
        - town
        - county
        - postcode
        - email
        - telephone
        - delivery_instructions
        - delivery_method
        - items
      properties:
        token:
          type: string
        order_id:
          type: string
        item_value:
          type: number
          format: float
        postage_value:
          type: number
          format: float
        gross_value:
          type: number
          format: float
        discount_value:
          type: number
          format: float
        delivery_date:
          type: string
          format: date
        customer_name:
          type: string
        business_name:
          type: string
        address_line_1:
          type: string
        address_line_2:
          type: string
        town:
          type: string
        county:
          type: string
        postcode:
          type: string
        email:
          type: string
        telephone:
          type: string
        delivery_instructions:
          type: string
        delivery_method:
          type: string
        items:
          $ref: '#/definitions/itemsArray'
    itemsArray:
      type: array
      required: item
      item:
        $ref: '#/definitions/item'
    item:
      required:
        - id
        - sku
        - qty
        - product_name
        - unit_price
      type: object
      properties:
        id:
          type: string
        sku:
          type: string
        qty:
          type: integer
          format: int32
        product_name:
          type: string
        unit_price:
          type: number
          format: float
  </code></pre>
  
  <p>please save me</p>
  
  <p>Thanks</p>
  
  <p>UPDATE - I FIGURED FEW DAYS LATER BASED ON FULL PET SHOP MARKUP, FORGOT TO POST THE ANSWER, EASY POINT FOR SOME</p>
  
  <pre><code>paths:
    /upload_order:
      post:
        description: create order
        operationId: upload_order
        parameters:
          - name: upload_order
            in: body
            description: upload order
            required: true
            schema:
              $ref: '#/definitions/uploadOrder'
        responses:
          '200':
            description: response
            schema:
              $ref: '#/definitions/upload_response'
          default:
            description: unexpected error
            schema:
              $ref: '#/definitions/errorModel'
  definitions:
    uploadOrder:
      type: object
      required:
        - upload_order
      properties:
        upload_order:
          $ref: '#/definitions/uploadOrderData'
    uploadOrderData:
      type: object
      required:
        - login
        - order
      properties:
        login:
          $ref: '#/definitions/login'
        order:
          $ref: '#/definitions/order'
    order:
      type: object
      required:
        - order_id
        - address_line_2
        - items
      properties:
        order_id:
          type: string
        item_value:
          type: string
          pattern: '^(\d{1,100}\.\d{2})$'
          default: '0.00'
        postage_value:
          type: string
          pattern: '^(\d{1,100}\.\d{2})$'
          default: '0.00'
        gross_value:
          type: string
          pattern: '^(\d{1,100}\.\d{2})$'
          default: '0.00'
        discount_value:
          type: string
          pattern: '^(\d{1,100}\.\d{2})$'
          default: '0.00'
        delivery_date:
          type: string
          format: date
        customer_name:
          type: string
        business_name:
          type: string
        address_line_1:
          type: string
        address_line_2:
          type: string
        town:
          type: string
        county:
          type: string
        postcode:
          type: string
        email:
          type: string
        telephone:
          type: string
        delivery_instructions:
          type: string
        delivery_method:
          type: string
        items:
          $ref: '#/definitions/orderItems'
    orderItems:
      type: array
      required:
        - item
      properties:
        item:
          $ref: '#/definitions/orderItem'
      items:
        $ref: '#/definitions/orderItem'
    orderItem:
      required:
        - id
        - sku
        - qty
        - product_name
        - unit_price
      type: object
      properties:
        id:
          type: string
        sku:
          type: string
        qty:
          type: integer
          format: int32
        product_name:
          type: string
        unit_price:
          type: string
          pattern: '^(\d{1,100}\.\d{2})$'
          default: '0.00'
    login:
      type: object
      required:
        - login
      properties:
        login:
          $ref: '#/definitions/login_data'
    login_data:
      type: object
      required:
        - username
        - password
        - channel_code
      properties:
        username:
          type: string
        password:
          type: string
        channel_code:
          type: string
    upload_response:
      type: object
      properties:
        response:
          $ref: '#/definitions/upload_response_data'
    upload_response_data:
      type: object
      required:
        - messages
        - success
      properties:
        messages:
          $ref: '#/definitions/messages'
        success:
          type: string
    errorModel:
      type: object
      required:
        - messages
      properties:
        messages:
          $ref: '#/definitions/messages'
    messages:
      type: array
      required:
        - message
      properties:
        message:
          $ref: '#/definitions/message'
      items:
        $ref: '#/definitions/message'
    message:
      type: string
  </code></pre>