This repository has been archived by the owner on Nov 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #135 from apiaryio/zdne/attributes-description
Attributes description
- Loading branch information
Showing
20 changed files
with
659 additions
and
139 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
FORMAT: 1A | ||
|
||
# Attributes API | ||
This API example demonstrates how to describe body attributes of a request or response message. | ||
|
||
In this case, the description is complementary (and duplicate!) to the provided JSON example in the body section. The [Advanced Attributes](09.%20Advanced%20Attributes.md) API example will demonstrate how to avoid duplicates and how to reuse attributes descriptions. | ||
|
||
## API Blueprint | ||
+ [Previous: Parameters](07.%20Parameters.md) | ||
+ [This: Raw API Blueprint](https://raw.github.com/apiaryio/api-blueprint/master/examples/08.%20Attributes.md) | ||
+ [Next: Advanced Attributes](09.%20Advanced%20Attributes.md) | ||
|
||
# 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. | ||
|
||
### Retrieve a Coupon [GET] | ||
Retrieves the coupon with the given ID. | ||
|
||
+ Response 200 (application/json) | ||
|
||
+ Attributes (object) | ||
+ id: 250FF (string) | ||
+ created: 1415203908 (number) - Time stamp | ||
+ 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 | ||
|
||
+ Body | ||
|
||
{ | ||
"id": "250FF", | ||
"created": 1415203908, | ||
"percent_off": 25, | ||
"redeem_by:" null | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
FORMAT: 1A | ||
|
||
# Advanced Attributes API | ||
Improving the previous [Attributes](08.%20Attributes.md) description example, this API example describes the `Coupon` resource attributes (data structure) regardless of the serialization format. These attributes can be later referenced using the resource name | ||
|
||
These attributes are then reused in the `Retrieve a Coupon` action. Since they describe the complete message, no explicit JSON body example is needed. | ||
|
||
Moving forward, the `Coupon` resource data structure is then reused when defining the attributes of the coupons collection resource – `Coupons`. | ||
|
||
The `Create a Coupon` action also demonstrate the description of request attributes – once defined, these attributes are implied on every `Create a Coupon` request unless the request specifies otherwise. Apparently, the description of action attributes is somewhat duplicate to the definition of `Coupon` resource attributes. We will address this in the next [Data Structures](10.%20Data%20Structures.md) example. | ||
|
||
## API Blueprint | ||
+ [Previous: Attributes](08.%20Attributes.md) | ||
+ [This: Raw API Blueprint](https://raw.github.com/apiaryio/api-blueprint/master/examples/09.%20Advanced%20Attributes.md) | ||
+ [Next: Data Structures](10.%20Data%20Structures.md) | ||
|
||
# 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 (object) | ||
+ id: 250FF (string) | ||
+ created: 1415203908 (number) - Time stamp | ||
+ 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 | ||
|
||
### 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 (number, optional) | ||
|
||
A limit on the number of objects to be returned. Limit can range between 1 and 100 items. | ||
|
||
+ Default: `10` | ||
|
||
+ Response 200 (application/json) | ||
+ Attributes (Coupons) | ||
|
||
### Create a Coupon [POST] | ||
Creates a new Coupon. | ||
|
||
+ Attributes (object) | ||
+ percent_off: 25 (number) | ||
+ redeem_by (number) | ||
|
||
+ Request (application/json) | ||
|
||
+ Response 200 (application/json) | ||
+ Attributes (Coupon) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
FORMAT: 1A | ||
|
||
# Data Structures API | ||
Following [Advanced Attributes](09.%20Advanced%20Attributes.md), 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 | ||
+ [Previous: Advanced Attributes](09.%20Advanced%20Attributes.md) | ||
+ [This: Raw API Blueprint](https://raw.github.com/apiaryio/api-blueprint/master/examples/10.%20Data%20Structures.md) | ||
+ [Next: Resource Model](11.%20Resource%20Model.md) | ||
|
||
# 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 (number, optional) | ||
|
||
A limit on the number of objects to be returned. Limit can range between 1 and 100 items. | ||
|
||
+ Default: `10` | ||
|
||
+ 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.