Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

api-smart-diff

Package Overview
Dependencies
Maintainers
1
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

api-smart-diff

Generate the diff between two API specifications (OpenAPI, AsyncAPI, JsonSchema)

  • 0.2.7
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
932
increased by84.92%
Maintainers
1
Weekly downloads
 
Created
Source

api-smart-diff

npm npm npm type definitions GitHub

This package provides utils to compute the diff between two API specifications.

Purpose

  • Generate API changelog
  • Identify breaking changes
  • Ensure API versioning consistency

Supported API specifications

  • OpenApi 3.0
  • AsyncApi 2.1
  • JsonSchema
  • Swagger 2.0 (Roadmap)
  • graphql (Roadmap)
  • gRPC (Roadmap)

Features

  • Generate diff for supported specifications
  • Generate merged spec with changes in metadata
  • Classify all changes as breaking, non-breaking, annotation
  • Supports custom classification rules
  • Resolves all $ref pointers, including external
  • Typescript syntax support out of the box
  • No dependencies, can be used in nodejs or browser

Installation

npm install api-smart-diff --save

Usage

Nodejs

import { apiDiff } from 'api-smart-diff'

const diff = apiDiff(oldSpec, newSpec, { rules: "OpenApi3" })
// {
//   action: "add" | "remove" | "replace",
//   after: 'value in newSpec',
//   before: 'value in oldSpec',
//   path: ['path, 'in', 'array', 'format'],
//   type: "annotation" | "breaking" | "non-breaking" | "unclassified"
// }

const merge = apiMerge(oldSpec, newSpec, { rules: "OpenApi3" })

Browsers

A browser version of api-smart-diff is also available via CDN:

<script src="https://cdn.jsdelivr.net/npm/api-smart-diff@latest/browser/api-smart-diff.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/api-smart-diff@latest/browser/api-smart-diff.js"></script>

Reference api-smart-diff.min.js in your HTML and use the global variable ApiSmartDiff.

<script>
  var diff = ApiSmartDiff.apiDiff(oldSpec, newSpec, { rules: "OpenApi3" })
  var merge = ApiSmartDiff.apiMerge(oldSpec, newSpec, { rules: "OpenApi3" })
</script>

License

MIT

Keywords

FAQs

Package last updated on 31 Mar 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc