Giter Club home page Giter Club logo

spego's Introduction

spego

bundle

A set of policies for Open Policy Agent to validate OpenAPI definitions.

  • Use opa eval to execute policies against OpenAPI documents
  • Built-in support for Conftest
  • Based on the rules used by Spectral.

Usage

Spego may be used as an Open Policy Agent (OPA) bundle. First, be sure to follow the instructions to install OPA.

git clone [email protected]:kevinswiber/spego.git
opa eval \
  --bundle ./spego/src \
  --format pretty \
  --input ./spego/example/inputs/openapi.json \
  "data.openapi.main.results"

Spego can also be used with Conftest. First, be sure to follow the instructions to download Conftest.

conftest pull git::https://github.com/kevinswiber/spego//src
conftest test -n "openapi.main" ./openapi.json

Note: Policy execution can be configured by adding a data file named data.openapi.ruleset as defined in the Configuration section.

Configuration

Example configuration

openapi:
  ruleset:
    extends: [['spego:oas', 'recommended']]
    rules:
      operation-success-response: error
      openapi-tags: true

Policies (Rules)

contact-properties

Contact object must have "name", "url" and "email".

duplicated-entry-in-enum

Recommended: true

Enum values must not have duplicate entry.

info-contact

Recommended: true

Info object must have "contact" object.

info-description

Recommended: true

Info "description" must be present and non-empty string.

info-license

Info object must have "license" object.

license-url

License object must include "url".

no-eval-in-markdown

Recommended: true

Markdown descriptions must not have "eval(".

no-script-tags-in-markdown

Recommended: true

Markdown descriptions must not have "<script>" tags.

openapi-tags-uniqueness

Recommended: true

Each tag must have a unique name.

openapi-tags

OpenAPI object must have non-empty "tags" array.

operation-description

Recommended: true

Operation "description" must be present and non-empty string.

operation-operationId-unique

Recommended: true

Every operation must have unique "operationId".

operation-operationId-valid-in-url

Recommended: true

operationId must not have characters that are invalid when used in URL.

operation-operationId

Recommended: true

Operation must have "operationId".

operation-parameters

Recommended: true

Operation parameters are unique and non-repeating.

operation-singular-tag

Operation must not have more than a singular tag.

operation-success-response

Recommended: true

Operation must have at least one "2xx" or "3xx" response.

operation-tag-defined

Recommended: true

Operation tags must be defined in global tags.

operation-tags

Recommended: true

Operation must have non-empty "tags" array.

path-declarations-must-exist

Recommended: true

Path parameter declarations must not be empty, ex."/given/{}" is invalid.

path-keys-no-trailing-slash

Recommended: true

Path must not end with slash.

path-not-include-query

Recommended: true

Path must not include query string.

path-params

Recommended: true

Path parameters must be defined and valid.

tag-description

Tag object must have "description".

spego's People

Contributors

kevinswiber avatar

Stargazers

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

Watchers

 avatar  avatar  avatar

Forkers

amzani

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.