Skip to content
This repository has been archived by the owner on Nov 8, 2024. It is now read-only.

Commit

Permalink
Initially expand data structures under resources too
Browse files Browse the repository at this point in the history
  • Loading branch information
pksunkara committed Feb 10, 2015
1 parent 3a393db commit 7ff1395
Show file tree
Hide file tree
Showing 4 changed files with 937 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"dependencies": {
"coffee-script": "~1.7.1",
"yargs": "~1.3.3",
"protagonist-experimental": "0.18.5",
"protagonist-experimental": "0.18.6",
"boutique": "git+ssh://[email protected]:apiaryio/boutique.git"
},
"devDependencies": {
Expand Down
9 changes: 8 additions & 1 deletion src/drafter.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,14 @@ class Drafter

if element.element is 'category'
for subElement in element.content
@dataStructures[subElement.name.literal] = subElement if subElement.element is 'dataStructure'

switch subElement.element
when 'dataStructure'
@dataStructures[subElement.name.literal] = subElement
when 'resource'

for resourceElement in subElement.content
@dataStructures[resourceElement.name.literal] = resourceElement if resourceElement.element is 'dataStructure'

# Expand the gathered data structures
for rule in rules
Expand Down
49 changes: 48 additions & 1 deletion test/fixtures/dataStructures.apib
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,50 @@ FORMAT: 1A
# Stripe
Inspired by stripe API

# 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)

### 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, number)

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

## Timestamp (number)
Expand Down Expand Up @@ -38,9 +82,12 @@ A clone of Coupon Base to be used for testing
## Timestamp Clone (Timestamp)
A clone of timestamp to be used for testing

## Coupon Clone (Coupon)
A clone of Coupon to be used for testing

## Subscription
+ id: 1000 (number)
+ plan: 'Startup' (string) - Subscription plan name
+ plan: `Startup` (string) - Subscription plan name
+ coupon (Coupon Base) - Coupon represting any existing discounts used by the customer during the subscription
+ One Of
+ Include Timestamps
Expand Down
Loading

0 comments on commit 7ff1395

Please sign in to comment.