Skip to content

Commit

Permalink
fix openapi version not validating
Browse files Browse the repository at this point in the history
This is a change for JSON::Validator 4.00 (I think). Fixes #111. Thanks
@eserte!
  • Loading branch information
preaction committed Jun 10, 2020
1 parent 8077199 commit a5dcbc8
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion dist.ini
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ Mojolicious::Plugin::OpenAPI = 2.12 ; fix the GET /api breakage
Mojolicious::Plugin::I18N = 1.6 ; Must be all-caps I18N!
Role::Tiny = 2.000001 ; Required for Mojolicious roles
Class::Method::Modifiers = 0 ; Required for around/before/after
JSON::Validator = 3.08
JSON::Validator = 4
Sys::Hostname = 0
File::Spec::Functions = 0
FindBin = 0
Expand Down
3 changes: 2 additions & 1 deletion eg/doc-site/myapp.pl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use Mojolicious::Lite;
use Mojo::SQLite;
use Mojo::JSON qw( true false );

plugin AutoReload => {};
plugin Config => { default => {} };
Expand All @@ -22,7 +23,7 @@
'x-view-item-url' => '/{path}',
properties => {
id => {
readOnly => 1,
readOnly => true,
},
markdown => {
format => 'markdown',
Expand Down
3 changes: 2 additions & 1 deletion eg/limited-editor/myapp.pl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use experimental qw( signatures postderef );
use Mojolicious::Lite;
use Mojo::SQLite;
use Mojo::JSON qw( true false );

helper sqlite => sub {
state $path = $ENV{TEST_YANCY_EXAMPLES} ? ':temp:' : app->home->child( 'data.db' );
Expand All @@ -19,7 +20,7 @@
title => 'Blog Posts',
properties => {
blog_post_id => {
readOnly => 1,
readOnly => true,
},
title => {
title => 'Title',
Expand Down
9 changes: 5 additions & 4 deletions eg/test-app/myapp.conf
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use Mojo::JSON qw( true false );
{
backend => 'test://localhost/yancy.data.json',
editor => { require_user => undef, },
Expand All @@ -17,7 +18,7 @@
properties => {
id => {
type => 'integer',
readOnly => 1,
readOnly => true,
},
title => {
'x-order' => 1,
Expand Down Expand Up @@ -59,7 +60,7 @@
id => {
title => 'ID',
type => 'integer',
readOnly => 1,
readOnly => true,
},
name => {
title => 'Name',
Expand Down Expand Up @@ -122,12 +123,12 @@
password => {
type => 'string',
format => 'password',
#writeOnly => 1,
#writeOnly => true,
},
created => {
type => 'string',
format => 'date-time',
readOnly => 1,
readOnly => true,
},
notes => {
type => [ 'string', 'null' ],
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojolicious/Plugin/Yancy.pm
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,7 @@ sub _build_validator {
# This fixes HTML forms submitting the string "20" not being
# detected as a number, or the number 1 not being detected as
# a boolean
coerce => { booleans => 1, numbers => 1 },
coerce => { booleans => 1, numbers => 1, strings => 1 },
);
my $formats = $v->formats;
$formats->{ password } = sub { undef };
Expand Down
2 changes: 1 addition & 1 deletion lib/Yancy/Plugin/Editor.pm
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ sub _openapi_spec_from_schema {
}

return {
info => $config->{info} || { title => $config->{title}, version => 1 },
info => $config->{info} || { title => $config->{title}, version => "1" },
swagger => '2.0',
host => $config->{host} // hostname(),
basePath => '/api',
Expand Down
3 changes: 2 additions & 1 deletion t/plugin/editor.t
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use FindBin qw( $Bin );
use Mojo::File qw( path );
use lib "".path( $Bin, '..', 'lib' );
use Local::Test qw( init_backend );
use Mojo::JSON qw( true false );
use Mojolicious;

local $ENV{MOJO_HOME} = path( $Bin, '..', 'share' );
Expand Down Expand Up @@ -54,7 +55,7 @@ subtest 'non-default backend' => sub {
properties => {
id => {
type => 'integer',
readOnly => 1,
readOnly => true,
},
name => {
type => 'string',
Expand Down

0 comments on commit a5dcbc8

Please sign in to comment.