NAME
JSON::Schema::Modern::Document::OpenAPI - One OpenAPI v3.1 document
VERSION
version 0.009
SYNOPSIS
use JSON::Schema::Modern;
use JSON::Schema::Modern::Document::OpenAPI;
my $js = JSON::Schema::Modern->new;
my $openapi_document = JSON::Schema::Modern::Document::OpenAPI->new(
evaluator => $js,
canonical_uri => 'https://example.com/v1/api',
schema => $schema,
metaschema_uri => 'https://example.com/my_custom_dialect',
);
DESCRIPTION
Provides structured parsing of an OpenAPI document, suitable as the base for more tooling such as request and response validation, code generation or form generation.
The provided document must be a valid OpenAPI document, as specified by the schema identified by https://spec.openapis.org/oas/3.1/schema-base/2021-09-28
(the latest document available) and the OpenAPI v3.1 specification.
ATTRIBUTES
These values are all passed as arguments to the constructor.
This class inherits all options from JSON::Schema::Modern::Document and implements the following new ones:
evaluator
A JSON::Schema::Modern object. Unlike in the parent class, this is REQUIRED, because loaded vocabularies, metaschemas and resource identifiers must be stored here as they are discovered in the OpenAPI document. This is the object that will be used for subsequent evaluation of data against schemas in the document, either manually or perhaps via a web framework plugin (coming soon).
metaschema_uri
The URI of the schema that describes the OpenAPI document itself. Defaults to https://spec.openapis.org/oas/3.1/schema-base/2021-09-28
(the latest document available).
json_schema_dialect
The URI of the metaschema to use for all embedded JSON Schemas in the document.
Overrides the value of jsonSchemaDialect
in the document, or the specification default (https://spec.openapis.org/oas/3.1/dialect/base
).
If you specify your own dialect here or in jsonSchemaDialect
, then you need to add the vocabularies and schemas to the implementation yourself. (see JSON::Schema::Modern/add_vocabulary
and JSON::Schema::Modern/add_schema
).
Note this is NOT the same as "metaschema_uri" in JSON::Schema::Modern::Document, which contains the URI describing the entire document (and is not a metaschema in this case, as the entire document is not a JSON Schema). Note that you may need to explicitly set that attribute as well if you change json_schema_dialect
, as the default metaschema used by the default metaschema_uri
can no longer be assumed.
METHODS
get_operationId
Returns the json pointer location of the operation containing the provided operationId
(suitable for passing to $document->get(..)
), or undef
if it is not contained in the document.
SUPPORT
Bugs may be submitted through https://github.com/karenetheridge/JSON-Schema-Modern-Document-OpenAPI/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.