JSON::Schema::Modern::Document::OpenAPI - One OpenAPI v3.1 document
version 0.012
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', );
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/latest (an alias for the latest document available)
https://spec.openapis.org/oas/3.1/schema-base/latest
and the OpenAPI v3.1 specification.
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:
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).
The URI of the schema that describes the OpenAPI document itself. Defaults to https://spec.openapis.org/oas/3.1/schema-base/latest (an alias for the latest document available).
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).
jsonSchemaDialect
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).
JSON::Schema::Modern/add_vocabulary
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.
json_schema_dialect
metaschema_uri
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.
operationId
$document->get(..)
undef
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.
irc.perl.org
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.
Karen Etheridge <ether@cpan.org>
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.
To install JSON::Schema::Modern::Document::OpenAPI, copy and paste the appropriate command in to your terminal.
cpanm
cpanm JSON::Schema::Modern::Document::OpenAPI
CPAN shell
perl -MCPAN -e shell install JSON::Schema::Modern::Document::OpenAPI
For more information on module installation, please visit the detailed CPAN module installation guide.