Skip to content

Instantly share code, notes, and snippets.

@jrep
Created January 10, 2015 02:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jrep/b3a20f7750922f3db491 to your computer and use it in GitHub Desktop.
Save jrep/b3a20f7750922f3db491 to your computer and use it in GitHub Desktop.
Multiple problems in examples/10. Data Structures.md
-*- mode: compilation; default-directory: "/Users/Shared/github/api-blueprint/examples/" -*-
Compilation started at Fri Jan 9 17:53:51
snowcrash -u 10.\ Data\ Structures.md
_version: 2.1
metadata:
- name: "FORMAT"
value: "1A"
name: "Data Structures API"
description: "Following [Advanced Attributes](09.%20Advanced%20Attributes.md), this example demonstrates defining arbitrary data structure to be reused by various attribute descriptions. \n\nSince a portion of the `Coupon` data structure is shared between the `Coupon` definition itself and the `Create a Coupon` action, it was separated into a `Coupon Base` data structure in the `Data Strucutes` API Blueprint Section. Doing so enables us to reuse it as a base-type of other attribute definitions.\n\n## API Blueprint\n\n+ [Previous: Advanced Attributes](09.%20Advanced%20Attributes.md)\n\n+ [This: Raw API Blueprint](https://raw.github.com/apiaryio/api-blueprint/master/examples/10.%20Data%20Structures.md)\n\n+ [Next: Resource Model](11.%20Resource%20Model.md)\n\n"
resourceGroups:
- name: "Coupons"
description:
resources:
- name: "Coupon"
description: "A coupon contains information about a percent-off or amount-off discount you might want to apply to a customer.\n\n"
uriTemplate: "/coupons/{id}"
model:
parameters:
- name: "id"
description: "The ID of the desired coupon.\n"
type: "string"
required: true
default:
example:
values:
actions:
- name: "Retrieve a Coupon"
description: "Retrieves the coupon with the given ID.\n\n"
method: "GET"
parameters:
examples:
- name:
description:
requests:
responses:
- name: "200"
description:
headers:
- name: "Content-Type"
value: "application/json"
body:
schema:
- name: "Coupons"
description:
uriTemplate: "/coupons{?limit}"
model:
parameters:
actions:
- name: "List all Coupons"
description: "Returns a list of your coupons.\n\n"
method: "GET"
parameters:
examples:
- name:
description:
requests:
responses:
- name: "200"
description:
headers:
- name: "Content-Type"
value: "application/json"
body:
schema:
- name: "Create a Coupon"
description: "Creates a new Coupon.\n\n"
method: "POST"
parameters:
examples:
- name:
description:
requests:
- name:
description:
headers:
- name: "Content-Type"
value: "application/json"
body:
schema:
responses:
- name: "200"
description:
headers:
- name: "Content-Type"
value: "application/json"
body:
schema:
OK.
warning: (5) ignoring unrecognized block; line 42, column 5 - line 43, column 1; line 44, column 5 - line 44, column 98
warning: (3) no parameters specified, expected a nested list of parameters, one parameter per list item; line 40, column 1 - line 45, column 1
Compilation finished at Fri Jan 9 17:53:51

FORMAT: 1A

Data Structures API

Following Advanced Attributes, this example demonstrates defining arbitrary data structure to be reused by various attribute descriptions.

Since a portion of the Coupon data structure is shared between the Coupon definition itself and the Create a Coupon action, it was separated into a Coupon Base data structure in the Data Strucutes API Blueprint Section. Doing so enables us to reuse it as a base-type of other attribute definitions.

API Blueprint

Group Coupons

Coupon [/coupons/{id}]

A coupon contains information about a percent-off or amount-off discount you might want to apply to a customer.

  • Parameters

    • id (string)

      The ID of the desired coupon.

  • Attributes (Coupon Base)

    • id: 250FF (string)
    • created: 1415203908 (number) - Time stamp

Retrieve a Coupon [GET]

Retrieves the coupon with the given ID.

  • Response 200 (application/json)
    • Attributes (Coupon)

Coupons [/coupons{?limit}]

  • Attributes (array[Coupon])

List all Coupons [GET]

Returns a list of your coupons.

  • Parameters

    • limit: 10 (optional)

      A limit on the number of objects to be returned. Limit can range between 1 and 100 items.

  • Response 200 (application/json)

    • Attributes (Coupons)

Create a Coupon [POST]

Creates a new Coupon.

  • Attributes (Coupon Base)

  • Request (application/json)

  • Response 200 (application/json)

    • Attributes (Coupon)

Data Structures

Coupon Base (object)

  • percent_off: 25 (number)

    A positive integer between 1 and 100 that represents the discount the coupon will apply.

  • redeem_by (number) - Date after which the coupon can no longer be redeemed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment