@@ -105,6 +105,18 @@ public class Generate implements Runnable {

@Option(name = {"--library"}, title = "library", description = CodegenConstants.LIBRARY_DESC)
private String library;

@Option(name = {"--git-user-id"}, title = "git user id", description = CodegenConstants.GIT_USER_ID_DESC)
private String gitUserId;

@Option(name = {"--git-repo-id"}, title = "git repo id", description = CodegenConstants.GIT_REPO_ID_DESC)
private String gitRepoId;

@Option(name = {"--release-note"}, title = "release note", description = CodegenConstants.RELEASE_NOTE_DESC)
private String releaseNote;

@Option(name = {"--release-version"}, title = "release version", description = CodegenConstants.RELEASE_VERSION_DESC)
private String releaseVersion;

@Override
public void run() {
@@ -183,6 +195,22 @@ public void run() {
configurator.setLibrary(library);
}

if (isNotEmpty(gitUserId)) {
configurator.setGitUserId(gitUserId);
}

if (isNotEmpty(gitRepoId)) {
configurator.setGitRepoId(gitRepoId);
}

if (isNotEmpty(releaseNote)) {
configurator.setReleaseNote(releaseNote);
}

if (isNotEmpty(releaseVersion)) {
configurator.setReleaseVersion(releaseVersion);
}

applySystemPropertiesKvp(systemProperties, configurator);
applyInstantiationTypesKvp(instantiationTypes, configurator);
applyImportMappingsKvp(importMappings, configurator);
@@ -167,4 +167,21 @@ public interface CodegenConfig {
* @return libray template
*/
String getLibrary();

void setGitUserId(String gitUserId);

String getGitUserId();

void setGitRepoId(String gitRepoId);

String getGitRepoId();

void setReleaseNote(String releaseNote);

String getReleaseNote();

void setReleaseVersion(String releaseVersion);

String getReleaseVersion();

}
@@ -91,4 +91,16 @@ public static enum MODEL_PROPERTY_NAMING_TYPE {camelCase, PascalCase, snake_case
public static final String OPTIONAL_EMIT_DEFAULT_VALUES = "optionalEmitDefaultValues";
public static final String OPTIONAL_EMIT_DEFAULT_VALUES_DESC = "Set DataMember's EmitDefaultValue, default false.";

public static final String GIT_USER_ID = "gitUserId";
public static final String GIT_USER_ID_DESC = "Git user ID, e.g. swagger-api.";

public static final String GIT_REPO_ID = "gitRepoId";
public static final String GIT_REPO_ID_DESC = "Git repo ID, e.g. swagger-codegen.";

public static final String RELEASE_NOTE = "releaseNote";
public static final String RELEASE_NOTE_DESC = "Release note, default to 'Minor update'.";

public static final String RELEASE_VERSION = "releaseVersion";
public static final String RELEASE_VERSION_DESC= "Release version, e.g. 1.2.5, default to 0.1.0.";

}
@@ -83,6 +83,7 @@ public class DefaultCodegen {
protected String library;
protected Boolean sortParamsByRequiredFlag = true;
protected Boolean ensureUniqueParams = true;
protected String gitUserId, gitRepoId, releaseNote, releaseVersion;

public List<CliOption> cliOptions() {
return cliOptions;
@@ -118,6 +119,7 @@ public void processOpts() {
if(additionalProperties.containsKey(CodegenConstants.MODEL_NAME_SUFFIX)){
this.setModelNameSuffix((String) additionalProperties.get(CodegenConstants.MODEL_NAME_SUFFIX));
}

}

// override with any special post-processing for all models
@@ -2337,6 +2339,11 @@ public Map<String, String> supportedLibraries() {
return supportedLibraries;
}

/**
* Set library template (sub-template).
*
* @param library Library template
*/
public void setLibrary(String library) {
if (library != null && !supportedLibraries.containsKey(library))
throw new RuntimeException("unknown library: " + library);
@@ -2352,6 +2359,78 @@ public String getLibrary() {
return library;
}

/**
* Set Git user ID.
*
* @param gitUserId Git user ID
*/
public void setGitUserId(String gitUserId) {
this.gitUserId = gitUserId;
}

/**
* Git user ID
*
* @return Git user ID
*/
public String getGitUserId() {
return gitUserId;
}

/**
* Set Git repo ID.
*
* @param gitRepoId Git repo ID
*/
public void setGitRepoId(String gitRepoId) {
this.gitRepoId = gitRepoId;
}

/**
* Git repo ID
*
* @return Git repo ID
*/
public String getGitRepoId() {
return gitRepoId;
}

/**
* Set release note.
*
* @param releaseNote Release note
*/
public void setReleaseNote(String releaseNote) {
this.releaseNote = releaseNote;
}

/**
* Release note
*
* @return Release note
*/
public String getReleaseNote() {
return releaseNote;
}

/**
* Set release version.
*
* @param releaseVersion Release version
*/
public void setReleaseVersion(String releaseVersion) {
this.releaseVersion = releaseVersion;
}

/**
* Release version
*
* @return Release version
*/
public String getReleaseVersion() {
return releaseVersion;
}

@SuppressWarnings("static-method")
protected CliOption buildLibraryCliOption(Map<String, String> supportedLibraries) {
StringBuilder sb = new StringBuilder("library template (sub-template) to use:");
@@ -60,6 +60,10 @@ public class CodegenConfigurator {
private Map<String, String> additionalProperties = new HashMap<String, String>();
private Map<String, String> importMappings = new HashMap<String, String>();
private Set<String> languageSpecificPrimitives = new HashSet<String>();
private String gitUserId="YOUR_GIT_USR_ID";
private String gitRepoId="YOUR_GIT_REPO_ID";
private String releaseNote="Minor update";
private String releaseVersion="0.1.0";

private final Map<String, String> dynamicProperties = new HashMap<String, String>(); //the map that holds the JsonAnySetter/JsonAnyGetter values

@@ -295,6 +299,42 @@ public CodegenConfigurator setLibrary(String library) {
return this;
}

public String getGitUserId() {
return gitUserId;
}

public CodegenConfigurator setGitUserId(String gitUserId) {
this.gitUserId = gitUserId;
return this;
}

public String getGitRepoId() {
return gitRepoId;
}

public CodegenConfigurator setGitRepoId(String gitRepoId) {
this.gitRepoId = gitRepoId;
return this;
}

public String getReleaseNote() {
return releaseNote;
}

public CodegenConfigurator setReleaseNote(String releaseNote) {
this.releaseNote = releaseNote;
return this;
}

public String getReleaseVersion() {
return releaseVersion;
}

public CodegenConfigurator setReleaseVersion(String releaseVersion) {
this.releaseVersion = releaseVersion;
return this;
}

public ClientOptInput toClientOptInput() {

Validate.notEmpty(lang, "language must be specified");
@@ -322,6 +362,10 @@ public ClientOptInput toClientOptInput() {
checkAndSetAdditionalProperty(templateDir, toAbsolutePathStr(templateDir), CodegenConstants.TEMPLATE_DIR);
checkAndSetAdditionalProperty(modelNamePrefix, CodegenConstants.MODEL_NAME_PREFIX);
checkAndSetAdditionalProperty(modelNameSuffix, CodegenConstants.MODEL_NAME_SUFFIX);
checkAndSetAdditionalProperty(gitUserId, CodegenConstants.GIT_USER_ID);
checkAndSetAdditionalProperty(gitRepoId, CodegenConstants.GIT_REPO_ID);
checkAndSetAdditionalProperty(releaseVersion, CodegenConstants.RELEASE_VERSION);
checkAndSetAdditionalProperty(releaseNote, CodegenConstants.RELEASE_NOTE);

handleDynamicProperties(config);

@@ -130,11 +130,13 @@ public void processOpts() {

supportingFiles.add(new SupportingFile("ApiClient.mustache", ("lib/" + modulePathPart).replace('/', File.separatorChar), "ApiClient.pm"));
supportingFiles.add(new SupportingFile("Configuration.mustache", ("lib/" + modulePathPart).replace('/', File.separatorChar), "Configuration.pm"));
supportingFiles.add(new SupportingFile("ApiFactory.mustache", ("lib/" + modulePathPart).replace('/', File.separatorChar), "ApiFactory.pm")); supportingFiles.add(new SupportingFile("Role.mustache", ("lib/" + modulePathPart).replace('/', File.separatorChar), "Role.pm"));
supportingFiles.add(new SupportingFile("ApiFactory.mustache", ("lib/" + modulePathPart).replace('/', File.separatorChar), "ApiFactory.pm"));
supportingFiles.add(new SupportingFile("Role.mustache", ("lib/" + modulePathPart).replace('/', File.separatorChar), "Role.pm"));
supportingFiles.add(new SupportingFile("AutoDoc.mustache", ("lib/" + modulePathPart + "/Role").replace('/', File.separatorChar), "AutoDoc.pm"));
supportingFiles.add(new SupportingFile("autodoc.script.mustache", "bin", "autodoc"));
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore"));
supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));
}

@Override
@@ -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'

@@ -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/
@@ -8,7 +8,7 @@ WWW::SwaggerClient::Role - a Moose role for the Swagger Petstore

Automatically generated by the Perl Swagger Codegen project:

- Build date: 2016-03-09T16:16:31.021+08:00
- Build date: 2016-03-11T16:15:14.769+08:00
- Build package: class io.swagger.codegen.languages.PerlClientCodegen
- Codegen version:

@@ -255,6 +255,7 @@ Class | Method | HTTP request | Description
- [WWW::SwaggerClient::Object::Category](docs/Category.md)
- [WWW::SwaggerClient::Object::InlineResponse200](docs/InlineResponse200.md)
- [WWW::SwaggerClient::Object::ModelReturn](docs/ModelReturn.md)
- [WWW::SwaggerClient::Object::Name](docs/Name.md)
- [WWW::SwaggerClient::Object::Order](docs/Order.md)
- [WWW::SwaggerClient::Object::Pet](docs/Pet.md)
- [WWW::SwaggerClient::Object::SpecialModelName](docs/SpecialModelName.md)
@@ -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]