Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated javascript es5 templates #1261

Merged
merged 1 commit into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,140 changes: 576 additions & 564 deletions src/main/resources/handlebars/javascript/ApiClient.mustache

Large diffs are not rendered by default.

167 changes: 91 additions & 76 deletions src/main/resources/handlebars/javascript/api.mustache
Original file line number Diff line number Diff line change
@@ -1,103 +1,118 @@
{{>licenseInfo}}
(function(root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['{{#invokerPackage}}{{&invokerPackage}}/{{/invokerPackage}}ApiClient'{{#imports}}, '{{#invokerPackage}}{{&invokerPackage}}/{{/invokerPackage}}{{#modelPackage}}{{&modelPackage}}/{{/modelPackage}}{{import}}'{{/imports}}], factory);
} else if (typeof module === 'object' && module.exports) {
// CommonJS-like environments that support module.exports, like Node.
module.exports = factory(require('../ApiClient'){{#imports}}, require('../{{#modelPackage}}{{&modelPackage}}/{{/modelPackage}}{{import}}'){{/imports}});
} else {
// Browser globals (root is window)
if (!root.{{&moduleName}}) {
root.{{&moduleName}} = {};
}
root.{{&moduleName}}.{{&classname}} = factory(root.{{&moduleName}}.ApiClient{{#imports}}, root.{{&moduleName}}.{{import}}{{/imports}});
}
}(this, function(ApiClient{{#imports}}, {{import}}{{/imports}}) {
'use strict';
{{=< >=}}
import ApiClient from "../ApiClient";
<#imports>import <import> from '../<#modelPackage><&modelPackage>/</modelPackage><import>';
</imports>

<#emitJSDoc>/**
* <baseName> service.
* @module <#invokerPackage><&invokerPackage>/</invokerPackage><#apiPackage><&apiPackage>/</apiPackage><classname>
* @version <projectVersion>
*/</emitJSDoc>
export default class <classname> {
{{#emitJSDoc}} /**
* {{baseName}} service.
* @module {{#invokerPackage}}{{&invokerPackage}}/{{/invokerPackage}}{{#apiPackage}}{{&apiPackage}}/{{/apiPackage}}{{classname}}
* @version {{projectVersion}}
*/

<#emitJSDoc>/**
* Constructs a new <&classname>. <#description>
* <description></description>
* @alias module:<#invokerPackage><&invokerPackage>/</invokerPackage><#apiPackage><apiPackage>/</apiPackage><classname>
* @class
* @param {module:<#invokerPackage><&invokerPackage>/</invokerPackage>ApiClient} [apiClient] Optional API client implementation to use,
* default to {@link module:<#invokerPackage><&invokerPackage>/</invokerPackage>ApiClient#instance} if unspecified.
*/</emitJSDoc>
constructor(apiClient) {
this.apiClient = apiClient || ApiClient.instance;
}
/**
* Constructs a new {{&classname}}. {{#description}}
* {{description}}{{/description}}
* @alias module:{{#invokerPackage}}{{&invokerPackage}}/{{/invokerPackage}}{{#apiPackage}}{{apiPackage}}/{{/apiPackage}}{{classname}}
* @class
* @param {module:{{#invokerPackage}}{{&invokerPackage}}/{{/invokerPackage}}ApiClient} [apiClient] Optional API client implementation to use,
* default to {@link module:{{#invokerPackage}}{{&invokerPackage}}/{{/invokerPackage}}ApiClient#instance} if unspecified.
*/
{{/emitJSDoc}} var exports = function(apiClient) {
this.apiClient = apiClient || ApiClient.instance;
<#operations><#operation><#emitJSDoc><^usePromises>
{{#operations}}{{#operation}}{{#emitJSDoc}}{{^usePromises}}
/**
* Callback function to receive the result of the <operationId> operation.
* @callback module:<#invokerPackage><invokerPackage>/</invokerPackage><#apiPackage><apiPackage>/</apiPackage><classname>~<operationId>Callback
* Callback function to receive the result of the {{operationId}} operation.
* @callback module:{{#invokerPackage}}{{invokerPackage}}/{{/invokerPackage}}{{#apiPackage}}{{apiPackage}}/{{/apiPackage}}{{classname}}~{{operationId}}Callback
* @param {String} error Error message, if any.
* @param <#vendorExtensions.x-jsdoc-type>{<&vendorExtensions.x-jsdoc-type>} data The data returned by the service call.</vendorExtensions.x-jsdoc-type><^vendorExtensions.x-jsdoc-type>data This operation does not return a value.</vendorExtensions.x-jsdoc-type>
* @param {{#vendorExtensions.x-jsdoc-type}}{{braces "left"}}{{&vendorExtensions.x-jsdoc-type}}{{braces "right"}} data The data returned by the service call.{{/vendorExtensions.x-jsdoc-type}}{{^vendorExtensions.x-jsdoc-type}}data This operation does not return a value.{{/vendorExtensions.x-jsdoc-type}}
* @param {String} response The complete HTTP response.
*/</usePromises>
*/{{/usePromises}}

/**<#summary>
* <summary></summary><#notes>
* <notes></notes><#parameters><#required>
* @param {<&vendorExtensions.x-jsdoc-type>} <paramName> <description></required></parameters><#hasOptionalParams>
* @param {Object} opts Optional parameters<#parameters><^required>
* @param {<&vendorExtensions.x-jsdoc-type>} opts.<paramName> <description><#defaultValue> (default to <.>)</defaultValue></required></parameters></hasOptionalParams><^usePromises>
* @param {module:<#invokerPackage><&invokerPackage>/</invokerPackage><#apiPackage><&apiPackage>/</apiPackage><&classname>~<operationId>Callback} callback The callback function, accepting three arguments: error, data, response<#returnType>
* data is of type: {@link <&vendorExtensions.x-jsdoc-type>}</returnType></usePromises><#usePromises>
* @return {Promise} a {@link https://www.promisejs.org/|Promise}<#returnType>, with an object containing data of type {@link <&vendorExtensions.x-jsdoc-type>} and HTTP response</returnType><^returnType>, with an object containing HTTP response</returnType></usePromises>
/**{{#summary}}
* {{summary}}{{/summary}}{{#notes}}
* {{notes}}{{/notes}}{{#allParams}}{{#required}}
* @param {{braces "left"}}{{&vendorExtensions.x-jsdoc-type}}{{braces "right"}} {{paramName}} {{description}}{{/required}}{{/allParams}}{{#hasOptionalParams}}
* @param {Object} opts Optional parameters{{#allParams}}{{^required}}
* @param {{braces "left"}}{{&vendorExtensions.x-jsdoc-type}}{{braces "right"}} opts.{{paramName}} {{description}}{{#defaultValue}} (default to {{.}}){{/defaultValue}}{{/required}}{{/allParams}}{{/hasOptionalParams}}{{^usePromises}}
* @param {module:{{#invokerPackage}}{{&invokerPackage}}/{{/invokerPackage}}{{#apiPackage}}{{&apiPackage}}/{{/apiPackage}}{{&classname}}~{{operationId}}Callback} callback The callback function, accepting three arguments: error, data, response{{#returnType}}
* data is of type: {{braces "left"}}@link {{&vendorExtensions.x-jsdoc-type}}{{braces "right"}}{{/returnType}}{{/usePromises}}{{#usePromises}}
* @return {Promise} a {@link https://www.promisejs.org/|Promise{{braces "right"}}{{#returnType}}, with an object containing data of type {@link {{&vendorExtensions.x-jsdoc-type}}{{braces "right"}} and HTTP response{{/returnType}}{{^returnType}}, with an object containing HTTP response{{/returnType}}{{/usePromises}}
*/
</emitJSDoc> <operationId><#usePromises>WithHttpInfo</usePromises>(<vendorExtensions.x-codegen-argList>) {<#hasOptionalParams>
opts = opts || {};</hasOptionalParams>
let postBody = <#bodyParam><#required><paramName></required><^required>opts['<paramName>']</required></bodyParam><^bodyParam>null</bodyParam>;
<#parameters><#required>
// verify the required parameter '<paramName>' is set
if (<paramName> === undefined || <paramName> === null) {
throw new Error("Missing the required parameter '<paramName>' when calling <operationId>");
{{/emitJSDoc}} this.{{operationId}}{{#usePromises}}WithHttpInfo{{/usePromises}} = function({{vendorExtensions.x-codegen-arg-list}}{{^usePromises}}{{#hasParams}}, {{/hasParams}}callback{{/usePromises}}) {{braces "left"}}{{#hasOptionalParams}}
opts = opts || {};{{/hasOptionalParams}}
var postBody = {{#bodyParam}}{{#required}}{{paramName}}{{/required}}{{^required}}opts['{{paramName}}']{{/required}}{{/bodyParam}}{{^bodyParam}}null{{/bodyParam}};
{{#allParams}}{{#required}}
// verify the required parameter '{{paramName}}' is set
if ({{paramName}} === undefined || {{paramName}} === null) {
throw new Error("Missing the required parameter '{{paramName}}' when calling {{operationId}}");
}
</required></parameters>
{{/required}}{{/allParams}}

let pathParams = {<#pathParams>
'<baseName>': <#required><paramName></required><^required>opts['<paramName>']</required><#hasMore>,</hasMore></pathParams>
var pathParams = {{braces "left"}}{{#pathParams}}
'{{baseName}}': {{#required}}{{paramName}}{{/required}}{{^required}}opts['{{paramName}}']{{/required}}{{#hasMore}},{{/hasMore}}{{/pathParams}}
};
let queryParams = {{braces "left"}}{{#queryParams}}
'{{baseName}}': {{#collectionFormat}}this.apiClient.buildCollectionParam({{#required}}{{paramName}}{{/required}}{{^required}}opts['{{paramName}}']{{/required}}, '{{collectionFormat}}'){{/collectionFormat}}{{^collectionFormat}}{{#required}}{{paramName}}{{/required}}{{^required}}opts['{{paramName}}']{{/required}}{{/collectionFormat}}{{#hasMore}},{{/hasMore}}{{/queryParams}}
};
let queryParams = {<#queryParams>
'<baseName>': <#collectionFormat>this.apiClient.buildCollectionParam(<#required><paramName></required><^required>opts['<paramName>']</required>, '<collectionFormat>')</collectionFormat><^collectionFormat><#required><paramName></required><^required>opts['<paramName>']</required></collectionFormat><#hasMore>,</hasMore></queryParams>
var collectionQueryParams = {{braces "left"}}{{#queryParams}}{{#collectionFormat}}
'{{baseName}}': {
value: {{#required}}{{paramName}}{{/required}}{{^required}}opts['{{paramName}}']{{/required}},
collectionFormat: '{{collectionFormat}}'
},{{/collectionFormat}}{{/queryParams}}
};
let headerParams = {<#headerParams>
'<baseName>': <#required><paramName></required><^required>opts['<paramName>']</required><#hasMore>,</hasMore></headerParams>
var headerParams = {{braces "left"}}{{#headerParams}}
'{{baseName}}': {{#required}}{{paramName}}{{/required}}{{^required}}opts['{{paramName}}']{{/required}}{{#hasMore}},{{/hasMore}}{{/headerParams}}
};
let formParams = {<#formParams>
'<baseName>': <#collectionFormat>this.apiClient.buildCollectionParam(<#required><paramName></required><^required>opts['<paramName>']</required>, '<collectionFormat>')</collectionFormat><^collectionFormat><#required><paramName></required><^required>opts['<paramName>']</required></collectionFormat><#hasMore>,</hasMore></formParams>
var formParams = {{braces "left"}}{{#formParams}}
'{{baseName}}': {{#collectionFormat}}this.apiClient.buildCollectionParam({{#required}}{{paramName}}{{/required}}{{^required}}opts['{{paramName}}']{{/required}}, '{{collectionFormat}}'){{/collectionFormat}}{{^collectionFormat}}{{#required}}{{paramName}}{{/required}}{{^required}}opts['{{paramName}}']{{/required}}{{/collectionFormat}}{{#hasMore}},{{/hasMore}}{{/formParams}}
};

let authNames = [<#authMethods>'<name>'<#hasMore>, </hasMore></authMethods>];
let contentTypes = [<#consumes>'<& mediaType>'<#hasMore>, </hasMore></consumes>];
let accepts = [<#produces>'<& mediaType>'<#hasMore>, </hasMore></produces>];
let returnType = <#returnType><&returnType></returnType><^returnType>null</returnType>;
var authNames = [{{#authMethods}}'{{name}}'{{#hasMore}}, {{/hasMore}}{{/authMethods}}];
var contentTypes = [{{#consumes}}'{{& mediaType}}'{{#hasMore}}, {{/hasMore}}{{/consumes}}];
var accepts = [{{#produces}}'{{& mediaType}}'{{#hasMore}}, {{/hasMore}}{{/produces}}];
var returnType = {{#returnType}}{{&returnType}}{{/returnType}}{{^returnType}}null{{/returnType}};

return this.apiClient.callApi(
'<&path>', '<httpMethod>',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType<^usePromises>, callback</usePromises>
'{{&path}}', '{{httpMethod}}',
pathParams, queryParams, collectionQueryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType{{^usePromises}}, callback{{/usePromises}}
);
}
<#usePromises>
<#emitJSDoc>
{{#usePromises}}
{{#emitJSDoc}}

/**<#summary>
* <summary></summary><#notes>
* <notes></notes><#parameters><#required>
* @param {<&vendorExtensions.x-jsdoc-type>} <paramName> <description></required></parameters><#hasOptionalParams>
* @param {Object} opts Optional parameters<#parameters><^required>
* @param {<&vendorExtensions.x-jsdoc-type>} opts.<paramName> <description><#defaultValue> (default to <.>)</defaultValue></required></parameters></hasOptionalParams><^usePromises>
* @param {module:<#invokerPackage><&invokerPackage>/</invokerPackage><#apiPackage><&apiPackage>/</apiPackage><&classname>~<operationId>Callback} callback The callback function, accepting three arguments: error, data, response<#returnType>
* data is of type: {@link <&vendorExtensions.x-jsdoc-type>}</returnType></usePromises><#usePromises>
* @return {Promise} a {@link https://www.promisejs.org/|Promise}<#returnType>, with data of type {@link <&vendorExtensions.x-jsdoc-type>}</returnType></usePromises>
/**{{#summary}}
* {{summary}}{{/summary}}{{#notes}}
* {{notes}}{{/notes}}{{#allParams}}{{#required}}
* @param {{braces "left"}}{{&vendorExtensions.x-jsdoc-type}}{{braces "right"}} {{paramName}} {{description}}{{/required}}{{/allParams}}{{#hasOptionalParams}}
* @param {Object} opts Optional parameters{{#allParams}}{{^required}}
* @param {{braces "left"}}{{&vendorExtensions.x-jsdoc-type}}{{braces "right"}} opts.{{paramName}} {{description}}{{#defaultValue}} (default to {{.}}){{/defaultValue}}{{/required}}{{/allParams}}{{/hasOptionalParams}}{{^usePromises}}
* @param {module:{{#invokerPackage}}{{&invokerPackage}}/{{/invokerPackage}}{{#apiPackage}}{{&apiPackage}}/{{/apiPackage}}{{&classname}}~{{operationId}}Callback} callback The callback function, accepting three arguments: error, data, response{{#returnType}}
* data is of type: {@link {{&vendorExtensions.x-jsdoc-type}}{{braces "right"}}{{/returnType}}{{/usePromises}}{{#usePromises}}
* @return {Promise} a {@link https://www.promisejs.org/|Promise}{{#returnType}}, with data of type {@link {{&vendorExtensions.x-jsdoc-type}}{{braces "right"}}{{/returnType}}{{/usePromises}}
*/
</emitJSDoc> <operationId>(<vendorExtensions.x-codegen-argList>) {
return this.<operationId>WithHttpInfo(<vendorExtensions.x-codegen-argList>)
{{/emitJSDoc}} this.{{operationId}} = function({{vendorExtensions.x-codegen-arg-list}}) {
return this.{{operationId}}WithHttpInfo({{vendorExtensions.x-codegen-arg-list}})
.then(function(response_and_data) {
return response_and_data.data;
});
}
</usePromises>
</operation></operations>
{{/usePromises}}
{{/operation}}{{/operations}} };

}
<={{ }}=>
return exports;
}));
28 changes: 17 additions & 11 deletions src/main/resources/handlebars/javascript/enumClass.mustache
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
{{#emitJSDoc}}/**
* Allowed values for the <code>{{baseName}}</code> property.
* @enum {{=<% %>=}}{<%datatype%>}<%={{ }}=%>
* @readonly
*/{{/emitJSDoc}}
export default {{datatypeWithEnum}} = {
{{#allowableValues}}{{#enumVars}}
{{#emitJSDoc}}/**
{{#emitJSDoc}}
/**
* Allowed values for the <code>{{baseName}}</code> property.
* @enum {{braces "left"}}{{datatype}}{{braces "right"}}
* @readonly
*/
{{/emitJSDoc}}
exports.{{datatypeWithEnum}} = {
{{#allowableValues}}
{{#enumVars}}
{{#emitJSDoc}}
/**
* value: {{{value}}}
* @const
*/{{/emitJSDoc}}
*/
{{/emitJSDoc}}
"{{name}}": {{{value}}}{{^@last}},
{{/@last}}
{{/enumVars}}{{/allowableValues}}
};
{{/enumVars}}
{{/allowableValues}}
};
Loading
Loading