GithubHelp home page GithubHelp logo

isabella232 / openapilint Goto Github PK

View Code? Open in Web Editor NEW

This project forked from paypal/openapilint

0.0 0.0 0.0 169 KB

Node.js linter for OpenAPI specs

License: MIT License

JavaScript 98.29% Ruby 1.71%

openapilint's Introduction

NPM version build status Downloads

openapilint

This project uses Node.js to implement an OpenAPI linter. As with any linter, there are configurable options for validating your OpenAPI specs.

Install openapilint

npm install openapilint --save

Usage

openapilint takes as input a json schema, and json config object:

const schema = {
  info: {
    description: 'handy description'
  }
};
const config = {
  "rules": {
    "docs-path": true,  // rule will be run, and has no special config
    "no-restricted-words": {"words": ["supersecretacronym"]},  // rule will be run with the specified config
    "root-tags": false // rule will not be run
  }
};

and returns a promise of the results:

const result = new OpenApiLint(config).lint(schema);

return result.then((lintResult) => {
  // Do something with the result Map.
}).catch((error) => {
  // Do something with the Error.
});

lintResult is a String -> RuleResult immutable Map of nested immutable objects for consumption. Specifically:

  • RuleResult is a String -> Object immutable Record with two keys, description (String) & failures (List<RuleFailure>).
  • RuleFailure is a String -> String immutable Record with two keys, location (String) & hint (String)

It is up to the implementer to parse this data and provide a useful error response to the user.

Rules

By default, only the rules in lib/rules are supported. Details of these rules can be found in docs/rules.

Dereferencing

Due to the complex nature of multi-file references, openapilint rules assume that all references are contained within the input. For simplicity, references to anything other than internally are treated as errors.

OpenAPI supported versions

openapilint supports Swagger 2.0. Support for OpenAPI 3.0 is not planned.

Comparison to other validators

openapilint does have some overlapping features with other json validators, such as joi and jsonschema. A developer using this project may choose to use those validators as a first wave of checks against a particular spec before running it through the openapilint set of rules. This is expected and encouraged. The rules implemented within openapilint go above and beyond those validators by targeting the common OpenAPI-specific problems.

License

See License.

Contributing

See Contributing.

Acknowledgements

This project was inspired by - and heavily influenced by - eslint, markdownlint, and swagger-api-checkstyle. The configuration schema and some code was modified for usage in this project.

openapilint's People

Contributors

braebot avatar braintreeps avatar kartikh avatar rachelmuller avatar

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.