NAME

openapi-validate - A command-line interface to OpenAPI document validation

VERSION

version 0.112

SYNOPSIS

openapi-validate --help

openapi-validate \
  [ --strict ] \
  [ --dump-identifiers ] \
  [ --document [ <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 --document openapi.yaml

produces output:

{
  "errors" : [
    {
      "error" : "duplicate of templated path \"/bar/{bar}\"",
      "instanceLocation" : "",
      "keywordLocation" : "/paths/~1bar~1{baz}"
    }
  ],
  "valid" : false
}

Or run:

openapi-validate --document openapi.json

produces output:

{
  "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:

* "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

Additionally, --document is used to provide the filename containing a JSON- or YAML-encoded OpenAPI document. You can use the --document option more than once to validate multiple documents at the same time, which is faster than using separate processes.

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 --document is not provided, STDIN is used as input.

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.