You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When writing in YAML, JSON syntax can be used for `dataValue` (as shown in the `noRating` example) but is not required.
2134
+
While this example shows the behavior of both `dataValue` and `serializedValue` for JSON (in the 'withRating` example), in most cases only the data form is needed.
2161
2135
2162
2136
```yaml
2163
-
parameters:
2164
-
- name: zipCode
2165
-
in: query
2137
+
content:
2138
+
application/json:
2166
2139
schema:
2167
-
type: string
2168
-
format: zip-code
2140
+
type: object
2141
+
required:
2142
+
- author
2143
+
- title
2144
+
properties:
2145
+
author:
2146
+
type: string
2147
+
title:
2148
+
type: string
2149
+
rating:
2150
+
type: number
2151
+
minimum: 1
2152
+
maximum: 5
2153
+
multipleOf: 0.5
2169
2154
examples:
2170
-
zip-example:
2171
-
$ref: '#/components/examples/zip-example'
2172
-
```
2173
-
2174
-
In a response:
2155
+
noRating:
2156
+
summary: A not-yet-rated work
2157
+
dataValue: {
2158
+
"author": "A. Writer",
2159
+
"title": "The Newest Book"
2160
+
}
2161
+
withRating:
2162
+
summary: A work with an average rating of 4.5 stars
2163
+
dataValue:
2164
+
author: A. Writer
2165
+
title: An Older Book
2166
+
rating: 4.5
2167
+
serializedValue: |
2168
+
{
2169
+
"author": "A. Writer",
2170
+
"title": "An Older Book",
2171
+
"rating": 4.5
2172
+
}
2173
+
```
2174
+
2175
+
###### Binary Examples
2176
+
2177
+
This example shows both `externalDataValue` and `externalSerializedValue` to emphasize that no encoding is taking place, but it is also valid to show only one or the other.
In the above example, we can just show the JSON string (or any JSON value) as-is, rather than stuffing a serialized JSON value into a JSON string, which would have looked like `"\"json\""`.
2189
+
###### Boolean Query Parameter Examples
2204
2190
2205
-
In contrast, a JSON string encoded inside of a URL-style form body:
2191
+
Since there is no standard for serializing boolean values (as discussed in [Appendix B](#appendix-b-data-type-conversion)), this example uses `dataValue` and `serializedValue` to show how booleans are serialized for this particular parameter:
2206
2192
2207
2193
```yaml
2208
-
application/x-www-form-urlencoded:
2209
-
schema:
2210
-
type: object
2211
-
properties:
2212
-
jsonValue:
2213
-
type: string
2214
-
encoding:
2215
-
jsonValue:
2216
-
contentType: application/json
2217
-
examples:
2218
-
jsonFormValue:
2219
-
description: 'The JSON string "json" as a form value'
2220
-
value: jsonValue=%22json%22
2194
+
name: flag
2195
+
in: query
2196
+
required: true
2197
+
schema:
2198
+
type: boolean
2199
+
examples:
2200
+
"true":
2201
+
dataValue: true
2202
+
serializedValue: flag=true
2203
+
"false":
2204
+
dataValue: false
2205
+
serializedValue: flag=false
2221
2206
```
2222
2207
2223
-
In this example, the JSON string had to be serialized before encoding it into the URL form value, so the example includes the quotation marks that are part of the JSON serialization, which are then URL percent-encoded.
2224
-
2225
2208
#### Link Object
2226
2209
2227
2210
The Link Object represents a possible design-time link for a response.
0 commit comments