serverless-reqvalidator-plugin
Advanced tools
Comparing version 3.0.0 to 3.1.0
{ | ||
"name": "serverless-reqvalidator-plugin", | ||
"version": "3.0.0", | ||
"version": "3.1.0", | ||
"description": "Serverless plugin for setting request validation", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -106,2 +106,19 @@ # serverless-reqvalidator-plugin | ||
### Use an external validator by ID | ||
If you have an existing request validator defined outside of CloudFormation e.g. Terraform, you can reference it by id. | ||
``` | ||
plugins: | ||
- serverless-reqvalidator-plugin | ||
service: my-service-a | ||
functions: | ||
hello: | ||
handler: handler.myHandler | ||
events: | ||
- http: | ||
path: hello | ||
reqValidatorName: | ||
id: 'g5ch0h' | ||
``` | ||
### Full example | ||
@@ -108,0 +125,0 @@ ``` |
@@ -32,2 +32,17 @@ 'use strict'; | ||
* | ||
* Use request validator by Id: | ||
* | ||
* myFuncGetItem: | ||
* handler: myFunc.get | ||
* name: ${self:provider.stage}-myFunc-get-item | ||
* events: | ||
* - http: | ||
* method: GET | ||
* path: mypath | ||
* cors: true | ||
* reqValidatorName: | ||
* id: 'g5ch0h' | ||
* | ||
* | ||
* | ||
* Resources used: | ||
@@ -48,2 +63,8 @@ * - https://www.snip2code.com/Snippet/1467589/adds-the-posibility-to-configure-AWS_IAM/ | ||
}, | ||
{ type: 'object', | ||
properties: { | ||
id: { type: 'string' }, | ||
}, | ||
required: ['id'], | ||
}, | ||
] | ||
@@ -111,2 +132,4 @@ }, | ||
resources[methodName].Properties.RequestValidatorId = reqValidatorName; | ||
} else if (reqValidatorName['id']) { | ||
resources[methodName].Properties.RequestValidatorId = reqValidatorName['id'] | ||
} else { // other use cases should be added here | ||
@@ -113,0 +136,0 @@ resources[methodName].Properties.RequestValidatorId = reqValidatorName; |
@@ -41,2 +41,9 @@ const Ajv = require('ajv'); | ||
}); | ||
it('should validate a configuration with an external reqValidatorName.id property', () => { | ||
const config = yaml.load(fs.readFileSync('./test/fixtures/externalValidatorId.yaml', 'utf8')); | ||
const valid = validateConfig(config.functions.hello.events[0].http); | ||
expect(valid).toBeTruthy(); | ||
}) | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
14219
4908
10
166
227