A flexible JSON/YAML linter for creating automated style guides, with baked in support for OpenAPI v2 & v3.

Related tags

JSON astrum
Overview

astrum

Astrum

A flexible JSON/YAML linter for creating automated style guides, with baked in support for OpenAPI v2 & v3.

OpenAPI is now a widely-adopted method for describing web APIs. With that fact comes the pressure to validate these specifications are up to date, accurately constructed, and presented for optimal developer usage.

Especially with the shift from OpenAPI v2 to v3, developers may require further assistance to ensure their specification matches the current v3 structure and format. Thankfully, Astrum allows developers to lint their API specification against OpenAPI v3 & v2 as well as best practices and custom rules.

🎁 Features

  • An easy to use customisable OpenAPI linter which performs linting based on the linting rules configured.
  • Supports OASv2.x and OASv3.0 Open API Specifications.
  • Supports both JSON and YAML formats.
  • Ready-to-use Functions: Built-in set of functions to help create custom rules.
  • Custom Functions: Create custom functions for advanced use cases.
  • Provides detailed information on the linting along with the line numbers at which the linting rules are applied on the open specification file.

Overview

⚙️ Architecture

Astrum is entirely built on Java and consists of three modules,

  • astrum-core
    • The module contains the core logic responsible for linting the OAS file.
  • astrum-api
    • Provides an Rest API to store the linting rules which will be used to lint the OAS specification.
  • astrum-cli
    • The astrum-cli can be used as a command-line interface which takes up a OAS specification file and runs linting rules on it.

Architecture

🪝 Usage

Pre-Requisite

  • JRE 11+ is required in the target machine. Steps to install

  • Install Maven

  • Checkout the astrum code from the repository to local machine

  • Build the astrum modules. Navigate to the folder, astrum and run the below command

    mvn clean install

This builds all the three modules of astrum in the target machine.

astrum-part1 astrum-part2

🧰 astrum-cli

Once the modules are built successfully, the astrum-cli component will be created as astrum-cli-0.0.1-SNAPSHOT.jar in the target directory. Go to the directory astrum-cli/target and run the below command to see the options supported by astrum-cli.

java -jar astrum-cli-0.0.1-SNAPSHOT.jar

This will output the parameters and options that are supported by astrum-cli like below.

-f, -sf, -swaggerFile= The OAS file to lint -h, --help Show this help message and exit.
-o, -output= The output file in which the linting report will be generated. -p, -prettyPrint The input OAS file will be pretty printed. This will allow to reference the line numbers of the
linting report. -r, -ruleFile= The custom rules file based on which the OAS file will be linted.
-skipLint The linting will be skipped and the input OAS file will be pretty printed in console.
-V, --version Print version information and exit.
The astrum-cli by default formats the input OAS specification file and writes it to the current path. This formatted file can be used to match the line numbers in the linting report.

Example Usages

  1. Using astrum-cli, lint a swagger specification and output the lint report to a output file using the default rules

    java -jar astrum-cli-0.0.1-SNAPSHOT.jar -swaggerFile={OASFilePath} -output={outputFilePath}/output.json

swaggerSpecificationFilePath: Location of OAS file in local Machine outputFilePath: Location of output file path which will contain the Linting results

  1. Using astrum-cli, lint a OAS specification and output the lint report to a output file using the custom rules

    java -jar astrum-cli-0.0.1-SNAPSHOT.jar -swaggerFile={OASFilePath} -output={outputFilePath}/output.json/output.json -r={customRuleFilePath}/rules.json

customRuleFilePath: Location of the rules file. Sample rule files can be found here

🔗 astrum-api

Pre-Requisite

  • JDK
  • MongoDB

MongoDB is used to store the rules created using the rest endpoints

Once the modules are built successfully, the astrum-api component will be created as 'astrum-api-0.0.1-SNAPSHOT.jar' in the target directory. Go to the directory astrum-api/target and run the below command to start up the API.

java -jar astrum-api-0.0.1-SNAPSHOT.jar
The API will be started in port 8080 and will expose the below endpoints to manage the rules.

Create Rule

POST /v1/astrum/rule
Update Rule
PUT /v1/astrum/rule

Delete Rule

DELETE /v1/astrum/rule/{ruleId}

Get Rule

GET /v1/astrum/rule/{ruleId}

Get All Rule

GET /v1/astrum/rule/

The lint endpoint is used to lint a swagger specification file and based on the managed rules

POST /v1/astrum/lint

The format endpoint is used to format the input swagger file to match with the line number generated in the linting report

POST /v1/astrum/format

✉️ astrum-core

The astrum-core module which contains the logic to lint the OAS specification has distributed as a maven dependency as well. We can use it in any of our JAVA projects which requires swagger linting.

<dependency>
  <groupId>io.apiwiz.astrum</groupId>
  <artifactId>astrum-core</artifactId>
  <version>0.1</version>
</dependency>

🤝 Support

If you need help using Astrum or have any questions, please use GitHub Discussions.

🪪 License

Astrum is 100% free and open-source, under Apache License 2.0.

You might also like...

Screaming fast JSON parsing and serialization library for Android.

Screaming fast JSON parsing and serialization library for Android.

#LoganSquare The fastest JSON parsing and serializing library available for Android. Based on Jackson's streaming API, LoganSquare is able to consiste

Dec 18, 2022

A modern JSON library for Kotlin and Java.

Moshi Moshi is a modern JSON library for Android and Java. It makes it easy to parse JSON into Java objects: String json = ...; Moshi moshi = new Mos

Dec 31, 2022

A fast JSON parser/generator for Java.

A fast JSON parser/generator for Java.

fastjson Fastjson is a Java library that can be used to convert Java Objects into their JSON representation. It can also be used to convert a JSON str

Dec 31, 2022

JSON query and transformation language

JSLT JSLT is a complete query and transformation language for JSON. The language design is inspired by jq, XPath, and XQuery. JSLT can be used as: a q

Dec 30, 2022

Sawmill is a JSON transformation Java library

Sawmill is a JSON transformation Java library

Update: June 25, 2020 The 2.0 release of Sawmill introduces a breaking change to the GeoIpProcessor to comply with the updated license of the MaxMind

Jan 1, 2023

Compare JSON in your Unit Tests

JsonUnit JsonUnit is a library that simplifies JSON comparison in tests. APIs AssertJ integration Hamcrest matchers Spring MVC assertions Spring WebTe

Dec 29, 2022

Genson a fast & modular Java Json library

Genson Genson is a complete json - java conversion library, providing full databinding, streaming and much more. Gensons main strengths? Easy to use

Jan 3, 2023

A reference implementation of a JSON package in Java.

JSON in Java [package org.json] Click here if you just want the latest release jar file. Overview JSON is a light-weight language-independent data int

Jan 6, 2023

Fast JSON parser for java projects

ig-json-parser Fast JSON parser for java projects. Getting started The easiest way to get started is to look at maven-example. For more comprehensive

Dec 26, 2022
Owner
Apiwiz
API Lifecycle Management engineered for better Productivity.
Apiwiz
MapNeat is a JVM library written in Kotlin that provides an easy to use DSL (Domain Specific Language) for transforming JSON to JSON, XML to JSON, POJO to JSON in a declarative way.

MapNeat is a JVM library written in Kotlin that provides an easy to use DSL (Domain Specific Language) for transforming JSON to JSON, XML to JSON, POJ

Andrei Ciobanu 59 Sep 17, 2022
Uber-project for (some) standard Jackson textual format backends: csv, properties, yaml (xml to be added in future)

Overview This is a multi-module umbrella project for Jackson standard text-format dataformat backends. Dataformat backends are used to support format

FasterXML, LLC 351 Dec 22, 2022
JSON to JSON transformation library written in Java.

Jolt JSON to JSON transformation library written in Java where the "specification" for the transform is itself a JSON document. Useful For Transformin

Bazaarvoice 1.3k Dec 30, 2022
Generate Java types from JSON or JSON Schema and annotates those types for data-binding with Jackson, Gson, etc

jsonschema2pojo jsonschema2pojo generates Java types from JSON Schema (or example JSON) and can annotate those types for data-binding with Jackson 2.x

Joe Littlejohn 5.9k Jan 5, 2023
Essential-json - JSON without fuss

Essential JSON Essential JSON Rationale Description Usage Inclusion in your project Parsing JSON Rendering JSON Building JSON Converting to JSON Refer

Claude Brisson 1 Nov 9, 2021
A simple java JSON deserializer that can convert a JSON into a java object in an easy way

JSavON A simple java JSON deserializer that can convert a JSON into a java object in an easy way. This library also provide a strong object convertion

null 0 Mar 18, 2022
A 250 lines single-source-file hackable JSON deserializer for the JVM. Reinventing the JSON wheel.

JSON Wheel Have you ever written scripts in Java 11+ and needed to operate on some JSON string? Have you ever needed to extract just that one deeply-n

Roman Böhm 14 Jan 4, 2023
High performance JVM JSON library

DSL-JSON library Fastest JVM (Java/Android/Scala/Kotlin) JSON library with advanced compile-time databinding support. Compatible with DSL Platform. Ja

New Generation Software Ltd 835 Jan 2, 2023
A Java serialization/deserialization library to convert Java Objects into JSON and back

Gson Gson is a Java library that can be used to convert Java Objects into their JSON representation. It can also be used to convert a JSON string to a

Google 21.7k Jan 8, 2023
High-performance JSON parser

HikariJSON A High-performance JSON parser. HikariJSON is targeted exclusively at Java 8. If you need legacy support, there are several decent librarie

Brett Wooldridge 454 Dec 31, 2022