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.
2146
+
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.
2173
2147
2174
2148
```yaml
2175
-
parameters:
2176
-
- name: zipCode
2177
-
in: query
2149
+
content:
2150
+
application/json:
2178
2151
schema:
2179
-
type: string
2180
-
format: zip-code
2152
+
type: object
2153
+
required:
2154
+
- author
2155
+
- title
2156
+
properties:
2157
+
author:
2158
+
type: string
2159
+
title:
2160
+
type: string
2161
+
rating:
2162
+
type: number
2163
+
minimum: 1
2164
+
maximum: 5
2165
+
multipleOf: 0.5
2181
2166
examples:
2182
-
zip-example:
2183
-
$ref: '#/components/examples/zip-example'
2184
-
```
2185
-
2186
-
In a response:
2167
+
noRating:
2168
+
summary: A not-yet-rated work
2169
+
dataValue: {
2170
+
"author": "A. Writer",
2171
+
"title": "The Newest Book"
2172
+
}
2173
+
withRating:
2174
+
summary: A work with an average rating of 4.5 stars
First, a request or response body that is just a JSON string (not an object containing a string):
2204
-
2205
-
```yaml
2206
-
application/json:
2207
-
schema:
2208
-
type: string
2209
-
examples:
2210
-
jsonBody:
2211
-
description: 'A body of just the JSON string "json"'
2212
-
value: json
2192
+
content:
2193
+
image/png:
2194
+
schema: {}
2195
+
examples:
2196
+
Red:
2197
+
externalValue: ./examples/2-by-2-red-pixels.png
2213
2198
```
2214
2199
2215
-
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\""`.
2200
+
###### Boolean Query Parameter Examples
2216
2201
2217
-
In contrast, a JSON string encoded inside of a URL-style form body:
2202
+
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:
2218
2203
2219
2204
```yaml
2220
-
application/x-www-form-urlencoded:
2221
-
schema:
2222
-
type: object
2223
-
properties:
2224
-
jsonValue:
2225
-
type: string
2226
-
encoding:
2227
-
jsonValue:
2228
-
contentType: application/json
2229
-
examples:
2230
-
jsonFormValue:
2231
-
description: 'The JSON string "json" as a form value'
2232
-
value: jsonValue=%22json%22
2205
+
name: flag
2206
+
in: query
2207
+
required: true
2208
+
schema:
2209
+
type: boolean
2210
+
examples:
2211
+
"true":
2212
+
dataValue: true
2213
+
serializedValue: flag=true
2214
+
"false":
2215
+
dataValue: false
2216
+
serializedValue: flag=false
2233
2217
```
2234
2218
2235
-
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.
2236
-
2237
2219
#### Link Object
2238
2220
2239
2221
The Link Object represents a possible design-time link for a response.
0 commit comments