Skip to content

Commit ce3a579

Browse files
authored
Merge pull request OAI#804 from OAI/Issue-778
URI Template support in parameters
2 parents 3356090 + b017b27 commit ce3a579

File tree

1 file changed

+55
-30
lines changed

1 file changed

+55
-30
lines changed

versions/3.0.md

Lines changed: 55 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ This object can be extended with [Specification Extensions](#specificationExtens
529529
"items": {
530530
"type": "string"
531531
},
532-
"collectionFormat": "csv"
532+
"style": "comma-delimited"
533533
}
534534
]
535535
}
@@ -561,9 +561,9 @@ parameters:
561561
description: ID of pet to use
562562
required: true
563563
type: array
564+
format: form
564565
items:
565-
type: string
566-
collectionFormat: csv
566+
type: string
567567
```
568568

569569
#### <a name="operationObject"></a>Operation Object
@@ -737,8 +737,6 @@ There are four possible parameter types.
737737
* Header - Custom headers that are expected as part of the request.
738738
* Cookie - Used to pass a specific cookie value to the API.
739739

740-
For complex parameter schemas, a serialization strategy is required.
741-
For all types, a serialization strategy must be declared.
742740

743741
##### Fixed Fields
744742
Field Name | Type | Description
@@ -748,35 +746,60 @@ Field Name | Type | Description
748746
<a name="parameterDescription"></a>description | `string` | A brief description of the parameter. This could contain examples of use. [CommonMark syntax](http://spec.commonmark.org/) can be used for rich text representation.
749747
<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`.
750748
<a name="parameterDeprecated"></a> deprecated | `boolean` | Specifies that a parameter is deprecated and should be transitioned out of usage.
749+
<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`.
751750

752-
753-
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:
751+
The rules for serialization of the parameter are specified in one of two ways.
752+
For simpler scenarios, a `Style` and `Schema` can be used to describe the structure and syntax of the parameter.
754753

755754
Field Name | Type | Description
756755
---|:---:|---
757-
<a name="parameterContent"></a>content | [Content Object](#contentObject) | The content of the request body.
756+
<a name="parameterStyle"></a>style | `string` | Describes how the parameter value will be serialized depending on type of the parameter value.
757+
<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. The default value is false.
758+
<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`.
759+
<a name="parameterSchema"></a>schema | [Schema Object](#schemaObject) | The schema defining the type used for the parameter.
758760

759-
By defining a subset of JSON-schema properties:
761+
For more complex scenarios a `content` object can be used to define the media-type and schema of the parameter.
760762

761763
Field Name | Type | Description
762764
---|:---:|---
763-
<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"`.
764-
<a name="parameterFormat"></a>format | `string` | The extending format for the previously mentioned [`type`](#parameterType). See [Data Type Formats](#dataTypeFormat) for further details.
765-
<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`.
766-
<a name="parameterItems"></a>items | [Items Object](#itemsObject) | **Required if [`type`](#parameterType) is "array".** Describes the type of items in the array.
767-
<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.
768-
<a name="parameterMaximum"></a>maximum | `number` | See http://json-schema.org/latest/json-schema-validation.html#anchor17.
769-
<a name="parameterExclusiveMaximum"></a>exclusiveMaximum | `boolean` | See http://json-schema.org/latest/json-schema-validation.html#anchor17.
770-
<a name="parameterMinimum"></a>minimum | `number` | See http://json-schema.org/latest/json-schema-validation.html#anchor21.
771-
<a name="parameterExclusiveMinimum"></a>exclusiveMinimum | `boolean` | See http://json-schema.org/latest/json-schema-validation.html#anchor21.
772-
<a name="parameterMaxLength"></a>maxLength | `integer` | See http://json-schema.org/latest/json-schema-validation.html#anchor26.
773-
<a name="parameterMinLength"></a>minLength | `integer` | See http://json-schema.org/latest/json-schema-validation.html#anchor29.
774-
<a name="parameterPattern"></a>pattern | `string` | See http://json-schema.org/latest/json-schema-validation.html#anchor33.
775-
<a name="parameterMaxItems"></a>maxItems | `integer` | See http://json-schema.org/latest/json-schema-validation.html#anchor42.
776-
<a name="parameterMinItems"></a>minItems | `integer` | See http://json-schema.org/latest/json-schema-validation.html#anchor45.
777-
<a name="parameterUniqueItems"></a>uniqueItems | `boolean` | See http://json-schema.org/latest/json-schema-validation.html#anchor49.
778-
<a name="parameterEnum"></a>enum | [*] | See http://json-schema.org/latest/json-schema-validation.html#anchor76.
779-
<a name="parameterMultipleOf"></a>multipleOf | `number` | See http://json-schema.org/latest/json-schema-validation.html#anchor14.
765+
<a name="parameterContent"></a>content | [Content Object](#contentObject) | The content of the request body.
766+
767+
In order to support common ways of serializing simple parameters, a set of `style` values are defined.
768+
769+
`style` | [`type`](#dataTypeType) | `in` | Comments
770+
----------- | ------ | -------- | --------
771+
matrix | `primitive`, `array`, `object` | `path` | Path-style parameters defined by [RFC6570](https://tools.ietf.org/html/rfc6570#section-3.2.7)
772+
label | `primitive`, `array`, `object` | `path` | Label style parameters defined by [RFC6570](https://tools.ietf.org/html/rfc6570#section-3.2.5)
773+
form | `primitive`, `array`, `object` | `query`| Form style parameters defined by [RFC6570](https://tools.ietf.org/html/rfc6570#section-3.2.8)
774+
commaDelimited | `array` | `query`, `path` | Comma seperated array values. This option replaces `collectionFormat` equal to `csv`.
775+
spaceDelimited | `array` | `query` | Space seperated array values. This option replaces `collectionFormat` equal to `ssv`.
776+
pipeDelimited | `array` | `query` | Pipe seperated array values. This option replaces `collectionFormat` equal to `pipes`.
777+
deepObject | `object` | `query` | Provides a simple way of rendering nested objects using form parameters.
778+
779+
780+
##### Style Examples
781+
782+
Assuming a parameter named `color` with one of the following values:
783+
784+
```
785+
string -> "blue"
786+
array -> ["blue","black","brown"]
787+
object -> { "R" : 100, "G" :200, "B" : 150 }
788+
```
789+
The following table shows examples of how those values would be rendered.
790+
791+
[`style`](#dataTypeFormat) | `explode` | `empty` | `string` | `array` | `object`
792+
----------- | ------ | -------- | -------- | --------|-------
793+
matrix | false | ;color | ;color=blue | ;color=blue,black,brown | ;color=R,100,G,200,B,150
794+
matrix | true | ;color | ;color=blue | ;color=blue;color=black;color=brown | ;R=100;G=200;B=150
795+
label | false | . | .blue | .blue.black.brown | .R.100.G.200.B.150
796+
label | true | . | .blue | .blue.black.brown | .R=100.G=200.B=150
797+
form | false | color= | color=blue | color=blue,black,brown | color=R,100,G,200,B,150
798+
form | true | color= | color=blue | color=blue&color=black&color=brown | R=100&G=200&B=150
799+
commaDelimited | false | n/a | n/a | blue,black,brown | R,100,G,200,B,150
800+
spaceDelimited | false | n/a | n/a | blue%20black%20brown | R%20100%20G%20200%20B%20150
801+
pipeDelimited | false | n/a | n/a | blue\|black\|brown | R\|100\|G\|200|G\|150
802+
deepObject | true | n/a | n/a | n/a | color[R]=100&color[G]=200&color[B]=150
780803

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

@@ -797,7 +820,7 @@ A header parameter with an array of 64 bit integer numbers:
797820
"format": "int64"
798821
}
799822
},
800-
"collectionFormat": "csv"
823+
"style": "commaDelimited"
801824
}
802825
```
803826

@@ -811,7 +834,7 @@ schema:
811834
items:
812835
type: integer
813836
format: int64
814-
collectionFormat: csv
837+
style: commaDelimited
815838
```
816839

817840
A path parameter of a string value:
@@ -849,7 +872,8 @@ An optional query parameter of a string value, allowing multiple values by repea
849872
"type": "string"
850873
}
851874
},
852-
"collectionFormat": "multi"
875+
"style": "form",
876+
"explode": true
853877
}
854878
```
855879

@@ -862,7 +886,8 @@ schema:
862886
type: array
863887
items:
864888
type: string
865-
collectionFormat: multi
889+
style: form
890+
explode: true
866891
```
867892

868893
A form data with file type for a file upload:

0 commit comments

Comments
 (0)