diff --git a/modules/openapi-generator/src/main/resources/htmlDocs2/index.mustache b/modules/openapi-generator/src/main/resources/htmlDocs2/index.mustache index e82cd10725d7..5d4e979dff84 100644 --- a/modules/openapi-generator/src/main/resources/htmlDocs2/index.mustache +++ b/modules/openapi-generator/src/main/resources/htmlDocs2/index.mustache @@ -243,7 +243,11 @@
-
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}}"
+
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}}"
{{>sample_java}}
diff --git a/modules/openapi-generator/src/main/resources/htmlDocs2/sample_android.mustache b/modules/openapi-generator/src/main/resources/htmlDocs2/sample_android.mustache index 53f1864a169f..c95321e3cc01 100644 --- a/modules/openapi-generator/src/main/resources/htmlDocs2/sample_android.mustache +++ b/modules/openapi-generator/src/main/resources/htmlDocs2/sample_android.mustache @@ -1,12 +1,12 @@ import {{{invokerPackage}}}.api.{{{classname}}}; public class {{{classname}}}Example { - public static void main(String[] args) { {{{classname}}} apiInstance = new {{{classname}}}(); {{#allParams}} {{{dataType}}} {{{paramName}}} = {{{example}}}; // {{{dataType}}} | {{{unescapedDescription}}} {{/allParams}} + try { {{#returnType}}{{{returnType}}} result = {{/returnType}}apiInstance.{{{operationId}}}({{#allParams}}{{{paramName}}}{{#hasMore}}, {{/hasMore}}{{/allParams}});{{#returnType}} System.out.println(result);{{/returnType}} diff --git a/modules/openapi-generator/src/main/resources/htmlDocs2/sample_csharp.mustache b/modules/openapi-generator/src/main/resources/htmlDocs2/sample_csharp.mustache index feb5c80ff9fa..ccc5b3fa54a7 100644 --- a/modules/openapi-generator/src/main/resources/htmlDocs2/sample_csharp.mustache +++ b/modules/openapi-generator/src/main/resources/htmlDocs2/sample_csharp.mustache @@ -10,18 +10,20 @@ namespace Example { public void main() { - {{#hasAuthMethods}}{{#authMethods}}{{#isBasic}} - // Configure HTTP basic authorization: {{{name}}} + {{#hasAuthMethods}} + {{#authMethods}} + {{^isBasicBearer}}{{#isBasic}}// Configure HTTP basic authorization: {{{name}}} Configuration.Default.Username = "YOUR_USERNAME"; - Configuration.Default.Password = "YOUR_PASSWORD";{{/isBasic}}{{#isApiKey}} - // Configure API key authorization: {{{name}}} + Configuration.Default.Password = "YOUR_PASSWORD";{{/isBasic}}{{/isBasicBearer}}{{#isBasicBearer}}// Configure Bearer{{#bearerFormat}} ({{{.}}}){{/bearerFormat}} access token for authorization: {{{name}}} + Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN";{{/isBasicBearer}}{{#isApiKey}}// Configure API key authorization: {{{name}}} Configuration.Default.ApiKey.Add("{{{keyParamName}}}", "YOUR_API_KEY"); // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed - // Configuration.Default.ApiKeyPrefix.Add("{{{keyParamName}}}", "Bearer");{{/isApiKey}}{{#isOAuth}} - // Configure OAuth2 access token for authorization: {{{name}}} - Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN";{{/isOAuth}}{{/authMethods}} + // Configuration.Default.ApiKeyPrefix.Add("{{{keyParamName}}}", "Bearer");{{/isApiKey}}{{#isOAuth}}// Configure OAuth2 access token for authorization: {{{name}}} + Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN";{{/isOAuth}} + {{/authMethods}} {{/hasAuthMethods}} - + + // Create an instance of the API class var apiInstance = new {{classname}}(); {{#allParams}} {{#isPrimitiveType}} @@ -32,16 +34,13 @@ namespace Example {{/isPrimitiveType}} {{/allParams}} - try - { + try { {{#summary}} // {{{.}}} {{/summary}} {{#returnType}}{{{.}}} result = {{/returnType}}apiInstance.{{{operationId}}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});{{#returnType}} Debug.WriteLine(result);{{/returnType}} - } - catch (Exception e) - { + } catch (Exception e) { Debug.Print("Exception when calling {{classname}}.{{operationId}}: " + e.Message ); } } diff --git a/modules/openapi-generator/src/main/resources/htmlDocs2/sample_java.mustache b/modules/openapi-generator/src/main/resources/htmlDocs2/sample_java.mustache index 236d2873bc57..adf2e0d750d9 100644 --- a/modules/openapi-generator/src/main/resources/htmlDocs2/sample_java.mustache +++ b/modules/openapi-generator/src/main/resources/htmlDocs2/sample_java.mustache @@ -7,15 +7,16 @@ import java.io.File; import java.util.*; public class {{{classname}}}Example { - public static void main(String[] args) { - {{#hasAuthMethods}}ApiClient defaultClient = Configuration.getDefaultApiClient(); - {{#authMethods}}{{#isBasic}} + {{#hasAuthMethods}} + ApiClient defaultClient = Configuration.getDefaultApiClient(); + {{#authMethods}} + {{^isBasicBearer}}{{#isBasic}} // Configure HTTP basic authorization: {{{name}}} HttpBasicAuth {{{name}}} = (HttpBasicAuth) defaultClient.getAuthentication("{{{name}}}"); {{{name}}}.setUsername("YOUR USERNAME"); - {{{name}}}.setPassword("YOUR PASSWORD");{{/isBasic}}{{#isBasicBearer}} - // Configure HTTP bearer authorization: {{{name}}} + {{{name}}}.setPassword("YOUR PASSWORD");{{/isBasic}}{{/isBasicBearer}}{{#isBasicBearer}} + // Configure Bearer{{#bearerFormat}} ({{{.}}}){{/bearerFormat}} access token for authorization: {{{name}}} HttpBearerAuth {{{name}}} = (HttpBearerAuth) defaultClient.getAuthentication("{{{name}}}"); {{{name}}}.setBearerToken("BEARER TOKEN");{{/isBasicBearer}}{{#isApiKey}} // Configure API key authorization: {{{name}}} @@ -28,11 +29,13 @@ public class {{{classname}}}Example { {{{name}}}.setAccessToken("YOUR ACCESS TOKEN");{{/isOAuth}} {{/authMethods}} {{/hasAuthMethods}} - + + // Create an instance of the API class {{{classname}}} apiInstance = new {{{classname}}}(); {{#allParams}} {{{dataType}}} {{{paramName}}} = {{{example}}}; // {{{dataType}}} | {{{unescapedDescription}}} {{/allParams}} + try { {{#returnType}}{{{returnType}}} result = {{/returnType}}apiInstance.{{{operationId}}}({{#allParams}}{{{paramName}}}{{#hasMore}}, {{/hasMore}}{{/allParams}});{{#returnType}} System.out.println(result);{{/returnType}} diff --git a/modules/openapi-generator/src/main/resources/htmlDocs2/sample_js.mustache b/modules/openapi-generator/src/main/resources/htmlDocs2/sample_js.mustache index 362400aaaa0e..705fd26831d9 100644 --- a/modules/openapi-generator/src/main/resources/htmlDocs2/sample_js.mustache +++ b/modules/openapi-generator/src/main/resources/htmlDocs2/sample_js.mustache @@ -1,22 +1,26 @@ var {{{jsModuleName}}} = require('{{{jsProjectName}}}'); {{#hasAuthMethods}} var defaultClient = {{{jsModuleName}}}.ApiClient.instance; -{{#authMethods}}{{#isBasic}} +{{#authMethods}}{{^isBasicBearer}}{{#isBasic}} // Configure HTTP basic authorization: {{{name}}} var {{{name}}} = defaultClient.authentications['{{{name}}}']; -{{{name}}}.username = 'YOUR USERNAME' -{{{name}}}.password = 'YOUR PASSWORD'{{/isBasic}}{{#isApiKey}} +{{{name}}}.username = 'YOUR USERNAME'; +{{{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}}} 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) -//{{{name}}}.apiKeyPrefix['{{{keyParamName}}}'] = "Token"{{/isApiKey}}{{#isOAuth}} +//{{{name}}}.apiKeyPrefix['{{{keyParamName}}}'] = "Token";{{/isApiKey}}{{#isOAuth}} // Configure OAuth2 access token for authorization: {{{name}}} var {{{name}}} = defaultClient.authentications['{{{name}}}']; -{{{name}}}.accessToken = "YOUR ACCESS TOKEN"{{/isOAuth}} +{{{name}}}.accessToken = "YOUR ACCESS TOKEN";{{/isOAuth}} {{/authMethods}} {{/hasAuthMethods}} +// Create an instance of the API class var api = new {{{jsModuleName}}}.{{{classname}}}(){{#hasParams}} {{#hasRequiredParams}} {{#requiredParams}} diff --git a/modules/openapi-generator/src/main/resources/htmlDocs2/sample_objc.mustache b/modules/openapi-generator/src/main/resources/htmlDocs2/sample_objc.mustache index 1a2762b56c5f..58074d2e3917 100644 --- a/modules/openapi-generator/src/main/resources/htmlDocs2/sample_objc.mustache +++ b/modules/openapi-generator/src/main/resources/htmlDocs2/sample_objc.mustache @@ -1,9 +1,12 @@ {{#hasAuthMethods}} {{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 setPassword:@"YOUR_PASSWORD"]; -{{/isBasic}}{{#isApiKey}} +[apiConfig setPassword:@"YOUR_PASSWORD"];{{/isBasic}}{{/isBasicBearer}}{{#isBasicBearer}} +// Configure Bearer{{#bearerFormat}} ({{{.}}}){{/bearerFormat}} access token for authorization: {{{name}}} +[apiConfig setAccessToken:@"YOUR_ACCESS_TOKEN"];{{/isBasicBearer}}{{#isApiKey}} // Configure API key authorization: (authentication scheme: {{{name}}}) [apiConfig setApiKey:@"YOUR_API_KEY" forApiKeyIdentifier:@"{{{keyParamName}}}"]; // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed @@ -11,23 +14,27 @@ {{/isApiKey}}{{#isOAuth}} // Configure OAuth2 access token for authorization: (authentication scheme: {{{name}}}) [apiConfig setAccessToken:@"YOUR_ACCESS_TOKEN"]; -{{/isOAuth}}{{/authMethods}} +{{/isOAuth}} +{{/authMethods}} {{/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]; +{{#allParams}} +{{{dataType}}} *{{paramName}} = {{{example}}}; // {{{unescapedDescription}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}} +{{/allParams}} {{#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}} {{paramName}}{{/secondaryParam}}:{{paramName}}{{/allParams}} {{#hasParams}}completionHandler: {{/hasParams}}^({{#returnBaseType}}{{{returnType}}} output, {{/returnBaseType}}NSError* error) { {{#returnType}} - if (output) { - NSLog(@"%@", output); - } + if (output) { + NSLog(@"%@", output); + } {{/returnType}} - if (error) { - NSLog(@"Error: %@", error); - } - }]; + if (error) { + NSLog(@"Error: %@", error); + } +}]; diff --git a/modules/openapi-generator/src/main/resources/htmlDocs2/sample_perl.mustache b/modules/openapi-generator/src/main/resources/htmlDocs2/sample_perl.mustache index 8eeb8a246a26..81c4f4250044 100644 --- a/modules/openapi-generator/src/main/resources/htmlDocs2/sample_perl.mustache +++ b/modules/openapi-generator/src/main/resources/htmlDocs2/sample_perl.mustache @@ -1,18 +1,24 @@ use Data::Dumper; use {{{perlModuleName}}}::Configuration; use {{perlModuleName}}::{{classname}}; -{{#hasAuthMethods}}{{#authMethods}}{{#isBasic}} +{{#hasAuthMethods}} +{{#authMethods}} +{{^isBasicBearer}}{{#isBasic}} # Configure HTTP basic authorization: {{{name}}} ${{{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}}} ${{{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}} +${{{perlModuleName}}}::Configuration::access_token = 'YOUR_ACCESS_TOKEN';{{/isOAuth}} +{{/authMethods}} {{/hasAuthMethods}} +# Create an instance of the API class 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}} diff --git a/modules/openapi-generator/src/main/resources/htmlDocs2/sample_php.mustache b/modules/openapi-generator/src/main/resources/htmlDocs2/sample_php.mustache index 4984056baeaf..e69eda84c10a 100644 --- a/modules/openapi-generator/src/main/resources/htmlDocs2/sample_php.mustache +++ b/modules/openapi-generator/src/main/resources/htmlDocs2/sample_php.mustache @@ -1,17 +1,23 @@ <?php require_once(__DIR__ . '/vendor/autoload.php'); -{{#hasAuthMethods}}{{#authMethods}}{{#isBasic}} +{{#hasAuthMethods}} +{{#authMethods}} +{{^isBasicBearer}}{{#isBasic}} // Configure HTTP basic authorization: {{{name}}} {{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}}} {{phpInvokerPackage}}\Configuration::getDefaultConfiguration()->setApiKey('{{{keyParamName}}}', 'YOUR_API_KEY'); // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // {{phpInvokerPackage}}\Configuration::getDefaultConfiguration()->setApiKeyPrefix('{{{keyParamName}}}', 'Bearer');{{/isApiKey}}{{#isOAuth}} // 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}} +// Create an instance of the API class $api_instance = new OpenAPITools\Client\Api\{{classname}}(); {{#allParams}}${{paramName}} = {{{example}}}; // {{{dataType}}} | {{{unescapedDescription}}} {{/allParams}} diff --git a/modules/openapi-generator/src/main/resources/htmlDocs2/sample_python.mustache b/modules/openapi-generator/src/main/resources/htmlDocs2/sample_python.mustache index 0afe46abce26..028b840f4f9e 100644 --- a/modules/openapi-generator/src/main/resources/htmlDocs2/sample_python.mustache +++ b/modules/openapi-generator/src/main/resources/htmlDocs2/sample_python.mustache @@ -3,19 +3,24 @@ import time import {{{pythonPackageName}}} from {{{pythonPackageName}}}.rest import ApiException from pprint import pprint -{{#hasAuthMethods}}{{#authMethods}}{{#isBasic}} +{{#hasAuthMethods}} +{{#authMethods}} +{{^isBasicBearer}}{{#isBasic}} # Configure HTTP basic authorization: {{{name}}} {{{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}}} {{{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}} +{{{pythonPackageName}}}.configuration.access_token = 'YOUR_ACCESS_TOKEN'{{/isOAuth}} +{{/authMethods}} {{/hasAuthMethods}} -# create an instance of the API class +# Create an instance of the API class api_instance = {{{pythonPackageName}}}.{{{classname}}}() {{#allParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{unescapedDescription}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}} {{/allParams}} diff --git a/modules/openapi-generator/src/main/resources/htmlDocs2/sample_rust.mustache b/modules/openapi-generator/src/main/resources/htmlDocs2/sample_rust.mustache index 92c7ea600dcc..89a16ecc2063 100644 --- a/modules/openapi-generator/src/main/resources/htmlDocs2/sample_rust.mustache +++ b/modules/openapi-generator/src/main/resources/htmlDocs2/sample_rust.mustache @@ -6,6 +6,6 @@ pub fn main() { let mut context = {{classname}}::Context::default(); let result = client.{{operationId}}({{#allParams}}{{paramName}}, {{/allParams}}&context).wait(); - println!("{:?}", result); + println!("{:?}", result); }