forked from loafle/openapi-generator-original
parent
691d89adeb
commit
713e6bba24
@ -19,6 +19,12 @@ public class CodegenConstants {
|
|||||||
public static final String PHP_INVOKER_PACKAGE = "phpInvokerPackage";
|
public static final String PHP_INVOKER_PACKAGE = "phpInvokerPackage";
|
||||||
public static final String PHP_INVOKER_PACKAGE_DESC = "root package for generated php code";
|
public static final String PHP_INVOKER_PACKAGE_DESC = "root package for generated php code";
|
||||||
|
|
||||||
|
public static final String PERL_MODULE_NAME = "perlModuleName";
|
||||||
|
public static final String PERL_MODULE_NAME_DESC = "root module name for generated perl code";
|
||||||
|
|
||||||
|
public static final String PYTHON_PACKAGE_NAME = "pythonPackageName";
|
||||||
|
public static final String PYTHON_PACKAGE_NAME_DESC = "package name for generated python code";
|
||||||
|
|
||||||
public static final String GROUP_ID = "groupId";
|
public static final String GROUP_ID = "groupId";
|
||||||
public static final String GROUP_ID_DESC = "groupId in generated pom.xml";
|
public static final String GROUP_ID_DESC = "groupId in generated pom.xml";
|
||||||
|
|
||||||
|
@ -24,6 +24,8 @@ public class StaticHtml2Generator extends DefaultCodegen implements CodegenConfi
|
|||||||
protected String artifactVersion = "1.0.0";
|
protected String artifactVersion = "1.0.0";
|
||||||
protected String jsProjectName;
|
protected String jsProjectName;
|
||||||
protected String jsModuleName;
|
protected String jsModuleName;
|
||||||
|
protected String perlModuleName = "WWW::SwaggerClient";
|
||||||
|
protected String pythonPackageName = "swagger_client";
|
||||||
|
|
||||||
public StaticHtml2Generator() {
|
public StaticHtml2Generator() {
|
||||||
super();
|
super();
|
||||||
@ -40,6 +42,8 @@ public class StaticHtml2Generator extends DefaultCodegen implements CodegenConfi
|
|||||||
cliOptions.add(new CliOption("licenseUrl", "a URL pointing to the full license"));
|
cliOptions.add(new CliOption("licenseUrl", "a URL pointing to the full license"));
|
||||||
cliOptions.add(new CliOption(CodegenConstants.INVOKER_PACKAGE, CodegenConstants.INVOKER_PACKAGE_DESC));
|
cliOptions.add(new CliOption(CodegenConstants.INVOKER_PACKAGE, CodegenConstants.INVOKER_PACKAGE_DESC));
|
||||||
cliOptions.add(new CliOption(CodegenConstants.PHP_INVOKER_PACKAGE, CodegenConstants.PHP_INVOKER_PACKAGE_DESC));
|
cliOptions.add(new CliOption(CodegenConstants.PHP_INVOKER_PACKAGE, CodegenConstants.PHP_INVOKER_PACKAGE_DESC));
|
||||||
|
cliOptions.add(new CliOption(CodegenConstants.PERL_MODULE_NAME, CodegenConstants.PERL_MODULE_NAME_DESC));
|
||||||
|
cliOptions.add(new CliOption(CodegenConstants.PYTHON_PACKAGE_NAME, CodegenConstants.PYTHON_PACKAGE_NAME_DESC));
|
||||||
cliOptions.add(new CliOption(CodegenConstants.PACKAGE_NAME, "C# package name"));
|
cliOptions.add(new CliOption(CodegenConstants.PACKAGE_NAME, "C# package name"));
|
||||||
cliOptions.add(new CliOption(CodegenConstants.GROUP_ID, CodegenConstants.GROUP_ID_DESC));
|
cliOptions.add(new CliOption(CodegenConstants.GROUP_ID, CodegenConstants.GROUP_ID_DESC));
|
||||||
cliOptions.add(new CliOption(CodegenConstants.ARTIFACT_ID, CodegenConstants.ARTIFACT_ID_DESC));
|
cliOptions.add(new CliOption(CodegenConstants.ARTIFACT_ID, CodegenConstants.ARTIFACT_ID_DESC));
|
||||||
@ -53,6 +57,8 @@ public class StaticHtml2Generator extends DefaultCodegen implements CodegenConfi
|
|||||||
additionalProperties.put("licenseUrl", "http://apache.org/licenses/LICENSE-2.0.html");
|
additionalProperties.put("licenseUrl", "http://apache.org/licenses/LICENSE-2.0.html");
|
||||||
additionalProperties.put(CodegenConstants.INVOKER_PACKAGE, invokerPackage);
|
additionalProperties.put(CodegenConstants.INVOKER_PACKAGE, invokerPackage);
|
||||||
additionalProperties.put(CodegenConstants.PHP_INVOKER_PACKAGE, phpInvokerPackage);
|
additionalProperties.put(CodegenConstants.PHP_INVOKER_PACKAGE, phpInvokerPackage);
|
||||||
|
additionalProperties.put(CodegenConstants.PERL_MODULE_NAME, perlModuleName);
|
||||||
|
additionalProperties.put(CodegenConstants.PYTHON_PACKAGE_NAME, pythonPackageName);
|
||||||
additionalProperties.put(CodegenConstants.PACKAGE_NAME, packageName);
|
additionalProperties.put(CodegenConstants.PACKAGE_NAME, packageName);
|
||||||
additionalProperties.put(CodegenConstants.GROUP_ID, groupId);
|
additionalProperties.put(CodegenConstants.GROUP_ID, groupId);
|
||||||
additionalProperties.put(CodegenConstants.ARTIFACT_ID, artifactId);
|
additionalProperties.put(CodegenConstants.ARTIFACT_ID, artifactId);
|
||||||
|
@ -218,6 +218,8 @@
|
|||||||
<!--<li class=""><a href="#examples-{{baseName}}-{{nickname}}-0-angular">Angular</a></li>-->
|
<!--<li class=""><a href="#examples-{{baseName}}-{{nickname}}-0-angular">Angular</a></li>-->
|
||||||
<li class=""><a href="#examples-{{baseName}}-{{nickname}}-0-csharp">C#</a></li>
|
<li class=""><a href="#examples-{{baseName}}-{{nickname}}-0-csharp">C#</a></li>
|
||||||
<li class=""><a href="#examples-{{baseName}}-{{nickname}}-0-php">PHP</a></li>
|
<li class=""><a href="#examples-{{baseName}}-{{nickname}}-0-php">PHP</a></li>
|
||||||
|
<li class=""><a href="#examples-{{baseName}}-{{nickname}}-0-perl">Perl</a></li>
|
||||||
|
<li class=""><a href="#examples-{{baseName}}-{{nickname}}-0-python">Python</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<div class="tab-content">
|
<div class="tab-content">
|
||||||
@ -253,6 +255,14 @@
|
|||||||
<div class="tab-pane" id="examples-{{baseName}}-{{nickname}}-0-php">
|
<div class="tab-pane" id="examples-{{baseName}}-{{nickname}}-0-php">
|
||||||
<pre class="prettyprint"><code class="language-php">{{>sample_php}}</code></pre>
|
<pre class="prettyprint"><code class="language-php">{{>sample_php}}</code></pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="tab-pane" id="examples-{{baseName}}-{{nickname}}-0-perl">
|
||||||
|
<pre class="prettyprint"><code class="language-perl">{{>sample_perl}}</code></pre>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="tab-pane" id="examples-{{baseName}}-{{nickname}}-0-python">
|
||||||
|
<pre class="prettyprint"><code class="language-python">{{>sample_python}}</code></pre>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<h2>Parameters</h2>
|
<h2>Parameters</h2>
|
||||||
|
@ -0,0 +1,26 @@
|
|||||||
|
use Data::Dumper;
|
||||||
|
use {{{perlModuleName}}}::Configuration;
|
||||||
|
use {{perlModuleName}}::{{classname}};
|
||||||
|
{{#hasAuthMethods}}{{#authMethods}}{{#isBasic}}
|
||||||
|
# Configure HTTP basic authorization: {{{name}}}
|
||||||
|
${{{perlModuleName}}}::Configuration::username = 'YOUR_USERNAME';
|
||||||
|
${{{perlModuleName}}}::Configuration::password = 'YOUR_PASSWORD';{{/isBasic}}{{#isApiKey}}
|
||||||
|
# Configure API key authorization: {{{name}}}
|
||||||
|
${{{perlModuleName}}}::Configuration::api_key->{'{{{keyParamName}}}'} = 'YOUR_API_KEY';
|
||||||
|
# uncomment below to setup prefix (e.g. Bearer) for API key, if needed
|
||||||
|
#${{{perlModuleName}}}::Configuration::api_key_prefix->{'{{{keyParamName}}}'} = "Bearer";{{/isApiKey}}{{#isOAuth}}
|
||||||
|
# Configure OAuth2 access token for authorization: {{{name}}}
|
||||||
|
${{{perlModuleName}}}::Configuration::access_token = 'YOUR_ACCESS_TOKEN';{{/isOAuth}}{{/authMethods}}
|
||||||
|
{{/hasAuthMethods}}
|
||||||
|
|
||||||
|
my $api_instance = {{perlModuleName}}::{{classname}}->new();
|
||||||
|
{{#allParams}}my ${{paramName}} = {{#isListContainer}}[{{/isListContainer}}{{#isBodyParam}}{{{perlModuleName}}}::Object::{{dataType}}->new(){{/isBodyParam}}{{^isBodyParam}}{{{example}}}{{/isBodyParam}}{{#isListContainer}}]{{/isListContainer}}; # {{{dataType}}} | {{{description}}}
|
||||||
|
{{/allParams}}
|
||||||
|
|
||||||
|
eval {
|
||||||
|
{{#returnType}}my $result = {{/returnType}}$api_instance->{{{operationId}}}({{#allParams}}{{paramName}} => ${{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});{{#returnType}}
|
||||||
|
print Dumper($result);{{/returnType}}
|
||||||
|
};
|
||||||
|
if ($@) {
|
||||||
|
warn "Exception when calling {{classname}}->{{operationId}}: $@\n";
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
from __future__ import print_statement
|
||||||
|
import time
|
||||||
|
import {{{pythonPackageName}}}
|
||||||
|
from {{{pythonPackageName}}}.rest import ApiException
|
||||||
|
from pprint import pprint
|
||||||
|
{{#hasAuthMethods}}{{#authMethods}}{{#isBasic}}
|
||||||
|
# Configure HTTP basic authorization: {{{name}}}
|
||||||
|
{{{pythonPackageName}}}.configuration.username = 'YOUR_USERNAME'
|
||||||
|
{{{pythonPackageName}}}.configuration.password = 'YOUR_PASSWORD'{{/isBasic}}{{#isApiKey}}
|
||||||
|
# Configure API key authorization: {{{name}}}
|
||||||
|
{{{pythonPackageName}}}.configuration.api_key['{{{keyParamName}}}'] = 'YOUR_API_KEY'
|
||||||
|
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
|
||||||
|
# {{{pythonPackageName}}}.configuration.api_key_prefix['{{{keyParamName}}}'] = 'Bearer'{{/isApiKey}}{{#isOAuth}}
|
||||||
|
# Configure OAuth2 access token for authorization: {{{name}}}
|
||||||
|
{{{pythonPackageName}}}.configuration.access_token = 'YOUR_ACCESS_TOKEN'{{/isOAuth}}{{/authMethods}}
|
||||||
|
{{/hasAuthMethods}}
|
||||||
|
|
||||||
|
# create an instance of the API class
|
||||||
|
api_instance = {{{pythonPackageName}}}.{{{classname}}}()
|
||||||
|
{{#allParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}}
|
||||||
|
{{/allParams}}
|
||||||
|
|
||||||
|
try:
|
||||||
|
{{#summary}} # {{{.}}}
|
||||||
|
{{/summary}} {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}({{#allParams}}{{#required}}{{paramName}}{{/required}}{{^required}}{{paramName}}={{paramName}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}){{#returnType}}
|
||||||
|
pprint(api_response){{/returnType}}
|
||||||
|
except ApiException as e:
|
||||||
|
print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e)
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user