Giter VIP home page Giter VIP logo

postman-open-technologies / openapi-linter Goto Github PK

View Code? Open in Web Editor NEW
9.0 2.0 4.0 949 KB

An open source implementation of Spectral for applying linting rules to an OpenAPI which can be deployed to AWS, Azure, and Heroku.

Home Page: https://api.linting.org/?rulesUrl=https://rules.linting.org/rulesets/base/

License: Apache License 2.0

JavaScript 6.18% TypeScript 86.98% Shell 1.41% Bicep 5.42%
openapi openapi3 spectral linting linting-rules

openapi-linter's Introduction

spec-linter

Deploy Deploy to Azure

Deploy to AWS

An API for linting OpenAPI, AsyncAPI, and other JSON/YAML documents, built on top of Spectral.

๐Ÿ›  Usage

See the published Postman Collection for more information on interacting with the spec-linter API.

Spectral config must be hosted at a URL. This API supports configuration in the following forms:

  • JSON/YAML file
  • Spectral JavaScript configuration (alpha, typically .spectral.js)
  • Spectral TypeScript configuration (alpha, typically .spectral.ts)

๐Ÿ™ Thanks

This project wouldn't be possible without the efforts of Stoplight and the Spectral contributors.

๐Ÿ“„ License

Apache-2.0

openapi-linter's People

Contributors

kevinswiber avatar kinlane avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

openapi-linter's Issues

Range line is always 0

While comparing spectraI-cli and Linter API results, I noticed the ranges were different while running the same rules on the same content, it appears that the API always returns line range with a 0 value. It seems that the request body is converted to a one line JSON document before processing (whatever the original format, yaml or json).

API outputs

API Output with YAML request body (range correspond to 1 line JSON)

{
    "code": "summary-short",
    "failure": {
        "source": "<REQUEST_BODY_0>",
        "range": {
            "start": {
                "line": 0,
                "character": 101
            },
            "end": {
                "line": 0,
                "character": 176
            }
        }
    }
}

API output with JSON request body (range correspond to 1 line JSON)

{
      "code": "summary-short",
      "failure": {
          "source": "<REQUEST_BODY_0>",
          "range": {
              "start": {
                  "line": 0,
                  "character": 101
              },
              "end": {
                  "line": 0,
                  "character": 176
              }
          }
      }
  }

API output with 1 line JSON request body (same result as CLI)

{
      "code": "summary-short",
      "failure": {
          "source": "<REQUEST_BODY_0>",
          "range": {
              "start": {
                  "line": 0,
                  "character": 101
              },
              "end": {
                  "line": 0,
                  "character": 176
              }
          }
      }
  }

CLI outputs

CLI Output with YAML file (correct line ranges)

{
        "code": "summary-short",
        "range": {
                "start": {
                        "line": 8,
                        "character": 15
                },
                "end": {
                        "line": 8,
                        "character": 88
                }
        },
        "source": ".../basic-swagger-2.0.yaml"
}

CLI Output with JSON file (correct line ranges)

{
        "code": "summary-short",
        "path": [
                "paths",
                "/resources",
                "get",
                "summary"
        ],
        "message": "An operation's summary must be short",
        "severity": 1,
        "range": {
                "start": {
                        "line": 9,
                        "character": 19
                },
                "end": {
                        "line": 9,
                        "character": 94
                }
        },
        "source": ".../basic-swagger-2.0.json"
}

CLI Output with YAML file converted to a 1 line JSON (same ranges as the API)

{
        "code": "summary-short",
        "range": {
                "start": {
                        "line": 0,
                        "character": 101
                },
                "end": {
                        "line": 0,
                        "character": 176
                }
        },
        "source": ".../basic-1-line-swagger-2.0.json"
}

Solution for Dynamic Rules

What do you think the best approach would be for allowing users to provide a comma-separated list of rules, rather than relying on just rule or ruleset URLs? I feel like we should keep a rules and ruleset URL option, but additionally provide a way of pulling from our central list of rules via Git or NPM, then users can pass in a comma separate list of which ones they want to use--the API builds the rules dynamic before linting occurs within API.

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.