@ibm-cloud/openapi-ruleset

1.15.9 • Public • Published

OpenAPI Ruleset

This package contains a custom Spectral ruleset for validating OpenAPI documents. It extends the spectral:oas ruleset, for which it defines custom severity levels. It also contains a number of additional rules based on API design requirements and guidance from IBM Cloud. This is the default ruleset used in the ibm-openapi-validator package.

Installation

npm install @ibm-cloud/openapi-ruleset

Note that installation is only required if using this package programmatically or extending it in a Spectral config file written in JavaScript. It is not required if extending the ruleset in a Spectral config file written in YAML or JSON.

Usage

Spectral config file - YAML or JSON

  • Note - no installation required. Spectral handles the import internally.
# .spectral.yaml
extends: '@ibm-cloud/openapi-ruleset'
rules:
  content-entry-provided: off

Spectral config file - JavaScript

// .spectral.js
const ibmOpenapiRuleset = require('@ibm-cloud/openapi-ruleset');

module.exports = {
  extends: ibmOpenapiRuleset,
  rules: {
    'content-entry-provided': 'off'
  }
};

Programmatically running Spectral

// your-module.js
const ibmOpenapiRuleset = require('@ibm-cloud/openapi-ruleset');
const { Spectral } = require('@stoplight/spectral-core');

function async runSpectral(openapiDocument) {
  const spectral = new Spectral();
  spectral.setRuleset(ibmOpenapiRuleset);
  results = await spectral.run(openapiDocument);
  console.log(results);
}

Readme

Keywords

none

Package Sidebar

Install

npm i @ibm-cloud/openapi-ruleset

Weekly Downloads

143,083

Version

1.15.9

License

Apache-2.0

Unpacked Size

1.09 MB

Total Files

272

Last publish

Collaborators

  • japetrsn
  • fanfei
  • jwsartor
  • dvesperini
  • kpnode
  • reggeenr
  • idsorg
  • smulampa
  • ibm-cloud-event-notifications
  • baijiebj
  • dpopp07
  • ricellis
  • cloudant-sdks-automation
  • secrets.automation
  • nvenkatesh
  • dpittner_ibm
  • externaluse.sqlquery
  • ibm-reggie
  • edwin_gonzales_ibm
  • ibm-devx-sdk