Coder Social home page Coder Social logo

magicmatatjahu / diff Goto Github PK

View Code? Open in Web Editor NEW

This project forked from asyncapi/diff

0.0 1.0 0.0 1.63 MB

Diff is a library that compares two AsyncAPI Documents and provides information about the differences by pointing out explicitly information like breaking changes.

License: Apache License 2.0

TypeScript 98.58% JavaScript 1.42%

diff's Introduction

AsyncAPI logo
Diff

AsyncDiff is a library that compares two AsyncAPI files and provides information about the differences by pointing out explicitly information like breaking changes.

npm npm

Installation

npm install @asyncapi/diff

Usage

NOTE: The library doesn't have a built-in parser to parse the given AsyncAPI document. Thus, you have to make sure they provide the valid & dereferenced AsyncAPI document as an input. You can use the AsyncAPI parser to parse and validate the AsyncAPI file first. You can use other tools, but you must make sure that the document is valid and dereferenced.

import { diff } from '@asyncapi/diff'; // const { diff } = require('@asyncapi/diff');

const output = diff(firstDocument, secondDocument, {
  overrides: {
    // object to override the standard
  },
});

Standard object

This library has a pre-configured standard which marks a change as breaking, non-breaking or unclassified. This standard data is stored as an object inside the standard.ts file.

The format of this standard object is explained in this document.

Overriding the standard

To understand the format of overriding object, take a look at this document.

The overrides object must be passed in the following format:

{
	[jsonPointer]: {
		add: 'breaking' | 'non-breaking' | 'unclassified'
		remove: 'breaking' | 'non-breaking' | 'unclassified'
		edit: 'breaking' | 'non-breaking' | 'unclassified'
	}
}

Example

See the API document to get all the helper methods this library offers.

  1. Without any overrides
const output = diff(firstDocument, secondDocument);

output.getOutput(); // the whole output data
output.breaking(); // the breaking changes
output.nonBreaking(); // the non-breaking changes
output.unclassified(); // the unclassified changes
  1. With overrides
const output = diff(firstDocument, secondDocument, {
  overrides: {
    '/servers/*/protocol': {
      add: 'non-breaking',
      remove: 'breaking',
      edit: 'unclassified',
    },
  },
});

API

Checkout the API document to see all the APIs this library offers.

Develop

  1. Write code and tests
  2. Make sure all tests pass npm run test
  3. Make sure code is well formatted and secure npm run lint

Contributing

Help us make this library more robust. Read CONTRIBUTING guide & start contributing.

diff's People

Contributors

aayushmau5 avatar asyncapi-bot avatar derberg avatar jonaslagoni avatar

Watchers

 avatar

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.