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
As of 0.0.64, you can now make use of [Request Schema Validators](https://www.serverless.com/framework/docs/providers/aws/events/apigateway#request-schema-validators). This allows you to define Request models via the `apiGateway` settings:
416
+
417
+
```yml
418
+
provider:
419
+
...
420
+
apiGateway:
421
+
request:
422
+
schemas:
423
+
post-create-model:
424
+
name: PostCreateModel
425
+
schema: ${file(api_schema/post_add_schema.json)}
426
+
description: "A Model validation for adding posts"
427
+
```
428
+
429
+
which are then used like:
430
+
431
+
```yml
432
+
functions:
433
+
create:
434
+
handler: posts.create
435
+
events:
436
+
- http:
437
+
path: posts/create
438
+
method: post
439
+
request:
440
+
schemas:
441
+
application/json: post-create-model
442
+
documentation:
443
+
...
444
+
```
445
+
446
+
The generator will match to the model within the `apiGateway` settings model list. If you are using the `apiGateway` to define models, please do not re-use any names that you might define in the [`models`](#models) list.
447
+
448
+
You can also skip writing a `requestBody` and `requestModels` if you have defined a `request` property in your event.
449
+
450
+
If you're not using `apiGateway`, you can still make use of `request` by writing in the other styles that serverless accepts for Request Schema Validators:
451
+
452
+
```yml
453
+
functions:
454
+
create:
455
+
handler: posts.create
456
+
events:
457
+
- http:
458
+
path: posts/create
459
+
method: post
460
+
request:
461
+
schemas:
462
+
application/json:
463
+
schema: ${file(create_request.json)}
464
+
name: PostCreateModel
465
+
description: 'Validation model for Creating Posts'
0 commit comments