forked from loafle/openapi-generator-original
Fix Basic Bearer auth examples for HTML2 Docs (#6579)
* add missing basic bearer auth examples * fix basic bearer auth header * add bearerFormat * fix all template formats and whitespacing
This commit is contained in:
parent
104a2a39b8
commit
a014915e62
@ -243,7 +243,11 @@
|
|||||||
|
|
||||||
<div class="tab-content">
|
<div class="tab-content">
|
||||||
<div class="tab-pane active" id="examples-{{baseName}}-{{nickname}}-0-curl">
|
<div class="tab-pane active" id="examples-{{baseName}}-{{nickname}}-0-curl">
|
||||||
<pre class="prettyprint"><code class="language-bsh">curl -X {{vendorExtensions.x-codegen-http-method-upper-case}}{{#authMethods}}{{#isApiKey}}{{#isKeyInHeader}} -H "{{keyParamName}}: [[apiKey]]"{{/isKeyInHeader}}{{/isApiKey}}{{#isBasic}}{{#hasProduces}} -H "Accept: {{#produces}}{{{mediaType}}}{{#hasMore}},{{/hasMore}}{{/produces}}"{{/hasProduces}}{{#hasConsumes}} -H "Content-Type: {{#consumes}}{{{mediaType}}}{{#hasMore}},{{/hasMore}}{{/consumes}}"{{/hasConsumes}} -H "Authorization: Basic [[basicHash]]"{{/isBasic}}{{/authMethods}} "{{basePath}}{{path}}{{#hasQueryParams}}?{{#queryParams}}{{^-first}}&{{/-first}}{{baseName}}={{vendorExtensions.x-eg}}{{/queryParams}}{{/hasQueryParams}}"</code></pre>
|
<pre class="prettyprint"><code class="language-bsh">curl -X {{vendorExtensions.x-codegen-http-method-upper-case}}{{#authMethods}}\
|
||||||
|
{{#isApiKey}}{{#isKeyInHeader}}-H "{{keyParamName}}: [[apiKey]]"{{/isKeyInHeader}}{{/isApiKey}}{{^isBasicBearer}}{{#isBasic}} -H "Authorization: Basic [[basicHash]]"{{/isBasic}}{{/isBasicBearer}}{{#isBasicBearer}} -H "Authorization: Bearer [[accessToken]]"{{/isBasicBearer}}{{/authMethods}}{{#hasProduces}}\
|
||||||
|
-H "Accept: {{#produces}}{{{mediaType}}}{{#hasMore}},{{/hasMore}}{{/produces}}"{{/hasProduces}}{{#hasConsumes}}\
|
||||||
|
-H "Content-Type: {{#consumes}}{{{mediaType}}}{{#hasMore}},{{/hasMore}}{{/consumes}}"{{/hasConsumes}}\
|
||||||
|
"{{basePath}}{{path}}{{#hasQueryParams}}?{{#queryParams}}{{^-first}}&{{/-first}}{{baseName}}={{vendorExtensions.x-eg}}{{/queryParams}}{{/hasQueryParams}}"</code></pre>
|
||||||
</div>
|
</div>
|
||||||
<div class="tab-pane" id="examples-{{baseName}}-{{nickname}}-0-java">
|
<div class="tab-pane" id="examples-{{baseName}}-{{nickname}}-0-java">
|
||||||
<pre class="prettyprint"><code class="language-java">{{>sample_java}}</code></pre>
|
<pre class="prettyprint"><code class="language-java">{{>sample_java}}</code></pre>
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
import {{{invokerPackage}}}.api.{{{classname}}};
|
import {{{invokerPackage}}}.api.{{{classname}}};
|
||||||
|
|
||||||
public class {{{classname}}}Example {
|
public class {{{classname}}}Example {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
{{{classname}}} apiInstance = new {{{classname}}}();
|
{{{classname}}} apiInstance = new {{{classname}}}();
|
||||||
{{#allParams}}
|
{{#allParams}}
|
||||||
{{{dataType}}} {{{paramName}}} = {{{example}}}; // {{{dataType}}} | {{{unescapedDescription}}}
|
{{{dataType}}} {{{paramName}}} = {{{example}}}; // {{{dataType}}} | {{{unescapedDescription}}}
|
||||||
{{/allParams}}
|
{{/allParams}}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
{{#returnType}}{{{returnType}}} result = {{/returnType}}apiInstance.{{{operationId}}}({{#allParams}}{{{paramName}}}{{#hasMore}}, {{/hasMore}}{{/allParams}});{{#returnType}}
|
{{#returnType}}{{{returnType}}} result = {{/returnType}}apiInstance.{{{operationId}}}({{#allParams}}{{{paramName}}}{{#hasMore}}, {{/hasMore}}{{/allParams}});{{#returnType}}
|
||||||
System.out.println(result);{{/returnType}}
|
System.out.println(result);{{/returnType}}
|
||||||
|
@ -10,18 +10,20 @@ namespace Example
|
|||||||
{
|
{
|
||||||
public void main()
|
public void main()
|
||||||
{
|
{
|
||||||
{{#hasAuthMethods}}{{#authMethods}}{{#isBasic}}
|
{{#hasAuthMethods}}
|
||||||
// Configure HTTP basic authorization: {{{name}}}
|
{{#authMethods}}
|
||||||
|
{{^isBasicBearer}}{{#isBasic}}// Configure HTTP basic authorization: {{{name}}}
|
||||||
Configuration.Default.Username = "YOUR_USERNAME";
|
Configuration.Default.Username = "YOUR_USERNAME";
|
||||||
Configuration.Default.Password = "YOUR_PASSWORD";{{/isBasic}}{{#isApiKey}}
|
Configuration.Default.Password = "YOUR_PASSWORD";{{/isBasic}}{{/isBasicBearer}}{{#isBasicBearer}}// Configure Bearer{{#bearerFormat}} ({{{.}}}){{/bearerFormat}} access token for authorization: {{{name}}}
|
||||||
// Configure API key authorization: {{{name}}}
|
Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN";{{/isBasicBearer}}{{#isApiKey}}// Configure API key authorization: {{{name}}}
|
||||||
Configuration.Default.ApiKey.Add("{{{keyParamName}}}", "YOUR_API_KEY");
|
Configuration.Default.ApiKey.Add("{{{keyParamName}}}", "YOUR_API_KEY");
|
||||||
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
|
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
|
||||||
// Configuration.Default.ApiKeyPrefix.Add("{{{keyParamName}}}", "Bearer");{{/isApiKey}}{{#isOAuth}}
|
// Configuration.Default.ApiKeyPrefix.Add("{{{keyParamName}}}", "Bearer");{{/isApiKey}}{{#isOAuth}}// Configure OAuth2 access token for authorization: {{{name}}}
|
||||||
// Configure OAuth2 access token for authorization: {{{name}}}
|
Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN";{{/isOAuth}}
|
||||||
Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN";{{/isOAuth}}{{/authMethods}}
|
{{/authMethods}}
|
||||||
{{/hasAuthMethods}}
|
{{/hasAuthMethods}}
|
||||||
|
|
||||||
|
// Create an instance of the API class
|
||||||
var apiInstance = new {{classname}}();
|
var apiInstance = new {{classname}}();
|
||||||
{{#allParams}}
|
{{#allParams}}
|
||||||
{{#isPrimitiveType}}
|
{{#isPrimitiveType}}
|
||||||
@ -32,16 +34,13 @@ namespace Example
|
|||||||
{{/isPrimitiveType}}
|
{{/isPrimitiveType}}
|
||||||
{{/allParams}}
|
{{/allParams}}
|
||||||
|
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
{{#summary}}
|
{{#summary}}
|
||||||
// {{{.}}}
|
// {{{.}}}
|
||||||
{{/summary}}
|
{{/summary}}
|
||||||
{{#returnType}}{{{.}}} result = {{/returnType}}apiInstance.{{{operationId}}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});{{#returnType}}
|
{{#returnType}}{{{.}}} result = {{/returnType}}apiInstance.{{{operationId}}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});{{#returnType}}
|
||||||
Debug.WriteLine(result);{{/returnType}}
|
Debug.WriteLine(result);{{/returnType}}
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
Debug.Print("Exception when calling {{classname}}.{{operationId}}: " + e.Message );
|
Debug.Print("Exception when calling {{classname}}.{{operationId}}: " + e.Message );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,15 +7,16 @@ import java.io.File;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class {{{classname}}}Example {
|
public class {{{classname}}}Example {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
{{#hasAuthMethods}}ApiClient defaultClient = Configuration.getDefaultApiClient();
|
{{#hasAuthMethods}}
|
||||||
{{#authMethods}}{{#isBasic}}
|
ApiClient defaultClient = Configuration.getDefaultApiClient();
|
||||||
|
{{#authMethods}}
|
||||||
|
{{^isBasicBearer}}{{#isBasic}}
|
||||||
// Configure HTTP basic authorization: {{{name}}}
|
// Configure HTTP basic authorization: {{{name}}}
|
||||||
HttpBasicAuth {{{name}}} = (HttpBasicAuth) defaultClient.getAuthentication("{{{name}}}");
|
HttpBasicAuth {{{name}}} = (HttpBasicAuth) defaultClient.getAuthentication("{{{name}}}");
|
||||||
{{{name}}}.setUsername("YOUR USERNAME");
|
{{{name}}}.setUsername("YOUR USERNAME");
|
||||||
{{{name}}}.setPassword("YOUR PASSWORD");{{/isBasic}}{{#isBasicBearer}}
|
{{{name}}}.setPassword("YOUR PASSWORD");{{/isBasic}}{{/isBasicBearer}}{{#isBasicBearer}}
|
||||||
// Configure HTTP bearer authorization: {{{name}}}
|
// Configure Bearer{{#bearerFormat}} ({{{.}}}){{/bearerFormat}} access token for authorization: {{{name}}}
|
||||||
HttpBearerAuth {{{name}}} = (HttpBearerAuth) defaultClient.getAuthentication("{{{name}}}");
|
HttpBearerAuth {{{name}}} = (HttpBearerAuth) defaultClient.getAuthentication("{{{name}}}");
|
||||||
{{{name}}}.setBearerToken("BEARER TOKEN");{{/isBasicBearer}}{{#isApiKey}}
|
{{{name}}}.setBearerToken("BEARER TOKEN");{{/isBasicBearer}}{{#isApiKey}}
|
||||||
// Configure API key authorization: {{{name}}}
|
// Configure API key authorization: {{{name}}}
|
||||||
@ -29,10 +30,12 @@ public class {{{classname}}}Example {
|
|||||||
{{/authMethods}}
|
{{/authMethods}}
|
||||||
{{/hasAuthMethods}}
|
{{/hasAuthMethods}}
|
||||||
|
|
||||||
|
// Create an instance of the API class
|
||||||
{{{classname}}} apiInstance = new {{{classname}}}();
|
{{{classname}}} apiInstance = new {{{classname}}}();
|
||||||
{{#allParams}}
|
{{#allParams}}
|
||||||
{{{dataType}}} {{{paramName}}} = {{{example}}}; // {{{dataType}}} | {{{unescapedDescription}}}
|
{{{dataType}}} {{{paramName}}} = {{{example}}}; // {{{dataType}}} | {{{unescapedDescription}}}
|
||||||
{{/allParams}}
|
{{/allParams}}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
{{#returnType}}{{{returnType}}} result = {{/returnType}}apiInstance.{{{operationId}}}({{#allParams}}{{{paramName}}}{{#hasMore}}, {{/hasMore}}{{/allParams}});{{#returnType}}
|
{{#returnType}}{{{returnType}}} result = {{/returnType}}apiInstance.{{{operationId}}}({{#allParams}}{{{paramName}}}{{#hasMore}}, {{/hasMore}}{{/allParams}});{{#returnType}}
|
||||||
System.out.println(result);{{/returnType}}
|
System.out.println(result);{{/returnType}}
|
||||||
|
@ -1,22 +1,26 @@
|
|||||||
var {{{jsModuleName}}} = require('{{{jsProjectName}}}');
|
var {{{jsModuleName}}} = require('{{{jsProjectName}}}');
|
||||||
{{#hasAuthMethods}}
|
{{#hasAuthMethods}}
|
||||||
var defaultClient = {{{jsModuleName}}}.ApiClient.instance;
|
var defaultClient = {{{jsModuleName}}}.ApiClient.instance;
|
||||||
{{#authMethods}}{{#isBasic}}
|
{{#authMethods}}{{^isBasicBearer}}{{#isBasic}}
|
||||||
// Configure HTTP basic authorization: {{{name}}}
|
// Configure HTTP basic authorization: {{{name}}}
|
||||||
var {{{name}}} = defaultClient.authentications['{{{name}}}'];
|
var {{{name}}} = defaultClient.authentications['{{{name}}}'];
|
||||||
{{{name}}}.username = 'YOUR USERNAME'
|
{{{name}}}.username = 'YOUR USERNAME';
|
||||||
{{{name}}}.password = 'YOUR PASSWORD'{{/isBasic}}{{#isApiKey}}
|
{{{name}}}.password = 'YOUR PASSWORD';{{/isBasic}}{{/isBasicBearer}}{{#isBasicBearer}}
|
||||||
|
// Configure Bearer{{#bearerFormat}} ({{{.}}}){{/bearerFormat}} access token for authorization: {{{name}}}
|
||||||
|
var {{{name}}} = defaultClient.authentications['{{{name}}}'];
|
||||||
|
{{{name}}}.accessToken = "YOUR ACCESS TOKEN";{{/isBasicBearer}}{{#isApiKey}}
|
||||||
// Configure API key authorization: {{{name}}}
|
// Configure API key authorization: {{{name}}}
|
||||||
var {{{name}}} = defaultClient.authentications['{{{name}}}'];
|
var {{{name}}} = defaultClient.authentications['{{{name}}}'];
|
||||||
{{{name}}}.apiKey = "YOUR API KEY"
|
{{{name}}}.apiKey = "YOUR API KEY";
|
||||||
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
|
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
|
||||||
//{{{name}}}.apiKeyPrefix['{{{keyParamName}}}'] = "Token"{{/isApiKey}}{{#isOAuth}}
|
//{{{name}}}.apiKeyPrefix['{{{keyParamName}}}'] = "Token";{{/isApiKey}}{{#isOAuth}}
|
||||||
// Configure OAuth2 access token for authorization: {{{name}}}
|
// Configure OAuth2 access token for authorization: {{{name}}}
|
||||||
var {{{name}}} = defaultClient.authentications['{{{name}}}'];
|
var {{{name}}} = defaultClient.authentications['{{{name}}}'];
|
||||||
{{{name}}}.accessToken = "YOUR ACCESS TOKEN"{{/isOAuth}}
|
{{{name}}}.accessToken = "YOUR ACCESS TOKEN";{{/isOAuth}}
|
||||||
{{/authMethods}}
|
{{/authMethods}}
|
||||||
{{/hasAuthMethods}}
|
{{/hasAuthMethods}}
|
||||||
|
|
||||||
|
// Create an instance of the API class
|
||||||
var api = new {{{jsModuleName}}}.{{{classname}}}(){{#hasParams}}
|
var api = new {{{jsModuleName}}}.{{{classname}}}(){{#hasParams}}
|
||||||
{{#hasRequiredParams}}
|
{{#hasRequiredParams}}
|
||||||
{{#requiredParams}}
|
{{#requiredParams}}
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
{{#hasAuthMethods}}
|
{{#hasAuthMethods}}
|
||||||
{{classPrefix}}Configuration *apiConfig = [{{classPrefix}}Configuration sharedConfig];
|
{{classPrefix}}Configuration *apiConfig = [{{classPrefix}}Configuration sharedConfig];
|
||||||
{{#authMethods}}{{#isBasic}}// Configure HTTP basic authorization (authentication scheme: {{{name}}})
|
{{#authMethods}}
|
||||||
|
{{^isBasicBearer}}{{#isBasic}}
|
||||||
|
// Configure HTTP basic authorization (authentication scheme: {{{name}}})
|
||||||
[apiConfig setUsername:@"YOUR_USERNAME"];
|
[apiConfig setUsername:@"YOUR_USERNAME"];
|
||||||
[apiConfig setPassword:@"YOUR_PASSWORD"];
|
[apiConfig setPassword:@"YOUR_PASSWORD"];{{/isBasic}}{{/isBasicBearer}}{{#isBasicBearer}}
|
||||||
{{/isBasic}}{{#isApiKey}}
|
// Configure Bearer{{#bearerFormat}} ({{{.}}}){{/bearerFormat}} access token for authorization: {{{name}}}
|
||||||
|
[apiConfig setAccessToken:@"YOUR_ACCESS_TOKEN"];{{/isBasicBearer}}{{#isApiKey}}
|
||||||
// Configure API key authorization: (authentication scheme: {{{name}}})
|
// Configure API key authorization: (authentication scheme: {{{name}}})
|
||||||
[apiConfig setApiKey:@"YOUR_API_KEY" forApiKeyIdentifier:@"{{{keyParamName}}}"];
|
[apiConfig setApiKey:@"YOUR_API_KEY" forApiKeyIdentifier:@"{{{keyParamName}}}"];
|
||||||
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
|
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
|
||||||
@ -11,23 +14,27 @@
|
|||||||
{{/isApiKey}}{{#isOAuth}}
|
{{/isApiKey}}{{#isOAuth}}
|
||||||
// Configure OAuth2 access token for authorization: (authentication scheme: {{{name}}})
|
// Configure OAuth2 access token for authorization: (authentication scheme: {{{name}}})
|
||||||
[apiConfig setAccessToken:@"YOUR_ACCESS_TOKEN"];
|
[apiConfig setAccessToken:@"YOUR_ACCESS_TOKEN"];
|
||||||
{{/isOAuth}}{{/authMethods}}
|
{{/isOAuth}}
|
||||||
|
{{/authMethods}}
|
||||||
{{/hasAuthMethods}}
|
{{/hasAuthMethods}}
|
||||||
{{#allParams}}{{{dataType}}} *{{paramName}} = {{{example}}}; // {{{unescapedDescription}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}}
|
|
||||||
{{/allParams}}
|
|
||||||
|
|
||||||
|
|
||||||
|
// Create an instance of the API class
|
||||||
{{classname}} *apiInstance = [[{{classname}} alloc] init];
|
{{classname}} *apiInstance = [[{{classname}} alloc] init];
|
||||||
|
{{#allParams}}
|
||||||
|
{{{dataType}}} *{{paramName}} = {{{example}}}; // {{{unescapedDescription}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}}
|
||||||
|
{{/allParams}}
|
||||||
|
|
||||||
{{#summary}}// {{{.}}}
|
{{#summary}}// {{{.}}}
|
||||||
{{/summary}}[apiInstance {{#vendorExtensions.x-objc-operationId}}{{vendorExtensions.x-objc-operationId}}{{/vendorExtensions.x-objc-operationId}}{{^vendorExtensions.x-objc-operationId}}{{nickname}}{{#hasParams}}With{{vendorExtensions.x-first-param-alt-name}}{{/hasParams}}{{^hasParams}}WithCompletionHandler: {{/hasParams}}{{/vendorExtensions.x-objc-operationId}}{{#allParams}}{{#secondaryParam}}
|
{{/summary}}[apiInstance {{#vendorExtensions.x-objc-operationId}}{{vendorExtensions.x-objc-operationId}}{{/vendorExtensions.x-objc-operationId}}{{^vendorExtensions.x-objc-operationId}}{{nickname}}{{#hasParams}}With{{vendorExtensions.x-first-param-alt-name}}{{/hasParams}}{{^hasParams}}WithCompletionHandler: {{/hasParams}}{{/vendorExtensions.x-objc-operationId}}{{#allParams}}{{#secondaryParam}}
|
||||||
{{paramName}}{{/secondaryParam}}:{{paramName}}{{/allParams}}
|
{{paramName}}{{/secondaryParam}}:{{paramName}}{{/allParams}}
|
||||||
{{#hasParams}}completionHandler: {{/hasParams}}^({{#returnBaseType}}{{{returnType}}} output, {{/returnBaseType}}NSError* error) {
|
{{#hasParams}}completionHandler: {{/hasParams}}^({{#returnBaseType}}{{{returnType}}} output, {{/returnBaseType}}NSError* error) {
|
||||||
{{#returnType}}
|
{{#returnType}}
|
||||||
if (output) {
|
if (output) {
|
||||||
NSLog(@"%@", output);
|
NSLog(@"%@", output);
|
||||||
}
|
}
|
||||||
{{/returnType}}
|
{{/returnType}}
|
||||||
if (error) {
|
if (error) {
|
||||||
NSLog(@"Error: %@", error);
|
NSLog(@"Error: %@", error);
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
|
@ -1,18 +1,24 @@
|
|||||||
use Data::Dumper;
|
use Data::Dumper;
|
||||||
use {{{perlModuleName}}}::Configuration;
|
use {{{perlModuleName}}}::Configuration;
|
||||||
use {{perlModuleName}}::{{classname}};
|
use {{perlModuleName}}::{{classname}};
|
||||||
{{#hasAuthMethods}}{{#authMethods}}{{#isBasic}}
|
{{#hasAuthMethods}}
|
||||||
|
{{#authMethods}}
|
||||||
|
{{^isBasicBearer}}{{#isBasic}}
|
||||||
# Configure HTTP basic authorization: {{{name}}}
|
# Configure HTTP basic authorization: {{{name}}}
|
||||||
${{{perlModuleName}}}::Configuration::username = 'YOUR_USERNAME';
|
${{{perlModuleName}}}::Configuration::username = 'YOUR_USERNAME';
|
||||||
${{{perlModuleName}}}::Configuration::password = 'YOUR_PASSWORD';{{/isBasic}}{{#isApiKey}}
|
${{{perlModuleName}}}::Configuration::password = 'YOUR_PASSWORD';{{/isBasic}}{{/isBasicBearer}}{{#isBasicBearer}}
|
||||||
|
# Configure Bearer{{#bearerFormat}} ({{{.}}}){{/bearerFormat}} access token for authorization: {{{name}}}
|
||||||
|
${{{perlModuleName}}}::Configuration::access_token = 'YOUR_ACCESS_TOKEN';{{/isBasicBearer}}{{#isApiKey}}
|
||||||
# Configure API key authorization: {{{name}}}
|
# Configure API key authorization: {{{name}}}
|
||||||
${{{perlModuleName}}}::Configuration::api_key->{'{{{keyParamName}}}'} = 'YOUR_API_KEY';
|
${{{perlModuleName}}}::Configuration::api_key->{'{{{keyParamName}}}'} = 'YOUR_API_KEY';
|
||||||
# uncomment below to setup prefix (e.g. Bearer) for API key, if needed
|
# uncomment below to setup prefix (e.g. Bearer) for API key, if needed
|
||||||
#${{{perlModuleName}}}::Configuration::api_key_prefix->{'{{{keyParamName}}}'} = "Bearer";{{/isApiKey}}{{#isOAuth}}
|
#${{{perlModuleName}}}::Configuration::api_key_prefix->{'{{{keyParamName}}}'} = "Bearer";{{/isApiKey}}{{#isOAuth}}
|
||||||
# Configure OAuth2 access token for authorization: {{{name}}}
|
# Configure OAuth2 access token for authorization: {{{name}}}
|
||||||
${{{perlModuleName}}}::Configuration::access_token = 'YOUR_ACCESS_TOKEN';{{/isOAuth}}{{/authMethods}}
|
${{{perlModuleName}}}::Configuration::access_token = 'YOUR_ACCESS_TOKEN';{{/isOAuth}}
|
||||||
|
{{/authMethods}}
|
||||||
{{/hasAuthMethods}}
|
{{/hasAuthMethods}}
|
||||||
|
|
||||||
|
# Create an instance of the API class
|
||||||
my $api_instance = {{perlModuleName}}::{{classname}}->new();
|
my $api_instance = {{perlModuleName}}::{{classname}}->new();
|
||||||
{{#allParams}}my ${{paramName}} = {{#isListContainer}}[{{/isListContainer}}{{#isBodyParam}}{{{perlModuleName}}}::Object::{{dataType}}->new(){{/isBodyParam}}{{^isBodyParam}}{{{example}}}{{/isBodyParam}}{{#isListContainer}}]{{/isListContainer}}; # {{{dataType}}} | {{{unescapedDescription}}}
|
{{#allParams}}my ${{paramName}} = {{#isListContainer}}[{{/isListContainer}}{{#isBodyParam}}{{{perlModuleName}}}::Object::{{dataType}}->new(){{/isBodyParam}}{{^isBodyParam}}{{{example}}}{{/isBodyParam}}{{#isListContainer}}]{{/isListContainer}}; # {{{dataType}}} | {{{unescapedDescription}}}
|
||||||
{{/allParams}}
|
{{/allParams}}
|
||||||
|
@ -1,17 +1,23 @@
|
|||||||
<?php
|
<?php
|
||||||
require_once(__DIR__ . '/vendor/autoload.php');
|
require_once(__DIR__ . '/vendor/autoload.php');
|
||||||
{{#hasAuthMethods}}{{#authMethods}}{{#isBasic}}
|
{{#hasAuthMethods}}
|
||||||
|
{{#authMethods}}
|
||||||
|
{{^isBasicBearer}}{{#isBasic}}
|
||||||
// Configure HTTP basic authorization: {{{name}}}
|
// Configure HTTP basic authorization: {{{name}}}
|
||||||
{{phpInvokerPackage}}\Configuration::getDefaultConfiguration()->setUsername('YOUR_USERNAME');
|
{{phpInvokerPackage}}\Configuration::getDefaultConfiguration()->setUsername('YOUR_USERNAME');
|
||||||
{{phpInvokerPackage}}\Configuration::getDefaultConfiguration()->setPassword('YOUR_PASSWORD');{{/isBasic}}{{#isApiKey}}
|
{{phpInvokerPackage}}\Configuration::getDefaultConfiguration()->setPassword('YOUR_PASSWORD');{{/isBasic}}{{/isBasicBearer}}{{#isBasicBearer}}
|
||||||
|
// Configure Bearer{{#bearerFormat}} ({{{.}}}){{/bearerFormat}} access token for authorization: {{{name}}}
|
||||||
|
{{phpInvokerPackage}}\Configuration::getDefaultConfiguration()->setAccessToken('{{{keyParamName}}}', 'YOUR_ACCESS_TOKEN');{{/isBasicBearer}}{{#isApiKey}}
|
||||||
// Configure API key authorization: {{{name}}}
|
// Configure API key authorization: {{{name}}}
|
||||||
{{phpInvokerPackage}}\Configuration::getDefaultConfiguration()->setApiKey('{{{keyParamName}}}', 'YOUR_API_KEY');
|
{{phpInvokerPackage}}\Configuration::getDefaultConfiguration()->setApiKey('{{{keyParamName}}}', 'YOUR_API_KEY');
|
||||||
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
|
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
|
||||||
// {{phpInvokerPackage}}\Configuration::getDefaultConfiguration()->setApiKeyPrefix('{{{keyParamName}}}', 'Bearer');{{/isApiKey}}{{#isOAuth}}
|
// {{phpInvokerPackage}}\Configuration::getDefaultConfiguration()->setApiKeyPrefix('{{{keyParamName}}}', 'Bearer');{{/isApiKey}}{{#isOAuth}}
|
||||||
// Configure OAuth2 access token for authorization: {{{name}}}
|
// Configure OAuth2 access token for authorization: {{{name}}}
|
||||||
{{phpInvokerPackage}}\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');{{/isOAuth}}{{/authMethods}}
|
{{phpInvokerPackage}}\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');{{/isOAuth}}
|
||||||
|
{{/authMethods}}
|
||||||
{{/hasAuthMethods}}
|
{{/hasAuthMethods}}
|
||||||
|
|
||||||
|
// Create an instance of the API class
|
||||||
$api_instance = new OpenAPITools\Client\Api\{{classname}}();
|
$api_instance = new OpenAPITools\Client\Api\{{classname}}();
|
||||||
{{#allParams}}${{paramName}} = {{{example}}}; // {{{dataType}}} | {{{unescapedDescription}}}
|
{{#allParams}}${{paramName}} = {{{example}}}; // {{{dataType}}} | {{{unescapedDescription}}}
|
||||||
{{/allParams}}
|
{{/allParams}}
|
||||||
|
@ -3,19 +3,24 @@ import time
|
|||||||
import {{{pythonPackageName}}}
|
import {{{pythonPackageName}}}
|
||||||
from {{{pythonPackageName}}}.rest import ApiException
|
from {{{pythonPackageName}}}.rest import ApiException
|
||||||
from pprint import pprint
|
from pprint import pprint
|
||||||
{{#hasAuthMethods}}{{#authMethods}}{{#isBasic}}
|
{{#hasAuthMethods}}
|
||||||
|
{{#authMethods}}
|
||||||
|
{{^isBasicBearer}}{{#isBasic}}
|
||||||
# Configure HTTP basic authorization: {{{name}}}
|
# Configure HTTP basic authorization: {{{name}}}
|
||||||
{{{pythonPackageName}}}.configuration.username = 'YOUR_USERNAME'
|
{{{pythonPackageName}}}.configuration.username = 'YOUR_USERNAME'
|
||||||
{{{pythonPackageName}}}.configuration.password = 'YOUR_PASSWORD'{{/isBasic}}{{#isApiKey}}
|
{{{pythonPackageName}}}.configuration.password = 'YOUR_PASSWORD'{{/isBasic}}{{/isBasicBearer}}{{#isBasicBearer}}
|
||||||
|
# Configure Bearer{{#bearerFormat}} ({{{.}}}){{/bearerFormat}} access token for authorization: {{{name}}}
|
||||||
|
{{{pythonPackageName}}}.configuration.access_token = 'YOUR_ACCESS_TOKEN'{{/isBasicBearer}}{{#isApiKey}}
|
||||||
# Configure API key authorization: {{{name}}}
|
# Configure API key authorization: {{{name}}}
|
||||||
{{{pythonPackageName}}}.configuration.api_key['{{{keyParamName}}}'] = 'YOUR_API_KEY'
|
{{{pythonPackageName}}}.configuration.api_key['{{{keyParamName}}}'] = 'YOUR_API_KEY'
|
||||||
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
|
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
|
||||||
# {{{pythonPackageName}}}.configuration.api_key_prefix['{{{keyParamName}}}'] = 'Bearer'{{/isApiKey}}{{#isOAuth}}
|
# {{{pythonPackageName}}}.configuration.api_key_prefix['{{{keyParamName}}}'] = 'Bearer'{{/isApiKey}}{{#isOAuth}}
|
||||||
# Configure OAuth2 access token for authorization: {{{name}}}
|
# Configure OAuth2 access token for authorization: {{{name}}}
|
||||||
{{{pythonPackageName}}}.configuration.access_token = 'YOUR_ACCESS_TOKEN'{{/isOAuth}}{{/authMethods}}
|
{{{pythonPackageName}}}.configuration.access_token = 'YOUR_ACCESS_TOKEN'{{/isOAuth}}
|
||||||
|
{{/authMethods}}
|
||||||
{{/hasAuthMethods}}
|
{{/hasAuthMethods}}
|
||||||
|
|
||||||
# create an instance of the API class
|
# Create an instance of the API class
|
||||||
api_instance = {{{pythonPackageName}}}.{{{classname}}}()
|
api_instance = {{{pythonPackageName}}}.{{{classname}}}()
|
||||||
{{#allParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{unescapedDescription}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}}
|
{{#allParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{unescapedDescription}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}}
|
||||||
{{/allParams}}
|
{{/allParams}}
|
||||||
|
@ -6,6 +6,6 @@ pub fn main() {
|
|||||||
|
|
||||||
let mut context = {{classname}}::Context::default();
|
let mut context = {{classname}}::Context::default();
|
||||||
let result = client.{{operationId}}({{#allParams}}{{paramName}}, {{/allParams}}&context).wait();
|
let result = client.{{operationId}}({{#allParams}}{{paramName}}, {{/allParams}}&context).wait();
|
||||||
println!("{:?}", result);
|
|
||||||
|
|
||||||
|
println!("{:?}", result);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user