Skip to content
This repository was archived by the owner on Jan 19, 2024. It is now read-only.
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
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
dist: trusty
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Travis CI was failing, after researching a bit I found that dist: trusty is needed if xvfb is used directly.

Doc: https://docs.travis-ci.com/user/gui-and-headless-browsers/#using-xvfb-directly


language: node_js

sudo: required
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "raml-javascript-generator",
"version": "2.1.2",
"version": "2.1.3",
"description": "Generate a JavaScript API client from RAML",
"main": "dist/index.js",
"config": {
Expand Down
7 changes: 4 additions & 3 deletions src/support/method.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ export function getRequestSnippet(method: any, resource: any) {
}

const parts = resource.relativeUri.split(/(?=[\/\.])/g);

return parts.map((part: string) => {
const requestMethod = parts.map((part: string) => {
const methodName = toMethodName(part);
const uriParams = Object.keys(getUsedUriParameters(part, resource.uriParameters));

Expand All @@ -35,7 +34,9 @@ export function getRequestSnippet(method: any, resource: any) {
}

return `${methodName}`;
}).join('.') + `.${camelCase(method.method)}([${type}, [options]])`;
Copy link
Contributor Author

@nestor-diaz nestor-diaz Oct 27, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to make this change because TSLint failed due to this string concatenation, it expects template literals.

}).join('.');

return `${requestMethod}.${camelCase(method.method)}([${type}, [options]])`;
}

/**
Expand Down
10 changes: 5 additions & 5 deletions src/templates/index.js.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ const request = (client, method, path, opts) => {
}

// Create prototype resources.
private createProtoResources(withParams: KeyedNestedResources, noParams: KeyedNestedResources) {
private createProtoResources(withParams: KeyedNestedResources, client: string, noParams: KeyedNestedResources) {
for (const key of Object.keys(withParams)) {
const child = withParams[key];

Expand All @@ -196,7 +196,7 @@ const request = (client, method, path, opts) => {
}

this.buffer.append(`\n`);
this.buffer.append(` ${child.methodName}${this.toParamsMethod(child, 'this.client', true)}`);
this.buffer.append(` ${child.methodName}${this.toParamsMethod(child, client, true)}`);
}
}

Expand All @@ -223,7 +223,7 @@ const request = (client, method, path, opts) => {

this.createThisResources(withParams, noParams, 'this.client');
this.buffer.line(` }`);
this.createProtoResources(withParams, noParams);
this.createProtoResources(withParams, 'this.client', noParams);
this.createProtoMethods(resource.methods, 'this.client', 'this.path');
if (className.indexOf('.') > 0) {
this.buffer.line(`};`);
Expand Down Expand Up @@ -368,7 +368,7 @@ class Client {
}
}
this.createProtoMethods(this.nestedTree.methods, 'this', `''`);
this.createProtoResources(this.withParams, this.noParams);
this.createProtoResources(this.withParams, 'this', this.noParams);
this.buffer.line(`}`);
}

Expand All @@ -382,7 +382,7 @@ class Client {

if (scheme.type === 'OAuth 2.0') {
this.buffer.return();
this.buffer.line('// eslint-disable-next-line');
Copy link
Contributor Author

@nestor-diaz nestor-diaz Oct 27, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to make this change because TSLint failed due to it expects two indentation spaces

this.buffer.line(' // eslint-disable-next-line');
this.buffer.line(` ${name}: function ${name}(options) {`);
this.buffer.multiline(` const schemeSettings = ${this.formatJSON(scheme.settings, 2, 4)};`);
this.buffer.line(` return new ClientOAuth2(Object.assign(schemeSettings, options));`);
Expand Down
2 changes: 1 addition & 1 deletion src/templates/package.json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ export const packageTemplate = (api: Api) => {
}
};

return JSON.stringify(json, null, 2) + '\n';
Copy link
Contributor Author

@nestor-diaz nestor-diaz Oct 27, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to make this change because TSLint failed due to this string concatenation, it expects template literals.

return `${JSON.stringify(json, null, 2)}\n`;
};