Git Product home page Git Product logo

bpce-api-guidelines-rulesets's Introduction

BPCE API Design Guidelines Rulesets โœ… ๐Ÿ†š โš ๏ธ

JavaScript Style Guide

Using Stoplight's Spectral and the BPCE API Design Guidelines Rulesets, you can ensure that an API design (provided as a Swagger 2.0 or OpenAPI 3, JSON or YAML file) is compliant with BPCE/Natixis API Design Guidelines. These rulesets are a work in progress and do not check yet all of our API Design Guidelines rules.

๐Ÿ”ด Linting an API description only ensures that the form of the API is compliant with our guidelines but does ensure that it is accurate, fully consistent and user friendly.
That's why, even linted, an API design must always be reviewed by the BPCE/Natixis API Team.


Usage ๐Ÿ”›

โš ๏ธ Spectral upgrade v5 to v6
Regarding Migration page, we tried to upgrade our linter repository
Due to major breaking changes into Spectral-JS interface, we can't use our test cases yet.
We still need to update our rulesets to be able to use them into Stoplight Studio

  • Dependencies Management Impact
    • @stoplight/spectral-core@^1.6.0
    • ajv@^8.6.2

Spectral

Description

Spectral is a JSON/YAML linter with out of the box support for OpenAPI 3.0 & 2.0 and AsyncAPI

Installation

Open a terminal and launch the following command line to install the spectral cli:

npm install -g @stoplight/[email protected]

or

yarn global add @stoplight/[email protected]

See Spectral documentation for more information and other installation options.

Linting a file

Checking compliance to BPCE/Natixis API Design guidelines is done using the rulesets/main-ruleset.yaml ruleset file.

spectral lint -r <path to ruleset> <path to Swagger or OpenAPI file in JSON or YAML format>

spectral lint -r rulesets/main-ruleset.yaml samples/example-swagger.yaml

Output can be turned into JSON using the -f flag:

spectral lint -f json -r rulesets/main-ruleset.yaml samples/example-swagger.yaml

Development ๐Ÿ‘ท

In order to add new rules or rulesets, we have test suite to ensure your Spectral rules are working as intending by providing a frame to your tests.

Setting up development environment

JavaScript Style Guide JavaScript Style Guide

This project uses mocha for testing rules, standard to lint the JS code and EditorConfig for coding styles.

Download dependencies using the following commands in a terminal:

npm install -g mocha
npm install -g standard
npm install

Source organization

  • rulesets: available rulesets, main-ruleset.yaml is the top level ruleset which includes the other ones
  • samples: sample Swagger 2.0 and OpenAPI 3 files to test with spectral cli
  • test: tests for rulesets (one js mocha test file for each ruleset)

Modifying rules

Spectral documentation describes anything you need to define your rulesets, rules and function. What follows only explains how this repo works.

Adding a ruleset

  • Create a new <ruleset name>-ruleset.yaml file in the rulesets folder
  • Add the matching test-<ruleset name>-ruleset.js test file in the tests folder

Adding or modifying a rule

  • Add or modify rule in the adequate ruleset file
  • Add all needed tests to the adequate test file

Testing ๐Ÿ›‚

JavaScript Mocha Test Run the following command to check that everything is ok

npm run test

You can also run a specific test file using:

mocha test/<filename>

mocha test/test-info-ruleset.js

Questions & Comments

Please contact [email protected] in case of questions.

bpce-api-guidelines-rulesets's People

Contributors

adhm3appgithub avatar onimenokyo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

ptitficus

bpce-api-guidelines-rulesets's Issues

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.