api-smart-diff is a JavaScript/TypeScript library designed to compute detailed differences between two JSON-based API specifications. It currently supports OpenAPI 3.0, AsyncAPI 2.x, JSON Schema, and GraphQL via GraphApi. Version 1.0.6 is the current stable release, offering a robust set of features for API versioning and changelog generation. Key differentiators include its ability to classify changes into 'breaking', 'non-breaking', 'deprecated', and 'annotation' types, generate human-readable descriptions for each change, and resolve `$ref` pointers (with external bundling). It provides extensive customization options for comparison rules, classification, and output annotation, making it highly adaptable for various CI/CD pipelines and documentation generation tasks. The library works seamlessly in both Node.js and browser environments and ships with full TypeScript support.
npm install api-smart-diffVerified import paths — ran on the pinned version, not inferred.
Compares two OpenAPI 3.0 specifications, detailing the changes and providing a merged document.
Use the `api-ref-bundler` package (`npm install api-ref-bundler`) to pre-process your API specifications and resolve all external `$ref`s before calling `apiCompare`.
Migrate your Swagger 2.0 specifications to OpenAPI 3.0 or an officially supported format. Alternatively, consider using a different tool that specifically supports Swagger 2.0.
Ensure your AsyncAPI specifications are version 2.x or earlier. For gRPC, no direct support is available; you may need to convert gRPC definitions to a supported format like JSON Schema or use a specialized gRPC diffing tool.
Access the main function through the global `ApiSmartDiff.apiCompare(before, after)` object. If you need ES module syntax in the browser, integrate a module bundler like Webpack or Rollup into your build process.
Install and use `api-ref-bundler` to resolve all external references in your `before` and `after` specification objects before passing them to `apiCompare`. Example: `const bundledSpec = await bundle({ spec: originalSpec });`Ensure the CDN script has loaded correctly in your HTML. Access the function via `ApiSmartDiff.apiCompare(before, after)`. If using a module bundler, verify your import statement for `apiCompare` is correct.
Validate your API specification files (OpenAPI, AsyncAPI, JsonSchema) against their respective schemas or use a linter to identify and correct any JSON syntax errors before passing them to `apiCompare`.
No dependency data recorded yet.