From 4d19fb6b2ff04f810de84ce672ba13069e68cbea Mon Sep 17 00:00:00 2001 From: wing328 Date: Sat, 21 Jan 2017 19:12:51 +0800 Subject: [PATCH] hide generation timestamp for perl (#4614) --- bin/perl-petstore.sh | 2 +- .../io/swagger/codegen/CodegenConstants.java | 3 +- .../codegen/languages/PerlClientCodegen.java | 15 +- .../src/main/resources/perl/README.mustache | 116 +++++----- .../src/main/resources/perl/Role.mustache | 150 +++++++------ .../options/PerlClientOptionsProvider.java | 1 + samples/client/petstore/perl/README.md | 126 ++++++----- .../petstore/perl/docs/Capitalization.md | 20 ++ .../client/petstore/perl/docs/ClassModel.md | 15 ++ samples/client/petstore/perl/docs/EnumTest.md | 1 + samples/client/petstore/perl/docs/FakeApi.md | 8 +- .../client/petstore/perl/docs/OuterEnum.md | 14 ++ .../perl/lib/WWW/SwaggerClient/FakeApi.pm | 4 +- .../SwaggerClient/Object/Capitalization.pm | 210 ++++++++++++++++++ .../WWW/SwaggerClient/Object/ClassModel.pm | 165 ++++++++++++++ .../lib/WWW/SwaggerClient/Object/EnumTest.pm | 13 +- .../lib/WWW/SwaggerClient/Object/OuterEnum.pm | 158 +++++++++++++ .../perl/lib/WWW/SwaggerClient/Role.pm | 154 +++++++------ .../perl/t/ArrayOfArrayOfNumberOnlyTest.t | 33 +++ .../petstore/perl/t/ArrayOfNumberOnlyTest.t | 33 +++ .../petstore/perl/t/CapitalizationTest.t | 33 +++ .../client/petstore/perl/t/ClassModelTest.t | 33 +++ samples/client/petstore/perl/t/ClientTest.t | 33 +++ .../client/petstore/perl/t/EnumArraysTest.t | 33 +++ samples/client/petstore/perl/t/FakeApiTest.t | 77 +++++++ .../petstore/perl/t/HasOnlyReadOnlyTest.t | 33 +++ samples/client/petstore/perl/t/ListTest.t | 33 +++ samples/client/petstore/perl/t/MapTestTest.t | 33 +++ .../client/petstore/perl/t/NumberOnlyTest.t | 33 +++ .../client/petstore/perl/t/OuterEnumTest.t | 33 +++ samples/client/petstore/perl/t/PetApiTest.t | 102 +++++++++ samples/client/petstore/perl/t/StoreApiTest.t | 64 ++++++ samples/client/petstore/perl/t/UserApiTest.t | 98 ++++++++ 33 files changed, 1598 insertions(+), 281 deletions(-) create mode 100644 samples/client/petstore/perl/docs/Capitalization.md create mode 100644 samples/client/petstore/perl/docs/ClassModel.md create mode 100644 samples/client/petstore/perl/docs/OuterEnum.md create mode 100644 samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/Capitalization.pm create mode 100644 samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/ClassModel.pm create mode 100644 samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/OuterEnum.pm create mode 100644 samples/client/petstore/perl/t/ArrayOfArrayOfNumberOnlyTest.t create mode 100644 samples/client/petstore/perl/t/ArrayOfNumberOnlyTest.t create mode 100644 samples/client/petstore/perl/t/CapitalizationTest.t create mode 100644 samples/client/petstore/perl/t/ClassModelTest.t create mode 100644 samples/client/petstore/perl/t/ClientTest.t create mode 100644 samples/client/petstore/perl/t/EnumArraysTest.t create mode 100644 samples/client/petstore/perl/t/FakeApiTest.t create mode 100644 samples/client/petstore/perl/t/HasOnlyReadOnlyTest.t create mode 100644 samples/client/petstore/perl/t/ListTest.t create mode 100644 samples/client/petstore/perl/t/MapTestTest.t create mode 100644 samples/client/petstore/perl/t/NumberOnlyTest.t create mode 100644 samples/client/petstore/perl/t/OuterEnumTest.t create mode 100644 samples/client/petstore/perl/t/PetApiTest.t create mode 100644 samples/client/petstore/perl/t/StoreApiTest.t create mode 100644 samples/client/petstore/perl/t/UserApiTest.t diff --git a/bin/perl-petstore.sh b/bin/perl-petstore.sh index f3eb5b17bd9..8dd64398708 100755 --- a/bin/perl-petstore.sh +++ b/bin/perl-petstore.sh @@ -27,7 +27,7 @@ fi # if you've executed sbt assembly previously it will use that instead. export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" # complex module name used for testing -ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l perl -o samples/client/petstore/perl" +ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l perl -o samples/client/petstore/perl -DhideGenerationTimestamp=true" java $JAVA_OPTS -jar $executable $ags diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenConstants.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenConstants.java index 8798cd579c5..a13a9552d3f 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenConstants.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenConstants.java @@ -148,7 +148,7 @@ public class CodegenConstants { public static final String GENERATE_MODEL_TESTS_DESC = "Specifies that model tests are to be generated."; public static final String HIDE_GENERATION_TIMESTAMP = "hideGenerationTimestamp"; - public static final String HIDE_GENERATION_TIMESTAMP_DESC = "Hides the generation timestamp."; + public static final String HIDE_GENERATION_TIMESTAMP_DESC = "Hides the generation timestamp when files are generated."; public static final String GENERATE_PROPERTY_CHANGED = "generatePropertyChanged"; public static final String GENERATE_PROPERTY_CHANGED_DESC = "Specifies that models support raising property changed events."; @@ -158,4 +158,5 @@ public class CodegenConstants { public static final String IGNORE_FILE_OVERRIDE = "ignoreFileOverride"; public static final String IGNORE_FILE_OVERRIDE_DESC = "Specifies an override location for the .swagger-codegen-ignore file. Most useful on initial generation."; + } diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PerlClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PerlClientCodegen.java index c0d9a0ef2ba..bf50765f1ca 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PerlClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PerlClientCodegen.java @@ -109,7 +109,8 @@ public class PerlClientCodegen extends DefaultCodegen implements CodegenConfig { CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG_DESC).defaultValue(Boolean.TRUE.toString())); cliOptions.add(CliOption.newBoolean(CodegenConstants.ENSURE_UNIQUE_PARAMS, CodegenConstants .ENSURE_UNIQUE_PARAMS_DESC).defaultValue(Boolean.TRUE.toString())); - + cliOptions.add(new CliOption(CodegenConstants.HIDE_GENERATION_TIMESTAMP, CodegenConstants.HIDE_GENERATION_TIMESTAMP_DESC) + .defaultValue(Boolean.TRUE.toString())); } @@ -134,6 +135,14 @@ public class PerlClientCodegen extends DefaultCodegen implements CodegenConfig { additionalProperties.put("apiDocPath", apiDocPath); additionalProperties.put("modelDocPath", modelDocPath); + // default HIDE_GENERATION_TIMESTAMP to true + if (!additionalProperties.containsKey(CodegenConstants.HIDE_GENERATION_TIMESTAMP)) { + additionalProperties.put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, Boolean.TRUE.toString()); + } else { + additionalProperties.put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, + Boolean.valueOf(additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP).toString())); + } + supportingFiles.add(new SupportingFile("ApiClient.mustache", ("lib/" + modulePathPart).replace('/', File.separatorChar), "ApiClient.pm")); supportingFiles.add(new SupportingFile("Configuration.mustache", ("lib/" + modulePathPart).replace('/', File.separatorChar), "Configuration.pm")); supportingFiles.add(new SupportingFile("ApiFactory.mustache", ("lib/" + modulePathPart).replace('/', File.separatorChar), "ApiFactory.pm")); @@ -161,7 +170,7 @@ public class PerlClientCodegen extends DefaultCodegen implements CodegenConfig { } @Override - public String escapeReservedWord(String name) { + public String escapeReservedWord(String name) { if(this.reservedWordsMappings().containsKey(name)) { return this.reservedWordsMappings().get(name); } @@ -399,7 +408,7 @@ public class PerlClientCodegen extends DefaultCodegen implements CodegenConfig { @Override public void setParameterExampleValue(CodegenParameter p) { - if (Boolean.TRUE.equals(p.isString) || Boolean.TRUE.equals(p.isBinary) || + if (Boolean.TRUE.equals(p.isString) || Boolean.TRUE.equals(p.isBinary) || Boolean.TRUE.equals(p.isByteArray) || Boolean.TRUE.equals(p.isFile)) { p.example = "'" + p.example + "'"; } else if (Boolean.TRUE.equals(p.isBoolean)) { diff --git a/modules/swagger-codegen/src/main/resources/perl/README.mustache b/modules/swagger-codegen/src/main/resources/perl/README.mustache index c732448cecf..512ddfbd065 100644 --- a/modules/swagger-codegen/src/main/resources/perl/README.mustache +++ b/modules/swagger-codegen/src/main/resources/perl/README.mustache @@ -10,7 +10,9 @@ Automatically generated by the [Swagger Codegen](https://github.com/swagger-api/ - API version: {{appVersion}} - Package version: {{moduleVersion}} +{{^hideGenerationTimestamp}} - Build date: {{generatedDate}} +{{/hideGenerationTimestamp}} - Build package: {{generatorClass}} {{#infoUrl}} For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}}) @@ -18,43 +20,43 @@ For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}}) ## A note on Moose -This role is the only component of the library that uses Moose. See -{{moduleName}}::ApiFactory for non-Moosey usage. +This role is the only component of the library that uses Moose. See +{{moduleName}}::ApiFactory for non-Moosey usage. # SYNOPSIS -The Perl Swagger Codegen project builds a library of Perl modules to interact with -a web service defined by a OpenAPI Specification. See below for how to build the +The Perl Swagger Codegen project builds a library of Perl modules to interact with +a web service defined by a OpenAPI Specification. See below for how to build the library. -This module provides an interface to the generated library. All the classes, -objects, and methods (well, not quite \*all\*, see below) are flattened into this -role. +This module provides an interface to the generated library. All the classes, +objects, and methods (well, not quite \*all\*, see below) are flattened into this +role. package MyApp; use Moose; with '{{moduleName}}::Role'; - + package main; - + my $api = MyApp->new({ tokens => $tokens }); - + my $pet = $api->get_pet_by_id(pet_id => $pet_id); - + ## Structure of the library The library consists of a set of API classes, one for each endpoint. These APIs -implement the method calls available on each endpoint. +implement the method calls available on each endpoint. -Additionally, there is a set of "object" classes, which represent the objects -returned by and sent to the methods on the endpoints. +Additionally, there is a set of "object" classes, which represent the objects +returned by and sent to the methods on the endpoints. -An API factory class is provided, which builds instances of each endpoint API. +An API factory class is provided, which builds instances of each endpoint API. -This Moose role flattens all the methods from the endpoint APIs onto the consuming -class. It also provides methods to retrieve the endpoint API objects, and the API -factory object, should you need it. +This Moose role flattens all the methods from the endpoint APIs onto the consuming +class. It also provides methods to retrieve the endpoint API objects, and the API +factory object, should you need it. For documentation of all these methods, see AUTOMATIC DOCUMENTATION below. @@ -67,33 +69,33 @@ required and where to put them. You just need to supply the tokens. # basic username => $username, password => $password, - + # oauth access_token => $oauth_token, - + # keys $some_key => { token => $token, - prefix => $prefix, - in => $in, # 'head||query', + prefix => $prefix, + in => $in, # 'head||query', }, - + $another => { token => $token, - prefix => $prefix, - in => $in, # 'head||query', - }, + prefix => $prefix, + in => $in, # 'head||query', + }, ..., - + }; - + my $api = MyApp->new({ tokens => $tokens }); Note these are all optional, as are `prefix` and `in`, and depend on the API you are accessing. Usually `prefix` and `in` will be determined by the code generator from the spec and you will not need to set them at run time. If not, `in` will -default to 'head' and `prefix` to the empty string. +default to 'head' and `prefix` to the empty string. The tokens will be placed in the `{{moduleName}}::Configuration` namespace -as follows, but you don't need to know about this. +as follows, but you don't need to know about this. - `${{moduleName}}::Configuration::username` @@ -124,22 +126,22 @@ as follows, but you don't need to know about this. - `${{moduleName}}::Configuration::access_token` - String. The OAuth access token. + String. The OAuth access token. # METHODS ## `base_url` -The generated code has the `base_url` already set as a default value. This method -returns (and optionally sets, but only if the API client has not been +The generated code has the `base_url` already set as a default value. This method +returns (and optionally sets, but only if the API client has not been created yet) the current value of `base_url`. ## `api_factory` -Returns an API factory object. You probably won't need to call this directly. +Returns an API factory object. You probably won't need to call this directly. $self->api_factory('Pet'); # returns a {{moduleName}}::PetApi instance - + $self->pet_api; # the same # MISSING METHODS @@ -149,9 +151,9 @@ Most of the methods on the API are delegated to individual endpoint API objects same method name (e.g. `new()`), these methods can't be delegated. So you need to call `$api->pet_api->new()`. -In principle, every API is susceptible to the presence of a few, random, undelegatable -method names. In practice, because of the way method names are constructed, it's -unlikely in general that any methods will be undelegatable, except for: +In principle, every API is susceptible to the presence of a few, random, undelegatable +method names. In practice, because of the way method names are constructed, it's +unlikely in general that any methods will be undelegatable, except for: new() class_documentation() @@ -164,12 +166,12 @@ you could also call them on class names. # BUILDING YOUR LIBRARY -See the homepage `https://github.com/swagger-api/swagger-codegen` for full details. -But briefly, clone the git repository, build the codegen codebase, set up your build +See the homepage `https://github.com/swagger-api/swagger-codegen` for full details. +But briefly, clone the git repository, build the codegen codebase, set up your build config file, then run the API build script. You will need git, Java 7 or 8 and Apache maven 3.0.3 or better already installed. -The config file should specify the project name for the generated library: +The config file should specify the project name for the generated library: {"moduleName":"WWW::MyProjectName"} @@ -184,8 +186,8 @@ Your library files will be built under `WWW::MyProjectName`. -c /path/to/config/file.json \ -o /path/to/output/folder -Bang, all done. Run the `autodoc` script in the `bin` directory to see the API -you just built. +Bang, all done. Run the `autodoc` script in the `bin` directory to see the API +you just built. # AUTOMATIC DOCUMENTATION @@ -197,28 +199,28 @@ output formats are supported: -w wide format (default) -n narrow format - -p POD format - -H HTML format + -p POD format + -H HTML format -m Markdown format -h print this help message -c your application class - + The `-c` option allows you to load and inspect your own application. A dummy namespace is used if you don't supply your own class. # DOCUMENTATION FROM THE OpenAPI Spec -Additional documentation for each class and method may be provided by the Swagger -spec. If so, this is available via the `class_documentation()` and -`method_documentation()` methods on each generated object class, and the -`method_documentation()` method on the endpoint API classes: +Additional documentation for each class and method may be provided by the Swagger +spec. If so, this is available via the `class_documentation()` and +`method_documentation()` methods on each generated object class, and the +`method_documentation()` method on the endpoint API classes: + + my $cmdoc = $api->pet_api->method_documentation->{$method_name}; + + my $odoc = $api->get_pet_by_id->(pet_id => $pet_id)->class_documentation; + my $omdoc = $api->get_pet_by_id->(pet_id => $pet_id)->method_documentation->{method_name}; - my $cmdoc = $api->pet_api->method_documentation->{$method_name}; - - my $odoc = $api->get_pet_by_id->(pet_id => $pet_id)->class_documentation; - my $omdoc = $api->get_pet_by_id->(pet_id => $pet_id)->method_documentation->{method_name}; - Each of these calls returns a hashref with various useful pieces of information. @@ -297,7 +299,7 @@ Class | Method | HTTP request | Description {{/authMethods}}{{#authMethods}}{{#last}} Authentication schemes defined for the API:{{/last}}{{/authMethods}} {{#authMethods}}## {{{name}}} -{{#isApiKey}}- **Type**: API key +{{#isApiKey}}- **Type**: API key - **API key parameter name**: {{{keyParamName}}} - **Location**: {{#isKeyInQuery}}URL query string{{/isKeyInQuery}}{{#isKeyInHeader}}HTTP header{{/isKeyInHeader}} {{/isApiKey}} @@ -312,5 +314,3 @@ Class | Method | HTTP request | Description {{/isOAuth}} {{/authMethods}} - - diff --git a/modules/swagger-codegen/src/main/resources/perl/Role.mustache b/modules/swagger-codegen/src/main/resources/perl/Role.mustache index 0c8c1a0375b..f853faeb726 100644 --- a/modules/swagger-codegen/src/main/resources/perl/Role.mustache +++ b/modules/swagger-codegen/src/main/resources/perl/Role.mustache @@ -1,6 +1,6 @@ {{>partial_license}} # -# NOTE: This class is auto generated by the swagger code generator program. +# NOTE: This class is auto generated by the swagger code generator program. # Do not edit the class manually. # Ref: https://github.com/swagger-api/swagger-codegen # @@ -21,7 +21,7 @@ has base_url => ( is => 'ro', has api_factory => ( is => 'ro', isa => '{{moduleName}}::ApiFactory', - builder => '_build_af', + builder => '_build_af', lazy => 1, documentation => 'Builds an instance of the endpoint API class', ); @@ -38,12 +38,14 @@ has _cfg => ( is => 'ro', default => '{{moduleName}}::Configuration', ); -has version_info => ( is => 'ro', - isa => 'HashRef', +has version_info => ( is => 'ro', + isa => 'HashRef', default => sub { { app_name => '{{appName}}', app_version => '{{appVersion}}', + {{^hideGenerationTimestamp}} generated_date => '{{generatedDate}}', + {{/hideGenerationTimestamp}} generator_class => '{{generatorClass}}', } }, documentation => 'Information about the application version and the codegen codebase version' @@ -51,36 +53,36 @@ has version_info => ( is => 'ro', sub BUILD { my $self = shift; - + $self->_cfg->accept_tokens( $self->tokens ) if keys %{$self->tokens}; - + # ignore these symbols imported into API namespaces my %outsiders = map {$_ => 1} qw( croak ); - + my %delegates; - + # collect the methods callable on each API foreach my $api_name ($self->api_factory->apis_available) { my $api_class = $self->api_factory->classname_for($api_name); my $methods = Class::Inspector->methods($api_class, 'expanded'); # not Moose, so use CI instead my @local_methods = grep {! /^_/} grep {! $outsiders{$_}} map {$_->[2]} grep {$_->[1] eq $api_class} @$methods; - push( @{$delegates{$_}}, {api_name => $api_name, api_class => $api_class} ) for @local_methods; + push( @{$delegates{$_}}, {api_name => $api_name, api_class => $api_class} ) for @local_methods; } - + # remove clashes foreach my $method (keys %delegates) { if ( @{$delegates{$method}} > 1 ) { my ($apis) = delete $delegates{$method}; } } - + # build the flattened API foreach my $api_name ($self->api_factory->apis_available) { my $att_name = sprintf "%s_api", lc($api_name); my $api_class = $self->api_factory->classname_for($api_name); my @delegated = grep { $delegates{$_}->[0]->{api_name} eq $api_name } keys %delegates; $log->debugf("Adding API: '%s' handles %s", $att_name, join ', ', @delegated); - $self->meta->add_attribute( $att_name => ( + $self->meta->add_attribute( $att_name => ( is => 'ro', isa => $api_class, default => sub {$self->api_factory->get_api($api_name)}, @@ -99,62 +101,64 @@ sub _build_af { =head1 NAME -{{moduleName}}::Role - a Moose role for the {{appName}} +{{moduleName}}::Role - a Moose role for the {{appName}} =head2 {{appName}} version: {{appVersion}} =head1 VERSION -Automatically generated by the Perl Swagger Codegen project: +Automatically generated by the Perl Swagger Codegen project: -=over 4 +=over 4 +{{^hideGenerationTimestamp}} =item Build date: {{generatedDate}} +{{/hideGenerationTimestamp}} =item Build package: {{generatorClass}} -=item Codegen version: +=item Codegen version: =back =head2 A note on Moose -This role is the only component of the library that uses Moose. See -{{moduleName}}::ApiFactory for non-Moosey usage. +This role is the only component of the library that uses Moose. See +{{moduleName}}::ApiFactory for non-Moosey usage. =head1 SYNOPSIS -The Perl Swagger Codegen project builds a library of Perl modules to interact with -a web service defined by a OpenAPI Specification. See below for how to build the +The Perl Swagger Codegen project builds a library of Perl modules to interact with +a web service defined by a OpenAPI Specification. See below for how to build the library. -This module provides an interface to the generated library. All the classes, -objects, and methods (well, not quite *all*, see below) are flattened into this -role. +This module provides an interface to the generated library. All the classes, +objects, and methods (well, not quite *all*, see below) are flattened into this +role. package MyApp; use Moose; with '{{moduleName}}::Role'; - + package main; - + my $api = MyApp->new({ tokens => $tokens }); - + my $pet = $api->get_pet_by_id(pet_id => $pet_id); - + =head2 Structure of the library The library consists of a set of API classes, one for each endpoint. These APIs -implement the method calls available on each endpoint. +implement the method calls available on each endpoint. -Additionally, there is a set of "object" classes, which represent the objects -returned by and sent to the methods on the endpoints. +Additionally, there is a set of "object" classes, which represent the objects +returned by and sent to the methods on the endpoints. -An API factory class is provided, which builds instances of each endpoint API. +An API factory class is provided, which builds instances of each endpoint API. -This Moose role flattens all the methods from the endpoint APIs onto the consuming -class. It also provides methods to retrieve the endpoint API objects, and the API -factory object, should you need it. +This Moose role flattens all the methods from the endpoint APIs onto the consuming +class. It also provides methods to retrieve the endpoint API objects, and the API +factory object, should you need it. For documentation of all these methods, see AUTOMATIC DOCUMENTATION below. @@ -167,33 +171,33 @@ required and where to put them. You just need to supply the tokens. # basic username => $username, password => $password, - + # oauth access_token => $oauth_token, - + # keys $some_key => { token => $token, - prefix => $prefix, - in => $in, # 'head||query', + prefix => $prefix, + in => $in, # 'head||query', }, - + $another => { token => $token, - prefix => $prefix, - in => $in, # 'head||query', - }, + prefix => $prefix, + in => $in, # 'head||query', + }, ..., - + }; - + my $api = MyApp->new({ tokens => $tokens }); Note these are all optional, as are C and C, and depend on the API you are accessing. Usually C and C will be determined by the code generator from the spec and you will not need to set them at run time. If not, C will -default to 'head' and C to the empty string. +default to 'head' and C to the empty string. The tokens will be placed in the C<{{moduleName}}::Configuration> namespace -as follows, but you don't need to know about this. +as follows, but you don't need to know about this. =over 4 @@ -226,7 +230,7 @@ all api keys require a prefix. =item C<${{moduleName}}::Configuration::access_token> -String. The OAuth access token. +String. The OAuth access token. =back @@ -234,16 +238,16 @@ String. The OAuth access token. =head2 C -The generated code has the C already set as a default value. This method -returns (and optionally sets, but only if the API client has not been +The generated code has the C already set as a default value. This method +returns (and optionally sets, but only if the API client has not been created yet) the current value of C. =head2 C -Returns an API factory object. You probably won't need to call this directly. - +Returns an API factory object. You probably won't need to call this directly. + $self->api_factory('Pet'); # returns a {{moduleName}}::PetApi instance - + $self->pet_api; # the same =head1 MISSING METHODS @@ -253,9 +257,9 @@ Most of the methods on the API are delegated to individual endpoint API objects same method name (e.g. C), these methods can't be delegated. So you need to call C<$api-Epet_api-Enew()>. -In principle, every API is susceptible to the presence of a few, random, undelegatable -method names. In practice, because of the way method names are constructed, it's -unlikely in general that any methods will be undelegatable, except for: +In principle, every API is susceptible to the presence of a few, random, undelegatable +method names. In practice, because of the way method names are constructed, it's +unlikely in general that any methods will be undelegatable, except for: new() class_documentation() @@ -268,12 +272,12 @@ you could also call them on class names. =head1 BUILDING YOUR LIBRARY -See the homepage C for full details. -But briefly, clone the git repository, build the codegen codebase, set up your build +See the homepage C for full details. +But briefly, clone the git repository, build the codegen codebase, set up your build config file, then run the API build script. You will need git, Java 7 or 8 and Apache maven 3.0.3 or better already installed. -The config file should specify the project name for the generated library: +The config file should specify the project name for the generated library: {"moduleName":"WWW::MyProjectName"} @@ -288,8 +292,8 @@ Your library files will be built under C. -c /path/to/config/file.json \ -o /path/to/output/folder -Bang, all done. Run the C script in the C directory to see the API -you just built. +Bang, all done. Run the C script in the C directory to see the API +you just built. =head1 AUTOMATIC DOCUMENTATION @@ -301,28 +305,28 @@ output formats are supported: -w wide format (default) -n narrow format - -p POD format - -H HTML 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 OpenAPI Spec -Additional documentation for each class and method may be provided by the Swagger -spec. If so, this is available via the C and -C methods on each generated object class, and the -C method on the endpoint API classes: +Additional documentation for each class and method may be provided by the Swagger +spec. If so, this is available via the C and +C methods on each generated object class, and the +C method on the endpoint API classes: - my $cmdoc = $api->pet_api->method_documentation->{$method_name}; - - my $odoc = $api->get_pet_by_id->(pet_id => $pet_id)->class_documentation; - my $omdoc = $api->get_pet_by_id->(pet_id => $pet_id)->method_documentation->{method_name}; - -Each of these calls returns a hashref with various useful pieces of information. + my $cmdoc = $api->pet_api->method_documentation->{$method_name}; + + my $odoc = $api->get_pet_by_id->(pet_id => $pet_id)->class_documentation; + my $omdoc = $api->get_pet_by_id->(pet_id => $pet_id)->method_documentation->{method_name}; + +Each of these calls returns a hashref with various useful pieces of information. =cut diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/PerlClientOptionsProvider.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/PerlClientOptionsProvider.java index 5ffe04bff2b..d1a0def86d3 100644 --- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/PerlClientOptionsProvider.java +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/PerlClientOptionsProvider.java @@ -24,6 +24,7 @@ public class PerlClientOptionsProvider implements OptionsProvider { .put(PerlClientCodegen.MODULE_VERSION, MODULE_VERSION_VALUE) .put(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG, "true") .put(CodegenConstants.ENSURE_UNIQUE_PARAMS, "true") + .put("hideGenerationTimestamp", "true") .build(); } diff --git a/samples/client/petstore/perl/README.md b/samples/client/petstore/perl/README.md index 8fff4f574d8..1fd5b85a80b 100644 --- a/samples/client/petstore/perl/README.md +++ b/samples/client/petstore/perl/README.md @@ -10,48 +10,47 @@ Automatically generated by the [Swagger Codegen](https://github.com/swagger-api/ - API version: 1.0.0 - Package version: 1.0.0 -- Build date: 2016-11-16T17:12:17.554+08:00 -- Build package: class io.swagger.codegen.languages.PerlClientCodegen +- Build package: io.swagger.codegen.languages.PerlClientCodegen ## A note on Moose -This role is the only component of the library that uses Moose. See -WWW::SwaggerClient::ApiFactory for non-Moosey usage. +This role is the only component of the library that uses Moose. See +WWW::SwaggerClient::ApiFactory for non-Moosey usage. # SYNOPSIS -The Perl Swagger Codegen project builds a library of Perl modules to interact with -a web service defined by a OpenAPI Specification. See below for how to build the +The Perl Swagger Codegen project builds a library of Perl modules to interact with +a web service defined by a OpenAPI Specification. See below for how to build the library. -This module provides an interface to the generated library. All the classes, -objects, and methods (well, not quite \*all\*, see below) are flattened into this -role. +This module provides an interface to the generated library. All the classes, +objects, and methods (well, not quite \*all\*, see below) are flattened into this +role. package MyApp; use Moose; with 'WWW::SwaggerClient::Role'; - + package main; - + my $api = MyApp->new({ tokens => $tokens }); - + my $pet = $api->get_pet_by_id(pet_id => $pet_id); - + ## Structure of the library The library consists of a set of API classes, one for each endpoint. These APIs -implement the method calls available on each endpoint. +implement the method calls available on each endpoint. -Additionally, there is a set of "object" classes, which represent the objects -returned by and sent to the methods on the endpoints. +Additionally, there is a set of "object" classes, which represent the objects +returned by and sent to the methods on the endpoints. -An API factory class is provided, which builds instances of each endpoint API. +An API factory class is provided, which builds instances of each endpoint API. -This Moose role flattens all the methods from the endpoint APIs onto the consuming -class. It also provides methods to retrieve the endpoint API objects, and the API -factory object, should you need it. +This Moose role flattens all the methods from the endpoint APIs onto the consuming +class. It also provides methods to retrieve the endpoint API objects, and the API +factory object, should you need it. For documentation of all these methods, see AUTOMATIC DOCUMENTATION below. @@ -64,33 +63,33 @@ required and where to put them. You just need to supply the tokens. # basic username => $username, password => $password, - + # oauth access_token => $oauth_token, - + # keys $some_key => { token => $token, - prefix => $prefix, - in => $in, # 'head||query', + prefix => $prefix, + in => $in, # 'head||query', }, - + $another => { token => $token, - prefix => $prefix, - in => $in, # 'head||query', - }, + prefix => $prefix, + in => $in, # 'head||query', + }, ..., - + }; - + my $api = MyApp->new({ tokens => $tokens }); Note these are all optional, as are `prefix` and `in`, and depend on the API you are accessing. Usually `prefix` and `in` will be determined by the code generator from the spec and you will not need to set them at run time. If not, `in` will -default to 'head' and `prefix` to the empty string. +default to 'head' and `prefix` to the empty string. The tokens will be placed in the `WWW::SwaggerClient::Configuration` namespace -as follows, but you don't need to know about this. +as follows, but you don't need to know about this. - `$WWW::SwaggerClient::Configuration::username` @@ -121,22 +120,22 @@ as follows, but you don't need to know about this. - `$WWW::SwaggerClient::Configuration::access_token` - String. The OAuth access token. + String. The OAuth access token. # METHODS ## `base_url` -The generated code has the `base_url` already set as a default value. This method -returns (and optionally sets, but only if the API client has not been +The generated code has the `base_url` already set as a default value. This method +returns (and optionally sets, but only if the API client has not been created yet) the current value of `base_url`. ## `api_factory` -Returns an API factory object. You probably won't need to call this directly. +Returns an API factory object. You probably won't need to call this directly. $self->api_factory('Pet'); # returns a WWW::SwaggerClient::PetApi instance - + $self->pet_api; # the same # MISSING METHODS @@ -146,9 +145,9 @@ Most of the methods on the API are delegated to individual endpoint API objects same method name (e.g. `new()`), these methods can't be delegated. So you need to call `$api->pet_api->new()`. -In principle, every API is susceptible to the presence of a few, random, undelegatable -method names. In practice, because of the way method names are constructed, it's -unlikely in general that any methods will be undelegatable, except for: +In principle, every API is susceptible to the presence of a few, random, undelegatable +method names. In practice, because of the way method names are constructed, it's +unlikely in general that any methods will be undelegatable, except for: new() class_documentation() @@ -161,12 +160,12 @@ you could also call them on class names. # BUILDING YOUR LIBRARY -See the homepage `https://github.com/swagger-api/swagger-codegen` for full details. -But briefly, clone the git repository, build the codegen codebase, set up your build +See the homepage `https://github.com/swagger-api/swagger-codegen` for full details. +But briefly, clone the git repository, build the codegen codebase, set up your build config file, then run the API build script. You will need git, Java 7 or 8 and Apache maven 3.0.3 or better already installed. -The config file should specify the project name for the generated library: +The config file should specify the project name for the generated library: {"moduleName":"WWW::MyProjectName"} @@ -181,8 +180,8 @@ Your library files will be built under `WWW::MyProjectName`. -c /path/to/config/file.json \ -o /path/to/output/folder -Bang, all done. Run the `autodoc` script in the `bin` directory to see the API -you just built. +Bang, all done. Run the `autodoc` script in the `bin` directory to see the API +you just built. # AUTOMATIC DOCUMENTATION @@ -194,28 +193,28 @@ output formats are supported: -w wide format (default) -n narrow format - -p POD format - -H HTML format + -p POD format + -H HTML format -m Markdown format -h print this help message -c your application class - + The `-c` option allows you to load and inspect your own application. A dummy namespace is used if you don't supply your own class. # DOCUMENTATION FROM THE OpenAPI Spec -Additional documentation for each class and method may be provided by the Swagger -spec. If so, this is available via the `class_documentation()` and -`method_documentation()` methods on each generated object class, and the -`method_documentation()` method on the endpoint API classes: +Additional documentation for each class and method may be provided by the Swagger +spec. If so, this is available via the `class_documentation()` and +`method_documentation()` methods on each generated object class, and the +`method_documentation()` method on the endpoint API classes: + + my $cmdoc = $api->pet_api->method_documentation->{$method_name}; + + my $odoc = $api->get_pet_by_id->(pet_id => $pet_id)->class_documentation; + my $omdoc = $api->get_pet_by_id->(pet_id => $pet_id)->method_documentation->{method_name}; - my $cmdoc = $api->pet_api->method_documentation->{$method_name}; - - my $odoc = $api->get_pet_by_id->(pet_id => $pet_id)->class_documentation; - my $omdoc = $api->get_pet_by_id->(pet_id => $pet_id)->method_documentation->{method_name}; - Each of these calls returns a hashref with various useful pieces of information. @@ -239,8 +238,10 @@ use WWW::SwaggerClient::Object::ApiResponse; use WWW::SwaggerClient::Object::ArrayOfArrayOfNumberOnly; use WWW::SwaggerClient::Object::ArrayOfNumberOnly; use WWW::SwaggerClient::Object::ArrayTest; +use WWW::SwaggerClient::Object::Capitalization; use WWW::SwaggerClient::Object::Cat; use WWW::SwaggerClient::Object::Category; +use WWW::SwaggerClient::Object::ClassModel; use WWW::SwaggerClient::Object::Client; use WWW::SwaggerClient::Object::Dog; use WWW::SwaggerClient::Object::EnumArrays; @@ -256,6 +257,7 @@ use WWW::SwaggerClient::Object::ModelReturn; use WWW::SwaggerClient::Object::Name; use WWW::SwaggerClient::Object::NumberOnly; use WWW::SwaggerClient::Object::Order; +use WWW::SwaggerClient::Object::OuterEnum; use WWW::SwaggerClient::Object::Pet; use WWW::SwaggerClient::Object::ReadOnlyFirst; use WWW::SwaggerClient::Object::SpecialModelName; @@ -285,8 +287,10 @@ use WWW::SwaggerClient::Object::ApiResponse; use WWW::SwaggerClient::Object::ArrayOfArrayOfNumberOnly; use WWW::SwaggerClient::Object::ArrayOfNumberOnly; use WWW::SwaggerClient::Object::ArrayTest; +use WWW::SwaggerClient::Object::Capitalization; use WWW::SwaggerClient::Object::Cat; use WWW::SwaggerClient::Object::Category; +use WWW::SwaggerClient::Object::ClassModel; use WWW::SwaggerClient::Object::Client; use WWW::SwaggerClient::Object::Dog; use WWW::SwaggerClient::Object::EnumArrays; @@ -302,6 +306,7 @@ use WWW::SwaggerClient::Object::ModelReturn; use WWW::SwaggerClient::Object::Name; use WWW::SwaggerClient::Object::NumberOnly; use WWW::SwaggerClient::Object::Order; +use WWW::SwaggerClient::Object::OuterEnum; use WWW::SwaggerClient::Object::Pet; use WWW::SwaggerClient::Object::ReadOnlyFirst; use WWW::SwaggerClient::Object::SpecialModelName; @@ -365,8 +370,10 @@ Class | Method | HTTP request | Description - [WWW::SwaggerClient::Object::ArrayOfArrayOfNumberOnly](docs/ArrayOfArrayOfNumberOnly.md) - [WWW::SwaggerClient::Object::ArrayOfNumberOnly](docs/ArrayOfNumberOnly.md) - [WWW::SwaggerClient::Object::ArrayTest](docs/ArrayTest.md) + - [WWW::SwaggerClient::Object::Capitalization](docs/Capitalization.md) - [WWW::SwaggerClient::Object::Cat](docs/Cat.md) - [WWW::SwaggerClient::Object::Category](docs/Category.md) + - [WWW::SwaggerClient::Object::ClassModel](docs/ClassModel.md) - [WWW::SwaggerClient::Object::Client](docs/Client.md) - [WWW::SwaggerClient::Object::Dog](docs/Dog.md) - [WWW::SwaggerClient::Object::EnumArrays](docs/EnumArrays.md) @@ -382,6 +389,7 @@ Class | Method | HTTP request | Description - [WWW::SwaggerClient::Object::Name](docs/Name.md) - [WWW::SwaggerClient::Object::NumberOnly](docs/NumberOnly.md) - [WWW::SwaggerClient::Object::Order](docs/Order.md) + - [WWW::SwaggerClient::Object::OuterEnum](docs/OuterEnum.md) - [WWW::SwaggerClient::Object::Pet](docs/Pet.md) - [WWW::SwaggerClient::Object::ReadOnlyFirst](docs/ReadOnlyFirst.md) - [WWW::SwaggerClient::Object::SpecialModelName](docs/SpecialModelName.md) @@ -393,7 +401,7 @@ Class | Method | HTTP request | Description ## api_key -- **Type**: API key +- **Type**: API key - **API key parameter name**: api_key - **Location**: HTTP header @@ -410,5 +418,3 @@ Class | Method | HTTP request | Description - **write:pets**: modify pets in your account - **read:pets**: read your pets - - diff --git a/samples/client/petstore/perl/docs/Capitalization.md b/samples/client/petstore/perl/docs/Capitalization.md new file mode 100644 index 00000000000..c63257baa52 --- /dev/null +++ b/samples/client/petstore/perl/docs/Capitalization.md @@ -0,0 +1,20 @@ +# WWW::SwaggerClient::Object::Capitalization + +## Load the model package +```perl +use WWW::SwaggerClient::Object::Capitalization; +``` + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**small_camel** | **string** | | [optional] +**capital_camel** | **string** | | [optional] +**small_snake** | **string** | | [optional] +**capital_snake** | **string** | | [optional] +**sca_eth_flow_points** | **string** | | [optional] +**att_name** | **string** | Name of the pet | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/perl/docs/ClassModel.md b/samples/client/petstore/perl/docs/ClassModel.md new file mode 100644 index 00000000000..95d325176df --- /dev/null +++ b/samples/client/petstore/perl/docs/ClassModel.md @@ -0,0 +1,15 @@ +# WWW::SwaggerClient::Object::ClassModel + +## Load the model package +```perl +use WWW::SwaggerClient::Object::ClassModel; +``` + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**_class** | **string** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/perl/docs/EnumTest.md b/samples/client/petstore/perl/docs/EnumTest.md index 0c3416150e1..07cc4d9ebce 100644 --- a/samples/client/petstore/perl/docs/EnumTest.md +++ b/samples/client/petstore/perl/docs/EnumTest.md @@ -11,6 +11,7 @@ Name | Type | Description | Notes **enum_string** | **string** | | [optional] **enum_integer** | **int** | | [optional] **enum_number** | **double** | | [optional] +**outer_enum** | [**OuterEnum**](OuterEnum.md) | | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/samples/client/petstore/perl/docs/FakeApi.md b/samples/client/petstore/perl/docs/FakeApi.md index c070d1a2059..642f8fd1fe8 100644 --- a/samples/client/petstore/perl/docs/FakeApi.md +++ b/samples/client/petstore/perl/docs/FakeApi.md @@ -19,6 +19,8 @@ Method | HTTP request | Description To test \"client\" model +To test \"client\" model + ### Example ```perl use Data::Dumper; @@ -138,6 +140,8 @@ void (empty response body) To test enum parameters +To test enum parameters + ### Example ```perl use Data::Dumper; @@ -151,7 +155,7 @@ my $enum_header_string_array = []; # ARRAY[string] | Header parameter enum test my $enum_header_string = 'enum_header_string_example'; # string | Header parameter enum test (string) my $enum_query_string_array = []; # ARRAY[string] | Query parameter enum test (string array) my $enum_query_string = 'enum_query_string_example'; # string | Query parameter enum test (string) -my $enum_query_integer = 3.4; # Number | Query parameter enum test (double) +my $enum_query_integer = 56; # int | Query parameter enum test (double) my $enum_query_double = 1.2; # double | Query parameter enum test (double) eval { @@ -172,7 +176,7 @@ Name | Type | Description | Notes **enum_header_string** | **string**| Header parameter enum test (string) | [optional] [default to -efg] **enum_query_string_array** | [**ARRAY[string]**](string.md)| Query parameter enum test (string array) | [optional] **enum_query_string** | **string**| Query parameter enum test (string) | [optional] [default to -efg] - **enum_query_integer** | **Number**| Query parameter enum test (double) | [optional] + **enum_query_integer** | **int**| Query parameter enum test (double) | [optional] **enum_query_double** | **double**| Query parameter enum test (double) | [optional] ### Return type diff --git a/samples/client/petstore/perl/docs/OuterEnum.md b/samples/client/petstore/perl/docs/OuterEnum.md new file mode 100644 index 00000000000..7d0056d6522 --- /dev/null +++ b/samples/client/petstore/perl/docs/OuterEnum.md @@ -0,0 +1,14 @@ +# WWW::SwaggerClient::Object::OuterEnum + +## Load the model package +```perl +use WWW::SwaggerClient::Object::OuterEnum; +``` + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/perl/lib/WWW/SwaggerClient/FakeApi.pm b/samples/client/petstore/perl/lib/WWW/SwaggerClient/FakeApi.pm index 32267333ba4..ebb8bb5b86e 100644 --- a/samples/client/petstore/perl/lib/WWW/SwaggerClient/FakeApi.pm +++ b/samples/client/petstore/perl/lib/WWW/SwaggerClient/FakeApi.pm @@ -348,7 +348,7 @@ sub test_endpoint_parameters { # @param string $enum_header_string Header parameter enum test (string) (optional, default to -efg) # @param ARRAY[string] $enum_query_string_array Query parameter enum test (string array) (optional) # @param string $enum_query_string Query parameter enum test (string) (optional, default to -efg) -# @param Number $enum_query_integer Query parameter enum test (double) (optional) +# @param int $enum_query_integer Query parameter enum test (double) (optional) # @param double $enum_query_double Query parameter enum test (double) (optional) { my $params = { @@ -383,7 +383,7 @@ sub test_endpoint_parameters { required => '0', }, 'enum_query_integer' => { - data_type => 'Number', + data_type => 'int', description => 'Query parameter enum test (double)', required => '0', }, diff --git a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/Capitalization.pm b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/Capitalization.pm new file mode 100644 index 00000000000..a1eb4353d3d --- /dev/null +++ b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/Capitalization.pm @@ -0,0 +1,210 @@ +=begin comment + +Swagger Petstore + +This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git + +=end comment + +=cut + +# +# NOTE: This class is auto generated by the swagger code generator program. +# Do not edit the class manually. +# Ref: https://github.com/swagger-api/swagger-codegen +# +package WWW::SwaggerClient::Object::Capitalization; + +require 5.6.0; +use strict; +use warnings; +use utf8; +use JSON qw(decode_json); +use Data::Dumper; +use Module::Runtime qw(use_module); +use Log::Any qw($log); +use Date::Parse; +use DateTime; + +use base ("Class::Accessor", "Class::Data::Inheritable"); + + +# +# +# +# NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually. +# REF: https://github.com/swagger-api/swagger-codegen +# + +=begin comment + +Swagger Petstore + +This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git + +=end comment + +=cut + +# +# NOTE: This class is auto generated by the swagger code generator program. +# Do not edit the class manually. +# Ref: https://github.com/swagger-api/swagger-codegen +# +__PACKAGE__->mk_classdata('attribute_map' => {}); +__PACKAGE__->mk_classdata('swagger_types' => {}); +__PACKAGE__->mk_classdata('method_documentation' => {}); +__PACKAGE__->mk_classdata('class_documentation' => {}); + +# new object +sub new { + my ($class, %args) = @_; + + my $self = bless {}, $class; + + foreach my $attribute (keys %{$class->attribute_map}) { + my $args_key = $class->attribute_map->{$attribute}; + $self->$attribute( $args{ $args_key } ); + } + + return $self; +} + +# return perl hash +sub to_hash { + return decode_json(JSON->new->convert_blessed->encode( shift )); +} + +# used by JSON for serialization +sub TO_JSON { + my $self = shift; + my $_data = {}; + foreach my $_key (keys %{$self->attribute_map}) { + if (defined $self->{$_key}) { + $_data->{$self->attribute_map->{$_key}} = $self->{$_key}; + } + } + return $_data; +} + +# from Perl hashref +sub from_hash { + my ($self, $hash) = @_; + + # loop through attributes and use swagger_types to deserialize the data + while ( my ($_key, $_type) = each %{$self->swagger_types} ) { + my $_json_attribute = $self->attribute_map->{$_key}; + if ($_type =~ /^array\[/i) { # array + my $_subclass = substr($_type, 6, -1); + my @_array = (); + foreach my $_element (@{$hash->{$_json_attribute}}) { + push @_array, $self->_deserialize($_subclass, $_element); + } + $self->{$_key} = \@_array; + } elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime + $self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute}); + } else { + $log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute); + } + } + + return $self; +} + +# deserialize non-array data +sub _deserialize { + my ($self, $type, $data) = @_; + $log->debugf("deserializing %s with %s",Dumper($data), $type); + + if ($type eq 'DateTime') { + return DateTime->from_epoch(epoch => str2time($data)); + } elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) { + return $data; + } else { # hash(model) + my $_instance = eval "WWW::SwaggerClient::Object::$type->new()"; + return $_instance->from_hash($data); + } +} + + + +__PACKAGE__->class_documentation({description => '', + class => 'Capitalization', + required => [], # TODO +} ); + +__PACKAGE__->method_documentation({ + 'small_camel' => { + datatype => 'string', + base_name => 'smallCamel', + description => '', + format => '', + read_only => '', + }, + 'capital_camel' => { + datatype => 'string', + base_name => 'CapitalCamel', + description => '', + format => '', + read_only => '', + }, + 'small_snake' => { + datatype => 'string', + base_name => 'small_Snake', + description => '', + format => '', + read_only => '', + }, + 'capital_snake' => { + datatype => 'string', + base_name => 'Capital_Snake', + description => '', + format => '', + read_only => '', + }, + 'sca_eth_flow_points' => { + datatype => 'string', + base_name => 'SCA_ETH_Flow_Points', + description => '', + format => '', + read_only => '', + }, + 'att_name' => { + datatype => 'string', + base_name => 'ATT_NAME', + description => 'Name of the pet ', + format => '', + read_only => '', + }, +}); + +__PACKAGE__->swagger_types( { + 'small_camel' => 'string', + 'capital_camel' => 'string', + 'small_snake' => 'string', + 'capital_snake' => 'string', + 'sca_eth_flow_points' => 'string', + 'att_name' => 'string' +} ); + +__PACKAGE__->attribute_map( { + 'small_camel' => 'smallCamel', + 'capital_camel' => 'CapitalCamel', + 'small_snake' => 'small_Snake', + 'capital_snake' => 'Capital_Snake', + 'sca_eth_flow_points' => 'SCA_ETH_Flow_Points', + 'att_name' => 'ATT_NAME' +} ); + +__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map}); + + +1; diff --git a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/ClassModel.pm b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/ClassModel.pm new file mode 100644 index 00000000000..90634705247 --- /dev/null +++ b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/ClassModel.pm @@ -0,0 +1,165 @@ +=begin comment + +Swagger Petstore + +This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git + +=end comment + +=cut + +# +# NOTE: This class is auto generated by the swagger code generator program. +# Do not edit the class manually. +# Ref: https://github.com/swagger-api/swagger-codegen +# +package WWW::SwaggerClient::Object::ClassModel; + +require 5.6.0; +use strict; +use warnings; +use utf8; +use JSON qw(decode_json); +use Data::Dumper; +use Module::Runtime qw(use_module); +use Log::Any qw($log); +use Date::Parse; +use DateTime; + +use base ("Class::Accessor", "Class::Data::Inheritable"); + + +# +#Model for testing model with \"_class\" property +# +# NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually. +# REF: https://github.com/swagger-api/swagger-codegen +# + +=begin comment + +Swagger Petstore + +This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git + +=end comment + +=cut + +# +# NOTE: This class is auto generated by the swagger code generator program. +# Do not edit the class manually. +# Ref: https://github.com/swagger-api/swagger-codegen +# +__PACKAGE__->mk_classdata('attribute_map' => {}); +__PACKAGE__->mk_classdata('swagger_types' => {}); +__PACKAGE__->mk_classdata('method_documentation' => {}); +__PACKAGE__->mk_classdata('class_documentation' => {}); + +# new object +sub new { + my ($class, %args) = @_; + + my $self = bless {}, $class; + + foreach my $attribute (keys %{$class->attribute_map}) { + my $args_key = $class->attribute_map->{$attribute}; + $self->$attribute( $args{ $args_key } ); + } + + return $self; +} + +# return perl hash +sub to_hash { + return decode_json(JSON->new->convert_blessed->encode( shift )); +} + +# used by JSON for serialization +sub TO_JSON { + my $self = shift; + my $_data = {}; + foreach my $_key (keys %{$self->attribute_map}) { + if (defined $self->{$_key}) { + $_data->{$self->attribute_map->{$_key}} = $self->{$_key}; + } + } + return $_data; +} + +# from Perl hashref +sub from_hash { + my ($self, $hash) = @_; + + # loop through attributes and use swagger_types to deserialize the data + while ( my ($_key, $_type) = each %{$self->swagger_types} ) { + my $_json_attribute = $self->attribute_map->{$_key}; + if ($_type =~ /^array\[/i) { # array + my $_subclass = substr($_type, 6, -1); + my @_array = (); + foreach my $_element (@{$hash->{$_json_attribute}}) { + push @_array, $self->_deserialize($_subclass, $_element); + } + $self->{$_key} = \@_array; + } elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime + $self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute}); + } else { + $log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute); + } + } + + return $self; +} + +# deserialize non-array data +sub _deserialize { + my ($self, $type, $data) = @_; + $log->debugf("deserializing %s with %s",Dumper($data), $type); + + if ($type eq 'DateTime') { + return DateTime->from_epoch(epoch => str2time($data)); + } elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) { + return $data; + } else { # hash(model) + my $_instance = eval "WWW::SwaggerClient::Object::$type->new()"; + return $_instance->from_hash($data); + } +} + + + +__PACKAGE__->class_documentation({description => 'Model for testing model with \"_class\" property', + class => 'ClassModel', + required => [], # TODO +} ); + +__PACKAGE__->method_documentation({ + '_class' => { + datatype => 'string', + base_name => '_class', + description => '', + format => '', + read_only => '', + }, +}); + +__PACKAGE__->swagger_types( { + '_class' => 'string' +} ); + +__PACKAGE__->attribute_map( { + '_class' => '_class' +} ); + +__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map}); + + +1; diff --git a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/EnumTest.pm b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/EnumTest.pm index b5d7d2f7798..6b5f9317c4d 100644 --- a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/EnumTest.pm +++ b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/EnumTest.pm @@ -163,18 +163,27 @@ __PACKAGE__->method_documentation({ format => '', read_only => '', }, + 'outer_enum' => { + datatype => 'OuterEnum', + base_name => 'outerEnum', + description => '', + format => '', + read_only => '', + }, }); __PACKAGE__->swagger_types( { 'enum_string' => 'string', 'enum_integer' => 'int', - 'enum_number' => 'double' + 'enum_number' => 'double', + 'outer_enum' => 'OuterEnum' } ); __PACKAGE__->attribute_map( { 'enum_string' => 'enum_string', 'enum_integer' => 'enum_integer', - 'enum_number' => 'enum_number' + 'enum_number' => 'enum_number', + 'outer_enum' => 'outerEnum' } ); __PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map}); diff --git a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/OuterEnum.pm b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/OuterEnum.pm new file mode 100644 index 00000000000..344b4624d82 --- /dev/null +++ b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Object/OuterEnum.pm @@ -0,0 +1,158 @@ +=begin comment + +Swagger Petstore + +This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git + +=end comment + +=cut + +# +# NOTE: This class is auto generated by the swagger code generator program. +# Do not edit the class manually. +# Ref: https://github.com/swagger-api/swagger-codegen +# +package WWW::SwaggerClient::Object::OuterEnum; + +require 5.6.0; +use strict; +use warnings; +use utf8; +use JSON qw(decode_json); +use Data::Dumper; +use Module::Runtime qw(use_module); +use Log::Any qw($log); +use Date::Parse; +use DateTime; + +use base ("Class::Accessor", "Class::Data::Inheritable"); + + +# +# +# +# NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually. +# REF: https://github.com/swagger-api/swagger-codegen +# + +=begin comment + +Swagger Petstore + +This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git + +=end comment + +=cut + +# +# NOTE: This class is auto generated by the swagger code generator program. +# Do not edit the class manually. +# Ref: https://github.com/swagger-api/swagger-codegen +# +__PACKAGE__->mk_classdata('attribute_map' => {}); +__PACKAGE__->mk_classdata('swagger_types' => {}); +__PACKAGE__->mk_classdata('method_documentation' => {}); +__PACKAGE__->mk_classdata('class_documentation' => {}); + +# new object +sub new { + my ($class, %args) = @_; + + my $self = bless {}, $class; + + foreach my $attribute (keys %{$class->attribute_map}) { + my $args_key = $class->attribute_map->{$attribute}; + $self->$attribute( $args{ $args_key } ); + } + + return $self; +} + +# return perl hash +sub to_hash { + return decode_json(JSON->new->convert_blessed->encode( shift )); +} + +# used by JSON for serialization +sub TO_JSON { + my $self = shift; + my $_data = {}; + foreach my $_key (keys %{$self->attribute_map}) { + if (defined $self->{$_key}) { + $_data->{$self->attribute_map->{$_key}} = $self->{$_key}; + } + } + return $_data; +} + +# from Perl hashref +sub from_hash { + my ($self, $hash) = @_; + + # loop through attributes and use swagger_types to deserialize the data + while ( my ($_key, $_type) = each %{$self->swagger_types} ) { + my $_json_attribute = $self->attribute_map->{$_key}; + if ($_type =~ /^array\[/i) { # array + my $_subclass = substr($_type, 6, -1); + my @_array = (); + foreach my $_element (@{$hash->{$_json_attribute}}) { + push @_array, $self->_deserialize($_subclass, $_element); + } + $self->{$_key} = \@_array; + } elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime + $self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute}); + } else { + $log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute); + } + } + + return $self; +} + +# deserialize non-array data +sub _deserialize { + my ($self, $type, $data) = @_; + $log->debugf("deserializing %s with %s",Dumper($data), $type); + + if ($type eq 'DateTime') { + return DateTime->from_epoch(epoch => str2time($data)); + } elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) { + return $data; + } else { # hash(model) + my $_instance = eval "WWW::SwaggerClient::Object::$type->new()"; + return $_instance->from_hash($data); + } +} + + + +__PACKAGE__->class_documentation({description => '', + class => 'OuterEnum', + required => [], # TODO +} ); + +__PACKAGE__->method_documentation({ +}); + +__PACKAGE__->swagger_types( { + +} ); + +__PACKAGE__->attribute_map( { + +} ); + +__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map}); + + +1; diff --git a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Role.pm b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Role.pm index f77724eee88..c1d15a27176 100644 --- a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Role.pm +++ b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Role.pm @@ -13,7 +13,7 @@ Generated by: https://github.com/swagger-api/swagger-codegen.git =cut # -# NOTE: This class is auto generated by the swagger code generator program. +# NOTE: This class is auto generated by the swagger code generator program. # Do not edit the class manually. # Ref: https://github.com/swagger-api/swagger-codegen # @@ -34,7 +34,7 @@ has base_url => ( is => 'ro', has api_factory => ( is => 'ro', isa => 'WWW::SwaggerClient::ApiFactory', - builder => '_build_af', + builder => '_build_af', lazy => 1, documentation => 'Builds an instance of the endpoint API class', ); @@ -51,49 +51,48 @@ has _cfg => ( is => 'ro', default => 'WWW::SwaggerClient::Configuration', ); -has version_info => ( is => 'ro', - isa => 'HashRef', +has version_info => ( is => 'ro', + isa => 'HashRef', default => sub { { app_name => 'Swagger Petstore', app_version => '1.0.0', - generated_date => '2016-11-16T17:12:17.554+08:00', - generator_class => 'class io.swagger.codegen.languages.PerlClientCodegen', + generator_class => 'io.swagger.codegen.languages.PerlClientCodegen', } }, documentation => 'Information about the application version and the codegen codebase version' ); sub BUILD { my $self = shift; - + $self->_cfg->accept_tokens( $self->tokens ) if keys %{$self->tokens}; - + # ignore these symbols imported into API namespaces my %outsiders = map {$_ => 1} qw( croak ); - + my %delegates; - + # collect the methods callable on each API foreach my $api_name ($self->api_factory->apis_available) { my $api_class = $self->api_factory->classname_for($api_name); my $methods = Class::Inspector->methods($api_class, 'expanded'); # not Moose, so use CI instead my @local_methods = grep {! /^_/} grep {! $outsiders{$_}} map {$_->[2]} grep {$_->[1] eq $api_class} @$methods; - push( @{$delegates{$_}}, {api_name => $api_name, api_class => $api_class} ) for @local_methods; + push( @{$delegates{$_}}, {api_name => $api_name, api_class => $api_class} ) for @local_methods; } - + # remove clashes foreach my $method (keys %delegates) { if ( @{$delegates{$method}} > 1 ) { my ($apis) = delete $delegates{$method}; } } - + # build the flattened API foreach my $api_name ($self->api_factory->apis_available) { my $att_name = sprintf "%s_api", lc($api_name); my $api_class = $self->api_factory->classname_for($api_name); my @delegated = grep { $delegates{$_}->[0]->{api_name} eq $api_name } keys %delegates; $log->debugf("Adding API: '%s' handles %s", $att_name, join ', ', @delegated); - $self->meta->add_attribute( $att_name => ( + $self->meta->add_attribute( $att_name => ( is => 'ro', isa => $api_class, default => sub {$self->api_factory->get_api($api_name)}, @@ -112,62 +111,59 @@ sub _build_af { =head1 NAME -WWW::SwaggerClient::Role - a Moose role for the Swagger Petstore +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: +Automatically generated by the Perl Swagger Codegen project: -=over 4 +=over 4 +=item Build package: io.swagger.codegen.languages.PerlClientCodegen -=item Build date: 2016-11-16T17:12:17.554+08:00 - -=item Build package: class io.swagger.codegen.languages.PerlClientCodegen - -=item Codegen version: +=item Codegen version: =back =head2 A note on Moose -This role is the only component of the library that uses Moose. See -WWW::SwaggerClient::ApiFactory for non-Moosey usage. +This role is the only component of the library that uses Moose. See +WWW::SwaggerClient::ApiFactory for non-Moosey usage. =head1 SYNOPSIS -The Perl Swagger Codegen project builds a library of Perl modules to interact with -a web service defined by a OpenAPI Specification. See below for how to build the +The Perl Swagger Codegen project builds a library of Perl modules to interact with +a web service defined by a OpenAPI Specification. See below for how to build the library. -This module provides an interface to the generated library. All the classes, -objects, and methods (well, not quite *all*, see below) are flattened into this -role. +This module provides an interface to the generated library. All the classes, +objects, and methods (well, not quite *all*, see below) are flattened into this +role. package MyApp; use Moose; with 'WWW::SwaggerClient::Role'; - + package main; - + my $api = MyApp->new({ tokens => $tokens }); - + my $pet = $api->get_pet_by_id(pet_id => $pet_id); - + =head2 Structure of the library The library consists of a set of API classes, one for each endpoint. These APIs -implement the method calls available on each endpoint. +implement the method calls available on each endpoint. -Additionally, there is a set of "object" classes, which represent the objects -returned by and sent to the methods on the endpoints. +Additionally, there is a set of "object" classes, which represent the objects +returned by and sent to the methods on the endpoints. -An API factory class is provided, which builds instances of each endpoint API. +An API factory class is provided, which builds instances of each endpoint API. -This Moose role flattens all the methods from the endpoint APIs onto the consuming -class. It also provides methods to retrieve the endpoint API objects, and the API -factory object, should you need it. +This Moose role flattens all the methods from the endpoint APIs onto the consuming +class. It also provides methods to retrieve the endpoint API objects, and the API +factory object, should you need it. For documentation of all these methods, see AUTOMATIC DOCUMENTATION below. @@ -180,33 +176,33 @@ required and where to put them. You just need to supply the tokens. # basic username => $username, password => $password, - + # oauth access_token => $oauth_token, - + # keys $some_key => { token => $token, - prefix => $prefix, - in => $in, # 'head||query', + prefix => $prefix, + in => $in, # 'head||query', }, - + $another => { token => $token, - prefix => $prefix, - in => $in, # 'head||query', - }, + prefix => $prefix, + in => $in, # 'head||query', + }, ..., - + }; - + my $api = MyApp->new({ tokens => $tokens }); Note these are all optional, as are C and C, and depend on the API you are accessing. Usually C and C will be determined by the code generator from the spec and you will not need to set them at run time. If not, C will -default to 'head' and C to the empty string. +default to 'head' and C to the empty string. The tokens will be placed in the C namespace -as follows, but you don't need to know about this. +as follows, but you don't need to know about this. =over 4 @@ -239,7 +235,7 @@ all api keys require a prefix. =item C<$WWW::SwaggerClient::Configuration::access_token> -String. The OAuth access token. +String. The OAuth access token. =back @@ -247,16 +243,16 @@ String. The OAuth access token. =head2 C -The generated code has the C already set as a default value. This method -returns (and optionally sets, but only if the API client has not been +The generated code has the C already set as a default value. This method +returns (and optionally sets, but only if the API client has not been created yet) the current value of C. =head2 C -Returns an API factory object. You probably won't need to call this directly. - +Returns an API factory object. You probably won't need to call this directly. + $self->api_factory('Pet'); # returns a WWW::SwaggerClient::PetApi instance - + $self->pet_api; # the same =head1 MISSING METHODS @@ -266,9 +262,9 @@ Most of the methods on the API are delegated to individual endpoint API objects same method name (e.g. C), these methods can't be delegated. So you need to call C<$api-Epet_api-Enew()>. -In principle, every API is susceptible to the presence of a few, random, undelegatable -method names. In practice, because of the way method names are constructed, it's -unlikely in general that any methods will be undelegatable, except for: +In principle, every API is susceptible to the presence of a few, random, undelegatable +method names. In practice, because of the way method names are constructed, it's +unlikely in general that any methods will be undelegatable, except for: new() class_documentation() @@ -281,12 +277,12 @@ you could also call them on class names. =head1 BUILDING YOUR LIBRARY -See the homepage C for full details. -But briefly, clone the git repository, build the codegen codebase, set up your build +See the homepage C for full details. +But briefly, clone the git repository, build the codegen codebase, set up your build config file, then run the API build script. You will need git, Java 7 or 8 and Apache maven 3.0.3 or better already installed. -The config file should specify the project name for the generated library: +The config file should specify the project name for the generated library: {"moduleName":"WWW::MyProjectName"} @@ -301,8 +297,8 @@ Your library files will be built under C. -c /path/to/config/file.json \ -o /path/to/output/folder -Bang, all done. Run the C script in the C directory to see the API -you just built. +Bang, all done. Run the C script in the C directory to see the API +you just built. =head1 AUTOMATIC DOCUMENTATION @@ -314,28 +310,28 @@ output formats are supported: -w wide format (default) -n narrow format - -p POD format - -H HTML 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 OpenAPI Spec -Additional documentation for each class and method may be provided by the Swagger -spec. If so, this is available via the C and -C methods on each generated object class, and the -C method on the endpoint API classes: +Additional documentation for each class and method may be provided by the Swagger +spec. If so, this is available via the C and +C methods on each generated object class, and the +C method on the endpoint API classes: - my $cmdoc = $api->pet_api->method_documentation->{$method_name}; - - my $odoc = $api->get_pet_by_id->(pet_id => $pet_id)->class_documentation; - my $omdoc = $api->get_pet_by_id->(pet_id => $pet_id)->method_documentation->{method_name}; - -Each of these calls returns a hashref with various useful pieces of information. + my $cmdoc = $api->pet_api->method_documentation->{$method_name}; + + my $odoc = $api->get_pet_by_id->(pet_id => $pet_id)->class_documentation; + my $omdoc = $api->get_pet_by_id->(pet_id => $pet_id)->method_documentation->{method_name}; + +Each of these calls returns a hashref with various useful pieces of information. =cut diff --git a/samples/client/petstore/perl/t/ArrayOfArrayOfNumberOnlyTest.t b/samples/client/petstore/perl/t/ArrayOfArrayOfNumberOnlyTest.t new file mode 100644 index 00000000000..55f3388253b --- /dev/null +++ b/samples/client/petstore/perl/t/ArrayOfArrayOfNumberOnlyTest.t @@ -0,0 +1,33 @@ +=begin comment + +Swagger Petstore + +This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git + +=end comment + +=cut + +# +# NOTE: This class is auto generated by the Swagger Codegen +# Please update the test cases below to test the model. +# Ref: https://github.com/swagger-api/swagger-codegen +# +use Test::More tests => 2; +use Test::Exception; + +use lib 'lib'; +use strict; +use warnings; + + +use_ok('WWW::SwaggerClient::Object::ArrayOfArrayOfNumberOnly'); + +my $instance = WWW::SwaggerClient::Object::ArrayOfArrayOfNumberOnly->new(); + +isa_ok($instance, 'WWW::SwaggerClient::Object::ArrayOfArrayOfNumberOnly'); + diff --git a/samples/client/petstore/perl/t/ArrayOfNumberOnlyTest.t b/samples/client/petstore/perl/t/ArrayOfNumberOnlyTest.t new file mode 100644 index 00000000000..278324d0124 --- /dev/null +++ b/samples/client/petstore/perl/t/ArrayOfNumberOnlyTest.t @@ -0,0 +1,33 @@ +=begin comment + +Swagger Petstore + +This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git + +=end comment + +=cut + +# +# NOTE: This class is auto generated by the Swagger Codegen +# Please update the test cases below to test the model. +# Ref: https://github.com/swagger-api/swagger-codegen +# +use Test::More tests => 2; +use Test::Exception; + +use lib 'lib'; +use strict; +use warnings; + + +use_ok('WWW::SwaggerClient::Object::ArrayOfNumberOnly'); + +my $instance = WWW::SwaggerClient::Object::ArrayOfNumberOnly->new(); + +isa_ok($instance, 'WWW::SwaggerClient::Object::ArrayOfNumberOnly'); + diff --git a/samples/client/petstore/perl/t/CapitalizationTest.t b/samples/client/petstore/perl/t/CapitalizationTest.t new file mode 100644 index 00000000000..f55d16c468c --- /dev/null +++ b/samples/client/petstore/perl/t/CapitalizationTest.t @@ -0,0 +1,33 @@ +=begin comment + +Swagger Petstore + +This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git + +=end comment + +=cut + +# +# NOTE: This class is auto generated by the Swagger Codegen +# Please update the test cases below to test the model. +# Ref: https://github.com/swagger-api/swagger-codegen +# +use Test::More tests => 2; +use Test::Exception; + +use lib 'lib'; +use strict; +use warnings; + + +use_ok('WWW::SwaggerClient::Object::Capitalization'); + +my $instance = WWW::SwaggerClient::Object::Capitalization->new(); + +isa_ok($instance, 'WWW::SwaggerClient::Object::Capitalization'); + diff --git a/samples/client/petstore/perl/t/ClassModelTest.t b/samples/client/petstore/perl/t/ClassModelTest.t new file mode 100644 index 00000000000..b0175148496 --- /dev/null +++ b/samples/client/petstore/perl/t/ClassModelTest.t @@ -0,0 +1,33 @@ +=begin comment + +Swagger Petstore + +This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git + +=end comment + +=cut + +# +# NOTE: This class is auto generated by the Swagger Codegen +# Please update the test cases below to test the model. +# Ref: https://github.com/swagger-api/swagger-codegen +# +use Test::More tests => 2; +use Test::Exception; + +use lib 'lib'; +use strict; +use warnings; + + +use_ok('WWW::SwaggerClient::Object::ClassModel'); + +my $instance = WWW::SwaggerClient::Object::ClassModel->new(); + +isa_ok($instance, 'WWW::SwaggerClient::Object::ClassModel'); + diff --git a/samples/client/petstore/perl/t/ClientTest.t b/samples/client/petstore/perl/t/ClientTest.t new file mode 100644 index 00000000000..e5763def392 --- /dev/null +++ b/samples/client/petstore/perl/t/ClientTest.t @@ -0,0 +1,33 @@ +=begin comment + +Swagger Petstore + +This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git + +=end comment + +=cut + +# +# NOTE: This class is auto generated by the Swagger Codegen +# Please update the test cases below to test the model. +# Ref: https://github.com/swagger-api/swagger-codegen +# +use Test::More tests => 2; +use Test::Exception; + +use lib 'lib'; +use strict; +use warnings; + + +use_ok('WWW::SwaggerClient::Object::Client'); + +my $instance = WWW::SwaggerClient::Object::Client->new(); + +isa_ok($instance, 'WWW::SwaggerClient::Object::Client'); + diff --git a/samples/client/petstore/perl/t/EnumArraysTest.t b/samples/client/petstore/perl/t/EnumArraysTest.t new file mode 100644 index 00000000000..2a8edae5870 --- /dev/null +++ b/samples/client/petstore/perl/t/EnumArraysTest.t @@ -0,0 +1,33 @@ +=begin comment + +Swagger Petstore + +This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git + +=end comment + +=cut + +# +# NOTE: This class is auto generated by the Swagger Codegen +# Please update the test cases below to test the model. +# Ref: https://github.com/swagger-api/swagger-codegen +# +use Test::More tests => 2; +use Test::Exception; + +use lib 'lib'; +use strict; +use warnings; + + +use_ok('WWW::SwaggerClient::Object::EnumArrays'); + +my $instance = WWW::SwaggerClient::Object::EnumArrays->new(); + +isa_ok($instance, 'WWW::SwaggerClient::Object::EnumArrays'); + diff --git a/samples/client/petstore/perl/t/FakeApiTest.t b/samples/client/petstore/perl/t/FakeApiTest.t new file mode 100644 index 00000000000..4855c9f7057 --- /dev/null +++ b/samples/client/petstore/perl/t/FakeApiTest.t @@ -0,0 +1,77 @@ +=begin comment + +Swagger Petstore + +This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git + +=end comment + +=cut + +# +# NOTE: This class is auto generated by Swagger Codegen +# Please update the test cases below to test the API endpoints. +# Ref: https://github.com/swagger-api/swagger-codegen +# +use Test::More tests => 1; #TODO update number of test cases +use Test::Exception; + +use lib 'lib'; +use strict; +use warnings; + +use_ok('WWW::SwaggerClient::FakeApi'); + +my $api = WWW::SwaggerClient::FakeApi->new(); +isa_ok($api, 'WWW::SwaggerClient::FakeApi'); + +# +# test_client_model test +# +{ + my $body = undef; # replace NULL with a proper value + my $result = $api->test_client_model(body => $body); +} + +# +# test_endpoint_parameters test +# +{ + my $number = undef; # replace NULL with a proper value + my $double = undef; # replace NULL with a proper value + my $pattern_without_delimiter = undef; # replace NULL with a proper value + my $byte = undef; # replace NULL with a proper value + my $integer = undef; # replace NULL with a proper value + my $int32 = undef; # replace NULL with a proper value + my $int64 = undef; # replace NULL with a proper value + my $float = undef; # replace NULL with a proper value + my $string = undef; # replace NULL with a proper value + my $binary = undef; # replace NULL with a proper value + my $date = undef; # replace NULL with a proper value + my $date_time = undef; # replace NULL with a proper value + my $password = undef; # replace NULL with a proper value + my $callback = undef; # replace NULL with a proper value + my $result = $api->test_endpoint_parameters(number => $number, double => $double, pattern_without_delimiter => $pattern_without_delimiter, byte => $byte, integer => $integer, int32 => $int32, int64 => $int64, float => $float, string => $string, binary => $binary, date => $date, date_time => $date_time, password => $password, callback => $callback); +} + +# +# test_enum_parameters test +# +{ + my $enum_form_string_array = undef; # replace NULL with a proper value + my $enum_form_string = undef; # replace NULL with a proper value + my $enum_header_string_array = undef; # replace NULL with a proper value + my $enum_header_string = undef; # replace NULL with a proper value + my $enum_query_string_array = undef; # replace NULL with a proper value + my $enum_query_string = undef; # replace NULL with a proper value + my $enum_query_integer = undef; # replace NULL with a proper value + my $enum_query_double = undef; # replace NULL with a proper value + my $result = $api->test_enum_parameters(enum_form_string_array => $enum_form_string_array, enum_form_string => $enum_form_string, enum_header_string_array => $enum_header_string_array, enum_header_string => $enum_header_string, enum_query_string_array => $enum_query_string_array, enum_query_string => $enum_query_string, enum_query_integer => $enum_query_integer, enum_query_double => $enum_query_double); +} + + +1; diff --git a/samples/client/petstore/perl/t/HasOnlyReadOnlyTest.t b/samples/client/petstore/perl/t/HasOnlyReadOnlyTest.t new file mode 100644 index 00000000000..ba598e0f2c4 --- /dev/null +++ b/samples/client/petstore/perl/t/HasOnlyReadOnlyTest.t @@ -0,0 +1,33 @@ +=begin comment + +Swagger Petstore + +This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git + +=end comment + +=cut + +# +# NOTE: This class is auto generated by the Swagger Codegen +# Please update the test cases below to test the model. +# Ref: https://github.com/swagger-api/swagger-codegen +# +use Test::More tests => 2; +use Test::Exception; + +use lib 'lib'; +use strict; +use warnings; + + +use_ok('WWW::SwaggerClient::Object::HasOnlyReadOnly'); + +my $instance = WWW::SwaggerClient::Object::HasOnlyReadOnly->new(); + +isa_ok($instance, 'WWW::SwaggerClient::Object::HasOnlyReadOnly'); + diff --git a/samples/client/petstore/perl/t/ListTest.t b/samples/client/petstore/perl/t/ListTest.t new file mode 100644 index 00000000000..9cf167906a9 --- /dev/null +++ b/samples/client/petstore/perl/t/ListTest.t @@ -0,0 +1,33 @@ +=begin comment + +Swagger Petstore + +This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git + +=end comment + +=cut + +# +# NOTE: This class is auto generated by the Swagger Codegen +# Please update the test cases below to test the model. +# Ref: https://github.com/swagger-api/swagger-codegen +# +use Test::More tests => 2; +use Test::Exception; + +use lib 'lib'; +use strict; +use warnings; + + +use_ok('WWW::SwaggerClient::Object::List'); + +my $instance = WWW::SwaggerClient::Object::List->new(); + +isa_ok($instance, 'WWW::SwaggerClient::Object::List'); + diff --git a/samples/client/petstore/perl/t/MapTestTest.t b/samples/client/petstore/perl/t/MapTestTest.t new file mode 100644 index 00000000000..acb1be0ccbd --- /dev/null +++ b/samples/client/petstore/perl/t/MapTestTest.t @@ -0,0 +1,33 @@ +=begin comment + +Swagger Petstore + +This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git + +=end comment + +=cut + +# +# NOTE: This class is auto generated by the Swagger Codegen +# Please update the test cases below to test the model. +# Ref: https://github.com/swagger-api/swagger-codegen +# +use Test::More tests => 2; +use Test::Exception; + +use lib 'lib'; +use strict; +use warnings; + + +use_ok('WWW::SwaggerClient::Object::MapTest'); + +my $instance = WWW::SwaggerClient::Object::MapTest->new(); + +isa_ok($instance, 'WWW::SwaggerClient::Object::MapTest'); + diff --git a/samples/client/petstore/perl/t/NumberOnlyTest.t b/samples/client/petstore/perl/t/NumberOnlyTest.t new file mode 100644 index 00000000000..4daf60b5dfb --- /dev/null +++ b/samples/client/petstore/perl/t/NumberOnlyTest.t @@ -0,0 +1,33 @@ +=begin comment + +Swagger Petstore + +This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git + +=end comment + +=cut + +# +# NOTE: This class is auto generated by the Swagger Codegen +# Please update the test cases below to test the model. +# Ref: https://github.com/swagger-api/swagger-codegen +# +use Test::More tests => 2; +use Test::Exception; + +use lib 'lib'; +use strict; +use warnings; + + +use_ok('WWW::SwaggerClient::Object::NumberOnly'); + +my $instance = WWW::SwaggerClient::Object::NumberOnly->new(); + +isa_ok($instance, 'WWW::SwaggerClient::Object::NumberOnly'); + diff --git a/samples/client/petstore/perl/t/OuterEnumTest.t b/samples/client/petstore/perl/t/OuterEnumTest.t new file mode 100644 index 00000000000..77c1962bb3f --- /dev/null +++ b/samples/client/petstore/perl/t/OuterEnumTest.t @@ -0,0 +1,33 @@ +=begin comment + +Swagger Petstore + +This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git + +=end comment + +=cut + +# +# NOTE: This class is auto generated by the Swagger Codegen +# Please update the test cases below to test the model. +# Ref: https://github.com/swagger-api/swagger-codegen +# +use Test::More tests => 2; +use Test::Exception; + +use lib 'lib'; +use strict; +use warnings; + + +use_ok('WWW::SwaggerClient::Object::OuterEnum'); + +my $instance = WWW::SwaggerClient::Object::OuterEnum->new(); + +isa_ok($instance, 'WWW::SwaggerClient::Object::OuterEnum'); + diff --git a/samples/client/petstore/perl/t/PetApiTest.t b/samples/client/petstore/perl/t/PetApiTest.t new file mode 100644 index 00000000000..cf0041edd12 --- /dev/null +++ b/samples/client/petstore/perl/t/PetApiTest.t @@ -0,0 +1,102 @@ +=begin comment + +Swagger Petstore + +This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git + +=end comment + +=cut + +# +# NOTE: This class is auto generated by Swagger Codegen +# Please update the test cases below to test the API endpoints. +# Ref: https://github.com/swagger-api/swagger-codegen +# +use Test::More tests => 1; #TODO update number of test cases +use Test::Exception; + +use lib 'lib'; +use strict; +use warnings; + +use_ok('WWW::SwaggerClient::PetApi'); + +my $api = WWW::SwaggerClient::PetApi->new(); +isa_ok($api, 'WWW::SwaggerClient::PetApi'); + +# +# add_pet test +# +{ + my $body = undef; # replace NULL with a proper value + my $result = $api->add_pet(body => $body); +} + +# +# delete_pet test +# +{ + my $pet_id = undef; # replace NULL with a proper value + my $api_key = undef; # replace NULL with a proper value + my $result = $api->delete_pet(pet_id => $pet_id, api_key => $api_key); +} + +# +# find_pets_by_status test +# +{ + my $status = undef; # replace NULL with a proper value + my $result = $api->find_pets_by_status(status => $status); +} + +# +# find_pets_by_tags test +# +{ + my $tags = undef; # replace NULL with a proper value + my $result = $api->find_pets_by_tags(tags => $tags); +} + +# +# get_pet_by_id test +# +{ + my $pet_id = undef; # replace NULL with a proper value + my $result = $api->get_pet_by_id(pet_id => $pet_id); +} + +# +# update_pet test +# +{ + my $body = undef; # replace NULL with a proper value + my $result = $api->update_pet(body => $body); +} + +# +# update_pet_with_form test +# +{ + my $pet_id = undef; # replace NULL with a proper value + my $name = undef; # replace NULL with a proper value + my $status = undef; # replace NULL with a proper value + my $result = $api->update_pet_with_form(pet_id => $pet_id, name => $name, status => $status); +} + +# +# upload_file test +# +{ + my $pet_id = undef; # replace NULL with a proper value + my $additional_metadata = undef; # replace NULL with a proper value + my $file = undef; # replace NULL with a proper value + my $result = $api->upload_file(pet_id => $pet_id, additional_metadata => $additional_metadata, file => $file); +} + + +1; diff --git a/samples/client/petstore/perl/t/StoreApiTest.t b/samples/client/petstore/perl/t/StoreApiTest.t new file mode 100644 index 00000000000..98c11bb5839 --- /dev/null +++ b/samples/client/petstore/perl/t/StoreApiTest.t @@ -0,0 +1,64 @@ +=begin comment + +Swagger Petstore + +This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git + +=end comment + +=cut + +# +# NOTE: This class is auto generated by Swagger Codegen +# Please update the test cases below to test the API endpoints. +# Ref: https://github.com/swagger-api/swagger-codegen +# +use Test::More tests => 1; #TODO update number of test cases +use Test::Exception; + +use lib 'lib'; +use strict; +use warnings; + +use_ok('WWW::SwaggerClient::StoreApi'); + +my $api = WWW::SwaggerClient::StoreApi->new(); +isa_ok($api, 'WWW::SwaggerClient::StoreApi'); + +# +# delete_order test +# +{ + my $order_id = undef; # replace NULL with a proper value + my $result = $api->delete_order(order_id => $order_id); +} + +# +# get_inventory test +# +{ + my $result = $api->get_inventory(); +} + +# +# get_order_by_id test +# +{ + my $order_id = undef; # replace NULL with a proper value + my $result = $api->get_order_by_id(order_id => $order_id); +} + +# +# place_order test +# +{ + my $body = undef; # replace NULL with a proper value + my $result = $api->place_order(body => $body); +} + + +1; diff --git a/samples/client/petstore/perl/t/UserApiTest.t b/samples/client/petstore/perl/t/UserApiTest.t new file mode 100644 index 00000000000..57a830412c0 --- /dev/null +++ b/samples/client/petstore/perl/t/UserApiTest.t @@ -0,0 +1,98 @@ +=begin comment + +Swagger Petstore + +This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + +OpenAPI spec version: 1.0.0 +Contact: apiteam@swagger.io +Generated by: https://github.com/swagger-api/swagger-codegen.git + +=end comment + +=cut + +# +# NOTE: This class is auto generated by Swagger Codegen +# Please update the test cases below to test the API endpoints. +# Ref: https://github.com/swagger-api/swagger-codegen +# +use Test::More tests => 1; #TODO update number of test cases +use Test::Exception; + +use lib 'lib'; +use strict; +use warnings; + +use_ok('WWW::SwaggerClient::UserApi'); + +my $api = WWW::SwaggerClient::UserApi->new(); +isa_ok($api, 'WWW::SwaggerClient::UserApi'); + +# +# create_user test +# +{ + my $body = undef; # replace NULL with a proper value + my $result = $api->create_user(body => $body); +} + +# +# create_users_with_array_input test +# +{ + my $body = undef; # replace NULL with a proper value + my $result = $api->create_users_with_array_input(body => $body); +} + +# +# create_users_with_list_input test +# +{ + my $body = undef; # replace NULL with a proper value + my $result = $api->create_users_with_list_input(body => $body); +} + +# +# delete_user test +# +{ + my $username = undef; # replace NULL with a proper value + my $result = $api->delete_user(username => $username); +} + +# +# get_user_by_name test +# +{ + my $username = undef; # replace NULL with a proper value + my $result = $api->get_user_by_name(username => $username); +} + +# +# login_user test +# +{ + my $username = undef; # replace NULL with a proper value + my $password = undef; # replace NULL with a proper value + my $result = $api->login_user(username => $username, password => $password); +} + +# +# logout_user test +# +{ + my $result = $api->logout_user(); +} + +# +# update_user test +# +{ + my $username = undef; # replace NULL with a proper value + my $body = undef; # replace NULL with a proper value + my $result = $api->update_user(username => $username, body => $body); +} + + +1;