Skip to content

Commit a3b0797

Browse files
committed
added schema for all parameters
1 parent 86b99d3 commit a3b0797

File tree

1 file changed

+35
-49
lines changed

1 file changed

+35
-49
lines changed

versions/3.0.md

+35-49
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,8 @@ There are five possible parameter types.
591591
* `application/x-www-form-urlencoded` - Similar to the format of Query parameters but as a payload. For example, `foo=1&bar=swagger` - both `foo` and `bar` are form parameters. This is normally used for simple parameters that are being transferred.
592592
* `multipart/form-data` - each parameter takes a section in the payload with an internal header. For example, for the header `Content-Disposition: form-data; name="submit-name"` the name of the parameter is `submit-name`. This type of form parameters is more commonly used for file transfers.
593593

594+
For complex parameter schemas, a serialization strategy is required. For parameter of type `in: body`, the serialization will be handled by the `consumes` attribute. For all other types, a serialization strategy must be declared.
595+
594596
##### Fixed Fields
595597
Field Name | Type | Description
596598
---|:---:|---
@@ -599,35 +601,7 @@ Field Name | Type | Description
599601
<a name="parameterDescription"></a>description | `string` | A brief description of the parameter. This could contain examples of use. [GFM syntax](https://help.github.com/articles/github-flavored-markdown) can be used for rich text representation.
600602
<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`.
601603
<a name="parameterDeprecated"></a> deprecated | `boolean` | Specifies that a parameter is deprecated and should be transitioned out of usage.
602-
603-
If [`in`](#parameterIn) is `"body"`:
604-
605-
Field Name | Type | Description
606-
---|:---:|---
607-
<a name="parameterSchema"></a>schema | [Schema Object](#schemaObject) | **Required.** The schema defining the type used for the body parameter.
608-
609-
If [`in`](#parameterIn) is any value other than `"body"`:
610-
611-
Field Name | Type | Description
612-
---|:---:|---
613-
<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"`. If `type` is `"file"`, the [`consumes`](#operationConsumes) MUST be either `"multipart/form-data"`, `" application/x-www-form-urlencoded"` or both and the parameter MUST be [`in`](#parameterIn) `"formData"`.
614-
<a name="parameterFormat"></a>format | `string` | The extending format for the previously mentioned [`type`](#parameterType). See [Data Type Formats](#dataTypeFormat) for further details.
615-
<a name="parameterAllowEmptyValue"/>allowEmptyValue | `boolean` | Sets the ability to pass empty-valued parameters. This is valid only for either `query` or `formData` parameters and allows you to send a parameter with a name only or an empty value. Default value is `false`.
616-
<a name="parameterItems"></a>items | [Items Object](#itemsObject) | **Required if [`type`](#parameterType) is "array".** Describes the type of items in the array.
617-
<a name="parameterCollectionFormat"></a>collectionFormat | `string` | Determines the format of the array if type array is used. Possible values are: <ul><li>`csv` - comma separated values `foo,bar`. <li>`ssv` - space separated values `foo bar`. <li>`tsv` - tab separated values `foo\tbar`. <li>`pipes` - pipe separated values <code>foo&#124;bar</code>. <li>`multi` - corresponds to multiple parameter instances instead of multiple values for a single instance `foo=bar&foo=baz`. This is valid only for parameters [`in`](#parameterIn) "query" or "formData". </ul> Default value is `csv`.
618-
<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.
619-
<a name="parameterMaximum"></a>maximum | `number` | See http://json-schema.org/latest/json-schema-validation.html#anchor17.
620-
<a name="parameterExclusiveMaximum"></a>exclusiveMaximum | `boolean` | See http://json-schema.org/latest/json-schema-validation.html#anchor17.
621-
<a name="parameterMinimum"></a>minimum | `number` | See http://json-schema.org/latest/json-schema-validation.html#anchor21.
622-
<a name="parameterExclusiveMinimum"></a>exclusiveMinimum | `boolean` | See http://json-schema.org/latest/json-schema-validation.html#anchor21.
623-
<a name="parameterMaxLength"></a>maxLength | `integer` | See http://json-schema.org/latest/json-schema-validation.html#anchor26.
624-
<a name="parameterMinLength"></a>minLength | `integer` | See http://json-schema.org/latest/json-schema-validation.html#anchor29.
625-
<a name="parameterPattern"></a>pattern | `string` | See http://json-schema.org/latest/json-schema-validation.html#anchor33.
626-
<a name="parameterMaxItems"></a>maxItems | `integer` | See http://json-schema.org/latest/json-schema-validation.html#anchor42.
627-
<a name="parameterMinItems"></a>minItems | `integer` | See http://json-schema.org/latest/json-schema-validation.html#anchor45.
628-
<a name="parameterUniqueItems"></a>uniqueItems | `boolean` | See http://json-schema.org/latest/json-schema-validation.html#anchor49.
629-
<a name="parameterEnum"></a>enum | [*] | See http://json-schema.org/latest/json-schema-validation.html#anchor76.
630-
<a name="parameterMultipleOf"></a>multipleOf | `number` | See http://json-schema.org/latest/json-schema-validation.html#anchor14.
604+
<a name="parameterSchema"></a>schema | [Schema Object](#schemaObject) | The schema defining the type used for the parameter.
631605

632606

633607
##### Patterned Fields
@@ -699,10 +673,12 @@ A header parameter with an array of 64 bit integer numbers:
699673
"in": "header",
700674
"description": "token to be passed as a header",
701675
"required": true,
702-
"type": "array",
703-
"items": {
704-
"type": "integer",
705-
"format": "int64"
676+
"schema": {
677+
"type": "array",
678+
"items": {
679+
"type": "integer",
680+
"format": "int64"
681+
}
706682
},
707683
"collectionFormat": "csv"
708684
}
@@ -713,11 +689,12 @@ name: token
713689
in: header
714690
description: token to be passed as a header
715691
required: true
716-
type: array
717-
items:
718-
type: integer
719-
format: int64
720-
collectionFormat: csv
692+
schema:
693+
type: array
694+
items:
695+
type: integer
696+
format: int64
697+
collectionFormat: csv
721698
```
722699

723700
A path parameter of a string value:
@@ -727,7 +704,9 @@ A path parameter of a string value:
727704
"in": "path",
728705
"description": "username to fetch",
729706
"required": true,
730-
"type": "string"
707+
"schema": {
708+
"type": "string"
709+
}
731710
}
732711
```
733712

@@ -736,7 +715,8 @@ name: username
736715
in: path
737716
description: username to fetch
738717
required: true
739-
type: string
718+
schema:
719+
type: string
740720
```
741721

742722
An optional query parameter of a string value, allowing multiple values by repeating the query parameter:
@@ -746,9 +726,11 @@ An optional query parameter of a string value, allowing multiple values by repea
746726
"in": "query",
747727
"description": "ID of the object to fetch",
748728
"required": false,
749-
"type": "array",
750-
"items": {
751-
"type": "string"
729+
"schema": {
730+
"type": "array",
731+
"items": {
732+
"type": "string"
733+
}
752734
},
753735
"collectionFormat": "multi"
754736
}
@@ -759,10 +741,11 @@ name: id
759741
in: query
760742
description: ID of the object to fetch
761743
required: false
762-
type: array
763-
items:
764-
type: string
765-
collectionFormat: multi
744+
schema:
745+
type: array
746+
items:
747+
type: string
748+
collectionFormat: multi
766749
```
767750

768751
A form data with file type for a file upload:
@@ -772,7 +755,9 @@ A form data with file type for a file upload:
772755
"in": "formData",
773756
"description": "The avatar of the user",
774757
"required": true,
775-
"type": "file"
758+
"schema": {
759+
"type": "file"
760+
}
776761
}
777762
```
778763

@@ -781,7 +766,8 @@ name: avatar
781766
in: formData
782767
description: The avatar of the user
783768
required: true
784-
type: file
769+
schema:
770+
type: file
785771
```
786772

787773
#### <a name="itemsObject"></a>Items Object

0 commit comments

Comments
 (0)