From 7faaa091cd6b15165ef0a91b6f2f349d33df77d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Simon=20Maria=20M=C3=B6llers?= Date: Mon, 29 Jan 2018 08:46:51 +0100 Subject: [PATCH] Fix generated module imports in Aurelia APIs (#7465) (#7520) --- .../languages/TypeScriptAureliaClientCodegen.java | 2 +- .../main/resources/typescript-aurelia/api.mustache | 3 ++- .../petstore/typescript-aurelia/default/PetApi.ts | 11 ++++------- .../petstore/typescript-aurelia/default/StoreApi.ts | 4 ++-- .../petstore/typescript-aurelia/default/UserApi.ts | 7 +++---- 5 files changed, 12 insertions(+), 15 deletions(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/TypeScriptAureliaClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/TypeScriptAureliaClientCodegen.java index 2661b4a00ecf..f9249d6f9261 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/TypeScriptAureliaClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/TypeScriptAureliaClientCodegen.java @@ -94,7 +94,7 @@ public Map postProcessOperations(Map objs) { // Collect models to be imported for (CodegenParameter param : op.allParams) { - if (!param.isPrimitiveType) { + if (!param.isPrimitiveType && !param.isListContainer && !param.dataType.equals("any")) { modelImports.add(param.dataType); } } diff --git a/modules/swagger-codegen/src/main/resources/typescript-aurelia/api.mustache b/modules/swagger-codegen/src/main/resources/typescript-aurelia/api.mustache index 89d08c3c527f..d035ba8530ca 100644 --- a/modules/swagger-codegen/src/main/resources/typescript-aurelia/api.mustache +++ b/modules/swagger-codegen/src/main/resources/typescript-aurelia/api.mustache @@ -30,6 +30,7 @@ export class {{classname}} extends Api { * Creates a new {{classname}} class. * * @param httpClient The Aurelia HTTP client to be injected. + * @param authStorage A storage for authentication data. */ constructor(httpClient: HttpClient, authStorage: AuthStorage) { super(httpClient, authStorage); @@ -57,7 +58,7 @@ export class {{classname}} extends Api { // Create URL to call const url = `${this.basePath}{{{path}}}`{{#pathParams}} - .replace(`{${'{{baseName}}'}}`, encodeURIComponent(String(${params['{{paramName}}']}))){{/pathParams}}; + .replace(`{${'{{baseName}}'}}`, encodeURIComponent(`${params['{{paramName}}']}`)){{/pathParams}}; const response = await this.httpClient.createRequest(url) // Set HTTP method diff --git a/samples/client/petstore/typescript-aurelia/default/PetApi.ts b/samples/client/petstore/typescript-aurelia/default/PetApi.ts index 446d31718540..3a4d7abab377 100644 --- a/samples/client/petstore/typescript-aurelia/default/PetApi.ts +++ b/samples/client/petstore/typescript-aurelia/default/PetApi.ts @@ -15,11 +15,8 @@ import { HttpClient } from 'aurelia-http-client'; import { Api } from './Api'; import { AuthStorage } from './AuthStorage'; import { - Array<string>, - any, Pet, ApiResponse, - Array<'available' | 'pending' | 'sold'>, } from './models'; /** @@ -141,7 +138,7 @@ export class PetApi extends Api { // Create URL to call const url = `${this.basePath}/pet/{petId}` - .replace(`{${'petId'}}`, encodeURIComponent(String(${params['petId']}))); + .replace(`{${'petId'}}`, encodeURIComponent(`${params['petId']}`)); const response = await this.httpClient.createRequest(url) // Set HTTP method @@ -234,7 +231,7 @@ export class PetApi extends Api { // Create URL to call const url = `${this.basePath}/pet/{petId}` - .replace(`{${'petId'}}`, encodeURIComponent(String(${params['petId']}))); + .replace(`{${'petId'}}`, encodeURIComponent(`${params['petId']}`)); const response = await this.httpClient.createRequest(url) // Set HTTP method @@ -297,7 +294,7 @@ export class PetApi extends Api { // Create URL to call const url = `${this.basePath}/pet/{petId}` - .replace(`{${'petId'}}`, encodeURIComponent(String(${params['petId']}))); + .replace(`{${'petId'}}`, encodeURIComponent(`${params['petId']}`)); const response = await this.httpClient.createRequest(url) // Set HTTP method @@ -334,7 +331,7 @@ export class PetApi extends Api { // Create URL to call const url = `${this.basePath}/pet/{petId}/uploadImage` - .replace(`{${'petId'}}`, encodeURIComponent(String(${params['petId']}))); + .replace(`{${'petId'}}`, encodeURIComponent(`${params['petId']}`)); const response = await this.httpClient.createRequest(url) // Set HTTP method diff --git a/samples/client/petstore/typescript-aurelia/default/StoreApi.ts b/samples/client/petstore/typescript-aurelia/default/StoreApi.ts index fbc4dabdee5d..c72d176fd164 100644 --- a/samples/client/petstore/typescript-aurelia/default/StoreApi.ts +++ b/samples/client/petstore/typescript-aurelia/default/StoreApi.ts @@ -71,7 +71,7 @@ export class StoreApi extends Api { // Create URL to call const url = `${this.basePath}/store/order/{orderId}` - .replace(`{${'orderId'}}`, encodeURIComponent(String(${params['orderId']}))); + .replace(`{${'orderId'}}`, encodeURIComponent(`${params['orderId']}`)); const response = await this.httpClient.createRequest(url) // Set HTTP method @@ -126,7 +126,7 @@ export class StoreApi extends Api { // Create URL to call const url = `${this.basePath}/store/order/{orderId}` - .replace(`{${'orderId'}}`, encodeURIComponent(String(${params['orderId']}))); + .replace(`{${'orderId'}}`, encodeURIComponent(`${params['orderId']}`)); const response = await this.httpClient.createRequest(url) // Set HTTP method diff --git a/samples/client/petstore/typescript-aurelia/default/UserApi.ts b/samples/client/petstore/typescript-aurelia/default/UserApi.ts index ff0eae5238d6..4113dd8cdc91 100644 --- a/samples/client/petstore/typescript-aurelia/default/UserApi.ts +++ b/samples/client/petstore/typescript-aurelia/default/UserApi.ts @@ -16,7 +16,6 @@ import { Api } from './Api'; import { AuthStorage } from './AuthStorage'; import { User, - Array<User>, } from './models'; /** @@ -192,7 +191,7 @@ export class UserApi extends Api { // Create URL to call const url = `${this.basePath}/user/{username}` - .replace(`{${'username'}}`, encodeURIComponent(String(${params['username']}))); + .replace(`{${'username'}}`, encodeURIComponent(`${params['username']}`)); const response = await this.httpClient.createRequest(url) // Set HTTP method @@ -220,7 +219,7 @@ export class UserApi extends Api { // Create URL to call const url = `${this.basePath}/user/{username}` - .replace(`{${'username'}}`, encodeURIComponent(String(${params['username']}))); + .replace(`{${'username'}}`, encodeURIComponent(`${params['username']}`)); const response = await this.httpClient.createRequest(url) // Set HTTP method @@ -309,7 +308,7 @@ export class UserApi extends Api { // Create URL to call const url = `${this.basePath}/user/{username}` - .replace(`{${'username'}}`, encodeURIComponent(String(${params['username']}))); + .replace(`{${'username'}}`, encodeURIComponent(`${params['username']}`)); const response = await this.httpClient.createRequest(url) // Set HTTP method