mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-11-28 06:23:48 +00:00
122 lines
3.7 KiB
Plaintext
122 lines
3.7 KiB
Plaintext
#
|
|
# Copyright 2015 Reverb Technologies, Inc.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
#
|
|
#
|
|
# NOTE: This class is auto generated by the swagger code generator program.
|
|
# Do not edit the class manually.
|
|
#
|
|
|
|
require 5.6.0;
|
|
use strict;
|
|
use warnings;
|
|
|
|
#use WWW::Swagger::Model::Category;
|
|
#use WWW::Swagger::Model::Pet;
|
|
|
|
{{#operations}}
|
|
package WWW::Swagger::{{classname}};
|
|
|
|
our $VERSION = '2.09';
|
|
|
|
|
|
sub new {
|
|
my $class = shift;
|
|
my $options = shift;
|
|
|
|
croak("You must supply an API client")
|
|
unless $options->{api_client};
|
|
|
|
my $self = {
|
|
api_client => $options->{api_client}
|
|
};
|
|
|
|
bless $self, $class;
|
|
|
|
}
|
|
|
|
{{#operation}}
|
|
#
|
|
# {{{nickname}}}
|
|
#
|
|
# {{{summary}}}
|
|
#
|
|
{{#allParams}} # @param {{dataType}} ${{paramName}} {{description}} {{^optional}}(required){{/optional}}{{#optional}}(optional){{/optional}}
|
|
{{/allParams}} # @return {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}
|
|
#
|
|
sub {{nickname}} {
|
|
my $self = shift;
|
|
my %args = @_;
|
|
|
|
# parse inputs
|
|
my $resource_path = "{{path}}";
|
|
$resource_path =~ s/{format}/json/;
|
|
|
|
my $method = "{{httpMethod}}";
|
|
my $query_params = {};
|
|
my $header_params = {};
|
|
my $form_params = {};
|
|
|
|
$header_params->{'Accept'} = '{{#produces}}{{mediaType}}{{#hasMore}},{{/hasMore}}{{/produces}}';
|
|
$header_params->{'Content-Type'} = '{{#consumes}}{{mediaType}}{{#hasMore}},{{/hasMore}}{{/consumes}}';
|
|
|
|
{{#queryParams}} # query params
|
|
if($args{ {{paramName}} }) {
|
|
$query_params->{'{{baseName}}'} = $self->api_client->to_query_value($args{ {{paramName}} });
|
|
}{{/queryParams}}
|
|
{{#headerParams}} # header params
|
|
if($args{ {{paramName}} }) {
|
|
$header_params->{'{{baseName}}'} = $self->apiClient->to_header_value($args{ {{paramName}} });
|
|
}{{/headerParams}}
|
|
{{#pathParams}} # path params
|
|
if( $args{ {{paramName}} }) {
|
|
my $base_variable = "{" + "{{baseName}}" + "}";
|
|
my $base_value = $self->api_client->to_path_value($args{ {{paramName}} });
|
|
$resource_path = s/$base_variable/$base_value/;
|
|
}{{/pathParams}}
|
|
{{#formParams}} # form params
|
|
if ($args{ {{paramName}} }) {
|
|
$form_params->{'{{baseName}}'} = {{#isFile}}'@' . {{/isFile}}$self->api_client->to_form_value($args{ {{paramName}} });
|
|
}{{/formParams}}
|
|
my $body;
|
|
{{#bodyParams}} # body params
|
|
if (isset(${{paramName}})) {
|
|
$body = ${{paramName}};
|
|
}{{/bodyParams}}
|
|
|
|
# for HTTP post (form)
|
|
$body = $body ? undef : $form_params;
|
|
|
|
if ($header_params->{'Content-Type'} eq "application/x-www-form-urlencoded") {
|
|
$body = http_build_query($body);
|
|
}
|
|
|
|
# make the API Call
|
|
my $response = $self->api_client->call_api($resource_path, $method,
|
|
$query_params, $body,
|
|
$header_params);
|
|
|
|
{{#returnType}}if(!$response) {
|
|
return;
|
|
}
|
|
|
|
my $response_object = $self->api_client->deserialize($response, '{{returnType}}');
|
|
return $response_object;{{/returnType}}
|
|
}
|
|
{{/operation}}
|
|
{{newline}}
|
|
{{/operations}}
|
|
|
|
1;
|