Updating security samples for Perl. (#5292)

This commit is contained in:
Paŭlo Ebermann
2017-04-04 08:40:58 +02:00
committed by wing328
parent f7b39a85a5
commit bebeac8ae8
20 changed files with 428 additions and 628 deletions

View File

@@ -1,57 +1,56 @@
# NAME
Something::Deep::Role - a Moose role for the Swagger Petstore */ ' \"
Something::Deep::Role - a Moose role for the Swagger Petstore */ ' \" =_end -- \\r\\n \\n \\r
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: \" \\ */ ' \" =_end --
# VERSION
Automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project:
- API version: 1.0.0 */ ' \"
- API version: 1.0.0 */ ' \" =_end -- \\r\\n \\n \\r
- Package version: 1.0.0
- Build date: 2016-06-28T16:32:37.043+08:00
- Build package: class io.swagger.codegen.languages.PerlClientCodegen
- Build package: io.swagger.codegen.languages.PerlClientCodegen
## A note on Moose
This role is the only component of the library that uses Moose. See
Something::Deep::ApiFactory for non-Moosey usage.
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
The Perl Swagger Codegen project builds a library of Perl modules to interact with
a web service defined by a OpenAPI Specification. See below for how to build the
library.
This module provides an interface to the generated library. All the classes,
objects, and methods (well, not quite \*all\*, see below) are flattened into this
role.
This module provides an interface to the generated library. All the classes,
objects, and methods (well, not quite \*all\*, see below) are flattened into this
role.
package MyApp;
use Moose;
with '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.
implement the method calls available on each endpoint.
Additionally, there is a set of "object" classes, which represent the objects
returned by and sent to the methods on the endpoints.
Additionally, there is a set of "object" classes, which represent the objects
returned by and sent to the methods on the endpoints.
An API factory class is provided, which builds instances of each endpoint API.
An API factory class is provided, which builds instances of each endpoint API.
This Moose role flattens all the methods from the endpoint APIs onto the consuming
class. It also provides methods to retrieve the endpoint API objects, and the API
factory object, should you need it.
This Moose role flattens all the methods from the endpoint APIs onto the consuming
class. It also provides methods to retrieve the endpoint API objects, and the API
factory object, should you need it.
For documentation of all these methods, see AUTOMATIC DOCUMENTATION below.
@@ -64,33 +63,33 @@ required and where to put them. You just need to supply the tokens.
# basic
username => $username,
password => $password,
# oauth
access_token => $oauth_token,
# keys
$some_key => { token => $token,
prefix => $prefix,
in => $in, # 'head||query',
prefix => $prefix,
in => $in, # 'head||query',
},
$another => { token => $token,
prefix => $prefix,
in => $in, # 'head||query',
},
prefix => $prefix,
in => $in, # 'head||query',
},
...,
};
my $api = MyApp->new({ tokens => $tokens });
Note these are all optional, as are `prefix` and `in`, and depend on the API
you are accessing. Usually `prefix` and `in` will be determined by the code generator from
the spec and you will not need to set them at run time. If not, `in` will
default to 'head' and `prefix` to the empty string.
default to 'head' and `prefix` to the empty string.
The tokens will be placed in the `Something::Deep::Configuration` namespace
as follows, but you don't need to know about this.
as follows, but you don't need to know about this.
- `$Something::Deep::Configuration::username`
@@ -121,22 +120,22 @@ as follows, but you don't need to know about this.
- `$Something::Deep::Configuration::access_token`
String. The OAuth access token.
String. The OAuth access token.
# METHODS
## `base_url`
The generated code has the `base_url` already set as a default value. This method
returns (and optionally sets, but only if the API client has not been
The generated code has the `base_url` already set as a default value. This method
returns (and optionally sets, but only if the API client has not been
created yet) the current value of `base_url`.
## `api_factory`
Returns an API factory object. You probably won't need to call this directly.
Returns an API factory object. You probably won't need to call this directly.
$self->api_factory('Pet'); # returns a Something::Deep::PetApi instance
$self->pet_api; # the same
# MISSING METHODS
@@ -146,9 +145,9 @@ Most of the methods on the API are delegated to individual endpoint API objects
same method name (e.g. `new()`), these methods can't be delegated. So you need
to call `$api->pet_api->new()`.
In principle, every API is susceptible to the presence of a few, random, undelegatable
method names. In practice, because of the way method names are constructed, it's
unlikely in general that any methods will be undelegatable, except for:
In principle, every API is susceptible to the presence of a few, random, undelegatable
method names. In practice, because of the way method names are constructed, it's
unlikely in general that any methods will be undelegatable, except for:
new()
class_documentation()
@@ -161,12 +160,12 @@ you could also call them on class names.
# BUILDING YOUR LIBRARY
See the homepage `https://github.com/swagger-api/swagger-codegen` for full details.
But briefly, clone the git repository, build the codegen codebase, set up your build
See the homepage `https://github.com/swagger-api/swagger-codegen` for full details.
But briefly, clone the git repository, build the codegen codebase, set up your build
config file, then run the API build script. You will need git, Java 7 or 8 and Apache
maven 3.0.3 or better already installed.
The config file should specify the project name for the generated library:
The config file should specify the project name for the generated library:
{"moduleName":"WWW::MyProjectName"}
@@ -181,8 +180,8 @@ Your library files will be built under `WWW::MyProjectName`.
-c /path/to/config/file.json \
-o /path/to/output/folder
Bang, all done. Run the `autodoc` script in the `bin` directory to see the API
you just built.
Bang, all done. Run the `autodoc` script in the `bin` directory to see the API
you just built.
# AUTOMATIC DOCUMENTATION
@@ -194,28 +193,28 @@ output formats are supported:
-w wide format (default)
-n narrow format
-p POD format
-H HTML format
-p POD format
-H HTML format
-m Markdown format
-h print this help message
-c your application class
The `-c` option allows you to load and inspect your own application. A dummy
namespace is used if you don't supply your own class.
# DOCUMENTATION FROM THE OpenAPI Spec
Additional documentation for each class and method may be provided by the Swagger
spec. If so, this is available via the `class_documentation()` and
`method_documentation()` methods on each generated object class, and the
`method_documentation()` method on the endpoint API classes:
Additional documentation for each class and method may be provided by the Swagger
spec. If so, this is available via the `class_documentation()` and
`method_documentation()` methods on each generated object class, and the
`method_documentation()` method on the endpoint API classes:
my $cmdoc = $api->pet_api->method_documentation->{$method_name};
my $odoc = $api->get_pet_by_id->(pet_id => $pet_id)->class_documentation;
my $omdoc = $api->get_pet_by_id->(pet_id => $pet_id)->method_documentation->{method_name};
my $cmdoc = $api->pet_api->method_documentation->{$method_name};
my $odoc = $api->get_pet_by_id->(pet_id => $pet_id)->class_documentation;
my $omdoc = $api->get_pet_by_id->(pet_id => $pet_id)->method_documentation->{method_name};
Each of these calls returns a hashref with various useful pieces of information.
@@ -248,38 +247,40 @@ use Something::Deep::Object::ModelReturn;
# for displaying the API response data
use Data::Dumper;
use Something::Deep::Configuration;
use Something::Deep::;
my $api_instance = Something::Deep::FakeApi->new();
my $test code inject */ ' " =end = 'test code inject */ ' " =end_example'; # string | To test code injection */ ' \"
my $test code inject */ ' " =end __ \r\n \n \r = 'test code inject */ ' " =end __ \r\n \n \r_example'; # string | To test code injection */ ' \" =_end -- \\r\\n \\n \\r
eval {
$api_instance->test_code_inject____end(test code inject */ ' " =end => $test code inject */ ' " =end);
$api_instance->test_code_inject____end__rn_n_r(test code inject */ ' " =end __ \r\n \n \r => $test code inject */ ' " =end __ \r\n \n \r);
};
if ($@) {
warn "Exception when calling FakeApi->test_code_inject____end: $@\n";
warn "Exception when calling FakeApi->test_code_inject____end__rn_n_r: $@\n";
}
```
# DOCUMENTATION FOR API ENDPOINTS
All URIs are relative to *https://petstore.swagger.io */ ' " =end/v2 */ ' " =end*
All URIs are relative to *https://petstore.swagger.io */ ' \" =_end -- \\r\\n \\n \\r/v2 */ ' \" =_end -- \\r\\n \\n \\r*
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_code_inject____end__rn_n_r**](docs/FakeApi.md#test_code_inject____end__rn_n_r) | **PUT** /fake | To test code injection */ ' \" =_end -- \\r\\n \\n \\r
# DOCUMENTATION FOR MODELS
- [Something::Deep::Object::ModelReturn](docs/ModelReturn.md)
# DOCUMENTATION FOR AUTHORIATION
# DOCUMENTATION FOR AUTHORIZATION
## api_key
- **Type**: API key
- **API key parameter name**: api_key */ ' " =end
- **Type**: API key
- **API key parameter name**: api_key */ ' " =end -- \r\n \n \r
- **Location**: HTTP header
## petstore_auth
@@ -288,8 +289,6 @@ Class | Method | HTTP request | Description
- **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
- **write:pets**: modify pets in your account */ ' \" =_end -- \\r\\n \\n \\r
- **read:pets**: read your pets */ ' \" =_end -- \\r\\n \\n \\r

View File

@@ -5,30 +5,32 @@
use Something::Deep::Object::FakeApi;
```
All URIs are relative to *https://petstore.swagger.io */ ' " =end/v2 */ ' " =end*
All URIs are relative to *https://petstore.swagger.io */ ' \" =_end -- \\r\\n \\n \\r/v2 */ ' \" =_end -- \\r\\n \\n \\r*
Method | HTTP request | Description
------------- | ------------- | -------------
[**test_code_inject____end**](FakeApi.md#test_code_inject____end) | **PUT** /fake | To test code injection */ ' \"
[**test_code_inject____end__rn_n_r**](FakeApi.md#test_code_inject____end__rn_n_r) | **PUT** /fake | To test code injection */ ' \" =_end -- \\r\\n \\n \\r
# **test_code_inject____end**
> test_code_inject____end(test code inject */ ' " =end => $test code inject */ ' " =end)
# **test_code_inject____end__rn_n_r**
> test_code_inject____end__rn_n_r(test code inject */ ' " =end __ \r\n \n \r => $test code inject */ ' " =end __ \r\n \n \r)
To test code injection */ ' \"
To test code injection */ ' \" =_end -- \\r\\n \\n \\r
### Example
```perl
use Data::Dumper;
use Something::Deep::Configuration;
use Something::Deep::FakeApi;
my $api_instance = Something::Deep::FakeApi->new();
my $test code inject */ ' " =end = 'test code inject */ ' " =end_example'; # string | To test code injection */ ' \"
my $test code inject */ ' " =end __ \r\n \n \r = 'test code inject */ ' " =end __ \r\n \n \r_example'; # string | To test code injection */ ' \" =_end -- \\r\\n \\n \\r
eval {
$api_instance->test_code_inject____end(test code inject */ ' " =end => $test code inject */ ' " =end);
$api_instance->test_code_inject____end__rn_n_r(test code inject */ ' " =end __ \r\n \n \r => $test code inject */ ' " =end __ \r\n \n \r);
};
if ($@) {
warn "Exception when calling FakeApi->test_code_inject____end: $@\n";
warn "Exception when calling FakeApi->test_code_inject____end__rn_n_r: $@\n";
}
```
@@ -36,7 +38,7 @@ if ($@) {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**test code inject */ ' " =end** | **string**| To test code injection */ ' \" | [optional]
**test code inject */ ' " =end __ \r\n \n \r** | **string**| To test code injection */ ' \" =_end -- \\r\\n \\n \\r | [optional]
### Return type
@@ -48,8 +50,8 @@ No authorization required
### HTTP request headers
- **Content-Type**: application/json, */ " =end
- **Accept**: application/json, */ " =end
- **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

@@ -8,7 +8,7 @@ use Something::Deep::Object::ModelReturn;
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**return** | **int** | property description */ ' \" | [optional]
**return** | **int** | property description */ ' \" =_end -- \\r\\n \\n \\r | [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

@@ -1,25 +1,13 @@
=begin comment
Swagger Petstore */ ' \"
Swagger Petstore */ ' \" =_end -- \\r\\n \\n \\r
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: \" \\ */ ' \" =_end --
OpenAPI spec version: 1.0.0 */ ' \"
Contact: apiteam@swagger.io */ ' \"
OpenAPI spec version: 1.0.0 */ ' \" =_end -- \\r\\n \\n \\r
Contact: apiteam@swagger.io */ ' \" =_end -- \\r\\n \\n \\r
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
@@ -58,7 +46,7 @@ sub _new_instance
my $class = shift;
my (%args) = (
'ua' => LWP::UserAgent->new,
'base_url' => 'https://petstore.swagger.io */ ' " =end/v2 */ ' " =end',
'base_url' => 'https://petstore.swagger.io */ ' \" =_end -- \\r\\n \\n \\r/v2 */ ' \" =_end -- \\r\\n \\n \\r',
@_
);
@@ -352,9 +340,9 @@ sub update_params_for_auth {
}
elsif ($auth eq 'api_key') {
my $api_key = $self->get_api_key_with_prefix('api_key */ ' " =end');
my $api_key = $self->get_api_key_with_prefix('api_key */ ' " =end -- \r\n \n \r');
if ($api_key) {
$header_params->{'api_key */ ' " =end'} = $api_key;
$header_params->{'api_key */ ' " =end -- \r\n \n \r'} = $api_key;
}
}
elsif ($auth eq 'petstore_auth') {

View File

@@ -1,25 +1,13 @@
=begin comment
Swagger Petstore */ ' \"
Swagger Petstore */ ' \" =_end -- \\r\\n \\n \\r
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: \" \\ */ ' \" =_end --
OpenAPI spec version: 1.0.0 */ ' \"
Contact: apiteam@swagger.io */ ' \"
OpenAPI spec version: 1.0.0 */ ' \" =_end -- \\r\\n \\n \\r
Contact: apiteam@swagger.io */ ' \" =_end -- \\r\\n \\n \\r
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

View File

@@ -1,25 +1,13 @@
=begin comment
Swagger Petstore */ ' \"
Swagger Petstore */ ' \" =_end -- \\r\\n \\n \\r
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: \" \\ */ ' \" =_end --
OpenAPI spec version: 1.0.0 */ ' \"
Contact: apiteam@swagger.io */ ' \"
OpenAPI spec version: 1.0.0 */ ' \" =_end -- \\r\\n \\n \\r
Contact: apiteam@swagger.io */ ' \" =_end -- \\r\\n \\n \\r
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
@@ -42,7 +30,7 @@ use constant VERSION => '1.0.0';
# class/static variables
our $http_timeout = 180;
our $http_user_agent = 'Perl-Swagger';
our $http_user_agent = 'Swagger-Codegen/1.0.0/perl';
# authentication setting
our $api_key = {};

View File

@@ -1,25 +1,13 @@
=begin comment
Swagger Petstore */ ' \"
Swagger Petstore */ ' \" =_end -- \\r\\n \\n \\r
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: \" \\ */ ' \" =_end --
OpenAPI spec version: 1.0.0 */ ' \"
Contact: apiteam@swagger.io */ ' \"
OpenAPI spec version: 1.0.0 */ ' \" =_end -- \\r\\n \\n \\r
Contact: apiteam@swagger.io */ ' \" =_end -- \\r\\n \\n \\r
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
@@ -64,33 +52,32 @@ sub new {
#
# test_code_inject____end
# test_code_inject____end__rn_n_r
#
# To test code injection */ ' \"
# To test code injection */ ' \" =_end -- \\r\\n \\n \\r
#
# @param string $test code inject */ ' " =end To test code injection */ ' \" (optional)
# @param string $test code inject */ ' " =end __ \r\n \n \r To test code injection */ ' \" =_end -- \\r\\n \\n \\r (optional)
{
my $params = {
'test code inject */ ' " =end' => {
'test code inject */ ' " =end __ \r\n \n \r' => {
data_type => 'string',
description => 'To test code injection */ ' \" ',
description => 'To test code injection */ ' \" =_end -- \\r\\n \\n \\r',
required => '0',
},
};
__PACKAGE__->method_documentation->{ 'test_code_inject____end' } = {
summary => 'To test code injection */ ' \" ',
__PACKAGE__->method_documentation->{ 'test_code_inject____end__rn_n_r' } = {
summary => 'To test code injection */ ' \" =_end -- \\r\\n \\n \\r',
params => $params,
returns => undef,
};
}
# @return void
#
sub test_code_inject____end {
sub test_code_inject____end__rn_n_r {
my ($self, %args) = @_;
# parse inputs
my $_resource_path = '/fake';
$_resource_path =~ s/{format}/json/; # default format to json
my $_method = 'PUT';
my $query_params = {};
@@ -98,15 +85,15 @@ sub test_code_inject____end {
my $form_params = {};
# 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json', '*/ " =end');
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');
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type('application/json', '*/ \" =_end -- ');
# form params
if ( exists $args{'test code inject */ ' " =end'} ) {
$form_params->{'test code inject */ ' " =end'} = $self->{api_client}->to_form_value($args{'test code inject */ ' " =end'});
if ( exists $args{'test code inject */ ' " =end __ \r\n \n \r'} ) {
$form_params->{'test code inject */ ' " =end -- \r\n \n \r'} = $self->{api_client}->to_form_value($args{'test code inject */ ' " =end __ \r\n \n \r'});
}
my $_body_data;

View File

@@ -1,25 +1,13 @@
=begin comment
Swagger Petstore */ ' \"
Swagger Petstore */ ' \" =_end -- \\r\\n \\n \\r
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: \" \\ */ ' \" =_end --
OpenAPI spec version: 1.0.0 */ ' \"
Contact: apiteam@swagger.io */ ' \"
OpenAPI spec version: 1.0.0 */ ' \" =_end -- \\r\\n \\n \\r
Contact: apiteam@swagger.io */ ' \" =_end -- \\r\\n \\n \\r
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
@@ -46,7 +34,7 @@ use base ("Class::Accessor", "Class::Data::Inheritable");
#
#Model for testing reserved words */ ' \"
#Model for testing reserved words */ ' \" =_end -- \\r\\n \\n \\r
#
# 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
@@ -54,26 +42,14 @@ use base ("Class::Accessor", "Class::Data::Inheritable");
=begin comment
Swagger Petstore */ ' \"
Swagger Petstore */ ' \" =_end -- \\r\\n \\n \\r
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: \" \\ */ ' \" =_end --
OpenAPI spec version: 1.0.0 */ ' \"
Contact: apiteam@swagger.io */ ' \"
OpenAPI spec version: 1.0.0 */ ' \" =_end -- \\r\\n \\n \\r
Contact: apiteam@swagger.io */ ' \" =_end -- \\r\\n \\n \\r
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
@@ -160,7 +136,7 @@ sub _deserialize {
__PACKAGE__->class_documentation({description => 'Model for testing reserved words */ ' \" ',
__PACKAGE__->class_documentation({description => 'Model for testing reserved words */ ' \" =_end -- \\r\\n \\n \\r',
class => 'ModelReturn',
required => [], # TODO
} );
@@ -169,7 +145,7 @@ __PACKAGE__->method_documentation({
'return' => {
datatype => 'int',
base_name => 'return',
description => 'property description */ ' \" ',
description => 'property description */ ' \" =_end -- \\r\\n \\n \\r',
format => '',
read_only => '',
},

View File

@@ -1,31 +1,19 @@
=begin comment
Swagger Petstore */ ' \"
Swagger Petstore */ ' \" =_end -- \\r\\n \\n \\r
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: \" \\ */ ' \" =_end --
OpenAPI spec version: 1.0.0 */ ' \"
Contact: apiteam@swagger.io */ ' \"
OpenAPI spec version: 1.0.0 */ ' \" =_end -- \\r\\n \\n \\r
Contact: apiteam@swagger.io */ ' \" =_end -- \\r\\n \\n \\r
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.
# 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
#
@@ -46,7 +34,7 @@ has base_url => ( is => 'ro',
has api_factory => ( is => 'ro',
isa => 'Something::Deep::ApiFactory',
builder => '_build_af',
builder => '_build_af',
lazy => 1,
documentation => 'Builds an instance of the endpoint API class',
);
@@ -63,49 +51,48 @@ has _cfg => ( is => 'ro',
default => 'Something::Deep::Configuration',
);
has version_info => ( is => 'ro',
isa => 'HashRef',
has version_info => ( is => 'ro',
isa => 'HashRef',
default => sub { {
app_name => 'Swagger Petstore */ ' \" ',
app_version => '1.0.0 */ ' \" ',
generated_date => '2016-06-28T16:32:37.043+08:00',
generator_class => 'class io.swagger.codegen.languages.PerlClientCodegen',
app_name => 'Swagger Petstore */ ' \" =_end -- \\r\\n \\n \\r',
app_version => '1.0.0 */ ' \" =_end -- \\r\\n \\n \\r',
generator_class => 'io.swagger.codegen.languages.PerlClientCodegen',
} },
documentation => 'Information about the application version and the codegen codebase version'
);
sub BUILD {
my $self = shift;
$self->_cfg->accept_tokens( $self->tokens ) if keys %{$self->tokens};
# ignore these symbols imported into API namespaces
my %outsiders = map {$_ => 1} qw( croak );
my %delegates;
# collect the methods callable on each API
foreach my $api_name ($self->api_factory->apis_available) {
my $api_class = $self->api_factory->classname_for($api_name);
my $methods = Class::Inspector->methods($api_class, 'expanded'); # not Moose, so use CI instead
my @local_methods = grep {! /^_/} grep {! $outsiders{$_}} map {$_->[2]} grep {$_->[1] eq $api_class} @$methods;
push( @{$delegates{$_}}, {api_name => $api_name, api_class => $api_class} ) for @local_methods;
push( @{$delegates{$_}}, {api_name => $api_name, api_class => $api_class} ) for @local_methods;
}
# remove clashes
foreach my $method (keys %delegates) {
if ( @{$delegates{$method}} > 1 ) {
my ($apis) = delete $delegates{$method};
}
}
# build the flattened API
foreach my $api_name ($self->api_factory->apis_available) {
my $att_name = sprintf "%s_api", lc($api_name);
my $api_class = $self->api_factory->classname_for($api_name);
my @delegated = grep { $delegates{$_}->[0]->{api_name} eq $api_name } keys %delegates;
$log->debugf("Adding API: '%s' handles %s", $att_name, join ', ', @delegated);
$self->meta->add_attribute( $att_name => (
$self->meta->add_attribute( $att_name => (
is => 'ro',
isa => $api_class,
default => sub {$self->api_factory->get_api($api_name)},
@@ -124,62 +111,59 @@ sub _build_af {
=head1 NAME
Something::Deep::Role - a Moose role for the Swagger Petstore */ ' \"
Something::Deep::Role - a Moose role for the Swagger Petstore */ ' \" =_end -- \\r\\n \\n \\r
=head2 Swagger Petstore */ ' \" version: 1.0.0 */ ' \"
=head2 Swagger Petstore */ ' \" =_end -- \\r\\n \\n \\r version: 1.0.0 */ ' \" =_end -- \\r\\n \\n \\r
=head1 VERSION
Automatically generated by the Perl Swagger Codegen project:
Automatically generated by the Perl Swagger Codegen project:
=over 4
=over 4
=item Build package: io.swagger.codegen.languages.PerlClientCodegen
=item Build date: 2016-06-28T16:32:37.043+08:00
=item Build package: class io.swagger.codegen.languages.PerlClientCodegen
=item Codegen version:
=item Codegen version:
=back
=head2 A note on Moose
This role is the only component of the library that uses Moose. See
Something::Deep::ApiFactory for non-Moosey usage.
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
The Perl Swagger Codegen project builds a library of Perl modules to interact with
a web service defined by a OpenAPI Specification. See below for how to build the
library.
This module provides an interface to the generated library. All the classes,
objects, and methods (well, not quite *all*, see below) are flattened into this
role.
This module provides an interface to the generated library. All the classes,
objects, and methods (well, not quite *all*, see below) are flattened into this
role.
package MyApp;
use Moose;
with '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.
implement the method calls available on each endpoint.
Additionally, there is a set of "object" classes, which represent the objects
returned by and sent to the methods on the endpoints.
Additionally, there is a set of "object" classes, which represent the objects
returned by and sent to the methods on the endpoints.
An API factory class is provided, which builds instances of each endpoint API.
An API factory class is provided, which builds instances of each endpoint API.
This Moose role flattens all the methods from the endpoint APIs onto the consuming
class. It also provides methods to retrieve the endpoint API objects, and the API
factory object, should you need it.
This Moose role flattens all the methods from the endpoint APIs onto the consuming
class. It also provides methods to retrieve the endpoint API objects, and the API
factory object, should you need it.
For documentation of all these methods, see AUTOMATIC DOCUMENTATION below.
@@ -192,33 +176,33 @@ required and where to put them. You just need to supply the tokens.
# basic
username => $username,
password => $password,
# oauth
access_token => $oauth_token,
# keys
$some_key => { token => $token,
prefix => $prefix,
in => $in, # 'head||query',
prefix => $prefix,
in => $in, # 'head||query',
},
$another => { token => $token,
prefix => $prefix,
in => $in, # 'head||query',
},
prefix => $prefix,
in => $in, # 'head||query',
},
...,
};
my $api = MyApp->new({ tokens => $tokens });
Note these are all optional, as are C<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.
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.
as follows, but you don't need to know about this.
=over 4
@@ -251,7 +235,7 @@ all api keys require a prefix.
=item C<$Something::Deep::Configuration::access_token>
String. The OAuth access token.
String. The OAuth access token.
=back
@@ -259,16 +243,16 @@ String. The OAuth access token.
=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
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.
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
@@ -278,9 +262,9 @@ Most of the methods on the API are delegated to individual endpoint API objects
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:
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()
@@ -293,12 +277,12 @@ 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
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:
The config file should specify the project name for the generated library:
{"moduleName":"WWW::MyProjectName"}
@@ -313,8 +297,8 @@ Your library files will be built under C<WWW::MyProjectName>.
-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.
Bang, all done. Run the C<autodoc> script in the C<bin> directory to see the API
you just built.
=head1 AUTOMATIC DOCUMENTATION
@@ -326,28 +310,28 @@ output formats are supported:
-w wide format (default)
-n narrow format
-p POD format
-H HTML format
-p POD format
-H HTML format
-m Markdown format
-h print this help message
-c your application class
The C<-c> option allows you to load and inspect your own application. A dummy
namespace is used if you don't supply your own class.
=head1 DOCUMENTATION FROM THE OpenAPI Spec
Additional documentation for each class and method may be provided by the Swagger
spec. If so, this is available via the C<class_documentation()> and
C<method_documentation()> methods on each generated object class, and the
C<method_documentation()> method on the endpoint API classes:
Additional documentation for each class and method may be provided by the Swagger
spec. If so, this is available via the 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.
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

View File

@@ -1,25 +1,13 @@
=begin comment
Swagger Petstore */ ' \"
Swagger Petstore */ ' \" =_end -- \\r\\n \\n \\r
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: \" \\ */ ' \" =_end --
OpenAPI spec version: 1.0.0 */ &#39; \&quot;
Contact: apiteam@swagger.io */ ' \"
OpenAPI spec version: 1.0.0 */ &#39; \&quot; &#x3D;_end -- \\r\\n \\n \\r
Contact: apiteam@swagger.io */ ' \" =_end -- \\r\\n \\n \\r
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