This project is a library (Java and JavaScript compatible) to implement data models for OpenAPI and AsyncAPI.
You can use this library to read an OpenAPI or AsyncAPI document, resulting in an instance of a data model. The data model can then be read or manipulated. It can also be validated.
The data model can be accessed directly, but there is also a robust visitor pattern available for more advanced analysis or transformation of the model.
This project is licensed under the Apache License 2.0.
For details on how to use the library, see the documentation included with the library on npmjs.com:
https://www.npmjs.com/package/apicurio-data-models
This documentation can also be found in this repository here:
The primary goal of this project is to be the official library to perform operations on OpenAPI and AsyncAPI documents. Both for the purpose of analyzing/processing (including validation) a document as well as making changes to it.
The library should be usable as broadly as possible, both as a dependency of other Java, Typescript or Javascript projects, as well as usable in a Java, Node.js, or browser based application.
Some example usage scenarios for this library include:
- An editor which can be used to create new documents (or modify existing ones).
- Auto-generate documentation from a document.
- Transform documents into other versions/formats.
- Auto-generate API clients.
An important design decision is that this project does not have any runtime dependencies. This means that you can use the library directly without including any other libraries. It also means you can use the project as a dependency in your projects without worrying about conflicts or dependency bloat.
Currently, the data model fully supports the following formats:
- OpenAPI 2.0
- OpenAPI 3.0.x
- AsyncAPI 2.0.0
Barring oversights or bugs, the full OpenAPI/AsyncAPI document can be read and written successfully. In addition, the visitor pattern has been fully implemented (along with both up and down traversing).
Validation of the OpenAPI/AsyncAPI specification exists, with all of the rules outlined in the spec having been implemented.
Please refer to the github repository's Issues and other resources for more information on the current status of the project.
One of the design goals of this library is to simultaneously support multiple versions of the OpenAPI specification. At the time of this writing, there are two versions of the OpenAPI specification:
Both of these versions are supported by the library. As new versions of the specification are released, the library will be updated to include support for them.
As of the time of this writing, the AsyncAPI specification is in the process of releasing version 2.0.0. This will be the first version of AsyncAPI supported by this library. As other versions are released, the library will be updated to support them. There are currently no plans to support older versions.
This section explains how to build, package, test, and publish the library. If you are a developer looking to make changes, this is a great place to start.
In order to build the library you will need to install the following tools:
- Java 8 (versions of Java greater than 8 can be used when running the library, but not for building it)
- Maven 3.5+
- Node.js 8.11+
- Yarn 1.15+
The first thing to do (obviously) is clone the repository. Once you've cloned the git repository, you can use maven to build the library into its two forms: a Java JAR and a javascript library module. This library is written using Java, but is then transpiled from Java into Typescript using jsweet and then compiled and bundled using typescript and rollup. All of this is done as part of the standard maven build process:
git clone https://github.com/Apicurio/apicurio-data-models.git
cd apicurio-data-models
mvn clean package -Ptranspilation
All testing is integrated into the maven build, so the standard mvn clean package -Ptranspilation
will also execute
all unit tests. If the maven build succeeds, then you know everything worked!
This project is open source, and we welcome anybody who wants to participate and contribute!
The easiest way to get started with the code is to create your own fork of this repository, and then clone your fork:
$ git clone [email protected]:<you>/apicurio-data-models.git
$ cd apicurio-data-models
$ git remote add upstream git://github.com/Apicurio/apicurio-data-models.git
At any time, you can pull changes from the upstream and merge them onto your master:
$ git checkout master # switches to the 'master' branch
$ git pull upstream master # fetches all 'upstream' changes and merges 'upstream/master' onto your 'master' branch
$ git push origin # pushes all the updates to your fork, which should be in-sync with 'upstream'
The general idea is to keep your 'master' branch in-sync with the 'upstream/master'.
If you want to fix a bug or make any changes, please log an issue in the github Issue Tracker describing the bug or new feature. Then we highly recommend making the changes on a topic branch named with the issue number. For example, this command creates a branch for issue #7:
$ git checkout -b apicurio-data-models-7
After you're happy with your changes and all unit tests run successfully, commit your changes on your topic branch. Then it's time to check for and pull any recent changes that were made in the official repository since you created your branch:
$ git checkout master # switches to the 'master' branch
$ git pull upstream master # fetches all 'upstream' changes and merges 'upstream/master' onto your 'master' branch
$ git checkout apicurio-data-models-7 # switches to your topic branch
$ git rebase master # reapplies your changes on top of the latest in master
# (i.e., the latest from master will be the new base for your changes)
If the pull grabbed a lot of changes, you should rerun the tests to make sure your changes are still good. You should then push your changes to your fork, and then generate a pull-request to submit your contribution:
$ git push origin apicurio-data-models-7 # pushes your topic branch into your public fork