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

api-design-principle-beta

v0.0.12

Published

API design principle

Downloads

556

Readme

API Design Principle (ADP) Documentation

This repository contains the documentation for API Design Principles (ADP), a comprehensive guide for designing and implementing APIs. It also deploys a Redocly ruleset as api-design-principle-beta/recommended.

Overview

The ADP documentation, built using VitePress, provides guidelines, best practices, and standards for API design across various categories. It aims to ensure consistency and quality in API development throughout the organization.

Key Features

  • Comprehensive API design principles
  • Multilingual support (English and Traditional Chinese)
  • Semantic versioning
  • OpenAPI examples
  • Developer experience focus

Structure

The documentation is organized into several categories, including:

  • ADP Overview
  • Engineering Principles
  • HTTP Basics
  • REST Basics
  • HTTP Semantics
  • OpenAPI Design
  • Error Design
  • Event Design
  • API Governance

Redocly Ruleset Usage

Installation

Install dependencies:

npm install -g @redocly/cli
npm add -D @redocly/openapi-core
npm add -D api-design-principle-beta

Configuration

Add .redocly.yaml to your API repo:

apiDefinitions:
  main: openapi.yaml
extends:
  - 'recommended'
  - 'api-design-principle-beta/recommended'
plugins:
  - ./node_modules/api-design-principle-beta/dist/plugin.cjs

Usage

Run with Redocly:

redocly lint

New Redocly Rules

The package includes several custom rules to enforce best practices:

  • api-design-principle-beta/always-return-json-object: Ensures top-level JSON responses are objects.
  • api-design-principle-beta/format-enumeration-upper-snake-case: Enforces upper snake case for enum values.
  • api-design-principle-beta/no-request-body-in-get-method: Prohibits request bodies in GET methods.
  • api-design-principle-beta/not-use-null-for-empty-array: Discourages null for empty arrays.
  • api-design-principle-beta/no-basic-auth-in-security-schemes: Prevents basic authentication in security schemes.
  • api-design-principle-beta/use-absolute-profile-url: Enforces absolute URLs for profiles.
  • api-design-principle-beta/use-camel-case-for-property-name: Encourages camel case for property names.
  • api-design-principle-beta/use-camel-case-for-query-parameter: Enforces camel case for query parameters.
  • api-design-principle-beta/use-common-date-and-time-format: Ensures common date and time formats.
  • api-design-principle-beta/use-extensible-enum: Promotes extensible enums.
  • api-design-principle-beta/use-kebab-case-for-path-parameter: Enforces kebab case for path parameters.
  • api-design-principle-beta/use-oas-3: Requires OpenAPI Specification 3.0.0 or higher.
  • api-design-principle-beta/use-string-enum: Ensures enums are represented as strings.
  • api-design-principle-beta/use-tls: Enforces TLS for server URLs.
  • api-design-principle-beta/check-x-audience: Validates the x-audience extension.
  • api-design-principle-beta/error4xx-rfc9457: Ensures 4xx error responses comply with RFC 9457.
  • api-design-principle-beta/error5xx-rfc9457: Ensures 5xx error responses comply with RFC 9457.

Contact

For questions or feedback, please contact [email protected].