khrt / Raisin

Raisin - a REST API micro framework for Perl 🐫 🐪
62 stars 31 forks source link

Tags created with <null> description in swagger file #51

Closed beccon4 closed 6 years ago

beccon4 commented 6 years ago

Raisin automatically creates tags for route parameters and subsequent resources. Unfortunately the swagger file comes out with an empty description - or null which causes an error in the Swagger editor:

This code:

use strict;
use warnings;
use Carp;

use HTTP::Status qw(:constants);

use Data::Dumper;
use Raisin::API;
use Types::Standard qw(HashRef Any Int Str);

plugin 'Logger', fallback => 1;
app->log(debug => 'Start');
api_format 'json';

middleware 'CrossOrigin',
    origins => q(*),
    methods => [qw/DELETE GET HEAD OPTIONS PATCH POST PUT/],
    headers => [qw/accept authorization content-type api_key_token/];
plugin 'Swagger';

swagger_setup(
    title       => 'Test Raisin Api',
    description => 'TestRaisin',
    contact     => {
        name  => 'Conrad Beckert',
        url   => 'http://beccon.de',
        email => 'info@beccon.de',
    },

    license => {
        name => 'Testmich - darf alles',
        url  => 'http://www.testmich.de',
    },
);

desc 'Users API';

resource cm => sub {
    summary 'cm sub';

    params requires('mac', type => Str);
    route_param mac => sub {
        desc 'route param desc';
        summary 'route param summary';
        resource 'foo' => sub {

            desc "foo desc";
            get sub {
                desc "foo get desc";
                my $params = shift;
                my $mac    = $params->{mac};

                res->status(HTTP_OK);
                return { hallo => $mac };
            };
            }
    };

    };

    run;

__END__

produces:

`tags:

Which the Swagger Editor marks as error.