Merge pull request #3229 from wing328/security_fix_perl

[Perl] better code injection handling for perl client
This commit is contained in:
wing328 2016-06-28 17:35:29 +08:00 committed by GitHub
commit 56b2b4f2eb
71 changed files with 5616 additions and 96 deletions

34
bin/security/perl-petstore.sh Executable file
View File

@ -0,0 +1,34 @@
#!/bin/sh
SCRIPT="$0"
while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
SCRIPT="$link"
else
SCRIPT=`dirname "$SCRIPT"`/"$link"
fi
done
if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`dirname "$SCRIPT"`/..
APP_DIR=`cd "${APP_DIR}"; pwd`
fi
executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
if [ ! -f "$executable" ]
then
mvn clean package
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-security-test.yaml -l perl -o samples/client/petstore-security-test/perl"
java $JAVA_OPTS -jar $executable $ags
java $JAVA_OPTS -jar $executable $ags --additional-properties moduleName=Something::Deep -o samples/client/petstore-security-test/perl/deep_module_test

View File

@ -373,7 +373,8 @@ public class PerlClientCodegen extends DefaultCodegen implements CodegenConfig {
return underscore("call_" + operationId);
}
return underscore(operationId);
//return underscore(operationId).replaceAll("[^A-Za-z0-9_]", "");
return underscore(sanitizeName(operationId));
}
public void setModuleName(String moduleName) {
@ -403,4 +404,15 @@ public class PerlClientCodegen extends DefaultCodegen implements CodegenConfig {
}
}
@Override
public String escapeQuotationMark(String input) {
return input.replace("'", "");
}
@Override
public String escapeUnsafeCharacters(String input) {
// remove =end, =cut to avoid code injection
return input.replace("=end", "").replace("=cut", "");
}
}

View File

@ -57,7 +57,7 @@ sub new {
},
{{/allParams}}
};
__PACKAGE__->method_documentation->{ {{operationId}} } = {
__PACKAGE__->method_documentation->{ '{{operationId}}' } = {
summary => '{{summary}}',
params => $params,
returns => {{#returnType}}'{{{returnType}}}'{{/returnType}}{{^returnType}}undef{{/returnType}},

View File

@ -0,0 +1,20 @@
/blib/
/.build/
_build/
cover_db/
inc/
Build
!Build/
Build.bat
.last_cover_stats
/Makefile
/Makefile.old
/MANIFEST.bak
/META.yml
/META.json
/MYMETA.*
nytprof.out
/pm_to_blib
*.o
*.bs
/_eumm/

View File

@ -0,0 +1,23 @@
# Swagger Codegen Ignore
# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen
# Use this file to prevent files from being overwritten by the generator.
# The patterns follow closely to .gitignore or .dockerignore.
# As an example, the C# client generator defines ApiClient.cs.
# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line:
#ApiClient.cs
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
#foo/*/qux
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
#foo/**/qux
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
# You can also negate patterns with an exclamation (!).
# For example, you can ignore all files in a docs folder with the file extension .md:
#docs/*.md
# Then explicitly reverse the ignore rule for a single file:
#!docs/README.md

View File

@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "{}"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright {yyyy} {name of copyright owner}
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@ -0,0 +1,295 @@
# NAME
WWW::SwaggerClient::Role - a Moose role for the 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: \" \\ */ ' \"
# VERSION
Automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project:
- API version: 1.0.0 */ ' \"
- Package version: 1.0.0
- Build date: 2016-06-28T16:32:36.006+08:00
- Build package: class 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.
# 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
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.
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.
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.
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.
## Configuring authentication
In the normal case, the OpenAPI Spec will describe what parameters are
required and where to put them. You just need to supply the tokens.
my $tokens = {
# basic
username => $username,
password => $password,
# oauth
access_token => $oauth_token,
# keys
$some_key => { token => $token,
prefix => $prefix,
in => $in, # 'head||query',
},
$another => { token => $token,
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.
The tokens will be placed in the `WWW::SwaggerClient::Configuration` namespace
as follows, but you don't need to know about this.
- `$WWW::SwaggerClient::Configuration::username`
String. The username for basic auth.
- `$WWW::SwaggerClient::Configuration::password`
String. The password for basic auth.
- `$WWW::SwaggerClient::Configuration::api_key`
Hashref. Keyed on the name of each key (there can be multiple tokens).
$WWW::SwaggerClient::Configuration::api_key = {
secretKey => 'aaaabbbbccccdddd',
anotherKey => '1111222233334444',
};
- `$WWW::SwaggerClient::Configuration::api_key_prefix`
Hashref. Keyed on the name of each key (there can be multiple tokens). Note not
all api keys require a prefix.
$WWW::SwaggerClient::Configuration::api_key_prefix = {
secretKey => 'string',
anotherKey => 'same or some other string',
};
- `$WWW::SwaggerClient::Configuration::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
created yet) the current value of `base_url`.
## `api_factory`
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
Most of the methods on the API are delegated to individual endpoint API objects
(e.g. Pet API, Store API, User API etc). Where different endpoint APIs use the
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:
new()
class_documentation()
method_documentation()
To call these methods, you need to get a handle on the relevant object, either
by calling `$api->foo_api` or by retrieving an object, e.g.
`$api->get_pet_by_id(pet_id => $pet_id)`. They are class methods, so
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
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:
{"moduleName":"WWW::MyProjectName"}
Your library files will be built under `WWW::MyProjectName`.
$ git clone https://github.com/swagger-api/swagger-codegen.git
$ cd swagger-codegen
$ mvn package
$ java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \
-i [URL or file path to JSON swagger API spec] \
-l perl \
-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.
# AUTOMATIC DOCUMENTATION
You can print out a summary of the generated API by running the included
`autodoc` script in the `bin` directory of your generated library. A few
output formats are supported:
Usage: autodoc [OPTION]
-w wide format (default)
-n narrow 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:
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.
# LOAD THE MODULES
To load the API packages:
```perl
use WWW::SwaggerClient::FakeApi;
```
To load the models:
```perl
use WWW::SwaggerClient::Object::ModelReturn;
````
# GETTING STARTED
Put the Perl SDK under the 'lib' folder in your project directory, then run the following
```perl
#!/usr/bin/perl
use lib 'lib';
use strict;
use warnings;
# load the API package
use WWW::SwaggerClient::FakeApi;
# load the models
use WWW::SwaggerClient::Object::ModelReturn;
# for displaying the API response data
use Data::Dumper;
my $api_instance = WWW::SwaggerClient::FakeApi->new();
my $test code inject */ ' " =end = 'test code inject */ ' " =end_example'; # string | To test code injection */ ' \"
eval {
$api_instance->test_code_inject____end(test code inject */ ' " =end => $test code inject */ ' " =end);
};
if ($@) {
warn "Exception when calling FakeApi->test_code_inject____end: $@\n";
}
```
# DOCUMENTATION FOR API ENDPOINTS
All URIs are relative to *https://petstore.swagger.io */ ' " =end/v2 */ ' " =end*
Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*FakeApi* | [**test_code_inject____end**](docs/FakeApi.md#test_code_inject____end) | **PUT** /fake | To test code injection */ ' \"
# DOCUMENTATION FOR MODELS
- [WWW::SwaggerClient::Object::ModelReturn](docs/ModelReturn.md)
# DOCUMENTATION FOR AUTHORIATION
## api_key
- **Type**: API key
- **API key parameter name**: api_key */ ' " =end
- **Location**: HTTP header
## petstore_auth
- **Type**: OAuth
- **Flow**: implicit
- **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog
- **Scopes**:
- **write:pets**: modify pets in your account */ ' " =end
- **read:pets**: read your pets */ ' " =end

View File

@ -0,0 +1,77 @@
#!/usr/bin/perl
use FindBin;
use File::Spec;
use lib File::Spec->catdir($FindBin::Bin, '..', 'lib');
use Moose::Util qw(apply_all_roles);
use Getopt::Std;
my %options=();
getopts("wnphmHc:", \%options);
help if $options{h};
my $my_app = $options{c} || 'My::App';
if ($options{c}) {
eval <<LOAD;
use $my_app;
apply_all_roles($my_app, "WWW::SwaggerClient::Role::AutoDoc");
LOAD
die $@ if $@;
}
else {
package My::App;
use Moose;
with ('WWW::SwaggerClient::Role', 'WWW::SwaggerClient::Role::AutoDoc');
}
package main;
my $opt;
$opt = 'wide' if $options{w};
$opt = 'narrow' if $options{n};
$opt = 'pod' if $options{p};
$opt = 'pod' if $options{H};
$opt = 'pod' if $options{m};
$opt ||= 'wide';
my $api = $my_app->new;
if ($options{H}) {
my $pod2html = "pod2html --backlink --css http://st.pimg.net/tucs/style.css?3";
open STDOUT, "| $pod2html" or die "Can't fork: $!";
$api->autodoc($opt);
close STDOUT or die "Can't close: $!";
}
elsif ($options{m}) {
my $pod2markdown = "pod2markdown --html-encode-chars 1";
open STDOUT, "| $pod2markdown" or die "Can't fork: $!";
$api->autodoc($opt);
close STDOUT or die "Can't close: $!";
}
else {
$api->autodoc($opt);
}
exit(0);
# --------------------
sub help {
print <<HELP;
Usage: autodoc [OPTION] [-c My::App::Class]
-w wide format (default)
-n narrow format
-p POD format
-H HTML format
-m Markdown format
-h print this help message
-c your application class
HELP
exit(0);
}

View File

@ -0,0 +1,20 @@
/blib/
/.build/
_build/
cover_db/
inc/
Build
!Build/
Build.bat
.last_cover_stats
/Makefile
/Makefile.old
/MANIFEST.bak
/META.yml
/META.json
/MYMETA.*
nytprof.out
/pm_to_blib
*.o
*.bs
/_eumm/

View File

@ -0,0 +1,23 @@
# Swagger Codegen Ignore
# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen
# Use this file to prevent files from being overwritten by the generator.
# The patterns follow closely to .gitignore or .dockerignore.
# As an example, the C# client generator defines ApiClient.cs.
# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line:
#ApiClient.cs
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
#foo/*/qux
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
#foo/**/qux
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
# You can also negate patterns with an exclamation (!).
# For example, you can ignore all files in a docs folder with the file extension .md:
#docs/*.md
# Then explicitly reverse the ignore rule for a single file:
#!docs/README.md

View File

@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "{}"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright {yyyy} {name of copyright owner}
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@ -0,0 +1,295 @@
# NAME
Something::Deep::Role - a Moose role for the Swagger Petstore */ &#39; \&quot;
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ */ ' \"
# VERSION
Automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project:
- API version: 1.0.0 */ &#39; \&quot;
- Package version: 1.0.0
- Build date: 2016-06-28T16:32:37.043+08:00
- Build package: class io.swagger.codegen.languages.PerlClientCodegen
## A note on Moose
This role is the only component of the library that uses Moose. See
Something::Deep::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
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.
package MyApp;
use Moose;
with 'Something::Deep::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.
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.
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.
## Configuring authentication
In the normal case, the OpenAPI Spec will describe what parameters are
required and where to put them. You just need to supply the tokens.
my $tokens = {
# basic
username => $username,
password => $password,
# oauth
access_token => $oauth_token,
# keys
$some_key => { token => $token,
prefix => $prefix,
in => $in, # 'head||query',
},
$another => { token => $token,
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.
The tokens will be placed in the `Something::Deep::Configuration` namespace
as follows, but you don't need to know about this.
- `$Something::Deep::Configuration::username`
String. The username for basic auth.
- `$Something::Deep::Configuration::password`
String. The password for basic auth.
- `$Something::Deep::Configuration::api_key`
Hashref. Keyed on the name of each key (there can be multiple tokens).
$Something::Deep::Configuration::api_key = {
secretKey => 'aaaabbbbccccdddd',
anotherKey => '1111222233334444',
};
- `$Something::Deep::Configuration::api_key_prefix`
Hashref. Keyed on the name of each key (there can be multiple tokens). Note not
all api keys require a prefix.
$Something::Deep::Configuration::api_key_prefix = {
secretKey => 'string',
anotherKey => 'same or some other string',
};
- `$Something::Deep::Configuration::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
created yet) the current value of `base_url`.
## `api_factory`
Returns an API factory object. You probably won't need to call this directly.
$self->api_factory('Pet'); # returns a Something::Deep::PetApi instance
$self->pet_api; # the same
# MISSING METHODS
Most of the methods on the API are delegated to individual endpoint API objects
(e.g. Pet API, Store API, User API etc). Where different endpoint APIs use the
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:
new()
class_documentation()
method_documentation()
To call these methods, you need to get a handle on the relevant object, either
by calling `$api->foo_api` or by retrieving an object, e.g.
`$api->get_pet_by_id(pet_id => $pet_id)`. They are class methods, so
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
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:
{"moduleName":"WWW::MyProjectName"}
Your library files will be built under `WWW::MyProjectName`.
$ git clone https://github.com/swagger-api/swagger-codegen.git
$ cd swagger-codegen
$ mvn package
$ java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \
-i [URL or file path to JSON swagger API spec] \
-l perl \
-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.
# AUTOMATIC DOCUMENTATION
You can print out a summary of the generated API by running the included
`autodoc` script in the `bin` directory of your generated library. A few
output formats are supported:
Usage: autodoc [OPTION]
-w wide format (default)
-n narrow 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:
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.
# LOAD THE MODULES
To load the API packages:
```perl
use Something::Deep::FakeApi;
```
To load the models:
```perl
use Something::Deep::Object::ModelReturn;
````
# GETTING STARTED
Put the Perl SDK under the 'lib' folder in your project directory, then run the following
```perl
#!/usr/bin/perl
use lib 'lib';
use strict;
use warnings;
# load the API package
use Something::Deep::FakeApi;
# load the models
use Something::Deep::Object::ModelReturn;
# for displaying the API response data
use Data::Dumper;
my $api_instance = Something::Deep::FakeApi->new();
my $test code inject */ &#39; &quot; &#x3D;end = 'test code inject */ ' " =end_example'; # string | To test code injection */ ' \"
eval {
$api_instance->test_code_inject____end(test code inject */ &#39; &quot; &#x3D;end => $test code inject */ &#39; &quot; &#x3D;end);
};
if ($@) {
warn "Exception when calling FakeApi->test_code_inject____end: $@\n";
}
```
# DOCUMENTATION FOR API ENDPOINTS
All URIs are relative to *https://petstore.swagger.io */ &#39; &quot; &#x3D;end/v2 */ &#39; &quot; &#x3D;end*
Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*FakeApi* | [**test_code_inject____end**](docs/FakeApi.md#test_code_inject____end) | **PUT** /fake | To test code injection */ &#39; \&quot;
# DOCUMENTATION FOR MODELS
- [Something::Deep::Object::ModelReturn](docs/ModelReturn.md)
# DOCUMENTATION FOR AUTHORIATION
## api_key
- **Type**: API key
- **API key parameter name**: api_key */ ' " =end
- **Location**: HTTP header
## petstore_auth
- **Type**: OAuth
- **Flow**: implicit
- **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog
- **Scopes**:
- **write:pets**: modify pets in your account */ ' " =end
- **read:pets**: read your pets */ ' " =end

View File

@ -0,0 +1,77 @@
#!/usr/bin/perl
use FindBin;
use File::Spec;
use lib File::Spec->catdir($FindBin::Bin, '..', 'lib');
use Moose::Util qw(apply_all_roles);
use Getopt::Std;
my %options=();
getopts("wnphmHc:", \%options);
help if $options{h};
my $my_app = $options{c} || 'My::App';
if ($options{c}) {
eval <<LOAD;
use $my_app;
apply_all_roles($my_app, "Something::Deep::Role::AutoDoc");
LOAD
die $@ if $@;
}
else {
package My::App;
use Moose;
with ('Something::Deep::Role', 'Something::Deep::Role::AutoDoc');
}
package main;
my $opt;
$opt = 'wide' if $options{w};
$opt = 'narrow' if $options{n};
$opt = 'pod' if $options{p};
$opt = 'pod' if $options{H};
$opt = 'pod' if $options{m};
$opt ||= 'wide';
my $api = $my_app->new;
if ($options{H}) {
my $pod2html = "pod2html --backlink --css http://st.pimg.net/tucs/style.css?3";
open STDOUT, "| $pod2html" or die "Can't fork: $!";
$api->autodoc($opt);
close STDOUT or die "Can't close: $!";
}
elsif ($options{m}) {
my $pod2markdown = "pod2markdown --html-encode-chars 1";
open STDOUT, "| $pod2markdown" or die "Can't fork: $!";
$api->autodoc($opt);
close STDOUT or die "Can't close: $!";
}
else {
$api->autodoc($opt);
}
exit(0);
# --------------------
sub help {
print <<HELP;
Usage: autodoc [OPTION] [-c My::App::Class]
-w wide format (default)
-n narrow format
-p POD format
-H HTML format
-m Markdown format
-h print this help message
-c your application class
HELP
exit(0);
}

View File

@ -0,0 +1,55 @@
# Something::Deep::FakeApi
## Load the API package
```perl
use Something::Deep::Object::FakeApi;
```
All URIs are relative to *https://petstore.swagger.io */ &#39; &quot; &#x3D;end/v2 */ &#39; &quot; &#x3D;end*
Method | HTTP request | Description
------------- | ------------- | -------------
[**test_code_inject____end**](FakeApi.md#test_code_inject____end) | **PUT** /fake | To test code injection */ &#39; \&quot;
# **test_code_inject____end**
> test_code_inject____end(test code inject */ &#39; &quot; &#x3D;end => $test code inject */ &#39; &quot; &#x3D;end)
To test code injection */ ' \"
### Example
```perl
use Data::Dumper;
my $api_instance = Something::Deep::FakeApi->new();
my $test code inject */ &#39; &quot; &#x3D;end = 'test code inject */ ' " =end_example'; # string | To test code injection */ ' \"
eval {
$api_instance->test_code_inject____end(test code inject */ &#39; &quot; &#x3D;end => $test code inject */ &#39; &quot; &#x3D;end);
};
if ($@) {
warn "Exception when calling FakeApi->test_code_inject____end: $@\n";
}
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**test code inject */ &#39; &quot; &#x3D;end** | **string**| To test code injection */ &#39; \&quot; | [optional]
### Return type
void (empty response body)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: application/json, */ " =end
- **Accept**: application/json, */ " =end
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

View File

@ -0,0 +1,15 @@
# Something::Deep::Object::ModelReturn
## Load the model package
```perl
use Something::Deep::Object::ModelReturn;
```
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**return** | **int** | property description */ &#39; \&quot; | [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)

View File

@ -0,0 +1,52 @@
#!/bin/sh
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
#
# Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update"
git_user_id=$1
git_repo_id=$2
release_note=$3
if [ "$git_user_id" = "" ]; then
git_user_id="GIT_USER_ID"
echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
fi
if [ "$git_repo_id" = "" ]; then
git_repo_id="GIT_REPO_ID"
echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
fi
if [ "$release_note" = "" ]; then
release_note="Minor update"
echo "[INFO] No command line input provided. Set \$release_note to $release_note"
fi
# Initialize the local directory as a Git repository
git init
# Adds the files in the local repository and stages them for commit.
git add .
# Commits the tracked changes and prepares them to be pushed to a remote repository.
git commit -m "$release_note"
# Sets the new remote
git_remote=`git remote`
if [ "$git_remote" = "" ]; then # git remote not defined
if [ "$GIT_TOKEN" = "" ]; then
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git crediential in your environment."
git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
else
git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
fi
fi
git pull origin master
# Pushes (Forces) the changes in the local repository up to the remote repository
echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git"
git push origin master 2>&1 | grep -v 'To https'

View File

@ -0,0 +1,410 @@
=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 */ &#39; \&quot;
Contact: apiteam@swagger.io */ ' \"
Generated by: https://github.com/swagger-api/swagger-codegen.git
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
=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 Something::Deep::ApiClient;
use strict;
use warnings;
use utf8;
use MIME::Base64;
use LWP::UserAgent;
use HTTP::Headers;
use HTTP::Response;
use HTTP::Request::Common qw(DELETE POST GET HEAD PUT);
use HTTP::Status;
use URI::Query;
use JSON;
use URI::Escape;
use Scalar::Util;
use Log::Any qw($log);
use Carp;
use Module::Runtime qw(use_module);
use Something::Deep::Configuration;
use base 'Class::Singleton';
sub _new_instance
{
my $class = shift;
my (%args) = (
'ua' => LWP::UserAgent->new,
'base_url' => 'https://petstore.swagger.io */ &#39; &quot; &#x3D;end/v2 */ &#39; &quot; &#x3D;end',
@_
);
return bless \%args, $class;
}
sub _cfg {'Something::Deep::Configuration'}
# Set the user agent of the API client
#
# @param string $user_agent The user agent of the API client
#
sub set_user_agent {
my ($self, $user_agent) = @_;
$self->{http_user_agent}= $user_agent;
}
# Set timeout
#
# @param integer $seconds Number of seconds before timing out [set to 0 for no timeout]
#
sub set_timeout {
my ($self, $seconds) = @_;
if (!looks_like_number($seconds)) {
croak('Timeout variable must be numeric.');
}
$self->{http_timeout} = $seconds;
}
# make the HTTP request
# @param string $resourcePath path to method endpoint
# @param string $method method to call
# @param array $queryParams parameters to be place in query URL
# @param array $postData parameters to be placed in POST body
# @param array $headerParams parameters to be place in request header
# @return mixed
sub call_api {
my $self = shift;
my ($resource_path, $method, $query_params, $post_params, $header_params, $body_data, $auth_settings) = @_;
# update parameters based on authentication settings
$self->update_params_for_auth($header_params, $query_params, $auth_settings);
my $_url = $self->{base_url} . $resource_path;
# build query
if (%$query_params) {
$_url = ($_url . '?' . eval { URI::Query->new($query_params)->stringify });
}
# body data
$body_data = to_json($body_data->to_hash) if defined $body_data && $body_data->can('to_hash'); # model to json string
my $_body_data = %$post_params ? $post_params : $body_data;
# Make the HTTP request
my $_request;
if ($method eq 'POST') {
# multipart
$header_params->{'Content-Type'} = lc $header_params->{'Content-Type'} eq 'multipart/form' ?
'form-data' : $header_params->{'Content-Type'};
$_request = POST($_url, %$header_params, Content => $_body_data);
}
elsif ($method eq 'PUT') {
# multipart
$header_params->{'Content-Type'} = lc $header_params->{'Content-Type'} eq 'multipart/form' ?
'form-data' : $header_params->{'Content-Type'};
$_request = PUT($_url, %$header_params, Content => $_body_data);
}
elsif ($method eq 'GET') {
my $headers = HTTP::Headers->new(%$header_params);
$_request = GET($_url, %$header_params);
}
elsif ($method eq 'HEAD') {
my $headers = HTTP::Headers->new(%$header_params);
$_request = HEAD($_url,%$header_params);
}
elsif ($method eq 'DELETE') { #TODO support form data
my $headers = HTTP::Headers->new(%$header_params);
$_request = DELETE($_url, %$headers);
}
elsif ($method eq 'PATCH') { #TODO
}
else {
}
$self->{ua}->timeout($self->{http_timeout} || $Something::Deep::Configuration::http_timeout);
$self->{ua}->agent($self->{http_user_agent} || $Something::Deep::Configuration::http_user_agent);
$log->debugf("REQUEST: %s", $_request->as_string);
my $_response = $self->{ua}->request($_request);
$log->debugf("RESPONSE: %s", $_response->as_string);
unless ($_response->is_success) {
croak(sprintf "API Exception(%s): %s\n%s", $_response->code, $_response->message, $_response->content);
}
return $_response->content;
}
# Take value and turn it into a string suitable for inclusion in
# the path, by url-encoding.
# @param string $value a string which will be part of the path
# @return string the serialized object
sub to_path_value {
my ($self, $value) = @_;
return uri_escape($self->to_string($value));
}
# Take value and turn it into a string suitable for inclusion in
# the query, by imploding comma-separated if it's an object.
# If it's a string, pass through unchanged. It will be url-encoded
# later.
# @param object $object an object to be serialized to a string
# @return string the serialized object
sub to_query_value {
my ($self, $object) = @_;
if (ref($object) eq 'ARRAY') {
return join(',', @$object);
} else {
return $self->to_string($object);
}
}
# Take value and turn it into a string suitable for inclusion in
# the header. If it's a string, pass through unchanged
# If it's a datetime object, format it in ISO8601
# @param string $value a string which will be part of the header
# @return string the header string
sub to_header_value {
my ($self, $value) = @_;
return $self->to_string($value);
}
# Take value and turn it into a string suitable for inclusion in
# the http body (form parameter). If it's a string, pass through unchanged
# If it's a datetime object, format it in ISO8601
# @param string $value the value of the form parameter
# @return string the form string
sub to_form_value {
my ($self, $value) = @_;
return $self->to_string($value);
}
# Take value and turn it into a string suitable for inclusion in
# the parameter. If it's a string, pass through unchanged
# If it's a datetime object, format it in ISO8601
# @param string $value the value of the parameter
# @return string the header string
sub to_string {
my ($self, $value) = @_;
if (ref($value) eq "DateTime") { # datetime in ISO8601 format
return $value->datetime();
}
else {
return $value;
}
}
# Deserialize a JSON string into an object
#
# @param string $class class name is passed as a string
# @param string $data data of the body
# @return object an instance of $class
sub deserialize
{
my ($self, $class, $data) = @_;
$log->debugf("deserializing %s for %s", $data, $class);
if (not defined $data) {
return undef;
} elsif ( (substr($class, 0, 5)) eq 'HASH[') { #hash
if ($class =~ /^HASH\[(.*),(.*)\]$/) {
my ($key_type, $type) = ($1, $2);
my %hash;
my $decoded_data = decode_json $data;
foreach my $key (keys %$decoded_data) {
if (ref $decoded_data->{$key} eq 'HASH') {
$hash{$key} = $self->deserialize($type, encode_json $decoded_data->{$key});
} else {
$hash{$key} = $self->deserialize($type, $decoded_data->{$key});
}
}
return \%hash;
} else {
#TODO log error
}
} elsif ( (substr($class, 0, 6)) eq 'ARRAY[' ) { # array of data
return $data if $data eq '[]'; # return if empty array
my $_sub_class = substr($class, 6, -1);
my $_json_data = decode_json $data;
my @_values = ();
foreach my $_value (@$_json_data) {
if (ref $_value eq 'ARRAY') {
push @_values, $self->deserialize($_sub_class, encode_json $_value);
} else {
push @_values, $self->deserialize($_sub_class, $_value);
}
}
return \@_values;
} elsif ($class eq 'DateTime') {
return DateTime->from_epoch(epoch => str2time($data));
} elsif (grep /^$class$/, ('string', 'int', 'float', 'bool', 'object')) {
return $data;
} else { # model
my $_instance = use_module("Something::Deep::Object::$class")->new;
if (ref $data eq "HASH") {
return $_instance->from_hash($data);
} else { # string, need to json decode first
return $_instance->from_hash(decode_json $data);
}
}
}
# return 'Accept' based on an array of accept provided
# @param [Array] header_accept_array Array fo 'Accept'
# @return String Accept (e.g. application/json)
sub select_header_accept
{
my ($self, @header) = @_;
if (@header == 0 || (@header == 1 && $header[0] eq '')) {
return undef;
} elsif (grep(/^application\/json$/i, @header)) {
return 'application/json';
} else {
return join(',', @header);
}
}
# return the content type based on an array of content-type provided
# @param [Array] content_type_array Array fo content-type
# @return String Content-Type (e.g. application/json)
sub select_header_content_type
{
my ($self, @header) = @_;
if (@header == 0 || (@header == 1 && $header[0] eq '')) {
return 'application/json'; # default to application/json
} elsif (grep(/^application\/json$/i, @header)) {
return 'application/json';
} else {
return join(',', @header);
}
}
# Get API key (with prefix if set)
# @param string key name
# @return string API key with the prefix
sub get_api_key_with_prefix
{
my ($self, $key_name) = @_;
my $api_key = $Something::Deep::Configuration::api_key->{$key_name};
return unless $api_key;
my $prefix = $Something::Deep::Configuration::api_key_prefix->{$key_name};
return $prefix ? "$prefix $api_key" : $api_key;
}
# update header and query param based on authentication setting
#
# @param array $headerParams header parameters (by ref)
# @param array $queryParams query parameters (by ref)
# @param array $authSettings array of authentication scheme (e.g ['api_key'])
sub update_params_for_auth {
my ($self, $header_params, $query_params, $auth_settings) = @_;
return $self->_global_auth_setup($header_params, $query_params)
unless $auth_settings && @$auth_settings;
# one endpoint can have more than 1 auth settings
foreach my $auth (@$auth_settings) {
# determine which one to use
if (!defined($auth)) {
# TODO show warning about auth setting not defined
}
elsif ($auth eq 'api_key') {
my $api_key = $self->get_api_key_with_prefix('api_key */ &#39; &quot; &#x3D;end');
if ($api_key) {
$header_params->{'api_key */ &#39; &quot; &#x3D;end'} = $api_key;
}
}
elsif ($auth eq 'petstore_auth') {
if ($Something::Deep::Configuration::access_token) {
$header_params->{'Authorization'} = 'Bearer ' . $Something::Deep::Configuration::access_token;
}
}
else {
# TODO show warning about security definition not found
}
}
}
# The endpoint API class has not found any settings for auth. This may be deliberate,
# in which case update_params_for_auth() will be a no-op. But it may also be that the
# OpenAPI Spec does not describe the intended authorization. So we check in the config for any
# auth tokens and if we find any, we use them for all endpoints;
sub _global_auth_setup {
my ($self, $header_params, $query_params) = @_;
my $tokens = $self->_cfg->get_tokens;
return unless keys %$tokens;
# basic
if (my $uname = delete $tokens->{username}) {
my $pword = delete $tokens->{password};
$header_params->{'Authorization'} = 'Basic '.encode_base64($uname.":".$pword);
}
# oauth
if (my $access_token = delete $tokens->{access_token}) {
$header_params->{'Authorization'} = 'Bearer ' . $access_token;
}
# other keys
foreach my $token_name (keys %$tokens) {
my $in = $tokens->{$token_name}->{in};
my $token = $self->get_api_key_with_prefix($token_name);
if ($in eq 'head') {
$header_params->{$token_name} = $token;
}
elsif ($in eq 'query') {
$query_params->{$token_name} = $token;
}
else {
die "Don't know where to put token '$token_name' ('$in' is not 'head' or 'query')";
}
}
}
1;

View File

@ -0,0 +1,131 @@
=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 */ &#39; \&quot;
Contact: apiteam@swagger.io */ ' \"
Generated by: https://github.com/swagger-api/swagger-codegen.git
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
=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 Something::Deep::ApiFactory;
use strict;
use warnings;
use utf8;
use Carp;
use Module::Find;
usesub Something::Deep::Object;
use Something::Deep::ApiClient;
=head1 Name
Something::Deep::ApiFactory - constructs APIs to retrieve Something::Deep objects
=head1 Synopsis
package My::Petstore::App;
use Something::Deep::ApiFactory;
my $api_factory = Something::Deep::ApiFactory->new( ... ); # any args for ApiClient constructor
# later...
my $pet_api = $api_factory->get_api('Pet');
# $pet_api isa Something::Deep::PetApi
my $pet = $pet_api->get_pet_by_id(pet_id => $pet_id);
# object attributes have proper accessors:
printf "Pet's name is %s", $pet->name;
# change the value stored on the object:
$pet->name('Dave');
=cut
# Load all the API classes and construct a lookup table at startup time
my %_apis = map { $_ =~ /^Something::Deep::(.*)$/; $1 => $_ }
grep {$_ =~ /Api$/}
usesub 'Something::Deep';
=head1 new()
Any parameters are optional, and are passed to and stored on the api_client object.
base_url: (optional)
supply this to change the default base URL taken from the Swagger definition.
=cut
sub new {
my ($class, %p) = (shift, @_);
$p{api_client} = Something::Deep::ApiClient->instance(%p);
return bless \%p, $class;
}
=head1 get_api($which)
Returns an API object of the requested type.
$which is a nickname for the class:
FooBarClient::BazApi has nickname 'Baz'
=cut
sub get_api {
my ($self, $which) = @_;
croak "API not specified" unless $which;
my $api_class = $_apis{"${which}Api"} || croak "No known API for '$which'";
return $api_class->new(api_client => $self->api_client);
}
=head1 api_client()
Returns the api_client object, should you ever need it.
=cut
sub api_client { $_[0]->{api_client} }
=head1 apis_available()
=cut
sub apis_available { return map { $_ =~ s/Api$//; $_ } sort keys %_apis }
=head1 classname_for()
=cut
sub classname_for {
my ($self, $api_name) = @_;
return $_apis{"${api_name}Api"};
}
1;

View File

@ -0,0 +1,111 @@
=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 */ &#39; \&quot;
Contact: apiteam@swagger.io */ ' \"
Generated by: https://github.com/swagger-api/swagger-codegen.git
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
=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 Something::Deep::Configuration;
use strict;
use warnings;
use utf8;
use Log::Any qw($log);
use Carp;
use constant VERSION => '1.0.0';
# class/static variables
our $http_timeout = 180;
our $http_user_agent = 'Perl-Swagger';
# authenticaiton setting
our $api_key = {};
our $api_key_prefix = {};
our $api_key_in = {};
# username and password for HTTP basic authentication
our $username = '';
our $password = '';
# access token for OAuth
our $access_token = '';
sub get_tokens {
my $class = shift;
my $tokens = {};
$tokens->{username} = $username if $username;
$tokens->{password} = $password if $password;
$tokens->{access_token} = $access_token if $access_token;
foreach my $token_name (keys %{ $api_key }) {
$tokens->{$token_name}->{token} = $api_key->{$token_name};
$tokens->{$token_name}->{prefix} = $api_key_prefix->{$token_name};
$tokens->{$token_name}->{in} = $api_key_in->{$token_name};
}
return $tokens;
}
sub clear_tokens {
my $class = shift;
my %tokens = %{$class->get_tokens}; # copy
$username = undef;
$password = undef;
$access_token = undef;
$api_key = {};
$api_key_prefix = {};
$api_key_in = {};
return \%tokens;
}
sub accept_tokens {
my ($class, $tokens) = @_;
foreach my $known_name (qw(username password access_token)) {
next unless $tokens->{$known_name};
eval "\$$known_name = delete \$tokens->{\$known_name}";
die $@ if $@;
}
foreach my $token_name (keys %$tokens) {
$api_key->{$token_name} = $tokens->{$token_name}->{token};
if ($tokens->{$token_name}->{prefix}) {
$api_key_prefix->{$token_name} = $tokens->{$token_name}->{prefix};
}
my $in = $tokens->{$token_name}->{in} || 'head';
croak "Tokens can only go in 'head' or 'query' (not in '$in')" unless $in =~ /^(?:head|query)$/;
$api_key_in->{$token_name} = $in;
}
}
1;

View File

@ -0,0 +1,123 @@
=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 */ &#39; \&quot;
Contact: apiteam@swagger.io */ ' \"
Generated by: https://github.com/swagger-api/swagger-codegen.git
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
=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 Something::Deep::FakeApi;
require 5.6.0;
use strict;
use warnings;
use utf8;
use Exporter;
use Carp qw( croak );
use Log::Any qw($log);
use Something::Deep::ApiClient;
use Something::Deep::Configuration;
use base "Class::Data::Inheritable";
__PACKAGE__->mk_classdata('method_documentation' => {});
sub new {
my $class = shift;
my (%self) = (
'api_client' => Something::Deep::ApiClient->instance,
@_
);
#my $self = {
# #api_client => $options->{api_client}
# api_client => $default_api_client
#};
bless \%self, $class;
}
#
# test_code_inject____end
#
# To test code injection */ ' \"
#
# @param string $test code inject */ &#39; &quot; &#x3D;end To test code injection */ &#39; \&quot; (optional)
{
my $params = {
'test code inject */ &#39; &quot; &#x3D;end' => {
data_type => 'string',
description => 'To test code injection */ &#39; \&quot; ',
required => '0',
},
};
__PACKAGE__->method_documentation->{ 'test_code_inject____end' } = {
summary => 'To test code injection */ &#39; \&quot; ',
params => $params,
returns => undef,
};
}
# @return void
#
sub test_code_inject____end {
my ($self, %args) = @_;
# parse inputs
my $_resource_path = '/fake';
$_resource_path =~ s/{format}/json/; # default format to json
my $_method = 'PUT';
my $query_params = {};
my $header_params = {};
my $form_params = {};
# 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json', '*/ " =end');
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type('application/json', '*/ " =end');
# form params
if ( exists $args{'test code inject */ &#39; &quot; &#x3D;end'} ) {
$form_params->{'test code inject */ &#39; &quot; &#x3D;end'} = $self->{api_client}->to_form_value($args{'test code inject */ &#39; &quot; &#x3D;end'});
}
my $_body_data;
# authentication setting, if any
my $auth_settings = [qw()];
# make the API Call
$self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
return;
}
1;

View File

@ -0,0 +1,189 @@
=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 */ &#39; \&quot;
Contact: apiteam@swagger.io */ ' \"
Generated by: https://github.com/swagger-api/swagger-codegen.git
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
=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 Something::Deep::Object::ModelReturn;
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 reserved words */ &#39; \&quot;
#
# 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 */ &#39; \&quot;
Contact: apiteam@swagger.io */ ' \"
Generated by: https://github.com/swagger-api/swagger-codegen.git
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
=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 "Something::Deep::Object::$type->new()";
return $_instance->from_hash($data);
}
}
__PACKAGE__->class_documentation({description => 'Model for testing reserved words */ &#39; \&quot; ',
class => 'ModelReturn',
required => [], # TODO
} );
__PACKAGE__->method_documentation({
'return' => {
datatype => 'int',
base_name => 'return',
description => 'property description */ &#39; \&quot; ',
format => '',
read_only => '',
},
});
__PACKAGE__->swagger_types( {
'return' => 'int'
} );
__PACKAGE__->attribute_map( {
'return' => 'return'
} );
__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
1;

View File

@ -0,0 +1,354 @@
=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 */ &#39; \&quot;
Contact: apiteam@swagger.io */ ' \"
Generated by: https://github.com/swagger-api/swagger-codegen.git
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
=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 Something::Deep::Role;
use utf8;
use Moose::Role;
use namespace::autoclean;
use Class::Inspector;
use Log::Any qw($log);
use Something::Deep::ApiFactory;
has base_url => ( is => 'ro',
required => 0,
isa => 'Str',
documentation => 'Root of the server that requests are sent to',
);
has api_factory => ( is => 'ro',
isa => 'Something::Deep::ApiFactory',
builder => '_build_af',
lazy => 1,
documentation => 'Builds an instance of the endpoint API class',
);
has tokens => ( is => 'ro',
isa => 'HashRef',
required => 0,
default => sub { {} },
documentation => 'The auth tokens required by the application - basic, OAuth and/or API key(s)',
);
has _cfg => ( is => 'ro',
isa => 'Str',
default => 'Something::Deep::Configuration',
);
has version_info => ( is => 'ro',
isa => 'HashRef',
default => sub { {
app_name => 'Swagger Petstore */ &#39; \&quot; ',
app_version => '1.0.0 */ &#39; \&quot; ',
generated_date => '2016-06-28T16:32:37.043+08:00',
generator_class => '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;
}
# 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 => (
is => 'ro',
isa => $api_class,
default => sub {$self->api_factory->get_api($api_name)},
lazy => 1,
handles => \@delegated,
) );
}
}
sub _build_af {
my $self = shift;
my %args;
$args{base_url} = $self->base_url if $self->base_url;
return Something::Deep::ApiFactory->new(%args);
}
=head1 NAME
Something::Deep::Role - a Moose role for the Swagger Petstore */ &#39; \&quot;
=head2 Swagger Petstore */ &#39; \&quot; version: 1.0.0 */ &#39; \&quot;
=head1 VERSION
Automatically generated by the Perl Swagger Codegen project:
=over 4
=item Build date: 2016-06-28T16:32:37.043+08:00
=item Build package: class io.swagger.codegen.languages.PerlClientCodegen
=item Codegen version:
=back
=head2 A note on Moose
This role is the only component of the library that uses Moose. See
Something::Deep::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
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.
package MyApp;
use Moose;
with 'Something::Deep::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.
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.
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.
=head2 Configuring authentication
In the normal case, the OpenAPI Spec will describe what parameters are
required and where to put them. You just need to supply the tokens.
my $tokens = {
# basic
username => $username,
password => $password,
# oauth
access_token => $oauth_token,
# keys
$some_key => { token => $token,
prefix => $prefix,
in => $in, # 'head||query',
},
$another => { token => $token,
prefix => $prefix,
in => $in, # 'head||query',
},
...,
};
my $api = MyApp->new({ tokens => $tokens });
Note these are all optional, as are C<prefix> and C<in>, and depend on the API
you are accessing. Usually C<prefix> and C<in> will be determined by the code generator from
the spec and you will not need to set them at run time. If not, C<in> will
default to 'head' and C<prefix> to the empty string.
The tokens will be placed in the C<Something::Deep::Configuration> namespace
as follows, but you don't need to know about this.
=over 4
=item C<$Something::Deep::Configuration::username>
String. The username for basic auth.
=item C<$Something::Deep::Configuration::password>
String. The password for basic auth.
=item C<$Something::Deep::Configuration::api_key>
Hashref. Keyed on the name of each key (there can be multiple tokens).
$Something::Deep::Configuration::api_key = {
secretKey => 'aaaabbbbccccdddd',
anotherKey => '1111222233334444',
};
=item C<$Something::Deep::Configuration::api_key_prefix>
Hashref. Keyed on the name of each key (there can be multiple tokens). Note not
all api keys require a prefix.
$Something::Deep::Configuration::api_key_prefix = {
secretKey => 'string',
anotherKey => 'same or some other string',
};
=item C<$Something::Deep::Configuration::access_token>
String. The OAuth access token.
=back
=head1 METHODS
=head2 C<base_url>
The generated code has the C<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 C<base_url>.
=head2 C<api_factory>
Returns an API factory object. You probably won't need to call this directly.
$self->api_factory('Pet'); # returns a Something::Deep::PetApi instance
$self->pet_api; # the same
=head1 MISSING METHODS
Most of the methods on the API are delegated to individual endpoint API objects
(e.g. Pet API, Store API, User API etc). Where different endpoint APIs use the
same method name (e.g. C<new()>), these methods can't be delegated. So you need
to call C<$api-E<gt>pet_api-E<gt>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:
new()
class_documentation()
method_documentation()
To call these methods, you need to get a handle on the relevant object, either
by calling C<$api-E<gt>foo_api> or by retrieving an object, e.g.
C<$api-E<gt>get_pet_by_id(pet_id =E<gt> $pet_id)>. They are class methods, so
you could also call them on class names.
=head1 BUILDING YOUR LIBRARY
See the homepage C<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:
{"moduleName":"WWW::MyProjectName"}
Your library files will be built under C<WWW::MyProjectName>.
$ git clone https://github.com/swagger-api/swagger-codegen.git
$ cd swagger-codegen
$ mvn package
$ java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \
-i [URL or file path to JSON swagger API spec] \
-l perl \
-c /path/to/config/file.json \
-o /path/to/output/folder
Bang, all done. Run the C<autodoc> script in the C<bin> directory to see the API
you just built.
=head1 AUTOMATIC DOCUMENTATION
You can print out a summary of the generated API by running the included
C<autodoc> script in the C<bin> directory of your generated library. A few
output formats are supported:
Usage: autodoc [OPTION]
-w wide format (default)
-n narrow format
-p POD format
-H HTML format
-m Markdown format
-h print this help message
-c your application class
The C<-c> option allows you to load and inspect your own application. A dummy
namespace is used if you don't supply your own class.
=head1 DOCUMENTATION FROM THE OpenAPI Spec
Additional documentation for each class and method may be provided by the Swagger
spec. If so, this is available via the C<class_documentation()> and
C<method_documentation()> methods on each generated object class, and the
C<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};
Each of these calls returns a hashref with various useful pieces of information.
=cut
1;

View File

@ -0,0 +1,458 @@
=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 */ &#39; \&quot;
Contact: apiteam@swagger.io */ ' \"
Generated by: https://github.com/swagger-api/swagger-codegen.git
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
=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 Something::Deep::Role::AutoDoc;
use List::MoreUtils qw(uniq);
use Moose::Role;
sub autodoc {
my ($self, $how) = @_;
die "Unknown format '$how'" unless $how =~ /^(pod|wide|narrow)$/;
$self->_printisa($how);
$self->_printmethods($how);
$self->_printattrs($how);
print "\n";
}
sub _printisa {
my ($self, $how) = @_;
my $meta = $self->meta;
my $myclass = ref $self;
my $super = join ', ', $meta->superclasses;
my @roles = $meta->calculate_all_roles;
#shift(@roles) if @roles > 1; # if > 1, the first is a composite, the rest are the roles
my $isa = join ', ', grep {$_ ne $myclass} $meta->linearized_isa;
my $sub = join ', ', $meta->subclasses;
my $dsub = join ', ', $meta->direct_subclasses;
my $app_name = $self->version_info->{app_name};
my $app_version = $self->version_info->{app_version};
my $generated_date = $self->version_info->{generated_date};
my $generator_class = $self->version_info->{generator_class};
$~ = $how eq 'pod' ? 'INHERIT_POD' : 'INHERIT';
write;
my ($rolepkg, $role_reqs);
foreach my $role (@roles) {
$rolepkg = $role->{package} || next; # some are anonymous, or something
next if $rolepkg eq 'Something::Deep::Role::AutoDoc';
$role_reqs = join ', ', keys %{$role->{required_methods}};
$role_reqs ||= '';
$~ = $how eq 'pod' ? 'ROLES_POD' : 'ROLES';
write;
}
if ($how eq 'pod') {
$~ = 'ROLES_POD_CLOSE';
write;
}
# ----- format specs -----
format INHERIT =
@* -
$myclass
ISA: @*
$isa
Direct subclasses: @*
$dsub
All subclasses: @*
$sub
Target API: @* @*
$app_name, $app_version
Generated on: @*
$generated_date
Generator class: @*
$generator_class
.
format ROLES =
Composes: ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ~
$rolepkg
requires: ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ~
$role_reqs
^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ~~
$role_reqs
.
format INHERIT_POD =
=head1 NAME
@*
$myclass
=head1 VERSION
=head2 @* version: @*
$app_name, $app_version
Automatically generated by the Perl Swagger Codegen project:
=over 4
=item Build date: @*
$generated_date
=item Build package: @*
$generator_class
=item Codegen version:
=back
=head1 INHERITANCE
=head2 Base class(es)
@*
$isa
=head2 Direct subclasses
@*
$dsub
=head2 All subclasses
@*
$sub
=head1 COMPOSITION
@* composes the following roles:
$myclass
.
format ROLES_POD =
=head2 C<@*>
$rolepkg
Requires:
@*
$role_reqs
.
format ROLES_POD_CLOSE =
.
# ----- / format specs -----
}
sub _printmethods {
my ($self, $how) = @_;
if ($how eq 'narrow') {
print <<HEAD;
METHODS
-------
HEAD
}
elsif ($how eq 'wide') {
$~ = 'METHODHEAD';
write;
}
elsif ($how eq 'pod') {
$~ = 'METHODHEAD_POD';
write;
}
else {
die "Don't know how to print '$how'";
}
$self->_printmethod($_, $how) for uniq sort $self->meta->get_all_method_names; #$self->meta->get_method_list,
if ($how eq 'pod') {
$~ = 'METHOD_POD_CLOSE';
write;
}
}
sub _printmethod {
my ($self, $methodname, $how) = @_;
return if $methodname =~ /^_/;
return if $self->meta->has_attribute($methodname);
my %internal = map {$_ => 1} qw(BUILD BUILDARGS meta can new DEMOLISHALL DESTROY
DOES isa BUILDALL does VERSION dump
);
return if $internal{$methodname};
my $method = $self->meta->get_method($methodname) or return; # symbols imported into namespaces i.e. not known by Moose
return if $method->original_package_name eq __PACKAGE__;
my $delegate_to = '';
my $via = '';
my $on = '';
my $doc = '';
my $original_pkg = $method->original_package_name;
if ($method->can('associated_attribute')) {
$delegate_to = $method->delegate_to_method;
my $aa = $method->associated_attribute;
$on = $aa->{isa};
$via = $aa->{name};
$original_pkg = $on;
$doc = $original_pkg->method_documentation->{$delegate_to}->{summary};
}
else {
$doc = $method->documentation;
}
if ($how eq 'narrow') {
$~ = 'METHOD_NARROW';
write;
}
elsif ($how eq 'pod' and $delegate_to) {
$~ = 'METHOD_POD_DELEGATED';
write;
}
elsif ($how eq 'pod') {
$~ = 'METHOD_POD';
write;
}
else {
$~ = 'METHOD';
write;
}
# ----- format specs -----
format METHODHEAD =
METHODS
-------
Name delegates to on via
===========================================================================================================================================================================
.
format METHOD =
@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<... @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<... @<<<<<<<<<<<<<<<<...
$methodname, $delegate_to, $on, $via
.
format METHOD_NARROW =
@*
$methodname
original pkg: @*
$original_pkg
delegates to: @*
$delegate_to
on: @*
$on
via: @*
$via
.
format METHODHEAD_POD =
=head1 METHODS
.
format METHOD_POD =
=head2 C<@*()>
$methodname
Defined in: @*
$original_pkg
.
format METHOD_POD_DELEGATED =
=head2 C<@*()>
$methodname
Defined in: @*
$original_pkg
Delegates to: @*()
$delegate_to
On: @*
$on
Via: @*()
$via
Doc: @*
$doc
Same as: $self->@*->@*()
$via, $delegate_to
.
format METHOD_POD_CLOSE =
.
# ----- / format specs -----
}
sub _printattrs {
my ($self, $how) = @_;
if ($how eq 'narrow') {
print <<HEAD;
ATTRIBUTES
----------
HEAD
}
elsif ($how eq 'wide') {
$~ = 'ATTRHEAD';
write;
}
elsif ($how eq 'pod') {
$~ = 'ATTRHEAD_POD';
write;
}
else {
die "Don't know how to print attributes '$how'";
}
$self->_printattr($_, $how) for sort $self->meta->get_attribute_list;
if ($how eq 'pod') {
$~ = 'ATTR_POD_CLOSE';
write;
}
}
sub _printattr {
my ($self, $attrname, $how) = @_;
return if $attrname =~ /^_/;
my $attr = $self->meta->get_attribute($attrname) or die "No attr for $attrname";
my $is;
$is = 'rw' if $attr->get_read_method && $attr->get_write_method;
$is = 'ro' if $attr->get_read_method && ! $attr->get_write_method;
$is = 'wo' if $attr->get_write_method && ! $attr->get_read_method;
$is = '--' if ! $attr->get_write_method && ! $attr->get_read_method;
$is or die "No \$is for $attrname";
my $tc = $attr->type_constraint || '';
my $from = $attr->associated_class->name || '';
my $reqd = $attr->is_required ? 'yes' : 'no';
my $lazy = $attr->is_lazy ? 'yes' : 'no';
my $has_doc = $attr->has_documentation ? 'yes' : 'no'; # *_api attributes will never have doc, but other attributes might have
my $doc = $attr->documentation || '';
my $handles = join ', ', sort @{$attr->handles || []};
$handles ||= '';
if ($how eq 'narrow') {
$~ = 'ATTR_NARROW';
}
elsif ($how eq 'pod') {
$~ = 'ATTR_POD';
}
else {
$~ = 'ATTR';
}
write;
# ----- format specs -----
format ATTRHEAD =
ATTRIBUTES
----------
Name is isa reqd lazy doc handles
==============================================================================================================
.
format ATTR =
@<<<<<<<<<<<<<<<<< @< @<<<<<<<<<<<<<<<<<<<<<<<< @<<< @<<< @<< ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$attrname, $is, $tc, $reqd, $lazy, $has_doc, $handles
^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ~~
$handles
.
format ATTR_NARROW =
@*
$attrname
is: @*
$is
isa: @*
$tc
reqd: @*
$reqd
lazy: @*
$lazy
doc: @*
$doc
handles: ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$handles
^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ~~
$handles
.
format ATTRHEAD_POD =
=head1 ATTRIBUTES
.
format ATTR_POD =
=head2 C<@*>
$attrname
is: @*
$is
isa: @*
$tc
reqd: @*
$reqd
lazy: @*
$lazy
doc: @*
$doc
handles: ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$handles
^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ~~
$handles
.
format ATTR_POD_CLOSE =
.
# ----- / format specs -----
}
1;

View File

@ -0,0 +1,53 @@
=begin comment
Swagger Petstore ' \" =end
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ ' \" =end
OpenAPI spec version: 1.0.0 &#39; \&quot; &#x3D;end
Contact: apiteam@swagger.io ' \" =end
Generated by: https://github.com/swagger-api/swagger-codegen.git
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
=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('Something::Deep::FakeApi');
my $api = Something::Deep::FakeApi->new();
isa_ok($api, 'Something::Deep::FakeApi');
#
# test_code_inject */ ' " =end test
#
{
my $test code inject */ &#39; &quot; &#x3D;end = undef; # replace NULL with a proper value
my $result = $api->test_code_inject */ &#39; &quot; &#x3D;end(test code inject */ &#39; &quot; &#x3D;end => $test code inject */ &#39; &quot; &#x3D;end);
}
1;

View File

@ -0,0 +1,45 @@
=begin comment
Swagger Petstore ' \" =end
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ ' \" =end
OpenAPI spec version: 1.0.0 &#39; \&quot; &#x3D;end
Contact: apiteam@swagger.io ' \" =end
Generated by: https://github.com/swagger-api/swagger-codegen.git
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
=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('Something::Deep::Object::ModelReturn');
my $instance = Something::Deep::Object::ModelReturn->new();
isa_ok($instance, 'Something::Deep::Object::ModelReturn');

View File

@ -0,0 +1,55 @@
# WWW::SwaggerClient::FakeApi
## Load the API package
```perl
use WWW::SwaggerClient::Object::FakeApi;
```
All URIs are relative to *https://petstore.swagger.io */ &#39; &quot; &#x3D;end/v2 */ &#39; &quot; &#x3D;end*
Method | HTTP request | Description
------------- | ------------- | -------------
[**test_code_inject____end**](FakeApi.md#test_code_inject____end) | **PUT** /fake | To test code injection */ &#39; \&quot;
# **test_code_inject____end**
> test_code_inject____end(test code inject */ &#39; &quot; &#x3D;end => $test code inject */ &#39; &quot; &#x3D;end)
To test code injection */ ' \"
### Example
```perl
use Data::Dumper;
my $api_instance = WWW::SwaggerClient::FakeApi->new();
my $test code inject */ &#39; &quot; &#x3D;end = 'test code inject */ ' " =end_example'; # string | To test code injection */ ' \"
eval {
$api_instance->test_code_inject____end(test code inject */ &#39; &quot; &#x3D;end => $test code inject */ &#39; &quot; &#x3D;end);
};
if ($@) {
warn "Exception when calling FakeApi->test_code_inject____end: $@\n";
}
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**test code inject */ &#39; &quot; &#x3D;end** | **string**| To test code injection */ &#39; \&quot; | [optional]
### Return type
void (empty response body)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: application/json, */ " =end
- **Accept**: application/json, */ " =end
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

View File

@ -0,0 +1,15 @@
# WWW::SwaggerClient::Object::ModelReturn
## Load the model package
```perl
use WWW::SwaggerClient::Object::ModelReturn;
```
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**return** | **int** | property description */ &#39; \&quot; | [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)

View File

@ -0,0 +1,52 @@
#!/bin/sh
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
#
# Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update"
git_user_id=$1
git_repo_id=$2
release_note=$3
if [ "$git_user_id" = "" ]; then
git_user_id="GIT_USER_ID"
echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
fi
if [ "$git_repo_id" = "" ]; then
git_repo_id="GIT_REPO_ID"
echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
fi
if [ "$release_note" = "" ]; then
release_note="Minor update"
echo "[INFO] No command line input provided. Set \$release_note to $release_note"
fi
# Initialize the local directory as a Git repository
git init
# Adds the files in the local repository and stages them for commit.
git add .
# Commits the tracked changes and prepares them to be pushed to a remote repository.
git commit -m "$release_note"
# Sets the new remote
git_remote=`git remote`
if [ "$git_remote" = "" ]; then # git remote not defined
if [ "$GIT_TOKEN" = "" ]; then
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git crediential in your environment."
git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
else
git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
fi
fi
git pull origin master
# Pushes (Forces) the changes in the local repository up to the remote repository
echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git"
git push origin master 2>&1 | grep -v 'To https'

View File

@ -0,0 +1,410 @@
=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 */ &#39; \&quot;
Contact: apiteam@swagger.io */ ' \"
Generated by: https://github.com/swagger-api/swagger-codegen.git
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
=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::ApiClient;
use strict;
use warnings;
use utf8;
use MIME::Base64;
use LWP::UserAgent;
use HTTP::Headers;
use HTTP::Response;
use HTTP::Request::Common qw(DELETE POST GET HEAD PUT);
use HTTP::Status;
use URI::Query;
use JSON;
use URI::Escape;
use Scalar::Util;
use Log::Any qw($log);
use Carp;
use Module::Runtime qw(use_module);
use WWW::SwaggerClient::Configuration;
use base 'Class::Singleton';
sub _new_instance
{
my $class = shift;
my (%args) = (
'ua' => LWP::UserAgent->new,
'base_url' => 'https://petstore.swagger.io */ &#39; &quot; &#x3D;end/v2 */ &#39; &quot; &#x3D;end',
@_
);
return bless \%args, $class;
}
sub _cfg {'WWW::SwaggerClient::Configuration'}
# Set the user agent of the API client
#
# @param string $user_agent The user agent of the API client
#
sub set_user_agent {
my ($self, $user_agent) = @_;
$self->{http_user_agent}= $user_agent;
}
# Set timeout
#
# @param integer $seconds Number of seconds before timing out [set to 0 for no timeout]
#
sub set_timeout {
my ($self, $seconds) = @_;
if (!looks_like_number($seconds)) {
croak('Timeout variable must be numeric.');
}
$self->{http_timeout} = $seconds;
}
# make the HTTP request
# @param string $resourcePath path to method endpoint
# @param string $method method to call
# @param array $queryParams parameters to be place in query URL
# @param array $postData parameters to be placed in POST body
# @param array $headerParams parameters to be place in request header
# @return mixed
sub call_api {
my $self = shift;
my ($resource_path, $method, $query_params, $post_params, $header_params, $body_data, $auth_settings) = @_;
# update parameters based on authentication settings
$self->update_params_for_auth($header_params, $query_params, $auth_settings);
my $_url = $self->{base_url} . $resource_path;
# build query
if (%$query_params) {
$_url = ($_url . '?' . eval { URI::Query->new($query_params)->stringify });
}
# body data
$body_data = to_json($body_data->to_hash) if defined $body_data && $body_data->can('to_hash'); # model to json string
my $_body_data = %$post_params ? $post_params : $body_data;
# Make the HTTP request
my $_request;
if ($method eq 'POST') {
# multipart
$header_params->{'Content-Type'} = lc $header_params->{'Content-Type'} eq 'multipart/form' ?
'form-data' : $header_params->{'Content-Type'};
$_request = POST($_url, %$header_params, Content => $_body_data);
}
elsif ($method eq 'PUT') {
# multipart
$header_params->{'Content-Type'} = lc $header_params->{'Content-Type'} eq 'multipart/form' ?
'form-data' : $header_params->{'Content-Type'};
$_request = PUT($_url, %$header_params, Content => $_body_data);
}
elsif ($method eq 'GET') {
my $headers = HTTP::Headers->new(%$header_params);
$_request = GET($_url, %$header_params);
}
elsif ($method eq 'HEAD') {
my $headers = HTTP::Headers->new(%$header_params);
$_request = HEAD($_url,%$header_params);
}
elsif ($method eq 'DELETE') { #TODO support form data
my $headers = HTTP::Headers->new(%$header_params);
$_request = DELETE($_url, %$headers);
}
elsif ($method eq 'PATCH') { #TODO
}
else {
}
$self->{ua}->timeout($self->{http_timeout} || $WWW::SwaggerClient::Configuration::http_timeout);
$self->{ua}->agent($self->{http_user_agent} || $WWW::SwaggerClient::Configuration::http_user_agent);
$log->debugf("REQUEST: %s", $_request->as_string);
my $_response = $self->{ua}->request($_request);
$log->debugf("RESPONSE: %s", $_response->as_string);
unless ($_response->is_success) {
croak(sprintf "API Exception(%s): %s\n%s", $_response->code, $_response->message, $_response->content);
}
return $_response->content;
}
# Take value and turn it into a string suitable for inclusion in
# the path, by url-encoding.
# @param string $value a string which will be part of the path
# @return string the serialized object
sub to_path_value {
my ($self, $value) = @_;
return uri_escape($self->to_string($value));
}
# Take value and turn it into a string suitable for inclusion in
# the query, by imploding comma-separated if it's an object.
# If it's a string, pass through unchanged. It will be url-encoded
# later.
# @param object $object an object to be serialized to a string
# @return string the serialized object
sub to_query_value {
my ($self, $object) = @_;
if (ref($object) eq 'ARRAY') {
return join(',', @$object);
} else {
return $self->to_string($object);
}
}
# Take value and turn it into a string suitable for inclusion in
# the header. If it's a string, pass through unchanged
# If it's a datetime object, format it in ISO8601
# @param string $value a string which will be part of the header
# @return string the header string
sub to_header_value {
my ($self, $value) = @_;
return $self->to_string($value);
}
# Take value and turn it into a string suitable for inclusion in
# the http body (form parameter). If it's a string, pass through unchanged
# If it's a datetime object, format it in ISO8601
# @param string $value the value of the form parameter
# @return string the form string
sub to_form_value {
my ($self, $value) = @_;
return $self->to_string($value);
}
# Take value and turn it into a string suitable for inclusion in
# the parameter. If it's a string, pass through unchanged
# If it's a datetime object, format it in ISO8601
# @param string $value the value of the parameter
# @return string the header string
sub to_string {
my ($self, $value) = @_;
if (ref($value) eq "DateTime") { # datetime in ISO8601 format
return $value->datetime();
}
else {
return $value;
}
}
# Deserialize a JSON string into an object
#
# @param string $class class name is passed as a string
# @param string $data data of the body
# @return object an instance of $class
sub deserialize
{
my ($self, $class, $data) = @_;
$log->debugf("deserializing %s for %s", $data, $class);
if (not defined $data) {
return undef;
} elsif ( (substr($class, 0, 5)) eq 'HASH[') { #hash
if ($class =~ /^HASH\[(.*),(.*)\]$/) {
my ($key_type, $type) = ($1, $2);
my %hash;
my $decoded_data = decode_json $data;
foreach my $key (keys %$decoded_data) {
if (ref $decoded_data->{$key} eq 'HASH') {
$hash{$key} = $self->deserialize($type, encode_json $decoded_data->{$key});
} else {
$hash{$key} = $self->deserialize($type, $decoded_data->{$key});
}
}
return \%hash;
} else {
#TODO log error
}
} elsif ( (substr($class, 0, 6)) eq 'ARRAY[' ) { # array of data
return $data if $data eq '[]'; # return if empty array
my $_sub_class = substr($class, 6, -1);
my $_json_data = decode_json $data;
my @_values = ();
foreach my $_value (@$_json_data) {
if (ref $_value eq 'ARRAY') {
push @_values, $self->deserialize($_sub_class, encode_json $_value);
} else {
push @_values, $self->deserialize($_sub_class, $_value);
}
}
return \@_values;
} elsif ($class eq 'DateTime') {
return DateTime->from_epoch(epoch => str2time($data));
} elsif (grep /^$class$/, ('string', 'int', 'float', 'bool', 'object')) {
return $data;
} else { # model
my $_instance = use_module("WWW::SwaggerClient::Object::$class")->new;
if (ref $data eq "HASH") {
return $_instance->from_hash($data);
} else { # string, need to json decode first
return $_instance->from_hash(decode_json $data);
}
}
}
# return 'Accept' based on an array of accept provided
# @param [Array] header_accept_array Array fo 'Accept'
# @return String Accept (e.g. application/json)
sub select_header_accept
{
my ($self, @header) = @_;
if (@header == 0 || (@header == 1 && $header[0] eq '')) {
return undef;
} elsif (grep(/^application\/json$/i, @header)) {
return 'application/json';
} else {
return join(',', @header);
}
}
# return the content type based on an array of content-type provided
# @param [Array] content_type_array Array fo content-type
# @return String Content-Type (e.g. application/json)
sub select_header_content_type
{
my ($self, @header) = @_;
if (@header == 0 || (@header == 1 && $header[0] eq '')) {
return 'application/json'; # default to application/json
} elsif (grep(/^application\/json$/i, @header)) {
return 'application/json';
} else {
return join(',', @header);
}
}
# Get API key (with prefix if set)
# @param string key name
# @return string API key with the prefix
sub get_api_key_with_prefix
{
my ($self, $key_name) = @_;
my $api_key = $WWW::SwaggerClient::Configuration::api_key->{$key_name};
return unless $api_key;
my $prefix = $WWW::SwaggerClient::Configuration::api_key_prefix->{$key_name};
return $prefix ? "$prefix $api_key" : $api_key;
}
# update header and query param based on authentication setting
#
# @param array $headerParams header parameters (by ref)
# @param array $queryParams query parameters (by ref)
# @param array $authSettings array of authentication scheme (e.g ['api_key'])
sub update_params_for_auth {
my ($self, $header_params, $query_params, $auth_settings) = @_;
return $self->_global_auth_setup($header_params, $query_params)
unless $auth_settings && @$auth_settings;
# one endpoint can have more than 1 auth settings
foreach my $auth (@$auth_settings) {
# determine which one to use
if (!defined($auth)) {
# TODO show warning about auth setting not defined
}
elsif ($auth eq 'api_key') {
my $api_key = $self->get_api_key_with_prefix('api_key */ &#39; &quot; &#x3D;end');
if ($api_key) {
$header_params->{'api_key */ &#39; &quot; &#x3D;end'} = $api_key;
}
}
elsif ($auth eq 'petstore_auth') {
if ($WWW::SwaggerClient::Configuration::access_token) {
$header_params->{'Authorization'} = 'Bearer ' . $WWW::SwaggerClient::Configuration::access_token;
}
}
else {
# TODO show warning about security definition not found
}
}
}
# The endpoint API class has not found any settings for auth. This may be deliberate,
# in which case update_params_for_auth() will be a no-op. But it may also be that the
# OpenAPI Spec does not describe the intended authorization. So we check in the config for any
# auth tokens and if we find any, we use them for all endpoints;
sub _global_auth_setup {
my ($self, $header_params, $query_params) = @_;
my $tokens = $self->_cfg->get_tokens;
return unless keys %$tokens;
# basic
if (my $uname = delete $tokens->{username}) {
my $pword = delete $tokens->{password};
$header_params->{'Authorization'} = 'Basic '.encode_base64($uname.":".$pword);
}
# oauth
if (my $access_token = delete $tokens->{access_token}) {
$header_params->{'Authorization'} = 'Bearer ' . $access_token;
}
# other keys
foreach my $token_name (keys %$tokens) {
my $in = $tokens->{$token_name}->{in};
my $token = $self->get_api_key_with_prefix($token_name);
if ($in eq 'head') {
$header_params->{$token_name} = $token;
}
elsif ($in eq 'query') {
$query_params->{$token_name} = $token;
}
else {
die "Don't know where to put token '$token_name' ('$in' is not 'head' or 'query')";
}
}
}
1;

View File

@ -0,0 +1,131 @@
=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 */ &#39; \&quot;
Contact: apiteam@swagger.io */ ' \"
Generated by: https://github.com/swagger-api/swagger-codegen.git
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
=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::ApiFactory;
use strict;
use warnings;
use utf8;
use Carp;
use Module::Find;
usesub WWW::SwaggerClient::Object;
use WWW::SwaggerClient::ApiClient;
=head1 Name
WWW::SwaggerClient::ApiFactory - constructs APIs to retrieve WWW::SwaggerClient objects
=head1 Synopsis
package My::Petstore::App;
use WWW::SwaggerClient::ApiFactory;
my $api_factory = WWW::SwaggerClient::ApiFactory->new( ... ); # any args for ApiClient constructor
# later...
my $pet_api = $api_factory->get_api('Pet');
# $pet_api isa WWW::SwaggerClient::PetApi
my $pet = $pet_api->get_pet_by_id(pet_id => $pet_id);
# object attributes have proper accessors:
printf "Pet's name is %s", $pet->name;
# change the value stored on the object:
$pet->name('Dave');
=cut
# Load all the API classes and construct a lookup table at startup time
my %_apis = map { $_ =~ /^WWW::SwaggerClient::(.*)$/; $1 => $_ }
grep {$_ =~ /Api$/}
usesub 'WWW::SwaggerClient';
=head1 new()
Any parameters are optional, and are passed to and stored on the api_client object.
base_url: (optional)
supply this to change the default base URL taken from the Swagger definition.
=cut
sub new {
my ($class, %p) = (shift, @_);
$p{api_client} = WWW::SwaggerClient::ApiClient->instance(%p);
return bless \%p, $class;
}
=head1 get_api($which)
Returns an API object of the requested type.
$which is a nickname for the class:
FooBarClient::BazApi has nickname 'Baz'
=cut
sub get_api {
my ($self, $which) = @_;
croak "API not specified" unless $which;
my $api_class = $_apis{"${which}Api"} || croak "No known API for '$which'";
return $api_class->new(api_client => $self->api_client);
}
=head1 api_client()
Returns the api_client object, should you ever need it.
=cut
sub api_client { $_[0]->{api_client} }
=head1 apis_available()
=cut
sub apis_available { return map { $_ =~ s/Api$//; $_ } sort keys %_apis }
=head1 classname_for()
=cut
sub classname_for {
my ($self, $api_name) = @_;
return $_apis{"${api_name}Api"};
}
1;

View File

@ -0,0 +1,111 @@
=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 */ &#39; \&quot;
Contact: apiteam@swagger.io */ ' \"
Generated by: https://github.com/swagger-api/swagger-codegen.git
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
=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::Configuration;
use strict;
use warnings;
use utf8;
use Log::Any qw($log);
use Carp;
use constant VERSION => '1.0.0';
# class/static variables
our $http_timeout = 180;
our $http_user_agent = 'Perl-Swagger';
# authenticaiton setting
our $api_key = {};
our $api_key_prefix = {};
our $api_key_in = {};
# username and password for HTTP basic authentication
our $username = '';
our $password = '';
# access token for OAuth
our $access_token = '';
sub get_tokens {
my $class = shift;
my $tokens = {};
$tokens->{username} = $username if $username;
$tokens->{password} = $password if $password;
$tokens->{access_token} = $access_token if $access_token;
foreach my $token_name (keys %{ $api_key }) {
$tokens->{$token_name}->{token} = $api_key->{$token_name};
$tokens->{$token_name}->{prefix} = $api_key_prefix->{$token_name};
$tokens->{$token_name}->{in} = $api_key_in->{$token_name};
}
return $tokens;
}
sub clear_tokens {
my $class = shift;
my %tokens = %{$class->get_tokens}; # copy
$username = undef;
$password = undef;
$access_token = undef;
$api_key = {};
$api_key_prefix = {};
$api_key_in = {};
return \%tokens;
}
sub accept_tokens {
my ($class, $tokens) = @_;
foreach my $known_name (qw(username password access_token)) {
next unless $tokens->{$known_name};
eval "\$$known_name = delete \$tokens->{\$known_name}";
die $@ if $@;
}
foreach my $token_name (keys %$tokens) {
$api_key->{$token_name} = $tokens->{$token_name}->{token};
if ($tokens->{$token_name}->{prefix}) {
$api_key_prefix->{$token_name} = $tokens->{$token_name}->{prefix};
}
my $in = $tokens->{$token_name}->{in} || 'head';
croak "Tokens can only go in 'head' or 'query' (not in '$in')" unless $in =~ /^(?:head|query)$/;
$api_key_in->{$token_name} = $in;
}
}
1;

View File

@ -0,0 +1,123 @@
=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 */ &#39; \&quot;
Contact: apiteam@swagger.io */ ' \"
Generated by: https://github.com/swagger-api/swagger-codegen.git
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
=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::FakeApi;
require 5.6.0;
use strict;
use warnings;
use utf8;
use Exporter;
use Carp qw( croak );
use Log::Any qw($log);
use WWW::SwaggerClient::ApiClient;
use WWW::SwaggerClient::Configuration;
use base "Class::Data::Inheritable";
__PACKAGE__->mk_classdata('method_documentation' => {});
sub new {
my $class = shift;
my (%self) = (
'api_client' => WWW::SwaggerClient::ApiClient->instance,
@_
);
#my $self = {
# #api_client => $options->{api_client}
# api_client => $default_api_client
#};
bless \%self, $class;
}
#
# test_code_inject____end
#
# To test code injection */ ' \"
#
# @param string $test code inject */ &#39; &quot; &#x3D;end To test code injection */ &#39; \&quot; (optional)
{
my $params = {
'test code inject */ &#39; &quot; &#x3D;end' => {
data_type => 'string',
description => 'To test code injection */ &#39; \&quot; ',
required => '0',
},
};
__PACKAGE__->method_documentation->{ 'test_code_inject____end' } = {
summary => 'To test code injection */ &#39; \&quot; ',
params => $params,
returns => undef,
};
}
# @return void
#
sub test_code_inject____end {
my ($self, %args) = @_;
# parse inputs
my $_resource_path = '/fake';
$_resource_path =~ s/{format}/json/; # default format to json
my $_method = 'PUT';
my $query_params = {};
my $header_params = {};
my $form_params = {};
# 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json', '*/ " =end');
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type('application/json', '*/ " =end');
# form params
if ( exists $args{'test code inject */ &#39; &quot; &#x3D;end'} ) {
$form_params->{'test code inject */ &#39; &quot; &#x3D;end'} = $self->{api_client}->to_form_value($args{'test code inject */ &#39; &quot; &#x3D;end'});
}
my $_body_data;
# authentication setting, if any
my $auth_settings = [qw()];
# make the API Call
$self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
return;
}
1;

View File

@ -0,0 +1,189 @@
=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 */ &#39; \&quot;
Contact: apiteam@swagger.io */ ' \"
Generated by: https://github.com/swagger-api/swagger-codegen.git
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
=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::ModelReturn;
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 reserved words */ &#39; \&quot;
#
# 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 */ &#39; \&quot;
Contact: apiteam@swagger.io */ ' \"
Generated by: https://github.com/swagger-api/swagger-codegen.git
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
=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 reserved words */ &#39; \&quot; ',
class => 'ModelReturn',
required => [], # TODO
} );
__PACKAGE__->method_documentation({
'return' => {
datatype => 'int',
base_name => 'return',
description => 'property description */ &#39; \&quot; ',
format => '',
read_only => '',
},
});
__PACKAGE__->swagger_types( {
'return' => 'int'
} );
__PACKAGE__->attribute_map( {
'return' => 'return'
} );
__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
1;

View File

@ -0,0 +1,354 @@
=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 */ &#39; \&quot;
Contact: apiteam@swagger.io */ ' \"
Generated by: https://github.com/swagger-api/swagger-codegen.git
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
=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::Role;
use utf8;
use Moose::Role;
use namespace::autoclean;
use Class::Inspector;
use Log::Any qw($log);
use WWW::SwaggerClient::ApiFactory;
has base_url => ( is => 'ro',
required => 0,
isa => 'Str',
documentation => 'Root of the server that requests are sent to',
);
has api_factory => ( is => 'ro',
isa => 'WWW::SwaggerClient::ApiFactory',
builder => '_build_af',
lazy => 1,
documentation => 'Builds an instance of the endpoint API class',
);
has tokens => ( is => 'ro',
isa => 'HashRef',
required => 0,
default => sub { {} },
documentation => 'The auth tokens required by the application - basic, OAuth and/or API key(s)',
);
has _cfg => ( is => 'ro',
isa => 'Str',
default => 'WWW::SwaggerClient::Configuration',
);
has version_info => ( is => 'ro',
isa => 'HashRef',
default => sub { {
app_name => 'Swagger Petstore */ &#39; \&quot; ',
app_version => '1.0.0 */ &#39; \&quot; ',
generated_date => '2016-06-28T16:32:36.006+08:00',
generator_class => '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;
}
# 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 => (
is => 'ro',
isa => $api_class,
default => sub {$self->api_factory->get_api($api_name)},
lazy => 1,
handles => \@delegated,
) );
}
}
sub _build_af {
my $self = shift;
my %args;
$args{base_url} = $self->base_url if $self->base_url;
return WWW::SwaggerClient::ApiFactory->new(%args);
}
=head1 NAME
WWW::SwaggerClient::Role - a Moose role for the Swagger Petstore */ &#39; \&quot;
=head2 Swagger Petstore */ &#39; \&quot; version: 1.0.0 */ &#39; \&quot;
=head1 VERSION
Automatically generated by the Perl Swagger Codegen project:
=over 4
=item Build date: 2016-06-28T16:32:36.006+08:00
=item Build package: class io.swagger.codegen.languages.PerlClientCodegen
=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.
=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
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.
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.
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.
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.
=head2 Configuring authentication
In the normal case, the OpenAPI Spec will describe what parameters are
required and where to put them. You just need to supply the tokens.
my $tokens = {
# basic
username => $username,
password => $password,
# oauth
access_token => $oauth_token,
# keys
$some_key => { token => $token,
prefix => $prefix,
in => $in, # 'head||query',
},
$another => { token => $token,
prefix => $prefix,
in => $in, # 'head||query',
},
...,
};
my $api = MyApp->new({ tokens => $tokens });
Note these are all optional, as are C<prefix> and C<in>, and depend on the API
you are accessing. Usually C<prefix> and C<in> will be determined by the code generator from
the spec and you will not need to set them at run time. If not, C<in> will
default to 'head' and C<prefix> to the empty string.
The tokens will be placed in the C<WWW::SwaggerClient::Configuration> namespace
as follows, but you don't need to know about this.
=over 4
=item C<$WWW::SwaggerClient::Configuration::username>
String. The username for basic auth.
=item C<$WWW::SwaggerClient::Configuration::password>
String. The password for basic auth.
=item C<$WWW::SwaggerClient::Configuration::api_key>
Hashref. Keyed on the name of each key (there can be multiple tokens).
$WWW::SwaggerClient::Configuration::api_key = {
secretKey => 'aaaabbbbccccdddd',
anotherKey => '1111222233334444',
};
=item C<$WWW::SwaggerClient::Configuration::api_key_prefix>
Hashref. Keyed on the name of each key (there can be multiple tokens). Note not
all api keys require a prefix.
$WWW::SwaggerClient::Configuration::api_key_prefix = {
secretKey => 'string',
anotherKey => 'same or some other string',
};
=item C<$WWW::SwaggerClient::Configuration::access_token>
String. The OAuth access token.
=back
=head1 METHODS
=head2 C<base_url>
The generated code has the C<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 C<base_url>.
=head2 C<api_factory>
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
Most of the methods on the API are delegated to individual endpoint API objects
(e.g. Pet API, Store API, User API etc). Where different endpoint APIs use the
same method name (e.g. C<new()>), these methods can't be delegated. So you need
to call C<$api-E<gt>pet_api-E<gt>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:
new()
class_documentation()
method_documentation()
To call these methods, you need to get a handle on the relevant object, either
by calling C<$api-E<gt>foo_api> or by retrieving an object, e.g.
C<$api-E<gt>get_pet_by_id(pet_id =E<gt> $pet_id)>. They are class methods, so
you could also call them on class names.
=head1 BUILDING YOUR LIBRARY
See the homepage C<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:
{"moduleName":"WWW::MyProjectName"}
Your library files will be built under C<WWW::MyProjectName>.
$ git clone https://github.com/swagger-api/swagger-codegen.git
$ cd swagger-codegen
$ mvn package
$ java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \
-i [URL or file path to JSON swagger API spec] \
-l perl \
-c /path/to/config/file.json \
-o /path/to/output/folder
Bang, all done. Run the C<autodoc> script in the C<bin> directory to see the API
you just built.
=head1 AUTOMATIC DOCUMENTATION
You can print out a summary of the generated API by running the included
C<autodoc> script in the C<bin> directory of your generated library. A few
output formats are supported:
Usage: autodoc [OPTION]
-w wide format (default)
-n narrow format
-p POD format
-H HTML format
-m Markdown format
-h print this help message
-c your application class
The C<-c> option allows you to load and inspect your own application. A dummy
namespace is used if you don't supply your own class.
=head1 DOCUMENTATION FROM THE OpenAPI Spec
Additional documentation for each class and method may be provided by the Swagger
spec. If so, this is available via the C<class_documentation()> and
C<method_documentation()> methods on each generated object class, and the
C<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};
Each of these calls returns a hashref with various useful pieces of information.
=cut
1;

View File

@ -0,0 +1,458 @@
=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 */ &#39; \&quot;
Contact: apiteam@swagger.io */ ' \"
Generated by: https://github.com/swagger-api/swagger-codegen.git
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
=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::Role::AutoDoc;
use List::MoreUtils qw(uniq);
use Moose::Role;
sub autodoc {
my ($self, $how) = @_;
die "Unknown format '$how'" unless $how =~ /^(pod|wide|narrow)$/;
$self->_printisa($how);
$self->_printmethods($how);
$self->_printattrs($how);
print "\n";
}
sub _printisa {
my ($self, $how) = @_;
my $meta = $self->meta;
my $myclass = ref $self;
my $super = join ', ', $meta->superclasses;
my @roles = $meta->calculate_all_roles;
#shift(@roles) if @roles > 1; # if > 1, the first is a composite, the rest are the roles
my $isa = join ', ', grep {$_ ne $myclass} $meta->linearized_isa;
my $sub = join ', ', $meta->subclasses;
my $dsub = join ', ', $meta->direct_subclasses;
my $app_name = $self->version_info->{app_name};
my $app_version = $self->version_info->{app_version};
my $generated_date = $self->version_info->{generated_date};
my $generator_class = $self->version_info->{generator_class};
$~ = $how eq 'pod' ? 'INHERIT_POD' : 'INHERIT';
write;
my ($rolepkg, $role_reqs);
foreach my $role (@roles) {
$rolepkg = $role->{package} || next; # some are anonymous, or something
next if $rolepkg eq 'WWW::SwaggerClient::Role::AutoDoc';
$role_reqs = join ', ', keys %{$role->{required_methods}};
$role_reqs ||= '';
$~ = $how eq 'pod' ? 'ROLES_POD' : 'ROLES';
write;
}
if ($how eq 'pod') {
$~ = 'ROLES_POD_CLOSE';
write;
}
# ----- format specs -----
format INHERIT =
@* -
$myclass
ISA: @*
$isa
Direct subclasses: @*
$dsub
All subclasses: @*
$sub
Target API: @* @*
$app_name, $app_version
Generated on: @*
$generated_date
Generator class: @*
$generator_class
.
format ROLES =
Composes: ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ~
$rolepkg
requires: ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ~
$role_reqs
^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ~~
$role_reqs
.
format INHERIT_POD =
=head1 NAME
@*
$myclass
=head1 VERSION
=head2 @* version: @*
$app_name, $app_version
Automatically generated by the Perl Swagger Codegen project:
=over 4
=item Build date: @*
$generated_date
=item Build package: @*
$generator_class
=item Codegen version:
=back
=head1 INHERITANCE
=head2 Base class(es)
@*
$isa
=head2 Direct subclasses
@*
$dsub
=head2 All subclasses
@*
$sub
=head1 COMPOSITION
@* composes the following roles:
$myclass
.
format ROLES_POD =
=head2 C<@*>
$rolepkg
Requires:
@*
$role_reqs
.
format ROLES_POD_CLOSE =
.
# ----- / format specs -----
}
sub _printmethods {
my ($self, $how) = @_;
if ($how eq 'narrow') {
print <<HEAD;
METHODS
-------
HEAD
}
elsif ($how eq 'wide') {
$~ = 'METHODHEAD';
write;
}
elsif ($how eq 'pod') {
$~ = 'METHODHEAD_POD';
write;
}
else {
die "Don't know how to print '$how'";
}
$self->_printmethod($_, $how) for uniq sort $self->meta->get_all_method_names; #$self->meta->get_method_list,
if ($how eq 'pod') {
$~ = 'METHOD_POD_CLOSE';
write;
}
}
sub _printmethod {
my ($self, $methodname, $how) = @_;
return if $methodname =~ /^_/;
return if $self->meta->has_attribute($methodname);
my %internal = map {$_ => 1} qw(BUILD BUILDARGS meta can new DEMOLISHALL DESTROY
DOES isa BUILDALL does VERSION dump
);
return if $internal{$methodname};
my $method = $self->meta->get_method($methodname) or return; # symbols imported into namespaces i.e. not known by Moose
return if $method->original_package_name eq __PACKAGE__;
my $delegate_to = '';
my $via = '';
my $on = '';
my $doc = '';
my $original_pkg = $method->original_package_name;
if ($method->can('associated_attribute')) {
$delegate_to = $method->delegate_to_method;
my $aa = $method->associated_attribute;
$on = $aa->{isa};
$via = $aa->{name};
$original_pkg = $on;
$doc = $original_pkg->method_documentation->{$delegate_to}->{summary};
}
else {
$doc = $method->documentation;
}
if ($how eq 'narrow') {
$~ = 'METHOD_NARROW';
write;
}
elsif ($how eq 'pod' and $delegate_to) {
$~ = 'METHOD_POD_DELEGATED';
write;
}
elsif ($how eq 'pod') {
$~ = 'METHOD_POD';
write;
}
else {
$~ = 'METHOD';
write;
}
# ----- format specs -----
format METHODHEAD =
METHODS
-------
Name delegates to on via
===========================================================================================================================================================================
.
format METHOD =
@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<... @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<... @<<<<<<<<<<<<<<<<...
$methodname, $delegate_to, $on, $via
.
format METHOD_NARROW =
@*
$methodname
original pkg: @*
$original_pkg
delegates to: @*
$delegate_to
on: @*
$on
via: @*
$via
.
format METHODHEAD_POD =
=head1 METHODS
.
format METHOD_POD =
=head2 C<@*()>
$methodname
Defined in: @*
$original_pkg
.
format METHOD_POD_DELEGATED =
=head2 C<@*()>
$methodname
Defined in: @*
$original_pkg
Delegates to: @*()
$delegate_to
On: @*
$on
Via: @*()
$via
Doc: @*
$doc
Same as: $self->@*->@*()
$via, $delegate_to
.
format METHOD_POD_CLOSE =
.
# ----- / format specs -----
}
sub _printattrs {
my ($self, $how) = @_;
if ($how eq 'narrow') {
print <<HEAD;
ATTRIBUTES
----------
HEAD
}
elsif ($how eq 'wide') {
$~ = 'ATTRHEAD';
write;
}
elsif ($how eq 'pod') {
$~ = 'ATTRHEAD_POD';
write;
}
else {
die "Don't know how to print attributes '$how'";
}
$self->_printattr($_, $how) for sort $self->meta->get_attribute_list;
if ($how eq 'pod') {
$~ = 'ATTR_POD_CLOSE';
write;
}
}
sub _printattr {
my ($self, $attrname, $how) = @_;
return if $attrname =~ /^_/;
my $attr = $self->meta->get_attribute($attrname) or die "No attr for $attrname";
my $is;
$is = 'rw' if $attr->get_read_method && $attr->get_write_method;
$is = 'ro' if $attr->get_read_method && ! $attr->get_write_method;
$is = 'wo' if $attr->get_write_method && ! $attr->get_read_method;
$is = '--' if ! $attr->get_write_method && ! $attr->get_read_method;
$is or die "No \$is for $attrname";
my $tc = $attr->type_constraint || '';
my $from = $attr->associated_class->name || '';
my $reqd = $attr->is_required ? 'yes' : 'no';
my $lazy = $attr->is_lazy ? 'yes' : 'no';
my $has_doc = $attr->has_documentation ? 'yes' : 'no'; # *_api attributes will never have doc, but other attributes might have
my $doc = $attr->documentation || '';
my $handles = join ', ', sort @{$attr->handles || []};
$handles ||= '';
if ($how eq 'narrow') {
$~ = 'ATTR_NARROW';
}
elsif ($how eq 'pod') {
$~ = 'ATTR_POD';
}
else {
$~ = 'ATTR';
}
write;
# ----- format specs -----
format ATTRHEAD =
ATTRIBUTES
----------
Name is isa reqd lazy doc handles
==============================================================================================================
.
format ATTR =
@<<<<<<<<<<<<<<<<< @< @<<<<<<<<<<<<<<<<<<<<<<<< @<<< @<<< @<< ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$attrname, $is, $tc, $reqd, $lazy, $has_doc, $handles
^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ~~
$handles
.
format ATTR_NARROW =
@*
$attrname
is: @*
$is
isa: @*
$tc
reqd: @*
$reqd
lazy: @*
$lazy
doc: @*
$doc
handles: ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$handles
^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ~~
$handles
.
format ATTRHEAD_POD =
=head1 ATTRIBUTES
.
format ATTR_POD =
=head2 C<@*>
$attrname
is: @*
$is
isa: @*
$tc
reqd: @*
$reqd
lazy: @*
$lazy
doc: @*
$doc
handles: ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$handles
^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ~~
$handles
.
format ATTR_POD_CLOSE =
.
# ----- / format specs -----
}
1;

View File

@ -0,0 +1,53 @@
=begin comment
Swagger Petstore ' \" =end
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ ' \" =end
OpenAPI spec version: 1.0.0 &#39; \&quot; &#x3D;end
Contact: apiteam@swagger.io ' \" =end
Generated by: https://github.com/swagger-api/swagger-codegen.git
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
=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_code_inject */ ' " =end test
#
{
my $test code inject */ &#39; &quot; &#x3D;end = undef; # replace NULL with a proper value
my $result = $api->test_code_inject */ &#39; &quot; &#x3D;end(test code inject */ &#39; &quot; &#x3D;end => $test code inject */ &#39; &quot; &#x3D;end);
}
1;

View File

@ -0,0 +1,45 @@
=begin comment
Swagger Petstore ' \" =end
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ ' \" =end
OpenAPI spec version: 1.0.0 &#39; \&quot; &#x3D;end
Contact: apiteam@swagger.io ' \" =end
Generated by: https://github.com/swagger-api/swagger-codegen.git
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
=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::ModelReturn');
my $instance = WWW::SwaggerClient::Object::ModelReturn->new();
isa_ok($instance, 'WWW::SwaggerClient::Object::ModelReturn');

View File

@ -2,7 +2,7 @@
WWW::SwaggerClient::Role - a Moose role for the 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: \" \\
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
# VERSION
@ -10,7 +10,7 @@ Automatically generated by the [Swagger Codegen](https://github.com/swagger-api/
- API version: 1.0.0
- Package version: 1.0.0
- Build date: 2016-06-10T22:39:40.931+08:00
- Build date: 2016-06-28T16:35:21.686+08:00
- Build package: class io.swagger.codegen.languages.PerlClientCodegen
## A note on Moose
@ -236,6 +236,8 @@ use WWW::SwaggerClient::Object::AdditionalPropertiesClass;
use WWW::SwaggerClient::Object::Animal;
use WWW::SwaggerClient::Object::AnimalFarm;
use WWW::SwaggerClient::Object::ApiResponse;
use WWW::SwaggerClient::Object::ArrayOfArrayOfNumberOnly;
use WWW::SwaggerClient::Object::ArrayOfNumberOnly;
use WWW::SwaggerClient::Object::ArrayTest;
use WWW::SwaggerClient::Object::Cat;
use WWW::SwaggerClient::Object::Category;
@ -243,10 +245,13 @@ use WWW::SwaggerClient::Object::Dog;
use WWW::SwaggerClient::Object::EnumClass;
use WWW::SwaggerClient::Object::EnumTest;
use WWW::SwaggerClient::Object::FormatTest;
use WWW::SwaggerClient::Object::HasOnlyReadOnly;
use WWW::SwaggerClient::Object::MapTest;
use WWW::SwaggerClient::Object::MixedPropertiesAndAdditionalPropertiesClass;
use WWW::SwaggerClient::Object::Model200Response;
use WWW::SwaggerClient::Object::ModelReturn;
use WWW::SwaggerClient::Object::Name;
use WWW::SwaggerClient::Object::NumberOnly;
use WWW::SwaggerClient::Object::Order;
use WWW::SwaggerClient::Object::Pet;
use WWW::SwaggerClient::Object::ReadOnlyFirst;
@ -274,6 +279,8 @@ use WWW::SwaggerClient::Object::AdditionalPropertiesClass;
use WWW::SwaggerClient::Object::Animal;
use WWW::SwaggerClient::Object::AnimalFarm;
use WWW::SwaggerClient::Object::ApiResponse;
use WWW::SwaggerClient::Object::ArrayOfArrayOfNumberOnly;
use WWW::SwaggerClient::Object::ArrayOfNumberOnly;
use WWW::SwaggerClient::Object::ArrayTest;
use WWW::SwaggerClient::Object::Cat;
use WWW::SwaggerClient::Object::Category;
@ -281,10 +288,13 @@ use WWW::SwaggerClient::Object::Dog;
use WWW::SwaggerClient::Object::EnumClass;
use WWW::SwaggerClient::Object::EnumTest;
use WWW::SwaggerClient::Object::FormatTest;
use WWW::SwaggerClient::Object::HasOnlyReadOnly;
use WWW::SwaggerClient::Object::MapTest;
use WWW::SwaggerClient::Object::MixedPropertiesAndAdditionalPropertiesClass;
use WWW::SwaggerClient::Object::Model200Response;
use WWW::SwaggerClient::Object::ModelReturn;
use WWW::SwaggerClient::Object::Name;
use WWW::SwaggerClient::Object::NumberOnly;
use WWW::SwaggerClient::Object::Order;
use WWW::SwaggerClient::Object::Pet;
use WWW::SwaggerClient::Object::ReadOnlyFirst;
@ -296,24 +306,13 @@ use WWW::SwaggerClient::Object::User;
use Data::Dumper;
my $api_instance = WWW::SwaggerClient::FakeApi->new();
my $number = 3.4; # Number | None
my $double = 1.2; # double | None
my $string = 'string_example'; # string | None
my $byte = 'B'; # string | None
my $integer = 56; # int | None
my $int32 = 56; # int | None
my $int64 = 789; # int | None
my $float = 3.4; # double | None
my $binary = 'B'; # string | None
my $date = DateTime->from_epoch(epoch => str2time('2013-10-20')); # DateTime | None
my $date_time = DateTime->from_epoch(epoch => str2time('2013-10-20T19:20:30+01:00')); # DateTime | None
my $password = 'password_example'; # string | None
my $test code inject */ &#x3D;end = 'test code inject */ =end_example'; # string | To test code injection */
eval {
$api_instance->test_endpoint_parameters(number => $number, double => $double, string => $string, byte => $byte, integer => $integer, int32 => $int32, int64 => $int64, float => $float, binary => $binary, date => $date, date_time => $date_time, password => $password);
$api_instance->test_code_inject__end(test code inject */ &#x3D;end => $test code inject */ &#x3D;end);
};
if ($@) {
warn "Exception when calling FakeApi->test_endpoint_parameters: $@\n";
warn "Exception when calling FakeApi->test_code_inject__end: $@\n";
}
```
@ -324,7 +323,9 @@ All URIs are relative to *http://petstore.swagger.io/v2*
Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*FakeApi* | [**test_code_inject__end**](docs/FakeApi.md#test_code_inject__end) | **PUT** /fake | To test code injection */
*FakeApi* | [**test_endpoint_parameters**](docs/FakeApi.md#test_endpoint_parameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
*FakeApi* | [**test_enum_query_parameters**](docs/FakeApi.md#test_enum_query_parameters) | **GET** /fake | To test enum query parameters
*PetApi* | [**add_pet**](docs/PetApi.md#add_pet) | **POST** /pet | Add a new pet to the store
*PetApi* | [**delete_pet**](docs/PetApi.md#delete_pet) | **DELETE** /pet/{petId} | Deletes a pet
*PetApi* | [**find_pets_by_status**](docs/PetApi.md#find_pets_by_status) | **GET** /pet/findByStatus | Finds Pets by status
@ -352,6 +353,8 @@ Class | Method | HTTP request | Description
- [WWW::SwaggerClient::Object::Animal](docs/Animal.md)
- [WWW::SwaggerClient::Object::AnimalFarm](docs/AnimalFarm.md)
- [WWW::SwaggerClient::Object::ApiResponse](docs/ApiResponse.md)
- [WWW::SwaggerClient::Object::ArrayOfArrayOfNumberOnly](docs/ArrayOfArrayOfNumberOnly.md)
- [WWW::SwaggerClient::Object::ArrayOfNumberOnly](docs/ArrayOfNumberOnly.md)
- [WWW::SwaggerClient::Object::ArrayTest](docs/ArrayTest.md)
- [WWW::SwaggerClient::Object::Cat](docs/Cat.md)
- [WWW::SwaggerClient::Object::Category](docs/Category.md)
@ -359,10 +362,13 @@ Class | Method | HTTP request | Description
- [WWW::SwaggerClient::Object::EnumClass](docs/EnumClass.md)
- [WWW::SwaggerClient::Object::EnumTest](docs/EnumTest.md)
- [WWW::SwaggerClient::Object::FormatTest](docs/FormatTest.md)
- [WWW::SwaggerClient::Object::HasOnlyReadOnly](docs/HasOnlyReadOnly.md)
- [WWW::SwaggerClient::Object::MapTest](docs/MapTest.md)
- [WWW::SwaggerClient::Object::MixedPropertiesAndAdditionalPropertiesClass](docs/MixedPropertiesAndAdditionalPropertiesClass.md)
- [WWW::SwaggerClient::Object::Model200Response](docs/Model200Response.md)
- [WWW::SwaggerClient::Object::ModelReturn](docs/ModelReturn.md)
- [WWW::SwaggerClient::Object::Name](docs/Name.md)
- [WWW::SwaggerClient::Object::NumberOnly](docs/NumberOnly.md)
- [WWW::SwaggerClient::Object::Order](docs/Order.md)
- [WWW::SwaggerClient::Object::Pet](docs/Pet.md)
- [WWW::SwaggerClient::Object::ReadOnlyFirst](docs/ReadOnlyFirst.md)

View File

@ -11,6 +11,7 @@ Name | Type | Description | Notes
**array_of_string** | **ARRAY[string]** | | [optional]
**array_array_of_integer** | **ARRAY[ARRAY[int]]** | | [optional]
**array_array_of_model** | **ARRAY[ARRAY[ReadOnlyFirst]]** | | [optional]
**array_of_enum** | **ARRAY[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)

View File

@ -9,9 +9,52 @@ All URIs are relative to *http://petstore.swagger.io/v2*
Method | HTTP request | Description
------------- | ------------- | -------------
[**test_code_inject__end**](FakeApi.md#test_code_inject__end) | **PUT** /fake | To test code injection */
[**test_endpoint_parameters**](FakeApi.md#test_endpoint_parameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
[**test_enum_query_parameters**](FakeApi.md#test_enum_query_parameters) | **GET** /fake | To test enum query parameters
# **test_code_inject__end**
> test_code_inject__end(test code inject */ &#x3D;end => $test code inject */ &#x3D;end)
To test code injection */
### Example
```perl
use Data::Dumper;
my $api_instance = WWW::SwaggerClient::FakeApi->new();
my $test code inject */ &#x3D;end = 'test code inject */ =end_example'; # string | To test code injection */
eval {
$api_instance->test_code_inject__end(test code inject */ &#x3D;end => $test code inject */ &#x3D;end);
};
if ($@) {
warn "Exception when calling FakeApi->test_code_inject__end: $@\n";
}
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**test code inject */ &#x3D;end** | **string**| To test code injection */ | [optional]
### Return type
void (empty response body)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: application/json, */ =end));(phpinfo(
- **Accept**: application/json, */ end
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
# **test_endpoint_parameters**
> test_endpoint_parameters(number => $number, double => $double, string => $string, byte => $byte, integer => $integer, int32 => $int32, int64 => $int64, float => $float, binary => $binary, date => $date, date_time => $date_time, password => $password)
@ -77,3 +120,48 @@ No authorization required
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
# **test_enum_query_parameters**
> test_enum_query_parameters(enum_query_string => $enum_query_string, enum_query_integer => $enum_query_integer, enum_query_double => $enum_query_double)
To test enum query parameters
### Example
```perl
use Data::Dumper;
my $api_instance = WWW::SwaggerClient::FakeApi->new();
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_double = 1.2; # double | Query parameter enum test (double)
eval {
$api_instance->test_enum_query_parameters(enum_query_string => $enum_query_string, enum_query_integer => $enum_query_integer, enum_query_double => $enum_query_double);
};
if ($@) {
warn "Exception when calling FakeApi->test_enum_query_parameters: $@\n";
}
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**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_double** | **double**| Query parameter enum test (double) | [optional]
### Return type
void (empty response body)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: application/json
- **Accept**: application/json
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

View File

@ -9,6 +9,7 @@ use WWW::SwaggerClient::Object::Model200Response;
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**name** | **int** | | [optional]
**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)

View File

@ -2,7 +2,7 @@
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: \" \\
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

View File

@ -2,7 +2,7 @@
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: \" \\
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

View File

@ -2,7 +2,7 @@
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: \" \\
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

View File

@ -2,7 +2,7 @@
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: \" \\
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
@ -63,6 +63,63 @@ sub new {
}
#
# test_code_inject__end
#
# To test code injection */
#
# @param string $test code inject */ &#x3D;end To test code injection */ (optional)
{
my $params = {
'test code inject */ &#x3D;end' => {
data_type => 'string',
description => 'To test code injection */ ',
required => '0',
},
};
__PACKAGE__->method_documentation->{ 'test_code_inject__end' } = {
summary => 'To test code injection */ ',
params => $params,
returns => undef,
};
}
# @return void
#
sub test_code_inject__end {
my ($self, %args) = @_;
# parse inputs
my $_resource_path = '/fake';
$_resource_path =~ s/{format}/json/; # default format to json
my $_method = 'PUT';
my $query_params = {};
my $header_params = {};
my $form_params = {};
# 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json', '*/ end');
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type('application/json', '*/ =end));(phpinfo(');
# form params
if ( exists $args{'test code inject */ &#x3D;end'} ) {
$form_params->{'test code inject */ &#x3D;end'} = $self->{api_client}->to_form_value($args{'test code inject */ &#x3D;end'});
}
my $_body_data;
# authentication setting, if any
my $auth_settings = [qw()];
# make the API Call
$self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
return;
}
#
# test_endpoint_parameters
#
@ -143,7 +200,7 @@ sub new {
required => '0',
},
};
__PACKAGE__->method_documentation->{ test_endpoint_parameters } = {
__PACKAGE__->method_documentation->{ 'test_endpoint_parameters' } = {
summary => 'Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 ',
params => $params,
returns => undef,
@ -261,4 +318,83 @@ sub test_endpoint_parameters {
return;
}
#
# test_enum_query_parameters
#
# To test enum query parameters
#
# @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 double $enum_query_double Query parameter enum test (double) (optional)
{
my $params = {
'enum_query_string' => {
data_type => 'string',
description => 'Query parameter enum test (string)',
required => '0',
},
'enum_query_integer' => {
data_type => 'Number',
description => 'Query parameter enum test (double)',
required => '0',
},
'enum_query_double' => {
data_type => 'double',
description => 'Query parameter enum test (double)',
required => '0',
},
};
__PACKAGE__->method_documentation->{ 'test_enum_query_parameters' } = {
summary => 'To test enum query parameters',
params => $params,
returns => undef,
};
}
# @return void
#
sub test_enum_query_parameters {
my ($self, %args) = @_;
# parse inputs
my $_resource_path = '/fake';
$_resource_path =~ s/{format}/json/; # default format to json
my $_method = 'GET';
my $query_params = {};
my $header_params = {};
my $form_params = {};
# 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json');
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type('application/json');
# query params
if ( exists $args{'enum_query_integer'}) {
$query_params->{'enum_query_integer'} = $self->{api_client}->to_query_value($args{'enum_query_integer'});
}
# form params
if ( exists $args{'enum_query_string'} ) {
$form_params->{'enum_query_string'} = $self->{api_client}->to_form_value($args{'enum_query_string'});
}
# form params
if ( exists $args{'enum_query_double'} ) {
$form_params->{'enum_query_double'} = $self->{api_client}->to_form_value($args{'enum_query_double'});
}
my $_body_data;
# authentication setting, if any
my $auth_settings = [qw()];
# make the API Call
$self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
return;
}
1;

View File

@ -2,7 +2,7 @@
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: \" \\
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
@ -56,7 +56,7 @@ use base ("Class::Accessor", "Class::Data::Inheritable");
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: \" \\
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

View File

@ -2,7 +2,7 @@
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: \" \\
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
@ -56,7 +56,7 @@ use base ("Class::Accessor", "Class::Data::Inheritable");
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: \" \\
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

View File

@ -2,7 +2,7 @@
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: \" \\
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
@ -56,7 +56,7 @@ use base ("Class::Accessor", "Class::Data::Inheritable");
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: \" \\
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

View File

@ -2,7 +2,7 @@
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: \" \\
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
@ -56,7 +56,7 @@ use base ("Class::Accessor", "Class::Data::Inheritable");
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: \" \\
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

View File

@ -2,7 +2,7 @@
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: \" \\
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
@ -56,7 +56,7 @@ use base ("Class::Accessor", "Class::Data::Inheritable");
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: \" \\
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
@ -187,18 +187,27 @@ __PACKAGE__->method_documentation({
format => '',
read_only => '',
},
'array_of_enum' => {
datatype => 'ARRAY[string]',
base_name => 'array_of_enum',
description => '',
format => '',
read_only => '',
},
});
__PACKAGE__->swagger_types( {
'array_of_string' => 'ARRAY[string]',
'array_array_of_integer' => 'ARRAY[ARRAY[int]]',
'array_array_of_model' => 'ARRAY[ARRAY[ReadOnlyFirst]]'
'array_array_of_model' => 'ARRAY[ARRAY[ReadOnlyFirst]]',
'array_of_enum' => 'ARRAY[string]'
} );
__PACKAGE__->attribute_map( {
'array_of_string' => 'array_of_string',
'array_array_of_integer' => 'array_array_of_integer',
'array_array_of_model' => 'array_array_of_model'
'array_array_of_model' => 'array_array_of_model',
'array_of_enum' => 'array_of_enum'
} );
__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});

View File

@ -2,7 +2,7 @@
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: \" \\
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
@ -56,7 +56,7 @@ use base ("Class::Accessor", "Class::Data::Inheritable");
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: \" \\
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

View File

@ -2,7 +2,7 @@
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: \" \\
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
@ -56,7 +56,7 @@ use base ("Class::Accessor", "Class::Data::Inheritable");
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: \" \\
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

View File

@ -2,7 +2,7 @@
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: \" \\
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
@ -56,7 +56,7 @@ use base ("Class::Accessor", "Class::Data::Inheritable");
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: \" \\
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

View File

@ -2,7 +2,7 @@
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: \" \\
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
@ -56,7 +56,7 @@ use base ("Class::Accessor", "Class::Data::Inheritable");
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: \" \\
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

View File

@ -2,7 +2,7 @@
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: \" \\
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
@ -56,7 +56,7 @@ use base ("Class::Accessor", "Class::Data::Inheritable");
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: \" \\
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

View File

@ -2,7 +2,7 @@
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: \" \\
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
@ -56,7 +56,7 @@ use base ("Class::Accessor", "Class::Data::Inheritable");
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: \" \\
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

View File

@ -2,7 +2,7 @@
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: \" \\
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
@ -56,7 +56,7 @@ use base ("Class::Accessor", "Class::Data::Inheritable");
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: \" \\
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

View File

@ -2,7 +2,7 @@
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: \" \\
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
@ -56,7 +56,7 @@ use base ("Class::Accessor", "Class::Data::Inheritable");
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: \" \\
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
@ -173,14 +173,23 @@ __PACKAGE__->method_documentation({
format => '',
read_only => '',
},
'class' => {
datatype => 'string',
base_name => 'class',
description => '',
format => '',
read_only => '',
},
});
__PACKAGE__->swagger_types( {
'name' => 'int'
'name' => 'int',
'class' => 'string'
} );
__PACKAGE__->attribute_map( {
'name' => 'name'
'name' => 'name',
'class' => 'class'
} );
__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});

View File

@ -2,7 +2,7 @@
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: \" \\
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
@ -56,7 +56,7 @@ use base ("Class::Accessor", "Class::Data::Inheritable");
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: \" \\
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

View File

@ -2,7 +2,7 @@
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: \" \\
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
@ -56,7 +56,7 @@ use base ("Class::Accessor", "Class::Data::Inheritable");
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: \" \\
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

View File

@ -2,7 +2,7 @@
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: \" \\
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
@ -56,7 +56,7 @@ use base ("Class::Accessor", "Class::Data::Inheritable");
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: \" \\
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

View File

@ -2,7 +2,7 @@
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: \" \\
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
@ -56,7 +56,7 @@ use base ("Class::Accessor", "Class::Data::Inheritable");
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: \" \\
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

View File

@ -2,7 +2,7 @@
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: \" \\
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
@ -56,7 +56,7 @@ use base ("Class::Accessor", "Class::Data::Inheritable");
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: \" \\
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

View File

@ -2,7 +2,7 @@
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: \" \\
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
@ -56,7 +56,7 @@ use base ("Class::Accessor", "Class::Data::Inheritable");
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: \" \\
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

View File

@ -2,7 +2,7 @@
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: \" \\
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
@ -56,7 +56,7 @@ use base ("Class::Accessor", "Class::Data::Inheritable");
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: \" \\
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

View File

@ -2,7 +2,7 @@
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: \" \\
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
@ -56,7 +56,7 @@ use base ("Class::Accessor", "Class::Data::Inheritable");
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: \" \\
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

View File

@ -2,7 +2,7 @@
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: \" \\
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
@ -77,7 +77,7 @@ sub new {
required => '1',
},
};
__PACKAGE__->method_documentation->{ add_pet } = {
__PACKAGE__->method_documentation->{ 'add_pet' } = {
summary => 'Add a new pet to the store',
params => $params,
returns => undef,
@ -145,7 +145,7 @@ sub add_pet {
required => '0',
},
};
__PACKAGE__->method_documentation->{ delete_pet } = {
__PACKAGE__->method_documentation->{ 'delete_pet' } = {
summary => 'Deletes a pet',
params => $params,
returns => undef,
@ -214,7 +214,7 @@ sub delete_pet {
required => '1',
},
};
__PACKAGE__->method_documentation->{ find_pets_by_status } = {
__PACKAGE__->method_documentation->{ 'find_pets_by_status' } = {
summary => 'Finds Pets by status',
params => $params,
returns => 'ARRAY[Pet]',
@ -280,7 +280,7 @@ sub find_pets_by_status {
required => '1',
},
};
__PACKAGE__->method_documentation->{ find_pets_by_tags } = {
__PACKAGE__->method_documentation->{ 'find_pets_by_tags' } = {
summary => 'Finds Pets by tags',
params => $params,
returns => 'ARRAY[Pet]',
@ -346,7 +346,7 @@ sub find_pets_by_tags {
required => '1',
},
};
__PACKAGE__->method_documentation->{ get_pet_by_id } = {
__PACKAGE__->method_documentation->{ 'get_pet_by_id' } = {
summary => 'Find pet by ID',
params => $params,
returns => 'Pet',
@ -414,7 +414,7 @@ sub get_pet_by_id {
required => '1',
},
};
__PACKAGE__->method_documentation->{ update_pet } = {
__PACKAGE__->method_documentation->{ 'update_pet' } = {
summary => 'Update an existing pet',
params => $params,
returns => undef,
@ -488,7 +488,7 @@ sub update_pet {
required => '0',
},
};
__PACKAGE__->method_documentation->{ update_pet_with_form } = {
__PACKAGE__->method_documentation->{ 'update_pet_with_form' } = {
summary => 'Updates a pet in the store with form data',
params => $params,
returns => undef,
@ -574,7 +574,7 @@ sub update_pet_with_form {
required => '0',
},
};
__PACKAGE__->method_documentation->{ upload_file } = {
__PACKAGE__->method_documentation->{ 'upload_file' } = {
summary => 'uploads an image',
params => $params,
returns => 'ApiResponse',

View File

@ -2,7 +2,7 @@
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: \" \\
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
@ -68,7 +68,7 @@ has version_info => ( is => 'ro',
default => sub { {
app_name => 'Swagger Petstore',
app_version => '1.0.0',
generated_date => '2016-06-10T22:39:40.931+08:00',
generated_date => '2016-06-28T16:35:21.686+08:00',
generator_class => 'class io.swagger.codegen.languages.PerlClientCodegen',
} },
documentation => 'Information about the application version and the codegen codebase version'
@ -134,7 +134,7 @@ Automatically generated by the Perl Swagger Codegen project:
=over 4
=item Build date: 2016-06-10T22:39:40.931+08:00
=item Build date: 2016-06-28T16:35:21.686+08:00
=item Build package: class io.swagger.codegen.languages.PerlClientCodegen

View File

@ -2,7 +2,7 @@
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: \" \\
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

View File

@ -2,7 +2,7 @@
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: \" \\
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
@ -77,7 +77,7 @@ sub new {
required => '1',
},
};
__PACKAGE__->method_documentation->{ delete_order } = {
__PACKAGE__->method_documentation->{ 'delete_order' } = {
summary => 'Delete purchase order by ID',
params => $params,
returns => undef,
@ -135,7 +135,7 @@ sub delete_order {
{
my $params = {
};
__PACKAGE__->method_documentation->{ get_inventory } = {
__PACKAGE__->method_documentation->{ 'get_inventory' } = {
summary => 'Returns pet inventories by status',
params => $params,
returns => 'HASH[string,int]',
@ -191,7 +191,7 @@ sub get_inventory {
required => '1',
},
};
__PACKAGE__->method_documentation->{ get_order_by_id } = {
__PACKAGE__->method_documentation->{ 'get_order_by_id' } = {
summary => 'Find purchase order by ID',
params => $params,
returns => 'Order',
@ -259,7 +259,7 @@ sub get_order_by_id {
required => '1',
},
};
__PACKAGE__->method_documentation->{ place_order } = {
__PACKAGE__->method_documentation->{ 'place_order' } = {
summary => 'Place an order for a pet',
params => $params,
returns => 'Order',

View File

@ -2,7 +2,7 @@
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: \" \\
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
@ -77,7 +77,7 @@ sub new {
required => '1',
},
};
__PACKAGE__->method_documentation->{ create_user } = {
__PACKAGE__->method_documentation->{ 'create_user' } = {
summary => 'Create user',
params => $params,
returns => undef,
@ -139,7 +139,7 @@ sub create_user {
required => '1',
},
};
__PACKAGE__->method_documentation->{ create_users_with_array_input } = {
__PACKAGE__->method_documentation->{ 'create_users_with_array_input' } = {
summary => 'Creates list of users with given input array',
params => $params,
returns => undef,
@ -201,7 +201,7 @@ sub create_users_with_array_input {
required => '1',
},
};
__PACKAGE__->method_documentation->{ create_users_with_list_input } = {
__PACKAGE__->method_documentation->{ 'create_users_with_list_input' } = {
summary => 'Creates list of users with given input array',
params => $params,
returns => undef,
@ -263,7 +263,7 @@ sub create_users_with_list_input {
required => '1',
},
};
__PACKAGE__->method_documentation->{ delete_user } = {
__PACKAGE__->method_documentation->{ 'delete_user' } = {
summary => 'Delete user',
params => $params,
returns => undef,
@ -327,7 +327,7 @@ sub delete_user {
required => '1',
},
};
__PACKAGE__->method_documentation->{ get_user_by_name } = {
__PACKAGE__->method_documentation->{ 'get_user_by_name' } = {
summary => 'Get user by user name',
params => $params,
returns => 'User',
@ -401,7 +401,7 @@ sub get_user_by_name {
required => '1',
},
};
__PACKAGE__->method_documentation->{ login_user } = {
__PACKAGE__->method_documentation->{ 'login_user' } = {
summary => 'Logs user into the system',
params => $params,
returns => 'string',
@ -471,7 +471,7 @@ sub login_user {
{
my $params = {
};
__PACKAGE__->method_documentation->{ logout_user } = {
__PACKAGE__->method_documentation->{ 'logout_user' } = {
summary => 'Logs out current logged in user session',
params => $params,
returns => undef,
@ -529,7 +529,7 @@ sub logout_user {
required => '1',
},
};
__PACKAGE__->method_documentation->{ update_user } = {
__PACKAGE__->method_documentation->{ 'update_user' } = {
summary => 'Updated user',
params => $params,
returns => undef,