forked from loafle/openapi-generator-original
Removed endpoint API class documentation code
- there is no standard way for a swagger spec to define descriptive information for an endpoint API - added markdown as a format to the autodoc script - added some version information to autogenerated docs
This commit is contained in:
@@ -33,11 +33,6 @@ use WWW::SwaggerClient::Configuration;
|
||||
use base "Class::Data::Inheritable";
|
||||
|
||||
__PACKAGE__->mk_classdata('method_documentation' => {});
|
||||
__PACKAGE__->mk_classdata('class_documentation' => {});
|
||||
|
||||
__PACKAGE__->class_documentation({description => '', # TODO
|
||||
class => 'PetApi',
|
||||
} );
|
||||
|
||||
sub new {
|
||||
my $class = shift;
|
||||
|
||||
@@ -10,25 +10,39 @@ use WWW::SwaggerClient::ApiFactory;
|
||||
has base_url => ( is => 'ro',
|
||||
required => 0,
|
||||
isa => 'Str',
|
||||
documentation => 'Root of the server that requests are sent to',
|
||||
);
|
||||
|
||||
has api_factory => ( is => 'ro',
|
||||
isa => 'WWW::SwaggerClient::ApiFactory',
|
||||
builder => '_build_af',
|
||||
lazy => 1,
|
||||
documentation => 'Builds an instance of the endpoint API class',
|
||||
);
|
||||
|
||||
has tokens => ( is => 'ro',
|
||||
isa => 'HashRef',
|
||||
required => 0,
|
||||
default => sub {{}}, # !
|
||||
default => sub { {} },
|
||||
documentation => 'The auth tokens required by the application - basic, OAuth and/or API key(s)',
|
||||
);
|
||||
|
||||
has _cfg => ( is => 'ro',
|
||||
isa => 'Str',
|
||||
default => 'WWW::SwaggerClient::Configuration',
|
||||
);
|
||||
|
||||
|
||||
has version_info => ( is => 'ro',
|
||||
isa => 'HashRef',
|
||||
default => sub { {
|
||||
app_name => 'Swagger Petstore',
|
||||
app_version => '1.0.0',
|
||||
generated_date => '2015-11-13T18:23:57.025Z',
|
||||
generator_class => 'class io.swagger.codegen.languages.PerlClientCodegen',
|
||||
} },
|
||||
documentation => 'Information about the application version and the codegen codebase version'
|
||||
);
|
||||
|
||||
sub BUILD {
|
||||
my $self = shift;
|
||||
|
||||
@@ -66,7 +80,6 @@ sub BUILD {
|
||||
default => sub {$self->api_factory->get_api($api_name)},
|
||||
lazy => 1,
|
||||
handles => \@delegated,
|
||||
documentation => $api_class->class_documentation->{description}, # not populated yet
|
||||
) );
|
||||
}
|
||||
}
|
||||
@@ -80,7 +93,23 @@ sub _build_af {
|
||||
|
||||
=head1 NAME
|
||||
|
||||
WWW::SwaggerClient::Role - a Moose role for the Perl Swagger Codegen project
|
||||
WWW::SwaggerClient::Role - a Moose role for the Swagger Petstore
|
||||
|
||||
=head2 Swagger Petstore version: 1.0.0
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
Automatically generated by the Perl Swagger Codegen project:
|
||||
|
||||
=over 4
|
||||
|
||||
=item Build date: 2015-11-13T18:23:57.025Z
|
||||
|
||||
=item Build package: class io.swagger.codegen.languages.PerlClientCodegen
|
||||
|
||||
=item Codegen version:
|
||||
|
||||
=back
|
||||
|
||||
=head2 A note on Moose
|
||||
|
||||
@@ -268,12 +297,13 @@ output formats are supported:
|
||||
-n narrow format
|
||||
-p POD format
|
||||
-H HTML format
|
||||
-m Markdown format
|
||||
-h print this help message
|
||||
-c your application class
|
||||
|
||||
The C<-c> option allows you to load and inspect your own application. A dummy
|
||||
namespace is used if you don't supply your own class.
|
||||
|
||||
|
||||
=head1 DOCUMENTATION FROM THE SWAGGER SPEC
|
||||
|
||||
Additional documentation for each class and method may be provided by the Swagger
|
||||
|
||||
@@ -28,11 +28,16 @@ sub _printisa {
|
||||
my $sub = join ', ', $meta->subclasses;
|
||||
my $dsub = join ', ', $meta->direct_subclasses;
|
||||
|
||||
my $app_name = $self->version_info->{app_name};
|
||||
my $app_version = $self->version_info->{app_version};
|
||||
my $generated_date = $self->version_info->{generated_date};
|
||||
my $generator_class = $self->version_info->{generator_class};
|
||||
|
||||
$~ = $how eq 'pod' ? 'INHERIT_POD' : 'INHERIT';
|
||||
write;
|
||||
|
||||
my ($rolepkg, $role_reqs);
|
||||
|
||||
$~ = $how eq 'pod' ? 'INHERIT_POD' : 'INHERIT';
|
||||
write;
|
||||
|
||||
foreach my $role (@roles) {
|
||||
$rolepkg = $role->{package} || next; # some are anonymous, or something
|
||||
next if $rolepkg eq 'WWW::SwaggerClient::Role::AutoDoc';
|
||||
@@ -58,6 +63,14 @@ $myclass
|
||||
$dsub
|
||||
All subclasses: @*
|
||||
$sub
|
||||
|
||||
Target API: @* @*
|
||||
$app_name, $app_version
|
||||
Generated on: @*
|
||||
$generated_date
|
||||
Generator class: @*
|
||||
$generator_class
|
||||
|
||||
.
|
||||
format ROLES =
|
||||
Composes: ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ~
|
||||
@@ -74,6 +87,26 @@ $myclass
|
||||
@*
|
||||
$myclass
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
=head2 @* version: @*
|
||||
$app_name, $app_version
|
||||
|
||||
Automatically generated by the Perl Swagger Codegen project:
|
||||
|
||||
=over 4
|
||||
|
||||
=item Build date: @*
|
||||
$generated_date
|
||||
|
||||
=item Build package: @*
|
||||
$generator_class
|
||||
|
||||
=item Codegen version:
|
||||
|
||||
|
||||
=back
|
||||
|
||||
=head1 INHERITANCE
|
||||
|
||||
=head2 Base class(es)
|
||||
@@ -90,6 +123,7 @@ $dsub
|
||||
|
||||
@*
|
||||
$sub
|
||||
|
||||
|
||||
=head1 COMPOSITION
|
||||
|
||||
@@ -171,6 +205,9 @@ sub _printmethod {
|
||||
$original_pkg = $on;
|
||||
$doc = $original_pkg->method_documentation->{$delegate_to}->{summary};
|
||||
}
|
||||
else {
|
||||
$doc = $method->documentation;
|
||||
}
|
||||
|
||||
if ($how eq 'narrow') {
|
||||
$~ = 'METHOD_NARROW';
|
||||
@@ -302,7 +339,7 @@ sub _printattr {
|
||||
my $from = $attr->associated_class->name || '';
|
||||
my $reqd = $attr->is_required ? 'yes' : 'no';
|
||||
my $lazy = $attr->is_lazy ? 'yes' : 'no';
|
||||
my $has_doc = $attr->has_documentation ? 'yes' : 'no';
|
||||
my $has_doc = $attr->has_documentation ? 'yes' : 'no'; # *_api attributes will never have doc, but other attributes might have
|
||||
my $doc = $attr->documentation || '';
|
||||
my $handles = join ', ', sort @{$attr->handles || []};
|
||||
$handles ||= '';
|
||||
|
||||
@@ -33,11 +33,6 @@ use WWW::SwaggerClient::Configuration;
|
||||
use base "Class::Data::Inheritable";
|
||||
|
||||
__PACKAGE__->mk_classdata('method_documentation' => {});
|
||||
__PACKAGE__->mk_classdata('class_documentation' => {});
|
||||
|
||||
__PACKAGE__->class_documentation({description => '', # TODO
|
||||
class => 'StoreApi',
|
||||
} );
|
||||
|
||||
sub new {
|
||||
my $class = shift;
|
||||
|
||||
@@ -33,11 +33,6 @@ use WWW::SwaggerClient::Configuration;
|
||||
use base "Class::Data::Inheritable";
|
||||
|
||||
__PACKAGE__->mk_classdata('method_documentation' => {});
|
||||
__PACKAGE__->mk_classdata('class_documentation' => {});
|
||||
|
||||
__PACKAGE__->class_documentation({description => '', # TODO
|
||||
class => 'UserApi',
|
||||
} );
|
||||
|
||||
sub new {
|
||||
my $class = shift;
|
||||
|
||||
Reference in New Issue
Block a user