Giter Club home page Giter Club logo

spectral-aws-apigateway-ruleset's Introduction

Spectral AWS API Gateway Ruleset

When working with AWS API Gateway, it uses a number of features that are a step away from the OpenAPI standard.

Usefully, the features are documented here AWS API Gateway Important Notes, but it's very easy for API developers to forget, or miss them.

This linter is designed to support only the OpenAPI v3 specificiation on AWS API Gateway. AWS' documentation is not particularly clear on the differences between the two implementations, but as historical documentation gets updated this library will hopefully become more accurate and relevant to v3. If you're using V2, please note that this linter is likely to provide you false-positive, and false-negative results.

Spectral

Spectral is an Open Source API Linter.

Spectral is an open source JSON/YAML linter, which allows you to create style guides for your structured data; things like OpenAPI/AsyncAPI/RAML descriptions, Kubernetes config, GitHub Actions, you name it, Spectral can help you lint it. Go beyond making sure they are “Technically Correct”, make sure they are useful.

Try it out:

If you've got npx installed, then you can run this ruleset with a single command, replacing $your_api.yml - with your API definition:

npx spectral lint -r https://raw.githubusercontent.com/andylockran/spectral-aws-apigateway-ruleset/main/aws_important_notes.yml $your_api.yaml

Instructions

To use this ruleset, simply extend your .spectral.yml ruleset by adding a reference to this ruleset, eg:

extends:
  - spectral:oas
  - spectral-aws-apigateway-ruleset

This pulls the definition directly from npm, so you don't have to even install it!

NPM package

spectral-aws-apigateway-ruleset

See: Spectral Instructions for npm for more details.

Contributing

The severity of each of these rules has been tweaked to follow my own usage. If you think the severity needs changing, or would prefer a more descriptive error message, please submit a PR.

For instructions on how to do so, refer to Custom Rulesets on the Spectral site.

Treeware

This package is Treeware. If you use it in production, then we ask that you buy the world a tree to thank us for our work. By contributing to the Treeware forest you’ll be creating employment for local families and restoring wildlife habitats.

spectral-aws-apigateway-ruleset's People

Contributors

02strich avatar andylockran avatar andyloughran avatar dependabot[bot] avatar garysassano avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

spectral-aws-apigateway-ruleset's Issues

aws-allowed-parameters should apply for input parameters only

For input parameters, only the following attributes are supported: name, in, required, type, description. Other attributes are ignored.

Input parameters are parameters defined for a form

    requestBody:
      content:
        application/x-www-form-urlencoded:
          schema:
            type: object
            properties:
              id:
                type: string
                format: uuid
              address:
                # complex types are stringified to support RFC 1866
                type: object
                properties: {}

or

    requestBody:
      content:
        multipart/form-data:
          schema:
            type: object
            properties:
              id:
                type: string
                format: uuid
              address:
                # default Content-Type for objects is `application/json`
                type: object
                properties: {}
              profileImage:
                # default Content-Type for string/binary is `application/octet-stream`
                type: string
                format: binary
              children:
                # default Content-Type for arrays is based on the `inner` type (text/plain here)
                type: array
                items:
                  type: string
              addresses:
                # default Content-Type for arrays is based on the `inner` type (object shown, so `application/json` in this example)
                type: array
                items:
                  type: '#/components/schemas/Address'

I believe the aws-allowed-parameters rule is overreaching by also applying this to path and query parameters.

https://swagger.io/specification/#request-body-object

`oneOf` rule should apply to OpenAPI 2.0 only

The ruleset currently has the following rule:

image

However, the AWS documentation states:

oneOf is not supported for OpenAPI 2.0 or SDK generation.

I have been able to use oneOf successfully in API Gateway with 3.0 which seems to confirm this.

Therefore, I suggest that this rule only applies to OpenAPI 2.0 specs.

Nimma fails when trying to test commonJS draft4 function

Trying to setup the tests to be able to run each of the aws_important_notes rules individually.

Fails to load the json draft-4 rule, as Nimma fails.

Saw this before ages ago, but need to work out why it's failing in the Jest context.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.