NAME
openapi-validate - A command-line interface to OpenAPI document validation
VERSION
version 0.116
SYNOPSIS
openapi-validate --help
openapi-validate \
[ --output-format <format> ] \
[ --strict ] \
[ --dump-identifiers ] \
[ --with-defaults ] \
[ <filename> ] [ ... ]
DESCRIPTION
A command-line interface to verify the correctness of an OpenAPI document.
openapi.yaml contains:
openapi: 3.2.0
$self: https://example.com/openapi.yaml
info:
title: my title
version: 1.2.3
paths:
/foo:
get: {}
/bar/{bar}:
post: {}
/bar/{baz}:
delete: {}
Run:
openapi-validate openapi.yaml
produces output:
{
"errors" : [
{
"error" : "duplicate of templated path \"/bar/{bar}\"",
"instanceLocation" : "",
"keywordLocation" : "/paths/~1bar~1{baz}"
}
],
"valid" : false
}
JSON documents are also supported, e.g.:
openapi-validate openapi.json
produces output for a valid document:
{
"valid": true
}
The exit value ($?) is 0 when the result is valid, 1 when it is invalid, and some other non-zero value if an exception occurred.
OPTIONS
The following options from JSON::Schema::Modern are available:
"output_format" in JSON::Schema::Modern: One of:
flag,basic,terse. Defaults tobasic."strict" in JSON::Schema::Modern: disallow unknown keywords in embedded JSON Schemas
"dump_identifiers" in JSON::Schema::Modern: print a list of all identifiers found in the schema
"with_defaults" in JSON::Schema::Modern: include list of defaults for missing data
The remainder of the command line arguments are used to provide the filename containing a JSON- or YAML-encoded OpenAPI document. You can use more than one filename to validate multiple documents at the same time, which is faster than using separate processes; each file is processed in order and made available to later documents, and the last file must be a valid OpenAPI document.
If the file looks like a JSON Schema rather than an OpenAPI document, it will be validated as such, and loaded into the evaluator so it can be used as a metaschema by your main document.
If you provide no filenames, STDIN is used as input, so you can pipe your content directly from another process.
GIVING THANKS
If you found this module to be useful, please show your appreciation by adding a +1 in MetaCPAN and a star in GitHub.
SUPPORT
Bugs may be submitted through https://github.com/karenetheridge/OpenAPI-Modern/issues.
I am also usually active on irc, as 'ether' at irc.perl.org and irc.libera.chat.
You can also find me on the JSON Schema Slack server and OpenAPI Slack server, which are also great resources for finding help.
AUTHOR
Karen Etheridge <ether@cpan.org>
COPYRIGHT AND LICENCE
This software is copyright (c) 2021 by Karen Etheridge.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
Some schema files have their own licence, in share/oas/LICENSE.