1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
use Mojo::Base -strict;
use JSON::Validator::Schema::OpenAPIv2;
use JSON::Validator::Util qw(str2data);
use Mojo::Loader qw(data_section);
use Test::Deep;
use Test::More;
my $cwd = Mojo::File->new(__FILE__)->dirname;
my $schema = JSON::Validator::Schema::OpenAPIv2->new($cwd->child(qw(spec v2-bundle.yaml)));
is_deeply $schema->errors, [], 'schema errors' or diag explain $schema->errors;
my $bundle = $schema->bundle;
is_deeply $bundle->errors, [], 'bundle errors' or diag explain $bundle->errors;
my $from_data = JSON::Validator::Schema::OpenAPIv2->new($bundle->data);
is_deeply $from_data->errors, [], 'from_data errors' or diag explain $from_data->errors;
is_deeply $from_data->data, str2data(data_section(qw(main exp.yaml))), 'from_data schema'
or diag explain $from_data->data;
done_testing;
__DATA__
@@ exp.yaml
---
swagger: "2.0"
info:
title: Bundled
version: "1.0"
basePath: /api
paths:
/user:
get:
parameters:
- $ref: "#/parameters/paths_yaml-parameters_id"
responses:
200:
description: A user
schema:
$ref: "#/x-def/User"
x-def:
User:
properties:
name:
type: string
parameters:
paths_yaml-parameters_id:
in: path
name: id
required: true
type: string
|