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
| path[path].[operation].externalDocs.url | functions.functions.[http OR httpApi].documentation.externalDocumentation.url |
90
91
| path[path].[operation].servers[].description | functions.functions.[http OR httpApi].documentation.servers.description |
91
92
| path[path].[operation].servers[].url | functions.functions.[http OR httpApi].documentation.servers.url |
93
+
| path[path].[operation].security | functions.functions.[http OR httpApi].documentation.security |
92
94
| path[path].[operation].deprecated | functions.functions.[http OR httpApi].documentation.deprecated |
93
95
| path[path].[operation].parameters | functions.functions.[http OR httpApi].documentation.[path/query/cookie/header]Params |
94
96
| path[path].[operation].parameters.name | functions.functions.[http OR httpApi].documentation.[path/query/cookie/header]Params.name |
@@ -219,6 +221,40 @@ functions:
219
221
220
222
For more info on `serverless.yml` syntax, see their docs.
221
223
224
+
#### securitySchemes
225
+
226
+
You can provide optional Security Schemes:
227
+
228
+
```yml
229
+
custom:
230
+
documentation:
231
+
securitySchemes:
232
+
my_api_key:
233
+
type: apiKey
234
+
name: api_key
235
+
in: header
236
+
```
237
+
238
+
It accepts all available Security Schemes and follows the specification: https://spec.openapis.org/oas/v3.0.3#security-scheme-object
239
+
240
+
#### Security on each operation
241
+
242
+
To apply an overall security scheme to all of your operations without having to add the documentation to each one, you can write it like:
243
+
244
+
```yml
245
+
custom:
246
+
documentation:
247
+
securitySchemes:
248
+
my_api_key:
249
+
type: apiKey
250
+
name: api_key
251
+
in: header
252
+
security:
253
+
- my_api_key: []
254
+
```
255
+
256
+
This will apply the requirement of each operation requiring your `my_api_key` security scheme, [you can override this](#security).
257
+
222
258
#### Models
223
259
224
260
There are two ways to write the Models. Models contain additional information that you can use to define schemas for endpoints. You must define the *content type* for each schema that you provide in the models.
@@ -304,20 +340,20 @@ custom:
304
340
content:
305
341
application/json:
306
342
schema: &ErrorItem
307
-
type: object
308
-
properties:
309
-
message:
310
-
type: string
311
-
code:
312
-
type: integer
343
+
type: object
344
+
properties:
345
+
message:
346
+
type: string
347
+
code:
348
+
type: integer
313
349
314
350
- name: "PutDocumentResponse"
315
351
description: "PUT Document response model (external reference example)"
316
352
content:
317
353
application/json:
318
354
schema:
319
-
type: array
320
-
items: *ErrorItem
355
+
type: array
356
+
items: *ErrorItem
321
357
```
322
358
323
359
`&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.
@@ -340,6 +376,7 @@ The `documentation` section of the event configuration can contain the following
340
376
* `pathParams`: a list of path parameters (see [pathParams](#pathparams) below)
341
377
* `cookieParams`: a list of cookie parameters (see [cookieParams](#cookieparams) below)
342
378
* `headerParams`: a list of headers (see [headerParams](#headerparams---request-headers) below)
379
+
* `security`: The security requirement to apply (see [security](#security) below)
343
380
* `methodResponses`: an array of response models and applicable status codes
344
381
* `statusCode`: applicable http status code (ie. 200/404/500 etc.)
345
382
* `responseBody`: contains description of the response
@@ -480,6 +517,62 @@ headerParams:
480
517
type: "string"
481
518
```
482
519
520
+
#### `security`
521
+
522
+
The `security` property allows you to specify the [Security Scheme](#securityschemes) to apply to the HTTP Request. If you have applied an `security` ([see Security on each operation](#security-on-each-operation)) then you can either leave this field off, or to override it with a different scheme you can write it like:
If you have specified an `security` at the document root, but this HTTP Request should not apply any security schemes, you should set security to be an array with an empty object:
555
+
556
+
```yml
557
+
custom:
558
+
documentation:
559
+
securitySchemes:
560
+
my_api_key:
561
+
type: apiKey
562
+
name: api_key
563
+
in: header
564
+
security:
565
+
- my_api_key: []
566
+
567
+
functions:
568
+
getData:
569
+
events:
570
+
- http:
571
+
documentation:
572
+
security:
573
+
- {}
574
+
```
575
+
483
576
#### `requestModels`
484
577
485
578
The `requestModels` property allows you to define models for the HTTP Request of the function event. You can define a different model for each different `Content-Type`. You can define a reference to the relevant request model named in the `models` section of your configuration (see [Defining Models](#models) section).
0 commit comments