Skip to content

Commit

Permalink
test for a swagger file to markdown with no x-api-blueprint
Browse files Browse the repository at this point in the history
shows that the markdown is output nicely with no line breaks to make
the codified sections break
  • Loading branch information
leejo committed Sep 25, 2015
1 parent c919824 commit e2538b9
Show file tree
Hide file tree
Showing 2 changed files with 242 additions and 0 deletions.
139 changes: 139 additions & 0 deletions t/markdown/advanced_attributes_no_extra_newlines.md
@@ -0,0 +1,139 @@
# NAME

Advanced Attributes API

# VERSION

1.0

# DESCRIPTION

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)

# BASEURL

No default URL is defined to this application.

# RESOURCES

## GET /coupons

List all Coupons

Returns a list of your coupons.

### Resource URL

GET http://example.com/coupons

### Parameters

.-------------------------------------------------------------------------------------------------------------------------------.
| Name | In | Type | Required | Description |
|-------------------------------------------------------------------------------------------------------------------------------|
| limit | query | number | No | A limit on the number of objects to be returned. Limit can range between 1 and 100 items. |
'-------------------------------------------------------------------------------------------------------------------------------'

### Responses

#### 200 - OK

The response message

[
{
"created": number, // Time stamp
"id": string, // No description.
"percent_off": 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
},
...
]

## GET /coupons/{id}

Retrieve a Coupon

Retrieves the coupon with the given ID.

### Resource URL

GET http://example.com/coupons/{id}

### Parameters

.-----------------------------------------------------------------.
| Name | In | Type | Required | Description |
|-----------------------------------------------------------------|
| id | path | string | Yes | The ID of the desired coupon. |
'-----------------------------------------------------------------'

### Responses

#### 200 - OK

The response message

{
"created": number, // Time stamp
"id": string, // No description.
"percent_off": 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
},

## POST /coupons

Create a Coupon

Creates a new Coupon.

### Resource URL

POST http://example.com/coupons

### Parameters

.-----------------------------------------------------.
| Name | In | Type | Required | Description |
|-----------------------------------------------------|
| coupon | body | schema | Yes | No description. |
'-----------------------------------------------------'

coupon:

{
"created": number, // Time stamp
"id": string, // No description.
"percent_off": 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
},

### Responses

#### 200 - OK

The response message

{
"created": number, // Time stamp
"id": string, // No description.
"percent_off": 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
},

# COPYRIGHT AND LICENSE

Unknown author

BSD - http://www.linfo.org/bsdlicense.html
103 changes: 103 additions & 0 deletions t/swagger/advanced_attributes_no_extra_newlines.yaml
@@ -0,0 +1,103 @@
---
x-api-blueprint:
resource_section: name_uri
action_section: name_method
attributes: true
swagger: "2.0"
info:
version: "1.0"
title: Advanced Attributes API
description: |
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)
paths:
/coupons/{id}:
get:
summary: Retrieve a Coupon
description: |
Retrieves the coupon with the given ID.
consumes:
- application/json
produces:
- application/json
parameters:
- in: path
name: id
description: The ID of the desired coupon.
type: string
required: true
responses:
200:
description: The response message
schema:
$ref: "#/definitions/Coupon"
/coupons:
get:
summary: List all Coupons
description: Returns a list of your coupons.
consumes:
- application/json
produces:
- application/json
parameters:
- in: query
name: limit
description: A limit on the number of objects to be returned. Limit can range between 1 and 100 items.
type: number
default: 10
required: false
responses:
200:
description: The response message
schema:
type: array
items:
$ref: "#/definitions/Coupon"
post:
summary: Create a Coupon
description: Creates a new Coupon.
consumes:
- application/json
produces:
- application/json
parameters:
- in: body
name: coupon
required: true
schema:
$ref: "#/definitions/Coupon"
responses:
200:
description: The response message
schema:
$ref: "#/definitions/Coupon"
definitions:
Coupon:
type: object
properties:
id:
type: string
x-example: 250FF
created:
type: number
description: Time stamp
x-example: 1415203908
percent_off:
type: number
x-example: 25
description: A positive integer between 1 and 100 that represents the discount the coupon will apply.
redeem_by:
type: number
description: Date after which the coupon can no longer be redeemed

# vim: ts=2:sw=2:et

0 comments on commit e2538b9

Please sign in to comment.