NAME
OpenAPI::PerlGenerator::Template::Mojo - Mojolicious templates for OpenAPI clients
SYNOPSIS
# override the 'foo' template
$OpenAPI::PerlGenerator::Template::Mojo::template{'foo'} = <<__MY_TEMPLATE__;
bar
__MY_TEMPLATE__
NAME
<%= $prefix %>::<%= $name %> -
SYNOPSIS
my $obj = <%= $prefix %>::<%= $name %>->new();
...
PROPERTIES
% for my $t (@included_types) { % for my $prop (sort keys $t->{properties}->%*) { % my $p = $t->{properties}->{$prop}; =head2 <%= property_name( $prop ) %>
% if( $p->{description} and $p->{description} =~ /\S/ ) { <%= $p->{description} =~ s/\s*$//r %>
% }
SYNOPSIS
PROPERTIES
openapi
ua
server
METHODS
% for my $method ($methods->@*) { % my $elt = $method->{elt}; % my $is_streaming = exists $elt->{responses}->{200} % && $elt->{responses}->{200}->{content} % && [keys $elt->{responses}->{200}->{content}->%*]->[0] eq 'application/x-ndjson' % ; % %# Sort the parameters according to where they go % my %parameters; % if( my $p = $elt->{parameters}) { % for my $p ($elt->{parameters}->@*) { % $parameters{ $p->{in} } //= []; % push $parameters{ $p->{in} }->@*, $p; % } % } % =head2 <%= $method->{name} %>
%# Generate the example invocation % if( $is_streaming ) { use Future::Utils 'repeat'; my $responses = $client-><%= $method->{name} %>(); repeat { my ($res) = $responses->shift; if( $res ) { my $str = $res->get; say $str; }
Future::Mojo->done( defined $res );
} until => sub($done) { $done->get };
% } else {
my $res = $client-><%= $method->{name} %>()->get;
% }
% if( $elt->{summary} and $elt->{summary} =~ /\S/ ) { <%= markdown_to_pod( $elt->{summary} =~ s/\s*$//r ) %>
%} %# List/add the invocation parameters % my $parameters = $elt->{parameters}; % if( $parameters ) { # parameters =head3 Parameters
% for my $p ($parameters->@* ) { =item <%= $p->{name} %>
% if( $p->{description} =~ /\S/ ) { <%= markdown_to_pod( $p->{description} =~ s/\s*$//r ) %>
% } % if( $p->{default}) { Defaults to <%= $p->{default} =%>
% } % } =back
% } # parameters %# %# Add the body/schema parameters: % (my $ct) = exists $elt->{requestBody} ? keys $elt->{requestBody}->{content}->%* : (); % my $type; % if( $ct ) { % $type = $ct && $elt->{requestBody}->{content}->{$ct}->{schema}; % }; % if( $type ) { % my @properties = (sort keys $type->{properties}->%*); % if( @properties ) {
Options
% for my $prop (@properties) { % my $p = $type->{properties}->{$prop}; =item <%= property_name( $prop ) %>
% if( $p->{description} ) { <%= markdown_to_pod( $p->{description} =~ s/\s*$//r ) %>
% } % } =back % } % }
%=include('return_types', { prefix => $prefix, elt => $elt });
NAME
<%= $prefix %>::<%= $name %> - Client for <%= $prefix %>
SYNOPSIS
use 5.020;
use <%= $prefix %>::<%= $name %>;
my $client = <%= $prefix %>::<%= $name %>->new(
server => '<%= $schema->{servers}->[0]->{url} // "https://example.com/" %>',
);
my $res = $client->someMethod()->get;
say $res;
METHODS
% for my $method ($methods->@*) { % my $elt = $method->{elt}; =head2 <%= $method->{name} %>
my $res = $client-><%= $method->{name} %>()->get;
% if( $elt->{summary} and $elt->{summary} =~ /\S/ ) { <%= $elt->{summary} =~ s/\s*$//r; %>
%} %=include('return_types', { prefix => $prefix, elt => $elt });
REPOSITORY
The public repository of this module is https://github.com/Corion/OpenAPI-PerlGenerator.
SUPPORT
The public support forum of this module is https://perlmonks.org/.
BUG TRACKER
Please report bugs in this module via the Github bug queue at https://github.com/Corion/OpenAPI-PerlGenerator/issues
AUTHOR
Max Maischein corion@cpan.org
COPYRIGHT (c)
Copyright 2024- by Max Maischein corion@cpan.org
.
LICENSE
This module is released under the Artistic License 2.0.
2 POD Errors
The following errors were encountered while parsing the POD:
- Around line 533:
You forgot a '=back' before '=head3'
- Around line 602:
You forgot a '=back' before '=head1'