forked from loafle/openapi-generator-original
add git push script to perl
This commit is contained in:
parent
3bebbada98
commit
2c5be10589
@ -60,10 +60,10 @@ public class CodegenConfigurator {
|
|||||||
private Map<String, String> additionalProperties = new HashMap<String, String>();
|
private Map<String, String> additionalProperties = new HashMap<String, String>();
|
||||||
private Map<String, String> importMappings = new HashMap<String, String>();
|
private Map<String, String> importMappings = new HashMap<String, String>();
|
||||||
private Set<String> languageSpecificPrimitives = new HashSet<String>();
|
private Set<String> languageSpecificPrimitives = new HashSet<String>();
|
||||||
private String gitUserId;
|
private String gitUserId="YOUR_GIT_USR_ID";
|
||||||
private String gitRepoId;
|
private String gitRepoId="YOUR_GIT_REPO_ID";
|
||||||
private String releaseNote;
|
private String releaseNote="Minor update";
|
||||||
private String releaseVersion;
|
private String releaseVersion="0.1.0";
|
||||||
|
|
||||||
private final Map<String, String> dynamicProperties = new HashMap<String, String>(); //the map that holds the JsonAnySetter/JsonAnyGetter values
|
private final Map<String, String> dynamicProperties = new HashMap<String, String>(); //the map that holds the JsonAnySetter/JsonAnyGetter values
|
||||||
|
|
||||||
|
52
modules/swagger-codegen/src/main/resources/perl/git_push.sh.mustache
Executable file
52
modules/swagger-codegen/src/main/resources/perl/git_push.sh.mustache
Executable 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="{{{gitUserId}}}"
|
||||||
|
echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$git_repo_id" = "" ]; then
|
||||||
|
git_repo_id="{{{gitRepoId}}}"
|
||||||
|
echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$release_note" = "" ]; then
|
||||||
|
release_note="{{{releaseNote}}}"
|
||||||
|
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'
|
||||||
|
|
@ -8,7 +8,7 @@ WWW::SwaggerClient::Role - a Moose role for the Swagger Petstore
|
|||||||
|
|
||||||
Automatically generated by the Perl Swagger Codegen project:
|
Automatically generated by the Perl Swagger Codegen project:
|
||||||
|
|
||||||
- Build date: 2016-03-11T14:45:16.064+08:00
|
- Build date: 2016-03-11T16:15:14.769+08:00
|
||||||
- Build package: class io.swagger.codegen.languages.PerlClientCodegen
|
- Build package: class io.swagger.codegen.languages.PerlClientCodegen
|
||||||
- Codegen version:
|
- Codegen version:
|
||||||
|
|
||||||
|
13
samples/client/petstore/perl/docs/Name.md
Normal file
13
samples/client/petstore/perl/docs/Name.md
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
# WWW::SwaggerClient::Object::Name
|
||||||
|
|
||||||
|
## Import the module
|
||||||
|
```perl
|
||||||
|
use WWW::SwaggerClient::Object::Name;
|
||||||
|
```
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------ | ------------- | ------------- | -------------
|
||||||
|
**name** | **int** | | [optional]
|
||||||
|
|
||||||
|
|
52
samples/client/petstore/perl/git_push.sh
Normal file
52
samples/client/petstore/perl/git_push.sh
Normal 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="YOUR_GIT_USR_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="YOUR_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'
|
||||||
|
|
@ -0,0 +1,127 @@
|
|||||||
|
package WWW::SwaggerClient::Object::Name;
|
||||||
|
|
||||||
|
require 5.6.0;
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use utf8;
|
||||||
|
use JSON qw(decode_json);
|
||||||
|
use Data::Dumper;
|
||||||
|
use Module::Runtime qw(use_module);
|
||||||
|
use Log::Any qw($log);
|
||||||
|
use Date::Parse;
|
||||||
|
use DateTime;
|
||||||
|
|
||||||
|
use base ("Class::Accessor", "Class::Data::Inheritable");
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
#
|
||||||
|
#
|
||||||
|
#NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
|
||||||
|
#
|
||||||
|
|
||||||
|
__PACKAGE__->mk_classdata('attribute_map' => {});
|
||||||
|
__PACKAGE__->mk_classdata('swagger_types' => {});
|
||||||
|
__PACKAGE__->mk_classdata('method_documentation' => {});
|
||||||
|
__PACKAGE__->mk_classdata('class_documentation' => {});
|
||||||
|
|
||||||
|
# new object
|
||||||
|
sub new {
|
||||||
|
my ($class, %args) = @_;
|
||||||
|
|
||||||
|
my $self = bless {}, $class;
|
||||||
|
|
||||||
|
foreach my $attribute (keys %{$class->attribute_map}) {
|
||||||
|
my $args_key = $class->attribute_map->{$attribute};
|
||||||
|
$self->$attribute( $args{ $args_key } );
|
||||||
|
}
|
||||||
|
|
||||||
|
return $self;
|
||||||
|
}
|
||||||
|
|
||||||
|
# return perl hash
|
||||||
|
sub to_hash {
|
||||||
|
return decode_json(JSON->new->convert_blessed->encode( shift ));
|
||||||
|
}
|
||||||
|
|
||||||
|
# used by JSON for serialization
|
||||||
|
sub TO_JSON {
|
||||||
|
my $self = shift;
|
||||||
|
my $_data = {};
|
||||||
|
foreach my $_key (keys %{$self->attribute_map}) {
|
||||||
|
if (defined $self->{$_key}) {
|
||||||
|
$_data->{$self->attribute_map->{$_key}} = $self->{$_key};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $_data;
|
||||||
|
}
|
||||||
|
|
||||||
|
# from Perl hashref
|
||||||
|
sub from_hash {
|
||||||
|
my ($self, $hash) = @_;
|
||||||
|
|
||||||
|
# loop through attributes and use swagger_types to deserialize the data
|
||||||
|
while ( my ($_key, $_type) = each %{$self->swagger_types} ) {
|
||||||
|
my $_json_attribute = $self->attribute_map->{$_key};
|
||||||
|
if ($_type =~ /^array\[/i) { # array
|
||||||
|
my $_subclass = substr($_type, 6, -1);
|
||||||
|
my @_array = ();
|
||||||
|
foreach my $_element (@{$hash->{$_json_attribute}}) {
|
||||||
|
push @_array, $self->_deserialize($_subclass, $_element);
|
||||||
|
}
|
||||||
|
$self->{$_key} = \@_array;
|
||||||
|
} elsif (exists $hash->{$_json_attribute}) { #hash(model), primitive, datetime
|
||||||
|
$self->{$_key} = $self->_deserialize($_type, $hash->{$_json_attribute});
|
||||||
|
} else {
|
||||||
|
$log->debugf("Warning: %s (%s) does not exist in input hash\n", $_key, $_json_attribute);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $self;
|
||||||
|
}
|
||||||
|
|
||||||
|
# deserialize non-array data
|
||||||
|
sub _deserialize {
|
||||||
|
my ($self, $type, $data) = @_;
|
||||||
|
$log->debugf("deserializing %s with %s",Dumper($data), $type);
|
||||||
|
|
||||||
|
if ($type eq 'DateTime') {
|
||||||
|
return DateTime->from_epoch(epoch => str2time($data));
|
||||||
|
} elsif ( grep( /^$type$/, ('int', 'double', 'string', 'boolean'))) {
|
||||||
|
return $data;
|
||||||
|
} else { # hash(model)
|
||||||
|
my $_instance = eval "WWW::SwaggerClient::Object::$type->new()";
|
||||||
|
return $_instance->from_hash($data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
__PACKAGE__->class_documentation({description => '',
|
||||||
|
class => 'Name',
|
||||||
|
required => [], # TODO
|
||||||
|
} );
|
||||||
|
|
||||||
|
__PACKAGE__->method_documentation({
|
||||||
|
'name' => {
|
||||||
|
datatype => 'int',
|
||||||
|
base_name => 'name',
|
||||||
|
description => '',
|
||||||
|
format => '',
|
||||||
|
read_only => '',
|
||||||
|
},
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
__PACKAGE__->swagger_types( {
|
||||||
|
'name' => 'int'
|
||||||
|
} );
|
||||||
|
|
||||||
|
__PACKAGE__->attribute_map( {
|
||||||
|
'name' => 'name'
|
||||||
|
} );
|
||||||
|
|
||||||
|
__PACKAGE__->mk_accessors(keys %{__PACKAGE__->attribute_map});
|
||||||
|
|
||||||
|
|
||||||
|
1;
|
@ -37,7 +37,7 @@ has version_info => ( is => 'ro',
|
|||||||
default => sub { {
|
default => sub { {
|
||||||
app_name => 'Swagger Petstore',
|
app_name => 'Swagger Petstore',
|
||||||
app_version => '1.0.0',
|
app_version => '1.0.0',
|
||||||
generated_date => '2016-03-11T14:45:16.064+08:00',
|
generated_date => '2016-03-11T16:15:14.769+08:00',
|
||||||
generator_class => 'class io.swagger.codegen.languages.PerlClientCodegen',
|
generator_class => 'class io.swagger.codegen.languages.PerlClientCodegen',
|
||||||
} },
|
} },
|
||||||
documentation => 'Information about the application version and the codegen codebase version'
|
documentation => 'Information about the application version and the codegen codebase version'
|
||||||
@ -103,7 +103,7 @@ Automatically generated by the Perl Swagger Codegen project:
|
|||||||
|
|
||||||
=over 4
|
=over 4
|
||||||
|
|
||||||
=item Build date: 2016-03-11T14:45:16.064+08:00
|
=item Build date: 2016-03-11T16:15:14.769+08:00
|
||||||
|
|
||||||
=item Build package: class io.swagger.codegen.languages.PerlClientCodegen
|
=item Build package: class io.swagger.codegen.languages.PerlClientCodegen
|
||||||
|
|
||||||
|
17
samples/client/petstore/perl/t/NameTest.t
Normal file
17
samples/client/petstore/perl/t/NameTest.t
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
# NOTE: This class is auto generated by the Swagger Codegen
|
||||||
|
# Please update the test case below to test the model.
|
||||||
|
|
||||||
|
use Test::More tests => 2;
|
||||||
|
use Test::Exception;
|
||||||
|
|
||||||
|
use lib 'lib';
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
|
||||||
|
|
||||||
|
use_ok('WWW::SwaggerClient::Object::Name');
|
||||||
|
|
||||||
|
my $instance = WWW::SwaggerClient::Object::Name->new();
|
||||||
|
|
||||||
|
isa_ok($instance, 'WWW::SwaggerClient::Object::Name');
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user