Javascript-Apollo.api.mustache Maven / Gradle / Ivy
{{>licenseInfo}}
{{=< >=}}
import ApiClient from "../ApiClient";
<#imports>import <&import> from '../<#modelPackage><&modelPackage>/';
<#emitJSDoc>/**
* service.
* @module <#invokerPackage><&invokerPackage>/<#apiPackage><&apiPackage>/
* @version <&projectVersion>
*/
export default class <&classname> extends ApiClient {
<#emitJSDoc>/**
* Constructs a new <&classname>. <#description>
*
* @alias module:<#invokerPackage><&invokerPackage>/<#apiPackage><&apiPackage>/
* @class
*/
constructor(baseURL = '<&basePath>') {
super(baseURL);
}
<#operations><#operation><#emitJSDoc>
/**<#summary>
* <&summary><#notes>
* <¬es><#allParams><#required>
* @param {<&vendorExtensions.x-jsdoc-type>} <¶mName> <&description><#hasOptionalParams>
* @param {Object} opts Optional parameters<#allParams><^required>
* @param {<&vendorExtensions.x-jsdoc-type>} opts.<¶mName> <&description><#defaultValue> (default to <&.>)
* @param requestInit Dynamic configuration. @see {@link https://github.com/apollographql/apollo-server/pull/1277}
<=| |=>* @return {Promise|#returnType|<|&vendorExtensions.x-jsdoc-type|>|/returnType|}|=< >=|
*/
async () {
<#vendorExtensions.x-codegen-has-optional-params>
opts = opts || {};
let postBody = <#bodyParam><#required><^required>opts['']<^bodyParam>null;
<#allParams>
<#required>
// verify the required parameter '' is set
if ( === undefined || === null) {
throw new Error("Missing the required parameter '' when calling ");
}
let pathParams = {<#pathParams>
'': <#required><^required>opts['']<^-last>,-last>
};
let queryParams = {<#queryParams>
'': <#collectionFormat>this.buildCollectionParam(<#required><^required>opts[''], '') <^collectionFormat><#required><^required>opts['']<^-last>,-last>
};
let headerParams = {
'User-Agent': '<#httpUserAgent><.><^httpUserAgent>OpenAPI-Generator/<&projectVersion>/Javascript',<#headerParams>
'': <#required><^required>opts['']<^-last>,-last>
};
let formParams = {<#formParams>
'': <#collectionFormat>this.buildCollectionParam(<#required><^required>opts[''], '') <^collectionFormat><#required><^required>opts['']<^-last>,-last>
};
let authNames = [<#authMethods>''<^-last>, -last>];
let contentTypes = [<#consumes>'<& mediaType>'<^-last>, -last>];
let accepts = [<#produces>'<& mediaType>'<^-last>, -last>];
let returnType = <#vendorExtensions.x-return-type><&vendorExtensions.x-return-type><^vendorExtensions.x-return-type>null;
<#servers.0>
let basePaths = [<#servers>''<^-last>, -last>];
let basePath = basePaths[0]; // by default use the first one in "servers" defined in OpenAPI
if (typeof opts['_base_path_index'] !== 'undefined') {
if (opts['_base_path_index'] >= basePaths.length || opts['_base_path_index'] < 0) {
throw new Error("Invalid index " + opts['_base_path_index'] + " when selecting the host settings. Must be less than " + basePaths.length);
}
basePath = basePaths[opts['_base_path_index']];
}
return this.callApi(
'<&path>', '',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, requestInit
);
}
}
<={{ }}=>