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
Attributes description #135
Merged
Merged
Changes from all commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
327edbe
Attributes section origin
791a112
Bump version to 1A8
ba1e24c
Update payload section
3ef901f
Add Attribute to keywords
2abe466
Relation of body, schema and attributes sections
67f57e0
Prepare tutorial examples for Attributes
f81ecf8
Attributes & data structures origin
b5b7b78
Fix link
9e89c09
Complete Attribute section, Data Structures origin
415e623
Attribute & Data Structure origin
1dfe8f9
Use "created" instead of "object"
fb235b4
Address review comments
6c8b59e
Use capitalized keywords
f71a920
Add Attributes to Resource & Action sections
71bc7b7
Address additional comments
44c5e91
Fix parameters in examples
pksunkara b67c0f6
Add missing comma
9046040
Add inline action syntax
pksunkara a7dfa1c
Propose resource relation syntax
pksunkara fe5ee04
Added an example for inline action
pksunkara 3d216cf
Mention uniqueness of relation
pksunkara ce77b0c
Merge pull request #161 from apiaryio/pksunkara/resource-relations
zdne f8d3106
Address review comments
pksunkara af06e89
Merge pull request #165 from apiaryio/pksunkara/relation
kylef 96cd421
Merge pull request #146 from apiaryio/pksunkara/fix-examples
kylef 5eff7a2
Merge pull request #159 from apiaryio/pksunkara/inline-action
zdne 4867528
Aligned parameters syntax with MSON
pksunkara 1ef4430
Move parameters in examples to new syntax
pksunkara 9cda6cc
Added relation to reserver list keywords
pksunkara 381dae9
Address review comments
pksunkara 75bcf6d
Added relation to polls hypermedia api
pksunkara 66d6828
Merge pull request #158 from apiaryio/pksunkara/parameters
zdne ff83fef
Update snowcrash references to drafter
pksunkara d80d1e1
Merge pull request #171 from apiaryio/pksunkara/relation
kylef 0151a55
Merge pull request #172 from apiaryio/pksunkara/docs
zdne e6dc7a2
Added format support information
pksunkara 2f115dc
Merge pull request #175 from apiaryio/pksunkara/prepare
zdne File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a follow-up to this, we should probably show an example where an attribute is optional.