npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

serverless-disable-request-validators

v1.0.3

Published

Serverless plugin to disable Request Validators from API Gateway

Downloads

3,211

Readme

serverless-disable-request-validators

serverless npm version Build Status

Serverless v2 plugin to disable API Gateway request validators.

What it does

It gives you the ability to disable or remove the API Gateway Request Validator on Serverless v2 until the Serverless Framework team introduces an opt-out flag or another mechanism to avoid the automatic creation of Request Validators in API Gateway when your Lambda functions have an schema associated with them.

If you have all request validations implemented in your Lambda, you probably don't to use the API Gateway Request Validator.

There are 3 legitimate use cases for these schemas:

  1. Apply basic request validation at the API Gateway level (before it reaches the Lambda);
  2. Export the API definition in another format - https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-export-api.html
  3. Generate a client SDK for some languages - https://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-generate-sdk-console.html

If you want cases 2 and 3 but not case 1, this plugin can help you!

Install

yarn add --dev serverless-disable-request-validators
# or
npm install -D serverless-disable-request-validators

Enable the plugin

Add the following plugin to your serverless.yml:

plugins:
  - serverless-disable-request-validators

Configure

You can configure the plugin behavior using the custom section in your serverless.yml file.

  1. Only disable the body and parameters validations directly in all validator resources (AWS::ApiGateway::RequestValidator):
custom:
  serverless-disable-request-validators:
    action: disable
  1. Only disassociate all the validator resources (AWS::ApiGateway::RequestValidator) from API resources (AWS::ApiGateway::Method), effectively deleting the references to the validator resources:
custom:
  serverless-disable-request-validators:
    action: disassociate
  1. To delete all validator (AWS::ApiGateway::RequestValidator) resources:
custom:
  serverless-disable-request-validators:
    action: delete

If no custom configuration is provided, the default action is disable.

Caveats

If during the same deploy you try to disassociate your APIs resources from a validator and also delete the referenced validator resource, it will fail with the following error message:

Error message in a picture

The reason seems to be that your deployed APIs still reference the validator resources and CloudFormation doesn't handle the dependency between them correctly. The solution is to deploy twice, as follows:

  1. Deploy 1: disassociate the validator using action: disassociate.
  2. Deploy 2: delete the validator using action: delete.