Skip to content

Commit 4d27de2

Browse files
authored
Update README.md
1 parent 24d5ec2 commit 4d27de2

1 file changed

Lines changed: 105 additions & 0 deletions

File tree

README.md

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,108 @@ functions:
102102
reqValidatorName:
103103
Fn::ImportValue: 'myReqValidator'
104104
```
105+
106+
### Full example
107+
```
108+
service:
109+
name: my-service
110+
111+
plugins:
112+
- serverless-webpack
113+
- serverless-reqvalidator-plugin
114+
- serverless-aws-documentation
115+
116+
provider:
117+
name: aws
118+
runtime: nodejs6.10
119+
region: eu-west-2
120+
environment:
121+
NODE_ENV: ${self:provider.stage}
122+
custom:
123+
documentation:
124+
api:
125+
info:
126+
version: '1.0.0'
127+
title: My API
128+
description: This is my API
129+
tags:
130+
-
131+
name: User
132+
description: User Management
133+
models:
134+
- name: MessageResponse
135+
contentType: "application/json"
136+
schema:
137+
type: object
138+
properties:
139+
message:
140+
type: string
141+
- name: RegisterUserRequest
142+
contentType: "application/json"
143+
schema:
144+
required:
145+
- email
146+
- password
147+
properties:
148+
email:
149+
type: string
150+
password:
151+
type: string
152+
- name: RegisterUserResponse
153+
contentType: "application/json"
154+
schema:
155+
type: object
156+
properties:
157+
result:
158+
type: string
159+
- name: 400JsonResponse
160+
contentType: "application/json"
161+
schema:
162+
type: object
163+
properties:
164+
message:
165+
type: string
166+
statusCode:
167+
type: number
168+
commonModelSchemaFragments:
169+
MethodResponse400Json:
170+
statusCode: '400'
171+
responseModels:
172+
"application/json": 400JsonResponse
173+
174+
functions:
175+
signUp:
176+
handler: handler.signUp
177+
events:
178+
- http:
179+
documentation:
180+
summary: "Register user"
181+
description: "Registers new user"
182+
tags:
183+
- User
184+
requestModels:
185+
"application/json": RegisterUserRequest
186+
method: post
187+
path: signup
188+
reqValidatorName: onlyBody
189+
methodResponses:
190+
- statusCode: '200'
191+
responseModels:
192+
"application/json": RegisterUserResponse
193+
- ${self:custom.commonModelSchemaFragments.MethodResponse400Json}
194+
195+
package:
196+
include:
197+
handler.ts
198+
199+
resources:
200+
Resources:
201+
onlyBody:
202+
Type: "AWS::ApiGateway::RequestValidator"
203+
Properties:
204+
Name: 'only-body'
205+
RestApiId:
206+
Ref: ApiGatewayRestApi
207+
ValidateRequestBody: true
208+
ValidateRequestParameters: false
209+
```

0 commit comments

Comments
 (0)