Skip to content

Commit

Permalink
Fix generated module imports in Aurelia APIs (#7465) (#7520)
Browse files Browse the repository at this point in the history
  • Loading branch information
ksm2 authored and wing328 committed Jan 29, 2018
1 parent 7c20316 commit 7faaa09
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public Map<String, Object> postProcessOperations(Map<String, Object> 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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down
11 changes: 4 additions & 7 deletions samples/client/petstore/typescript-aurelia/default/PetApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,8 @@ import { HttpClient } from 'aurelia-http-client';
import { Api } from './Api';
import { AuthStorage } from './AuthStorage';
import {
Array&lt;string&gt;,
any,
Pet,
ApiResponse,
Array&lt;&#39;available&#39; | &#39;pending&#39; | &#39;sold&#39;&gt;,
} from './models';

/**
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
7 changes: 3 additions & 4 deletions samples/client/petstore/typescript-aurelia/default/UserApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { Api } from './Api';
import { AuthStorage } from './AuthStorage';
import {
User,
Array&lt;User&gt;,
} from './models';

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

0 comments on commit 7faaa09

Please # to comment.