Skip to content

URI Template support in parameters #804

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Jan 27, 2017
Merged
58 changes: 49 additions & 9 deletions versions/3.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ This object can be extended with [Specification Extensions](#specificationExtens
"items": {
"type": "string"
},
"collectionFormat": "csv"
"style": "comma-delimited"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change to camelCase

}
]
}
Expand Down Expand Up @@ -561,9 +561,9 @@ parameters:
description: ID of pet to use
required: true
type: array
format: form
items:
type: string
collectionFormat: csv
type: string
```

#### <a name="operationObject"></a>Operation Object
Expand Down Expand Up @@ -749,7 +749,6 @@ Field Name | Type | Description
<a name="parameterRequired"></a>required | `boolean` | Determines whether this parameter is mandatory. If the parameter is [`in`](#parameterIn) "path", this property is **required** and its value MUST be `true`. Otherwise, the property MAY be included and its default value is `false`.
<a name="parameterDeprecated"></a> deprecated | `boolean` | Specifies that a parameter is deprecated and should be transitioned out of usage.


The content of the parameter is specified in one of two ways. By passing a schema and content-type, complex parameters may be serialized and passed:

Field Name | Type | Description
Expand All @@ -760,8 +759,11 @@ By defining a subset of JSON-schema properties:

Field Name | Type | Description
---|:---:|---
<a name="parameterType"></a>type | `string` | **Required.** The type of the parameter. Since the parameter is not located at the request body, it is limited to simple types (that is, not an object). The value MUST be one of `"string"`, `"number"`, `"integer"`, `"boolean"`, `"array"` or `"file"`.
<a name="parameterType"></a>type | `string` | **Required.** The type of the parameter. Since the parameter is not located at the request body, it is limited to simple types (that is, not an object). The value MUST be one of `"string"`, `"number"`, `"integer"`, `"boolean"`, `"array"` or `"object"`.
<a name="parameterFormat"></a>format | `string` | The extending format for the previously mentioned [`type`](#parameterType). See [Data Type Formats](#dataTypeFormat) for further details.
<a name="parameterStyle"></a>style | `string` | Describes how the parameter value will be serialized depending on the specified [`type`](#parameterType).
<a name="parameterAllowReserved"></a>allowReserved | `boolean` | Determines whether the parameter value should allow reserved characters, as defined by [RFC3986](https://tools.ietf.org/html/rfc3986#section-2.2) `:/?#[]@!$&'()*+,;=` to be included without percent-encoding. This property only applies to parameters with an `in` value of `query`. The default value is `false`.
<a name="parameterExplode"></a>explode | `boolean` | When this is true, parameter values of type `array` or `object` generate seperate parameters for each value of the array, or key-value-pair of the map. For other types of parameters this property has no effect.
<a name="parameterAllowEmptyValue"/>allowEmptyValue | `boolean` | Sets the ability to pass empty-valued parameters. This is valid only for `query` parameters and allows you to send a parameter with a name only or an empty value. Default value is `false`.
<a name="parameterItems"></a>items | [Items Object](#itemsObject) | **Required if [`type`](#parameterType) is "array".** Describes the type of items in the array.
<a name="parameterDefault"></a>default | * | Declares the value of the parameter that the server will use if none is provided, for example a "count" to control the number of results per page might default to 100 if not supplied by the client in the request. (Note: "default" has no meaning for required parameters.) See http://json-schema.org/latest/json-schema-validation.html#anchor101. Unlike JSON Schema this value MUST conform to the defined [`type`](#parameterType) for this parameter.
Expand All @@ -778,6 +780,42 @@ Field Name | Type | Description
<a name="parameterEnum"></a>enum | [*] | See http://json-schema.org/latest/json-schema-validation.html#anchor76.
<a name="parameterMultipleOf"></a>multipleOf | `number` | See http://json-schema.org/latest/json-schema-validation.html#anchor14.

In order to support alternate ways of serializing parameters, a set of `style` values are defined.

`style` | [`type`](#dataTypeType) | `in` | Comments
----------- | ------ | -------- | --------
matrix | `string`, `array`, `object` | `path` | Path-style parameters defined by [RFC6570](https://tools.ietf.org/html/rfc6570#section-3.2.7)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everywhere it says string as the type, it should be primitive (it can be any primitive)

label | `string`, `array`, `object` | `path` | Label style parameters defined by [RFC6570](https://tools.ietf.org/html/rfc6570#section-3.2.5)
form | `string`, `array`, `object` | `query`| Form style parameters defined by [RFC6570](https://tools.ietf.org/html/rfc6570#section-3.2.8)
commaDelimited | `array` | `query`, `path` | Comma separated array values. This option replaces `collectionFormat` equal to `csv`.
spaceDelimited | `array` | `query`, `path` | Space separated array values. This option replaces `collectionFormat` equal to `ssv`.
pipeDelimited | `array` | `query`, `path` | Pipe separated array values. This option replaces `collectionFormat` equal to `pipes`.
deepObject | `object` | `query` | Provides a simple way of rendering nested objects using form parameters.


##### Style Examples

Assuming a parameter named `color` with one of the following values:

```
string -> "blue"
array -> ["blue","black","brown"]
object -> { "R" : 100, "G" :200, "B" : 150 }
```
The following table shows examples of how those values would be rendered.

[`style`](#dataTypeFormat) | `explode` | `empty` | `string` | `array` | `object`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Header should be primitive instead of string

----------- | ------ | -------- | -------- | --------|-------
matrix | false | ;color | ;color=blue | ;color=blue,black,brown | ;color=R,100,G,200,B,150
matrix | true | ;color | ;color=blue | ;color=blue;color=black;color=brown | ;R=100;G=200;B=150
label | false | . | .blue | .blue.black.brown | .R.100.G.200.B.150
label | true | . | .blue | .blue.black.brown | .R=100.G=200.B=150
form | false | color= | color=blue | color=blue,black,brown | color=x,100,y,200
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

object example not updated

form | true | color= | color=blue | color=blue&color=black&color=brown | x=100&y=200
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

object example not updated

spaceDelimited | false | n/a | n/a | blue%20black%20brown | R%20100%20G%20200%20B%20150
pipeDelimited | false | n/a | n/a | blue\|black\|brown | R\|100\|G\|200|G\|150
deepObject | true | n/a | n/a | n/a | person[name]=Bob&person[lastname]=Brown
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wat


This object can be extended with [Specification Extensions](#specificationExtensions).

##### Parameter Object Examples
Expand All @@ -797,7 +835,7 @@ A header parameter with an array of 64 bit integer numbers:
"format": "int64"
}
},
"collectionFormat": "csv"
"style": "comma-delimited"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change to camelCase

}
```

Expand All @@ -811,7 +849,7 @@ schema:
items:
type: integer
format: int64
collectionFormat: csv
style: comma-delimited
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change to camelCase

```

A path parameter of a string value:
Expand Down Expand Up @@ -849,7 +887,8 @@ An optional query parameter of a string value, allowing multiple values by repea
"type": "string"
}
},
"collectionFormat": "multi"
"style": "form",
"explode": true
}
```

Expand All @@ -862,7 +901,8 @@ schema:
type: array
items:
type: string
collectionFormat: multi
style: form
explode: true
```

A form data with file type for a file upload:
Expand Down