.\" Automatically generated by Pod::Man 4.10 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "JSON::Validator::OpenAPI 3pm" .TH JSON::Validator::OpenAPI 3pm "2018-11-17" "perl v5.28.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" JSON::Validator::OpenAPI \- OpenAPI is both a subset and superset of JSON Schema .SH "DESCRIPTION" .IX Header "DESCRIPTION" JSON::Validator::OpenAPI can validate Open \s-1API\s0 (also known as \*(L"Swagger\*(R") requests and responses that is passed through a Mojolicious powered web application. .PP Currently v2 should be fully supported, while v3 should be considered higly \&\s-1EXPERIMENTAL.\s0 .PP Please report in issues or open pull requests to enhance the 3.0 support. .PP See also Mojolicious::Plugin::OpenAPI for more details about how to use this module. .SH "ATTRIBUTES" .IX Header "ATTRIBUTES" JSON::Validator::OpenAPI inherits all attributes from JSON::Validator. .SS "formats" .IX Subsection "formats" Open \s-1API\s0 support the same formats as JSON::Validator, but adds the following to the set: .IP "\(bu" 4 byte .Sp A padded, base64\-encoded string of bytes, encoded with a \s-1URL\s0 and filename safe alphabet. Defined by \s-1RFC4648.\s0 .IP "\(bu" 4 date .Sp An \s-1RFC3339\s0 date in the format YYYY-MM-DD .IP "\(bu" 4 double .Sp Cannot test double values with higher precision then what the \*(L"number\*(R" type already provides. .IP "\(bu" 4 float .Sp Will always be true if the input is a number, meaning there is no difference between \*(L"float\*(R" and \*(L"double\*(R". Patches are welcome. .IP "\(bu" 4 int32 .Sp A signed 32 bit integer. .IP "\(bu" 4 int64 .Sp A signed 64 bit integer. Note: This check is only available if Perl is compiled to use 64 bit integers. .SS "version" .IX Subsection "version" .Vb 1 \& $str = $self\->version; .Ve .PP Used to get the OpenAPI Schema version to use. Will be set automatically when using \*(L"load_and_validate_schema\*(R", unless already set. Supported values are \&\*(L"2\*(R" an \*(L"3\*(R". .SH "METHODS" .IX Header "METHODS" JSON::Validator::OpenAPI inherits all attributes from JSON::Validator. .SS "load_and_validate_schema" .IX Subsection "load_and_validate_schema" .Vb 1 \& $self = $self\->load_and_validate_schema($schema, \e%args); .Ve .PP Will load and validate \f(CW$schema\fR against the OpenAPI specification. \f(CW$schema\fR can be anything \*(L"schema\*(R" in JSON::Validator accepts. The expanded specification will be stored in \*(L"schema\*(R" in JSON::Validator on success. See \&\*(L"schema\*(R" in JSON::Validator for the different version of \f(CW$url\fR that can be accepted. .PP \&\f(CW%args\fR can be used to further instruct the expansion and validation process: .IP "\(bu" 2 allow_invalid_ref .Sp Setting this to a true value, will disable the first pass. This is useful if you don't like the restrictions set by OpenAPI, regarding where you can use \&\f(CW$ref\fR in your specification. .IP "\(bu" 2 version_from_class .Sp Setting this to a module/class name will use the version number from the class and overwrite the version in the specification: .Sp .Vb 5 \& { \& "info": { \& "version": "1.00" // <\-\- this value \& } \& } .Ve .PP The validation is done with a two pass process: .IP "1." 2 First it will check if the \f(CW$ref\fR is only specified on the correct places. This can be disabled by setting \*(L"allow_invalid_ref\*(R" to a true value. .IP "2." 2 Validate the expanded version of the spec, (without any \f(CW$ref\fR) against the OpenAPI schema. .SS "validate_input" .IX Subsection "validate_input" .Vb 1 \& @errors = $self\->validate_input($data, $schema); .Ve .PP This method will make sure \*(L"readOnly\*(R" is taken into account, when validating data sent to your \s-1API.\s0 .SS "validate_request" .IX Subsection "validate_request" .Vb 1 \& @errors = $self\->validate_request($c, $schema, \e%input); .Ve .PP Takes an Mojolicious::Controller and a schema definition and returns a list of errors, if any. Validated input parameters are moved into the \f(CW%input\fR hash. .SS "validate_response" .IX Subsection "validate_response" .Vb 1 \& @errors = $self\->validate_response($c, $schema, $status, $data); .Ve .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" Copyright (C) 2014\-2015, Jan Henning Thorsen .PP This program is free software, you can redistribute it and/or modify it under the terms of the Artistic License version 2.0. .SH "SEE ALSO" .IX Header "SEE ALSO" JSON::Validator. .PP