Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
A

apidom

> 编程语言
Open source

Semantic parser for API specifications

100 stars0 likes2 views
WebsiteGitHub

About

Semantic parser for API specifications

ApiDOM

The purpose of ApiDOM is to provide a single, unifying structure for describing APIs across API description language and serialization formats. There currently exists several API description languages one can choose when defining an API, from OpenAPI, RAML, API Blueprint or others. There are also many serialization formats such as XML, YAML or JSON. Without a way to parse these formats to the same structure, developers are required to handle each format one-by-one, each in a different way and each translating to their internal domain model. This is tedious, time-consuming, and requires each maintainer to stay in step with every format they support.

ApiDOM solves this complex problem in a simple way. It allows parsers to parse to a single structure and allows tool builders to consume one structure for all formats.

Table of Contents

  • Getting started
    • Prerequisites
    • Installation
    • Usage
    • ApiDOM Playground
  • Development
    • Prerequisites
    • Setting up
    • Setting up via docker
    • Setting up via GitHub Codespaces
    • npm scripts
    • Build artifacts
    • Using this monorepo as a local dev dependency
  • Contributing
  • Documentation
    • What is an Element ?
    • As a way to annotate JSON
    • As a unifying structure
    • As a queryable structure
    • ApiDOM stages
  • ApiDOM packages
    • ApiDOM AST
    • ApiDOM Core
    • Retrieving ApiDOM Elements
    • ApiDOM Namespaces
    • ApiDOM Parsers
    • Advanced ApiDOM Manipulations
    • ApiDOM Language Service
  • License
  • Software Bill Of Materials (SBOM)

Getting started

Prerequisites

These prerequisites are required both for installing ApiDOM as a npm package and local development setup.

  • node-gyp >=10 with Python 3.x
  • GLIBC >=2.29
  • GCC compiler
  • emscripten or docker needs to be installed, we recommend going with a docker option

Installation

Assuming prerequisites are already installed, ApiDOM npm packages are installable and works with Node.js >=12.20.0 =24.19.0 and npm >=11.17.0 are the minimum required versions that this repo runs on, but we recommend using the latest version of Node.js@24.

Setting up

Run the following commands to setup the repository for local development:

bash
 $ git clone https://github.com/swagger-api/apidom.git
 $ cd apidom
 $ npm i
 $ npm run build

Setting up via docker

There are situations, when satisfying all the prerequisites of this repository on you local development machine is just not possible. In that case, you can use docker to get around it. Repository directory is mounted as volume inside a running container called apidom-dev. That way you can edit code locally on your development machine and run npm scripts inside the apidom-dev docker container.

Build the ApiDOM docker image:

bash
 $ git clone https://github.com/swagger-api/apidom.git
 $ cd apidom
 $ docker-compose up

Install dependencies and build ApiDOM inside the docker container:

bash
$ docker exec -it apidom-dev npm i --verbose
$ docker exec -it apidom-dev npm run build

Run npm scripts inside the docker container:

bash
$ docker exec -it apidom-dev npm run test

Note: monorepo needs to be build in order for monorepo package topology to work correctly.

Setting up via GitHub Codespaces

This repository is configured to work with GitHub Codespaces. Create a new codespace by picking this repository from the list of available repositories. Once the codespace is created, run following commands inside the codespace terminal:

bash
 $ npm i
 $ npm run build

npm scripts

Some npm scripts run in parallel. Default maximum parallelization is set 2. This is due to the fact that our CI runs on GitHub Actions which uses GitHub hosted runners with 2-core CPUs. If you have computer with more than 2 CPU cores, you can speed running npm scripts by creating an environment variable called CPU_CORES and assign it a number of your CPU cores.

Assuming 4 CPU cores are available:

bash
  $ export CPU_CORES=4
  $ npm run build

build scripts now runs much faster than before.

Build artifacts

bash
 $ npm run build

Test

You must first build the artifacts before running tests.

bash
 $ npm run test

Lint

bash
 $ npm run lint

Check TypeScript types

bash
 $ npm run typescript:check-types

Generate TypeScript types

bash
 $ npm run typescript:declaration

Clean

bash
 $ npm run clean

Build artifacts

All the packages have identical build system and expose build artifacts in identical way. After building artifacts, every package will contain five (5) additional directories. All the build artifacts are polymorphic - they can run in different environments like Web Browser, Node.js or Web Worker.

***.cjs**

These files are generated inside src/ directory. Contain ES5 compatible code with CommonJS style imports. These build fragments are ideal for legacy Node.js and similar environments.

***.mjs**

These files are generated inside src/ directory. Contain ES5 compatible code with ES6 imports. These build fragments are ideal for modern Node.js, bundling with Webpack or similar bundlers.

dist/

This directory contains bundled build fragments that use UMD modules. They're ideal for browser usage. The fragments are both in minified and un-minified form.

types/

TypeScript types generated from the source code.

Using this monorepo as a local dev dependency

For using this monorepo as a local dev dependency for dependent project, following commands needs to be issued inside the monorepo directory after it has been cloned to a local filesystem:

bash
 $ npm i
 $ npm run build
 $ npm run link

This will install the dependencies, built the monorepo and link all it's packages to global node_modules.

Usage in dependent project

Now that we have monorepo packages globally linked we can use them in dependent project. Let's say dependent project needs to directly use following packages:

  • @swagger-api/apidom-ast
  • @swagger-api/apidom-core

Issuing following command from inside the dependent project will link these packages:

bash
 $ npm link @swagger-api/apidom-ast @swagger-api/apidom-core

If more packages (or all of them) need to be used in dependent project, they need to be explicitly enumerated using above command and separated by single empty space.

Notice that we link packages using single npm link command. This is necessary because of how npm link works internally. Always use single npm link command with multiple package names as argument.

Don't ever do this!

bash
 $ npm link @swagger-api/apidom-ast
 $ npm link @swagger-api/apidom-core

Setting up npm script in dependent project can help keep things DRY.

Cleaning up

Dependent project

The best way to unlink monorepo packages from dependent project is to run following command inside the dependent project:

bash
 $ npm i

Running npm i will remove the links to monorepo packages and install the packages from npm registry.

Note: running npm unlink in dependent project will remove the link to monorepo package, but will leave the dependent project node_modules in corrupted state as there is no version of the package installed anymore. Running npm i is always a prefered way to restore your node_modules to original state.

ApiDOM monorepo

It is not necessary to unlink monorepo packages from global node_modules. But if you want to keep your global node_modules tidy you can run the following command in monorepo directory:

bash
 $ npm run unlink

Running above npm script will unlink all monorepo packages from global node_modules.

If you want to just unlink particular monorepo packages, you have to enumerate them explicitly:

bash
 $ npm unlink --global @swagger-api/apidom-ast @swagger-api/apidom-core

Contributing

This project uses swagger-api GitHub organizations contributing guide. You can obtain copy of this contributing guide at https://github.com/swagger-api/.github/blob/master/CONTRIBUTING.md. Read our contributing guide to learn about our development process, how to propose bugfixes and improvements, and how to build and test your changes to ApiDOM.

Documentation

If there is one thing API description languages have taught us, it is that a single contract provides the best and fastest way to design and iterate on an API. Developers building the API can move independently as they progress towards the defined contract found in the OpenAPI or RAML document. Conversely, API consumers can build tools for consuming the API based on the API definition document.

This same pattern has proven to be just as valuable for building API description languages and tooling. ApiDOM is the contract for producing and consuming the many API description languages and serialization formats and allows everyone to move quickly and independently.

What is an Element ?

ApiDOM is made up of many small elements that have a rich semantic meaning given their value and context. An element is an individual piece that makes up an API, and can range from defining a resource to providing an example of an HTTP request.

The ApiDOM defines elements to be used for:

Describing an API Describing data structures used within that API Describing parse results when parsing API-related documents These elements also seek to provide a way to decouple APIs and their semantics from the implementation details.

The structure of an ApiDOM is recursive by nature. When looking for specific elements, it is best to traverse the ApiDOM tree to look for a match. Querying the ApiDOM tree will decouple our code from specific API description language. Also, it decouples our code from the specific structure of these documents as long as they are semantically equivalent.

As a way to annotate JSON

ApiDOM provides the ability to take a normal JSON structure and add a layer on top of it for the purpose of annotating and adding semantic data. Instead of creating an entirely different st

Issues· 14 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

TypeScriptastasyncapihacktoberfestjavascript

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 18, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言