diff --git a/templates/openapi-generator/javascript/README.mustache b/templates/openapi-generator/javascript/README.mustache index 6217ae83..31a80650 100644 --- a/templates/openapi-generator/javascript/README.mustache +++ b/templates/openapi-generator/javascript/README.mustache @@ -1,13 +1,9 @@ -# FattureInCloud JavaScript SDK - -[![NPM](https://img.shields.io/npm/v/@fattureincloud/fattureincloud-js-sdk?color=g)](https://www.npmjs.com/package/@fattureincloud/fattureincloud-js-sdk) ![unit tests](https://github.com/fattureincloud/fattureincloud-js-sdk/actions/workflows/validate.yml/badge.svg) - -{{projectName}} - JavaScript client for Fatture in Cloud API. +# {{projectName}} +{{moduleName}} - JavaScript client for {{projectName}} {{#appDescriptionWithNewLines}} {{{.}}} {{/appDescriptionWithNewLines}} - This SDK is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project: - API version: {{appVersion}} @@ -15,9 +11,8 @@ This SDK is automatically generated by the [OpenAPI Generator](https://openapi-g {{^hideGenerationTimestamp}} - Build date: {{generatedDate}} {{/hideGenerationTimestamp}} +- Generator version: {{generatorVersion}} - Build package: {{generatorClass}} - - {{#infoUrl}} For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}}) {{/infoUrl}} @@ -26,16 +21,55 @@ For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}}) ### For [Node.js](https://nodejs.org/) -Using npm: +#### npm + +To publish the library as a [npm](https://www.npmjs.com/), please follow the procedure in ["Publishing npm packages"](https://docs.npmjs.com/getting-started/publishing-npm-packages). + +Then install it via: ```shell -npm install {{{projectName}}} +npm install {{{projectName}}} --save ``` -Using yarn: +Finally, you need to build the module: + +```shell +npm run build +``` + +##### Local development + +To use the library locally without publishing to a remote npm registry, first install the dependencies by changing into the directory containing `package.json` (and this README). Let's call this `JAVASCRIPT_CLIENT_DIR`. Then run: + +```shell +npm install +``` + +Next, [link](https://docs.npmjs.com/cli/link) it globally in npm with the following, also from `JAVASCRIPT_CLIENT_DIR`: + +```shell +npm link +``` + +To use the link you just defined in your project, switch to the directory you want to use your {{{projectName}}} from, and run: + +```shell +npm link /path/to/ +``` + +Finally, you need to build the module: + +```shell +npm run build +``` + +#### git + +If the library is hosted at a git repository, e.g.https://github.com/{{gitUserId}}{{^gitUserId}}YOUR_USERNAME{{/gitUserId}}/{{gitRepoId}}{{^gitRepoId}}{{projectName}}{{/gitRepoId}} +then install it via: ```shell - yarn add {{{projectName}}} + npm install {{gitUserId}}{{^gitUserId}}YOUR_USERNAME{{/gitUserId}}/{{gitRepoId}}{{^gitRepoId}}{{projectName}}{{/gitRepoId}} --save ``` ### For browser @@ -186,7 +220,7 @@ Class | Method | HTTP request | Description - **Flow**: {{flow}} - **Authorization URL**: {{authorizationUrl}} - **Scopes**: {{^scopes}}N/A{{/scopes}} -{{#scopes}} - _{{scope}}_: {{description}} +{{#scopes}} - {{scope}}: {{description}} {{/scopes}} {{/isOAuth}} diff --git a/templates/openapi-generator/javascript/api_doc.mustache b/templates/openapi-generator/javascript/api_doc.mustache index 825a2fa9..0a68747b 100644 --- a/templates/openapi-generator/javascript/api_doc.mustache +++ b/templates/openapi-generator/javascript/api_doc.mustache @@ -69,19 +69,19 @@ let opts = { {{/-last}} {{/optionalParams}} {{#usePromises}} -apiInstance.{{{operationId}}}({{#requiredParams}}{{{paramName}}}{{^-last}}, {{/-last}}{{/requiredParams}}{{#optionalParams}}{{#-last}}{{#hasRequiredParams}}, {{/hasRequiredParams}}opts{{/-last}}{{/optionalParams}}).then(({{#returnType}}result{{/returnType}}) => { - {{#returnType}}console.log('API called successfully. Returned result: ' + JSON.stringify(result));{{/returnType}}{{^returnType}}console.log('API called successfully.');{{/returnType}} +apiInstance.{{{operationId}}}({{#requiredParams}}{{{paramName}}}{{^-last}}, {{/-last}}{{/requiredParams}}{{#optionalParams}}{{#-last}}{{#hasRequiredParams}}, {{/hasRequiredParams}}opts{{/-last}}{{/optionalParams}}).then(({{#returnType}}data{{/returnType}}) => { + {{#returnType}}console.log('API called successfully. Returned data: ' + data);{{/returnType}}{{^returnType}}console.log('API called successfully.');{{/returnType}} }, (error) => { console.error(error); }); {{/usePromises}} {{^usePromises}} -apiInstance.{{{operationId}}}({{#requiredParams}}{{{paramName}}}{{^-last}}, {{/-last}}{{/requiredParams}}{{#optionalParams}}{{#-last}}{{#hasRequiredParams}}, {{/hasRequiredParams}}opts{{/-last}}{{/optionalParams}}{{#hasParams}}, {{/hasParams}}(error, result, response) => { +apiInstance.{{{operationId}}}({{#requiredParams}}{{{paramName}}}{{^-last}}, {{/-last}}{{/requiredParams}}{{#optionalParams}}{{#-last}}{{#hasRequiredParams}}, {{/hasRequiredParams}}opts{{/-last}}{{/optionalParams}}{{#hasParams}}, {{/hasParams}}(error, data, response) => { if (error) { console.error(error); } else { - {{#returnType}}console.log('API called successfully. Returned result: ' + JSON.stringify(result));{{/returnType}}{{^returnType}}console.log('API called successfully.');{{/returnType}} + {{#returnType}}console.log('API called successfully. Returned data: ' + data);{{/returnType}}{{^returnType}}console.log('API called successfully.');{{/returnType}} } }); {{/usePromises}} diff --git a/templates/openapi-generator/javascript/index.mustache b/templates/openapi-generator/javascript/index.mustache index d3fd9411..56213101 100644 --- a/templates/openapi-generator/javascript/index.mustache +++ b/templates/openapi-generator/javascript/index.mustache @@ -5,22 +5,6 @@ import ApiClient from './ApiClient'; {{/models}}{{#apiInfo}}{{#apis}}import {{importPath}} from './{{#apiPackage}}{{.}}/{{/apiPackage}}{{importPath}}'; {{/apis}}{{/apiInfo}} -import Condition from './filter/Condition'; -import Filter from './filter/Filter'; -import Expression from './filter/Expression'; -import Conjunction from './filter/Conjunction'; -import Disjunction from './filter/Disjunction'; -import Operator from './filter/Operator'; - -import OAuth2Manager from './oauth2/OAuth2'; -import OAuth2AuthorizationCodeManager from './oauth2/OAuth2AuthorizationCode'; -import OAuth2TokenResponse from './oauth2/OAuth2TokenResponse'; -import OAuth2AuthorizationCodeParams from './oauth2/OAuth2AuthorizationCodeParams'; -import OAuth2DeviceCodeManager from './oauth2/OAuth2DeviceCode'; -import OAuth2DeviceCodeResponse from './oauth2/OAuth2DeviceCodeResponse'; -import Scope from './oauth2/Scope'; - - {{#emitJSDoc}}/**{{#projectDescription}} * {{.}}.
{{/projectDescription}} * The index module provides access to constructors for all the classes which comprise the public API. @@ -53,85 +37,6 @@ import Scope from './oauth2/Scope'; * @version {{projectVersion}} */{{/emitJSDoc}} export { - - /** - * The Condition service constructor. - * @property {module:filter/Condition} - */ - Condition, - - /** - * The Conjunction service constructor. - * @property {module:filter/Conjunction} - */ - Conjunction, - - /** - * The Disjunction service constructor. - * @property {module:filter/Disjunction} - */ - Disjunction, - - /** - * The Expression service constructor. - * @property {module:filter/Expression} - */ - Expression, - - /** - * The Filter service constructor. - * @property {module:filter/Filter} - */ - Filter, - - /** - * The Operator service constructor. - * @property {module:api/Operator} - */ - Operator, - - /** - * The OAuth2Manager service constructor. - * @property {module:api/OAuth2Manager} - */ - OAuth2Manager, - - /** - * The OAuth2AuthorizationCodeManager service constructor. - * @property {module:api/OAuth2AuthorizationCodeManager} - */ - OAuth2AuthorizationCodeManager, - - /** - * The Scope service constructor. - * @property {module:api/Scope} - */ - Scope, - - /** - * The OAuth2TokenResponse service constructor. - * @property {module:api/OAuth2TokenResponse} - */ - OAuth2TokenResponse, - - /** - * The OAuth2AuthorizationCodeParams service constructor. - * @property {module:api/OAuth2AuthorizationCodeParams} - */ - OAuth2AuthorizationCodeParams, - - /** - * The OAuth2DeviceCodeManager service constructor. - * @property {module:api/OAuth2DeviceCodeManager} - */ - OAuth2DeviceCodeManager, - - /** - * The OAuth2DeviceCodeResponse service constructor. - * @property {module:api/OAuth2DeviceCodeResponse} - */ - OAuth2DeviceCodeResponse, - {{=< >=}} <#emitJSDoc>/** * The ApiClient constructor. @@ -146,8 +51,8 @@ export { <#apiInfo><#apis>, <#emitJSDoc>/** - * The service constructor. - * @property {module:<#invokerPackage>/<#apiPackage>/} - */ + * The service constructor. + * @property {module:<#invokerPackage>/<#apiPackage>/} + */ };<={{ }}=>