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
Copy file name to clipboardExpand all lines: README.md
+33Lines changed: 33 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -222,6 +222,39 @@ custom:
222
222
type: "string"
223
223
```
224
224
225
+
##### Model re-use
226
+
227
+
Through the magic of YAML, you can re-use models:
228
+
229
+
```yml
230
+
custom:
231
+
documentation:
232
+
...
233
+
models:
234
+
- name: "ErrorResponse"
235
+
description: "This is an error"
236
+
content:
237
+
application/json:
238
+
schema: &ErrorItem
239
+
type: object
240
+
properties:
241
+
message:
242
+
type: string
243
+
code:
244
+
type: integer
245
+
246
+
- name: "PutDocumentResponse"
247
+
description: "PUT Document response model (external reference example)"
248
+
content:
249
+
application/json:
250
+
schema:
251
+
type: array
252
+
items: *ErrorItem
253
+
```
254
+
255
+
`&ErrorItem`in the above example creates a node anchor (&ErrorItem) to the `ErrorResponse` schema which then can be used in the `PutDocumentResponse` schema via the reference (*ErrorItem). The node anchor needs to be declared first before it can be used elsewhere via the reference, swapping the above example around would result in an error.
256
+
257
+
225
258
#### Functions
226
259
227
260
To define the documentation for a given function event, you need to create a `documentation` attribute for your http event in your `serverless.yml` file.
0 commit comments