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

Checking templates for javascript SDK #1000

Closed
Closed
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
60 changes: 47 additions & 13 deletions templates/openapi-generator/javascript/README.mustache
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
# 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}}
- Package version: {{projectVersion}}
{{^hideGenerationTimestamp}}
- Build date: {{generatedDate}}
{{/hideGenerationTimestamp}}
- Generator version: {{generatorVersion}}
- Build package: {{generatorClass}}


{{#infoUrl}}
For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}})
{{/infoUrl}}
Expand All @@ -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/<JAVASCRIPT_CLIENT_DIR>
```

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
Expand Down Expand Up @@ -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}}

Expand Down
8 changes: 4 additions & 4 deletions templates/openapi-generator/javascript/api_doc.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
Expand Down
101 changes: 3 additions & 98 deletions templates/openapi-generator/javascript/index.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
* {{.}}.<br>{{/projectDescription}}
* The <code>index</code> module provides access to constructors for all the classes which comprise the public API.
Expand Down Expand Up @@ -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.
Expand All @@ -146,8 +51,8 @@ export {
<importPath></models><#apiInfo><#apis>,

<#emitJSDoc>/**
* The <importPath> service constructor.
* @property {module:<#invokerPackage><invokerPackage>/</invokerPackage><#apiPackage><apiPackage>/</apiPackage><importPath>}
*/</emitJSDoc>
* The <importPath> service constructor.
* @property {module:<#invokerPackage><invokerPackage>/</invokerPackage><#apiPackage><apiPackage>/</apiPackage><importPath>}
*/</emitJSDoc>
<importPath></apis></apiInfo>
};<={{ }}=>