webapi-parser is a JavaScript and Java library that acts as a thin wrapper around the API Modeling Framework (AMF) to parse, validate, and navigate API specifications. It supports various formats including RAML 0.8, RAML 1.0, OpenAPI (OAS) 2.0, and OpenAPI (OAS) 3.0 (currently in beta). The current stable version is v0.5.0. The library receives updates driven primarily by new releases of the underlying AMF framework, leading to a somewhat irregular but active release cadence. Its key differentiator is its ability to uniformly process multiple API definition languages through a consistent object model, making it suitable for tooling that needs to work across different specification types.
npm install webapi-parserVerified import paths — ran on the pinned version, not inferred.
Parses a basic OpenAPI 3.0 specification string and demonstrates how to access its title, version, and iterate through endpoints and operations within the resulting WebApi model, including basic error checking.
Review the AMF 4.0.3 release notes and webapi-parser documentation for updated security model interfaces and adjust type definitions and access patterns accordingly.
For OpenAPI 3.0 documents, always use `WebApiParser.oas30.parse(specString)`.
To retrieve the string value, call `.value()` on the returned `StrField` (e.g., `scalarNode.value.value()`). For nullable values, use `.option()`.
Consult the AMF 4.0.1 release notes for detailed JSON-LD changes. If you are interacting with the underlying AMF model directly, verify your code against the new structure.
Adjust type casting or type checks to handle `AnyShape`. Since `NodeShape` is a subclass of `AnyShape`, direct usage might continue to work if only `AnyShape` methods are used, but explicit casting may be required for `NodeShape`-specific functionality.
For OpenAPI 3.0 specifications, use the dedicated `WebApiParser.oas30.parse(specString)` method.
Access the underlying string value first by calling `.value()` on the `StrField` (e.g., `scalarNode.value.value().startsWith(...)`).
Ensure you are using the correct import for your environment: `import { WebApiParser } from 'webapi-parser';` for ESM/TypeScript or `const { WebApiParser } = require('webapi-parser');` for CommonJS.No dependency data recorded yet.