npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@fortellis/spec-linter

v1.0.0

Published

Validate fortellis API specifications

Downloads

1

Readme

Fortellis Specification Validator

The Fortellis specification validator can be used to ensure that API specifications conform to the Fortellis rules and standards. More information on the Fortellis rules and standards can be found here.

Installation

npm i @fortellis/spec-validator

Usage

The spec validator exposes two functions for linting api specifications, one for yaml strings and one for parsed JSON objects. Both return an array of resulting linting notices in the spec. A valid spec will return an empty array.

JSON Objects

const { lint } = require('@fortellis/spec-validator');

const mySpec = {
  // ...
};
const results = lint(mySpec);

Yaml String

const fs = require('fs');
const { lintRaw } = require('@fortellis/spec-validator');

const mySpec = fs.readFileSync('./my-spec.yaml', 'utf8');
const results = lintRaw(mySpec);

Options

Both functions take a second argument to supply an options object. The options object will allow you to partially customize the behavior of the linter. The following are available items in the options object:

| Key | Type | Description | Default | | ---------- | ------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | | rulesets | object | Define the rulesets used in the linter. Each ruleset is a key in this object. | {} | | severity | enum (number) | Determine the level of linting notice that should be returned in the results array (error (0), warn (1), info (2), hint (3)). These severity levels are exported as Severity from @fortellis/spec-validator. | 0 | | verbose | boolean | Enable/Disable logging from the linter | false |

Results

The results array that shows you all of the linter notices for the passed in spec will contain objects will a bunch of information about the specific notice and where the notice is located in the spec.

| Key | Type | Description | | ---------- | ------ | --------------------------------------------------------------------------------------------------------------------------------- | | code | string | Where the notice originated from. | | message | string | The human readable description of the cause of the notice. | | severity | number | The severity level of the notice (error (0), warn (1), info (2), hint (3)). | | path | array | An array of keys denoting the location of the notice within the spec. | | range | object | Contains the start and end objects which denote the exact line and character location of the notice within the original spec. |

Example

{
  code: 'parser',
  message: 'Mapping key must be a string scalar rather than number',
  severity: 0,
  path: [
    'paths',
    '/my-endpoint',
    'get',
    'responses',
    '200'
  ],
  range: {
    start: {
      line: 44,
      character: 8
    },
    end: {
      line: 44,
      character: 11
    }
  }
}