Request validation using serverless framework

前端 未结 5 1018
再見小時候
再見小時候 2020-12-31 05:46

I am using serverless framework for the backend. How can I implement request validation? (do not want to write validation inside lambda functions).

5条回答
  •  长发绾君心
    2020-12-31 05:52

    As Ivan indicated, there is no need for external plugins as this is supported by the Serverless framework. However, I think the way to configure this has changed.

    functions:
      create:
        handler: posts.create
        events:
          - http:
              path: posts/create
              method: post
              request:
                schema:
                  application/json: ${file(create_request.json)}
    

    This example was taken from: https://www.serverless.com/framework/docs/providers/aws/events/apigateway/#request-schema-validators

提交回复
热议问题