This project refers to the OpenAPI Specification project from the OpenAPI initiative.
The Reedelk OpenAPI v3.x serializer/deserializer library is a lightweight library to serialize/deserialize OpenAPI v3.x model to/from JSON and to/from YAML.
The library uses only JSON-java (org.json) and SnakeYAML as dependencies making it the perfect choice if you are just looking for a very lightweight solution to serialize/deserialize OpenAPI v3.x definitions.
- Serialize OpenAPI v3.x model to JSON
- Serialize OpenAPI v3.x model to YAML
- Deserialize OpenAPI v3.x model from JSON
- Deserialize OpenAPI v3.x model from YAML
Add the Reedelk Repository to your pom.xml:
<repositories>
<repository>
<id>reedelk-repository</id>
<name>Reedelk Repository</name>
<url>http://repository.reedelk.com/release/</url>
</repository>
</repositories>
Add the following dependency to your pom.xml file:
<dependency>
<groupId>com.reedelk</groupId>
<artifactId>reedelk-openapi</artifactId>
<version>X.Y.Z</version>
</dependency>
InfoObject infoModel = new InfoObject();
infoModel.setDescription("This is a sample API.");
infoModel.setVersion("1.0.2");
OpenApiObject openApiModel = new OpenApiObject();
openApiModel.setInfo(info);
// to JSON string
String openApiAsJson = OpenApi.toJson(openApiModel);
// to YAML string
String openApiAsYaml = OpenApi.toYaml(openApiModel);
// from JSON string
String openApiAsJson = "{"openapi": "3.0.3","info": {"title": "API","version": "v1" }}";
OpenApiObject openApiModel = OpenApi.from(openApiAsJson);
InfoObject infoModel = actual.getInfo();
...
// from YAML string
String openApiAsYaml = "openapi: 3.0.0
info:
version: 1.0.2
title: Petstore API";
OpenApiObject openApiModel = OpenApi.from(openApiAsYaml);
InfoObject infoModel = actual.getInfo();
...
- If you find a bug in Reedelk OpenAPI, please file a bug report.
- If you want to discuss Reedelk OpenAPI, suggest new features, you have issues getting started with the library or just say 'Hi', let us know in the Reedelk Slack Developers Community .