| 1 | 1 | ▶ | use Moose::Util::TypeConstraints; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||
| 3 | coerce 'Swagger::Schema::Parameter', | ||||||||||||||||||||||||||||||||
| 4 | from 'HashRef', | ||||||||||||||||||||||||||||||||
| 5 | 14 | ▶ | via { | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||
| 6 | 14 | ▶ | if (exists $_->{ in } and $_->{ in } eq 'body') { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%3/3
exists $_->{"in"} and $_->{"in"} eq "body"
MC/DC100%2/2
exists $_->{"in"} and $_->{"in"} eq "body"
exists $_->{"in"}
$_->{"in"} eq "body"
Truth table100%3/3
A and B
A= exists $_->{"in"}B= $_->{"in"} eq "body"
| |||||||||||||||||||||||||||||||||
| 7 | 1 | return Swagger::Schema::BodyParameter->new($_); | |||||||||||||||||||||||||||||||
| 8 | } elsif ($_->{ '$ref' }) { | ||||||||||||||||||||||||||||||||
| 9 | 7 | return Swagger::Schema::RefParameter->new($_); | |||||||||||||||||||||||||||||||
| 10 | } else { | ||||||||||||||||||||||||||||||||
| 11 | 6 | return Swagger::Schema::OtherParameter->new($_); | |||||||||||||||||||||||||||||||
| 12 | } | ||||||||||||||||||||||||||||||||
| 13 | 1 | }; | |||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||
| 15 | 1 | package Swagger::Schema { | |||||||||||||||||||||||||||||||
| 16 | 1 | our $VERSION = '1.04'; | |||||||||||||||||||||||||||||||
| 17 | #ABSTRACT: Object model for Swagger schema files | ||||||||||||||||||||||||||||||||
| 18 | 1 | ▶ | use MooseX::DataModel; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 19 | 1 | ▶ | use Moose::Util::TypeConstraints; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 20 | 1 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||
| 22 | 1 | key swagger => (isa => enum([ '2.0' ]), required => 1); | |||||||||||||||||||||||||||||||
| 23 | 1 | key info => (isa => 'Swagger::Schema::Info', required => 1); | |||||||||||||||||||||||||||||||
| 24 | 1 | key host => (isa => 'Str'); #MAY contain a port | |||||||||||||||||||||||||||||||
| 25 | 2 | ▶ | key basePath => (isa => subtype(as 'Str', where { $_ =~ /^\// })); | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 26 | 1 | array schemes => (isa => enum([ 'http', 'https', 'ws', 'wss'])); | |||||||||||||||||||||||||||||||
| 27 | 1 | array consumes => (isa => 'Str'); #Str must be mime type: https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#mimeTypes | |||||||||||||||||||||||||||||||
| 28 | 1 | array produces => (isa => 'Str'); | |||||||||||||||||||||||||||||||
| 29 | 1 | object paths => (isa => 'Swagger::Schema::Path', required => 1); | |||||||||||||||||||||||||||||||
| 30 | 1 | object definitions => (isa => 'Swagger::Schema::Schema'); | |||||||||||||||||||||||||||||||
| 31 | 1 | object parameters => (isa => 'Swagger::Schema::Parameter'); | |||||||||||||||||||||||||||||||
| 32 | 1 | object responses => (isa => 'Swagger::Schema::Response'); | |||||||||||||||||||||||||||||||
| 33 | 1 | object securityDefinitions => (isa => 'Swagger::Schema::SecurityScheme'); | |||||||||||||||||||||||||||||||
| 34 | # The below declaration is declared as Any, because there is no way to represent | ||||||||||||||||||||||||||||||||
| 35 | # any array of hashrefs of strings | ||||||||||||||||||||||||||||||||
| 36 | #array security => (isa => 'Swagger::Schema::SecurityRequirement'); | ||||||||||||||||||||||||||||||||
| 37 | 1 | array security => (isa => 'Any'); | |||||||||||||||||||||||||||||||
| 38 | 1 | array tags => (isa => 'Swagger::Schema::Tag'); | |||||||||||||||||||||||||||||||
| 39 | 1 | key externalDocs => (isa => 'Swagger::Schema::ExternalDocumentation'); | |||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||
| 42 | 1 | package Swagger::Schema::SecurityScheme { | |||||||||||||||||||||||||||||||
| 43 | 1 | ▶ | use MooseX::DataModel; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 44 | 1 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||
| 48 | #package Swagger::Schema::SecurityRequirement { | ||||||||||||||||||||||||||||||||
| 49 | # use MooseX::DataModel; | ||||||||||||||||||||||||||||||||
| 50 | # | ||||||||||||||||||||||||||||||||
| 51 | # # See the security attribute in Swagger::Schema | ||||||||||||||||||||||||||||||||
| 52 | # # this object is more like a plain hashref | ||||||||||||||||||||||||||||||||
| 53 | # # it only has a patterned field {name}, which holds an array of strings | ||||||||||||||||||||||||||||||||
| 54 | # | ||||||||||||||||||||||||||||||||
| 55 | # no MooseX::DataModel; | ||||||||||||||||||||||||||||||||
| 56 | #} | ||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||
| 58 | 1 | package Swagger::Schema::Path { | |||||||||||||||||||||||||||||||
| 59 | 1 | ▶ | use MooseX::DataModel; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 60 | 1 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||
| 62 | 1 | key get => (isa => 'Swagger::Schema::Operation'); | |||||||||||||||||||||||||||||||
| 63 | 1 | key put => (isa => 'Swagger::Schema::Operation'); | |||||||||||||||||||||||||||||||
| 64 | 1 | key post => (isa => 'Swagger::Schema::Operation'); | |||||||||||||||||||||||||||||||
| 65 | 1 | key delete => (isa => 'Swagger::Schema::Operation'); | |||||||||||||||||||||||||||||||
| 66 | 1 | key options => (isa => 'Swagger::Schema::Operation'); | |||||||||||||||||||||||||||||||
| 67 | 1 | key head => (isa => 'Swagger::Schema::Operation'); | |||||||||||||||||||||||||||||||
| 68 | 1 | key patch => (isa => 'Swagger::Schema::Operation'); | |||||||||||||||||||||||||||||||
| 69 | 1 | array parameters => (isa => 'Swagger::Schema::Parameter'); | |||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||
| 72 | 1 | package Swagger::Schema::Tag { | |||||||||||||||||||||||||||||||
| 73 | 1 | ▶ | use MooseX::DataModel; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 74 | 1 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||
| 76 | 1 | key name => (isa => 'Str'); | |||||||||||||||||||||||||||||||
| 77 | 1 | key description => (isa => 'Str'); | |||||||||||||||||||||||||||||||
| 78 | 1 | key externalDocs => (isa => 'Swagger::Schema::ExternalDocumentation'); | |||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||
| 81 | 1 | enum 'Swagger::Schema::ParameterTypes', | |||||||||||||||||||||||||||||||
| 82 | [qw/string number integer boolean array file object/]; | ||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||
| 84 | 1 | package Swagger::Schema::Schema { | |||||||||||||||||||||||||||||||
| 85 | 1 | ▶ | use MooseX::DataModel; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 86 | 1 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||
| 88 | 1 | key ref => (isa => 'Str', location => '$ref'); | |||||||||||||||||||||||||||||||
| 89 | 1 | key x_ms_client_flatten => (isa => 'Bool', location => 'x-ms-client-flatten'); | |||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||
| 91 | 1 | key type => (isa => 'Swagger::Schema::ParameterTypes'); | |||||||||||||||||||||||||||||||
| 92 | 1 | key format => (isa => 'Str'); | |||||||||||||||||||||||||||||||
| 93 | 1 | key allowEmptyValue => (isa => 'Bool'); | |||||||||||||||||||||||||||||||
| 94 | 1 | key collectionFormat => (isa => 'Str'); | |||||||||||||||||||||||||||||||
| 95 | 1 | key default => (isa => 'Any'); | |||||||||||||||||||||||||||||||
| 96 | 1 | key maximum => (isa => 'Int'); | |||||||||||||||||||||||||||||||
| 97 | 1 | key exclusiveMaximum => (isa => 'Bool'); | |||||||||||||||||||||||||||||||
| 98 | 1 | key minimum => (isa => 'Int'); | |||||||||||||||||||||||||||||||
| 99 | 1 | key exclusiveMinumum => (isa => 'Bool'); | |||||||||||||||||||||||||||||||
| 100 | 1 | key maxLength => (isa => 'Int'); | |||||||||||||||||||||||||||||||
| 101 | 1 | key minLength => (isa => 'Int'); | |||||||||||||||||||||||||||||||
| 102 | 1 | key pattern => (isa => 'Str'); | |||||||||||||||||||||||||||||||
| 103 | 1 | key maxItems => (isa => 'Int'); | |||||||||||||||||||||||||||||||
| 104 | 1 | key minItems => (isa => 'Int'); | |||||||||||||||||||||||||||||||
| 105 | 1 | key uniqueItems => (isa => 'Bool'); | |||||||||||||||||||||||||||||||
| 106 | 1 | array enum => (isa => 'Any'); | |||||||||||||||||||||||||||||||
| 107 | 1 | key multipleOf => (isa => 'Num'); | |||||||||||||||||||||||||||||||
| 108 | #x-^ patterned fields | ||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||
| 110 | 1 | key items => (isa => 'Swagger::Schema::Schema'); | |||||||||||||||||||||||||||||||
| 111 | 1 | array allOf => (isa => 'Swagger::Schema::Schema'); | |||||||||||||||||||||||||||||||
| 112 | 1 | object properties => (isa => 'Swagger::Schema::Schema'); | |||||||||||||||||||||||||||||||
| 113 | 1 | key additionalProperties => (isa => 'Swagger::Schema::Schema'); | |||||||||||||||||||||||||||||||
| 114 | 1 | key readOnly => (isa => 'Bool'); | |||||||||||||||||||||||||||||||
| 115 | #key xml => (isa => 'Swagger::Schema::XML'); | ||||||||||||||||||||||||||||||||
| 116 | 1 | key externalDocs => (isa => 'Swagger::Schema::ExternalDocumentation'); | |||||||||||||||||||||||||||||||
| 117 | 1 | key example => (isa => 'Any'); | |||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||
| 120 | 1 | package Swagger::Schema::Parameter { | |||||||||||||||||||||||||||||||
| 121 | 1 | ▶ | use MooseX::DataModel; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 122 | 1 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||
| 124 | 1 | key name => (isa => 'Str'); | |||||||||||||||||||||||||||||||
| 125 | 1 | key in => (isa => 'Str'); | |||||||||||||||||||||||||||||||
| 126 | 1 | key description => (isa => 'Str'); | |||||||||||||||||||||||||||||||
| 127 | 1 | key required => (isa => 'Bool'); | |||||||||||||||||||||||||||||||
| 128 | 1 | key x_ms_client_flatten => (isa => 'Bool', location => 'x-ms-client-flatten'); | |||||||||||||||||||||||||||||||
| 129 | 1 | key x_ms_skip_url_encoding => (isa => 'Bool', location => 'x-ms-skip-url-encoding'); | |||||||||||||||||||||||||||||||
| 130 | 1 | key x_ms_enum => (isa => 'Swagger::Schema::MSX::Enum', location => 'x-ms-enum'); | |||||||||||||||||||||||||||||||
| 131 | 1 | key x_ms_parameter_grouping => (isa => 'Swagger::Schema::MSX::ParameterGrouping', location => 'x-ms-parameter-grouping'); | |||||||||||||||||||||||||||||||
| 132 | 1 | key x_ms_client_request_id => (isa => 'Bool', location => 'x-ms-client-request-id'); | |||||||||||||||||||||||||||||||
| 133 | 1 | key x_ms_client_name => (isa => 'Str', location => 'x-ms-client-name'); | |||||||||||||||||||||||||||||||
| 134 | 1 | key x_ms_parameter_location => (isa => 'Str', location => 'x-ms-parameter-location'); | |||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||
| 137 | 1 | package Swagger::Schema::MSX::ParameterGrouping { | |||||||||||||||||||||||||||||||
| 138 | 1 | ▶ | use MooseX::DataModel; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 139 | 1 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||
| 141 | 1 | key name => (isa => 'Str'); | |||||||||||||||||||||||||||||||
| 142 | 1 | key postfix => (isa => 'Str'); | |||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||
| 145 | 1 | package Swagger::Schema::MSX::Enum { | |||||||||||||||||||||||||||||||
| 146 | 1 | ▶ | use MooseX::DataModel; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 147 | 1 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||
| 149 | 1 | key name => (isa => 'Str'); | |||||||||||||||||||||||||||||||
| 150 | 1 | key modelAsString => (isa => 'Bool'); | |||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||
| 153 | 1 | package Swagger::Schema::RefParameter { | |||||||||||||||||||||||||||||||
| 154 | 1 | ▶ | use MooseX::DataModel; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 155 | 1 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||
| 157 | 1 | extends 'Swagger::Schema::Parameter'; | |||||||||||||||||||||||||||||||
| 158 | 1 | key ref => (isa => 'Str', location => '$ref'); | |||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||
| 161 | 1 | package Swagger::Schema::BodyParameter { | |||||||||||||||||||||||||||||||
| 162 | 1 | ▶ | use MooseX::DataModel; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 163 | 1 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||
| 165 | 1 | extends 'Swagger::Schema::Parameter'; | |||||||||||||||||||||||||||||||
| 166 | 1 | key schema => (isa => 'Swagger::Schema::Schema', required => 1); | |||||||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||
| 169 | 1 | package Swagger::Schema::OtherParameter { | |||||||||||||||||||||||||||||||
| 170 | 1 | ▶ | use MooseX::DataModel; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 171 | 1 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||
| 173 | 1 | extends 'Swagger::Schema::Parameter'; | |||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||
| 175 | 1 | key type => (isa => 'Swagger::Schema::ParameterTypes', required => 1); | |||||||||||||||||||||||||||||||
| 176 | 1 | key format => (isa => 'Str'); | |||||||||||||||||||||||||||||||
| 177 | 1 | key allowEmptyValue => (isa => 'Bool'); | |||||||||||||||||||||||||||||||
| 178 | 1 | object items => (isa => 'Any'); | |||||||||||||||||||||||||||||||
| 179 | 1 | key collectionFormat => (isa => 'Str'); | |||||||||||||||||||||||||||||||
| 180 | 1 | key default => (isa => 'Any'); | |||||||||||||||||||||||||||||||
| 181 | 1 | key maximum => (isa => 'Int'); | |||||||||||||||||||||||||||||||
| 182 | 1 | key exclusiveMaximum => (isa => 'Bool'); | |||||||||||||||||||||||||||||||
| 183 | 1 | key minimum => (isa => 'Int'); | |||||||||||||||||||||||||||||||
| 184 | 1 | key exclusiveMinumum => (isa => 'Bool'); | |||||||||||||||||||||||||||||||
| 185 | 1 | key maxLength => (isa => 'Int'); | |||||||||||||||||||||||||||||||
| 186 | 1 | key minLength => (isa => 'Int'); | |||||||||||||||||||||||||||||||
| 187 | 1 | key pattern => (isa => 'Str'); | |||||||||||||||||||||||||||||||
| 188 | 1 | key maxItems => (isa => 'Int'); | |||||||||||||||||||||||||||||||
| 189 | 1 | key minItems => (isa => 'Int'); | |||||||||||||||||||||||||||||||
| 190 | 1 | key uniqueItems => (isa => 'Bool'); | |||||||||||||||||||||||||||||||
| 191 | 1 | array enum => (isa => 'Any'); | |||||||||||||||||||||||||||||||
| 192 | 1 | key multipleOf => (isa => 'Num'); | |||||||||||||||||||||||||||||||
| 193 | #x-^ patterned fields | ||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||
| 196 | 1 | enum 'Swagger::Schema::CollectionFormat', | |||||||||||||||||||||||||||||||
| 197 | [qw/csv ssv tsv pipes/]; | ||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||
| 199 | 1 | package Swagger::Schema::Item { | |||||||||||||||||||||||||||||||
| 200 | 1 | ▶ | use MooseX::DataModel; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 201 | 1 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||
| 203 | 1 | key type => (isa => 'Swagger::Schema::ParameterTypes', required => 1); | |||||||||||||||||||||||||||||||
| 204 | 1 | key format => (isa => 'Str'); | |||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||
| 206 | 1 | array items => (isa => 'Swagger::Schema::Item'); | |||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||
| 208 | 1 | key collectionFormat => (isa => 'Swagger::Schema::CollectionFormat'); | |||||||||||||||||||||||||||||||
| 209 | 1 | key default => (isa => 'Any'); | |||||||||||||||||||||||||||||||
| 210 | 1 | key maximum => (isa => 'Num'); | |||||||||||||||||||||||||||||||
| 211 | 1 | key exclusiveMaximum => (isa => 'Bool'); | |||||||||||||||||||||||||||||||
| 212 | 1 | key minimum => (isa => 'Num'); | |||||||||||||||||||||||||||||||
| 213 | 1 | key exclusiveMinimum => (isa => 'Bool'); | |||||||||||||||||||||||||||||||
| 214 | 1 | key maxLength => (isa => 'Int'); | |||||||||||||||||||||||||||||||
| 215 | 1 | key minLength => (isa => 'Int'); | |||||||||||||||||||||||||||||||
| 216 | 1 | key pattern => (isa => 'Str'); | |||||||||||||||||||||||||||||||
| 217 | 1 | key maxItems => (isa => 'Int'); | |||||||||||||||||||||||||||||||
| 218 | 1 | key minItems => (isa => 'Int'); | |||||||||||||||||||||||||||||||
| 219 | 1 | key uniqueItems => (isa => 'Bool'); | |||||||||||||||||||||||||||||||
| 220 | 1 | array enum => (isa => 'Any'); | |||||||||||||||||||||||||||||||
| 221 | 1 | key multipleOf => (isa => 'Num'); | |||||||||||||||||||||||||||||||
| 222 | #x-^ patterned fields | ||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||
| 225 | 1 | package Swagger::Schema::Operation { | |||||||||||||||||||||||||||||||
| 226 | 1 | ▶ | use MooseX::DataModel; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 227 | 1 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||
| 229 | 1 | array tags => (isa => 'Str'); | |||||||||||||||||||||||||||||||
| 230 | 1 | key summary => (isa => 'Str'); | |||||||||||||||||||||||||||||||
| 231 | 1 | key description => (isa => 'Str'); | |||||||||||||||||||||||||||||||
| 232 | 1 | key externalDocs => (isa => 'Swagger::Schema::ExternalDocumentation'); | |||||||||||||||||||||||||||||||
| 233 | 1 | key operationId => (isa => 'Str'); | |||||||||||||||||||||||||||||||
| 234 | 1 | array consumes => (isa => 'Str'); #Must be a Mime Type | |||||||||||||||||||||||||||||||
| 235 | 1 | array produces => (isa => 'Str'); #Must be a Mime Type | |||||||||||||||||||||||||||||||
| 236 | 1 | array parameters => (isa => 'Swagger::Schema::Parameter'); | |||||||||||||||||||||||||||||||
| 237 | 1 | object responses => (isa => 'Swagger::Schema::Response'); | |||||||||||||||||||||||||||||||
| 238 | 1 | array schemes => (isa => 'Str'); | |||||||||||||||||||||||||||||||
| 239 | 1 | key deprecated => (isa => 'Bool'); | |||||||||||||||||||||||||||||||
| 240 | 1 | key x_ms_long_running_operation => (isa => 'Bool', location => 'x-ms-long-running-operation'); | |||||||||||||||||||||||||||||||
| 241 | #key security => (isa => | ||||||||||||||||||||||||||||||||
| 242 | #TODO: x-^ fields | ||||||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||
| 245 | 1 | package Swagger::Schema::Response { | |||||||||||||||||||||||||||||||
| 246 | 1 | ▶ | use MooseX::DataModel; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 247 | 1 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||
| 249 | 1 | key description => (isa => 'Str'); | |||||||||||||||||||||||||||||||
| 250 | 1 | key schema => (isa => 'Swagger::Schema::Parameter'); | |||||||||||||||||||||||||||||||
| 251 | 1 | object headers => (isa => 'Swagger::Schema::Header'); | |||||||||||||||||||||||||||||||
| 252 | #key examples => (isa => ''); | ||||||||||||||||||||||||||||||||
| 253 | #TODO: patterned fields | ||||||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||
| 256 | 1 | package Swagger::Schema::Header { | |||||||||||||||||||||||||||||||
| 257 | 1 | ▶ | use MooseX::DataModel; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 258 | 1 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||
| 260 | 1 | key description => (isa => 'Str'); | |||||||||||||||||||||||||||||||
| 261 | 1 | key type => (isa => 'Str', required => 1); | |||||||||||||||||||||||||||||||
| 262 | 1 | key format => (isa => 'Str'); | |||||||||||||||||||||||||||||||
| 263 | 1 | object items => (isa => 'HashRef'); | |||||||||||||||||||||||||||||||
| 264 | 1 | key collectionFormat => (isa => 'Str'); | |||||||||||||||||||||||||||||||
| 265 | 1 | key default => (isa => 'Any'); | |||||||||||||||||||||||||||||||
| 266 | 1 | key maximum => (isa => 'Int'); | |||||||||||||||||||||||||||||||
| 267 | 1 | key exclusiveMaximum => (isa => 'Bool'); | |||||||||||||||||||||||||||||||
| 268 | 1 | key minimum => (isa => 'Int'); | |||||||||||||||||||||||||||||||
| 269 | 1 | key exclusiveMinumum => (isa => 'Bool'); | |||||||||||||||||||||||||||||||
| 270 | 1 | key maxLength => (isa => 'Int'); | |||||||||||||||||||||||||||||||
| 271 | 1 | key minLength => (isa => 'Int'); | |||||||||||||||||||||||||||||||
| 272 | 1 | key pattern => (isa => 'Str'); | |||||||||||||||||||||||||||||||
| 273 | 1 | key maxItems => (isa => 'Int'); | |||||||||||||||||||||||||||||||
| 274 | 1 | key minItems => (isa => 'Int'); | |||||||||||||||||||||||||||||||
| 275 | 1 | key uniqueItems => (isa => 'Bool'); | |||||||||||||||||||||||||||||||
| 276 | 1 | array enum => (isa => 'Any'); | |||||||||||||||||||||||||||||||
| 277 | 1 | key multipleOf => (isa => 'Num'); | |||||||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||
| 280 | 1 | package Swagger::Schema::ExternalDocumentation { | |||||||||||||||||||||||||||||||
| 281 | 1 | ▶ | use MooseX::DataModel; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 282 | 1 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||
| 284 | 1 | key description => (isa => 'Str'); | |||||||||||||||||||||||||||||||
| 285 | 1 | key url => (isa => 'Str', required => 1); #Must be in the format of a URL | |||||||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||
| 288 | 1 | package Swagger::Schema::Info { | |||||||||||||||||||||||||||||||
| 289 | 1 | ▶ | use MooseX::DataModel; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 290 | 1 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||
| 292 | 1 | key title => (isa => 'Str', required => 1); | |||||||||||||||||||||||||||||||
| 293 | 1 | key description => (isa => 'Str'); #Can contain GFM | |||||||||||||||||||||||||||||||
| 294 | 1 | key termsOfService => (isa => 'Str'); | |||||||||||||||||||||||||||||||
| 295 | 1 | key contact => (isa => 'Swagger::Schema::Contact'); | |||||||||||||||||||||||||||||||
| 296 | 1 | key license => (isa => 'Swagger::Schema::License'); | |||||||||||||||||||||||||||||||
| 297 | 1 | key version => (isa => 'Str', required => 1); | |||||||||||||||||||||||||||||||
| 298 | #TODO: x-^ extensions | ||||||||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||
| 301 | 1 | package Swagger::Schema::License { | |||||||||||||||||||||||||||||||
| 302 | 1 | ▶ | use MooseX::DataModel; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 303 | 1 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||
| 305 | 1 | key name => (isa => 'Str', required => 1); | |||||||||||||||||||||||||||||||
| 306 | 1 | key url => (isa => 'Str'); #Must be in the format of a URL | |||||||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||
| 309 | 1 | package Swagger::Schema::Contact { | |||||||||||||||||||||||||||||||
| 310 | 1 | ▶ | use MooseX::DataModel; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 311 | 1 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||
| 313 | 1 | key name => (isa => 'Str'); | |||||||||||||||||||||||||||||||
| 314 | 1 | key url => (isa => 'Str'); | |||||||||||||||||||||||||||||||
| 315 | 1 | key email => (isa => 'Str'); | |||||||||||||||||||||||||||||||
| 316 | } | ||||||||||||||||||||||||||||||||
| 317 | ### main pod documentation begin ### | ||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||
| 319 | =encoding UTF-8 | ||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||
| 321 | =head1 NAME | ||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||
| 323 | Swagger::Schema - Object access to Swagger / OpenAPI schema files | ||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||
| 325 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||
| 327 | use File::Slurp; | ||||||||||||||||||||||||||||||||
| 328 | my $data = read_file($swagger_file); | ||||||||||||||||||||||||||||||||
| 329 | my $schema = Swagger::Schema->MooseX::DataModel::new_from_json($data); | ||||||||||||||||||||||||||||||||
| 330 | # use the object model | ||||||||||||||||||||||||||||||||
| 331 | say "This API consists of:"; | ||||||||||||||||||||||||||||||||
| 332 | foreach my $path (sort keys %{ $schema->paths }){ | ||||||||||||||||||||||||||||||||
| 333 | foreach my $http_verb (sort keys %{ $schema->paths->{ $path } }) { | ||||||||||||||||||||||||||||||||
| 334 | say "$http_verb on $path"; | ||||||||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||
| 338 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||
| 340 | Get programmatic access to a Swagger / OpenAPI file (version 2). | ||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||
| 342 | If you're looking for OpenAPI 3 support, take a look at: L<Swagger::Schema::V3> | ||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||
| 344 | =head1 OBJECT MODEL | ||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||
| 346 | The object model is defined with L<MooseX::DataModel>. Take a look at the | ||||||||||||||||||||||||||||||||
| 347 | C<lib/Swagger/Schema.pm> file or the swagger spec | ||||||||||||||||||||||||||||||||
| 348 | L<https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md> | ||||||||||||||||||||||||||||||||
| 349 | to know what you can find inside the objects | ||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||
| 351 | =head1 SEE ALSO | ||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||
| 353 | L<https://github.com/OAI/OpenAPI-Specification> | ||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||
| 355 | L<http://swagger.io> | ||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||
| 357 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||
| 359 | Jose Luis Martinez | ||||||||||||||||||||||||||||||||
| 360 | CAPSiDE | ||||||||||||||||||||||||||||||||
| 361 | jlmartinez@capside.com | ||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||
| 363 | =head1 THANKS | ||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||
| 365 | Andrew Solomon for contributions to the V3 Swagger code | ||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||
| 367 | =head1 BUGS and SOURCE | ||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||
| 369 | The source code is located here: https://github.com/pplu/swagger-schema-perl | ||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||
| 371 | Please report bugs to: https://github.com/pplu/swagger-schema-perl/issues | ||||||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||||||
| 373 | =head1 COPYRIGHT and LICENSE | ||||||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||||||
| 375 | Copyright (c) 2015 by CAPSiDE | ||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||
| 377 | This code is distributed under the Apache 2 License. The full text of the | ||||||||||||||||||||||||||||||||
| 378 | license can be found in the LICENSE file included with this module. | ||||||||||||||||||||||||||||||||