go-asyncapi-validator

module
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 20, 2023 License: MIT

README

Go AsyncAPI Validator CLI

A simple cli-tool to validate JSON against a provided AsyncAPI spec using JSONPath. Currently it supports AsyncAPI V2.0.0

Installation

  1. Clone the repository:
git clone https://github.com/max-weis/go-asyncapi-validator.git
  1. Navigate to the cloned repository:
cd go-asyncapi-validator
  1. Build the CLI tool:
go build -o aa-validator
  1. Move the binary to a directory in your PATH if desired:
sudo mv aa-validator /usr/local/bin/

After these steps, you should see an executable named validator on your system.

Usage

To use the CLI tool, you need to provide three arguments:

  • spec: Path to the AsyncAPI specification file.
  • json: Path to the JSON file that you want to validate against the spec.
  • jsonpath: The JSONPath expression which points to the location of the schema inside the spec.

Here's the general usage:

aa-validator -spec [PATH_TO_SPEC] -json [PATH_TO_JSON] -jsonpath [JSONPATH_EXPRESSION]
Example:

To run the example project, just run:

aa-validator -spec ./examples/spec.json -json ./examples/example.json -jsonpath $.channels.personUpdates.subscribe.message.payload

If the provided JSON is valid against the given schema, the tool will output:

the provided JSON is valid

Otherwise, it will print validation errors.

Directories

Path Synopsis
cmd
validator command
pkg
validator
TODO: add dereferencing functionality
TODO: add dereferencing functionality

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL