JSON::Schema::Modern::Document::OpenAPI - One OpenAPI v3.1 document


version 0.059


  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 => '',
    schema => $schema,
    metaschema_uri => '',


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 (an alias for the latest document available)

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 (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 (

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.



Returns the json pointer location of the operation containing the provided operationId (suitable for passing to $document->get(..)), or undef if the location does not exist in the document.



Bugs may be submitted through

I am also usually active on irc, as 'ether' at and

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


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.