@goast/typescript 0.0.1 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,11 +1,11 @@
1
- # typescript
2
-
3
- This library was generated with [Nx](https://nx.dev).
4
-
5
- ## Building
6
-
7
- Run `nx build typescript` to build the library.
8
-
9
- ## Running unit tests
10
-
11
- Run `nx test typescript` to execute the unit tests via [Jest](https://jestjs.io).
1
+ # typescript
2
+
3
+ This library was generated with [Nx](https://nx.dev).
4
+
5
+ ## Building
6
+
7
+ Run `nx build typescript` to build the library.
8
+
9
+ ## Running unit tests
10
+
11
+ Run `nx test typescript` to execute the unit tests via [Jest](https://jestjs.io).
@@ -31,6 +31,7 @@ export class UrlBuilder {
31
31
  .map((key) => `${key}=${this.queryParams[key]}`)
32
32
  .join('&');
33
33
  const path = this.path.replace(/\{([^}]+)\}/g, (_, name) => this.pathParams[name]);
34
- return `${this.baseUrl}${path || '/'}${queryString ? '?' + queryString : ''}`;
34
+ const url = `${this.baseUrl}${path || '/'}${queryString ? '?' + queryString : ''}`;
35
+ return url.replace(/(?<!:)[\\/]+(?=\/)|[\\/](?=\?)/g, '');
35
36
  }
36
37
  }
@@ -93,8 +93,9 @@ class DefaultTypeScriptFetchClientGenerator extends file_generator_1.TypeScriptF
93
93
  builder
94
94
  .append('export class ')
95
95
  .append(this.getClassName(ctx))
96
- .appendIf(this.shouldGenerateInterface(ctx), (builder) => builder.addImport(this.getInterfaceName(ctx), this.getInterfaceFilePath(ctx)))
97
- .append(' implements ', this.getInterfaceName(ctx));
96
+ .appendIf(this.shouldGenerateInterface(ctx), (builder) => builder
97
+ .addImport(this.getInterfaceName(ctx), this.getInterfaceFilePath(ctx))
98
+ .append(' implements ', this.getInterfaceName(ctx)));
98
99
  }
99
100
  generateClassContent(ctx, builder) {
100
101
  builder
@@ -160,7 +161,7 @@ class DefaultTypeScriptFetchClientGenerator extends file_generator_1.TypeScriptF
160
161
  .append('params: ')
161
162
  .parenthesize('{}', (builder) => builder.forEach(params, (builder, parameter) => {
162
163
  var _a;
163
- return builder.appendLine(`${this.toPropertyName(ctx, parameter.name)}: ${this.getTypeName(ctx, builder, (_a = parameter.schema) === null || _a === void 0 ? void 0 : _a.id)};`);
164
+ return builder.appendLine(this.toPropertyName(ctx, parameter.name), parameter.required ? ': ' : '?: ', this.getTypeName(ctx, builder, (_a = parameter.schema) === null || _a === void 0 ? void 0 : _a.id), ';');
164
165
  }), { indent: true, multiline: true }))
165
166
  .appendLineIf(params.length > 0 && !!bodySchemaId, ',')
166
167
  .appendIf(!!bodySchemaId, (builder) => builder.append(`body: ${this.getTypeName(ctx, builder, bodySchemaId)}`))
@@ -90,8 +90,9 @@ export class DefaultTypeScriptFetchClientGenerator extends TypeScriptFileGenerat
90
90
  builder
91
91
  .append('export class ')
92
92
  .append(this.getClassName(ctx))
93
- .appendIf(this.shouldGenerateInterface(ctx), (builder) => builder.addImport(this.getInterfaceName(ctx), this.getInterfaceFilePath(ctx)))
94
- .append(' implements ', this.getInterfaceName(ctx));
93
+ .appendIf(this.shouldGenerateInterface(ctx), (builder) => builder
94
+ .addImport(this.getInterfaceName(ctx), this.getInterfaceFilePath(ctx))
95
+ .append(' implements ', this.getInterfaceName(ctx)));
95
96
  }
96
97
  generateClassContent(ctx, builder) {
97
98
  builder
@@ -157,7 +158,7 @@ export class DefaultTypeScriptFetchClientGenerator extends TypeScriptFileGenerat
157
158
  .append('params: ')
158
159
  .parenthesize('{}', (builder) => builder.forEach(params, (builder, parameter) => {
159
160
  var _a;
160
- return builder.appendLine(`${this.toPropertyName(ctx, parameter.name)}: ${this.getTypeName(ctx, builder, (_a = parameter.schema) === null || _a === void 0 ? void 0 : _a.id)};`);
161
+ return builder.appendLine(this.toPropertyName(ctx, parameter.name), parameter.required ? ': ' : '?: ', this.getTypeName(ctx, builder, (_a = parameter.schema) === null || _a === void 0 ? void 0 : _a.id), ';');
161
162
  }), { indent: true, multiline: true }))
162
163
  .appendLineIf(params.length > 0 && !!bodySchemaId, ',')
163
164
  .appendIf(!!bodySchemaId, (builder) => builder.append(`body: ${this.getTypeName(ctx, builder, bodySchemaId)}`))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@goast/typescript",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "repository": "https://github.com/MaSch0212/goast.git",
5
5
  "author": {
6
6
  "name": "Marc Schmidt (MaSch0212)",