Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,16 @@ export class BaseService {
return httpParams.append(key, value.toString());
} else if (value instanceof Date) {
return httpParams.append(key, value.toISOString());
} else if (Array.isArray(value)) {
// Otherwise, if it's an array, add each element.
} else if (Array.isArray(value) || value instanceof Set) {
// Otherwise, if it's an array or set, add each element.
const array = Array.isArray(value) ? value : Array.from(value);
if (paramStyle === QueryParamStyle.Form) {
return httpParams.set(key, value, {explode: explode, delimiter: ','});
return httpParams.set(key, array, {explode: explode, delimiter: ','});
} else if (paramStyle === QueryParamStyle.SpaceDelimited) {
return httpParams.set(key, value, {explode: explode, delimiter: ' '});
return httpParams.set(key, array, {explode: explode, delimiter: ' '});
} else {
// PipeDelimited
return httpParams.set(key, value, {explode: explode, delimiter: '|'});
return httpParams.set(key, array, {explode: explode, delimiter: '|'});
}
} else {
// Otherwise, if it's an object, add each field.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,17 @@ paths:
required: false
schema:
type: string
- in: query
name: tags
style: form
explode: true
description: Tags
required: false
schema:
type: array
items:
type: string
uniqueItems: true
responses:
'200':
description: Ok
Expand Down Expand Up @@ -71,6 +82,17 @@ paths:
required: false
schema:
type: string
- in: query
name: tags
style: form
explode: false
description: Tags
required: false
schema:
type: array
items:
type: string
uniqueItems: true

responses:
'200':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,16 @@ export class BaseService {
return httpParams.append(key, value.toString());
} else if (value instanceof Date) {
return httpParams.append(key, value.toISOString());
} else if (Array.isArray(value)) {
// Otherwise, if it's an array, add each element.
} else if (Array.isArray(value) || value instanceof Set) {
// Otherwise, if it's an array or set, add each element.
const array = Array.isArray(value) ? value : Array.from(value);
if (paramStyle === QueryParamStyle.Form) {
return httpParams.set(key, value, {explode: explode, delimiter: ','});
return httpParams.set(key, array, {explode: explode, delimiter: ','});
} else if (paramStyle === QueryParamStyle.SpaceDelimited) {
return httpParams.set(key, value, {explode: explode, delimiter: ' '});
return httpParams.set(key, array, {explode: explode, delimiter: ' '});
} else {
// PipeDelimited
return httpParams.set(key, value, {explode: explode, delimiter: '|'});
return httpParams.set(key, array, {explode: explode, delimiter: '|'});
}
} else {
// Otherwise, if it's an object, add each field.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,15 @@ export class DefaultService extends BaseService {
* @param ids Ids
* @param filter Filter
* @param country Filter
* @param tags Tags
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
* @param options additional options
*/
public searchExplode(ids?: Array<number>, filter?: Filter, country?: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<Response>;
public searchExplode(ids?: Array<number>, filter?: Filter, country?: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<Response>>;
public searchExplode(ids?: Array<number>, filter?: Filter, country?: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<Response>>;
public searchExplode(ids?: Array<number>, filter?: Filter, country?: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<any> {
public searchExplode(ids?: Array<number>, filter?: Filter, country?: string, tags?: Set<string>, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<Response>;
public searchExplode(ids?: Array<number>, filter?: Filter, country?: string, tags?: Set<string>, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<Response>>;
public searchExplode(ids?: Array<number>, filter?: Filter, country?: string, tags?: Set<string>, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<Response>>;
public searchExplode(ids?: Array<number>, filter?: Filter, country?: string, tags?: Set<string>, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<any> {

let localVarQueryParameters = new OpenApiHttpParams(this.encoder);

Expand Down Expand Up @@ -80,6 +81,15 @@ export class DefaultService extends BaseService {
);


localVarQueryParameters = this.addToHttpParams(
localVarQueryParameters,
'tags',
<any>tags,
QueryParamStyle.Form,
true,
);


let localVarHeaders = this.defaultHeaders;

const localVarHttpHeaderAcceptSelected: string | undefined = options?.httpHeaderAccept ?? this.configuration.selectHeaderAccept([
Expand Down Expand Up @@ -126,14 +136,15 @@ export class DefaultService extends BaseService {
* @param ids Ids
* @param filter Filter
* @param country Filter
* @param tags Tags
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
* @param options additional options
*/
public searchNotExplode(ids?: Array<number>, filter?: Filter, country?: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<Response>;
public searchNotExplode(ids?: Array<number>, filter?: Filter, country?: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<Response>>;
public searchNotExplode(ids?: Array<number>, filter?: Filter, country?: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<Response>>;
public searchNotExplode(ids?: Array<number>, filter?: Filter, country?: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<any> {
public searchNotExplode(ids?: Array<number>, filter?: Filter, country?: string, tags?: Set<string>, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<Response>;
public searchNotExplode(ids?: Array<number>, filter?: Filter, country?: string, tags?: Set<string>, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<Response>>;
public searchNotExplode(ids?: Array<number>, filter?: Filter, country?: string, tags?: Set<string>, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<Response>>;
public searchNotExplode(ids?: Array<number>, filter?: Filter, country?: string, tags?: Set<string>, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<any> {

let localVarQueryParameters = new OpenApiHttpParams(this.encoder);

Expand Down Expand Up @@ -164,6 +175,15 @@ export class DefaultService extends BaseService {
);


localVarQueryParameters = this.addToHttpParams(
localVarQueryParameters,
'tags',
<any>tags,
QueryParamStyle.Form,
false,
);


let localVarHeaders = this.defaultHeaders;

const localVarHttpHeaderAcceptSelected: string | undefined = options?.httpHeaderAccept ?? this.configuration.selectHeaderAccept([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const ids: number[] = [4, 5];
const filter: Filter = {name: 'John', age: 37, nicknames: ['Joe', 'Joey']};
const filterWithSpecialCharacters: Filter = {name: 'Éléonore &,|+', age: 42, nicknames: ['Elé', 'Ellie']};
const country: string = "Belgium";
const tags: Set<string> = new Set(['a', 'b']);

describe('Form Query Param testing', () => {
let httpTesting: HttpTestingController;
Expand Down Expand Up @@ -80,6 +81,18 @@ describe('Form Query Param testing', () => {
expect(req.request.method).toEqual('GET');
});

it('should separate the query parameter with ampersands (set only)', async () => {
service.searchExplode(undefined, undefined, undefined, tags).subscribe();
const req = httpTesting.expectOne('http://localhost/search_explode?tags=a&tags=b');
expect(req.request.method).toEqual('GET');
});

it('should separate the query parameter with ampersands (all set including tags)', async () => {
service.searchExplode(ids, filter, country, tags).subscribe();
const req = httpTesting.expectOne('http://localhost/search_explode?ids=4&ids=5&name=John&age=37&nicknames=Joe&nicknames=Joey&country=Belgium&tags=a&tags=b');
expect(req.request.method).toEqual('GET');
});

it('should separate the query parameter with comma (all set)', async () => {
service.searchNotExplode(ids, filter, country).subscribe();
const req = httpTesting.expectOne('http://localhost/search_not_explode?ids=4,5&filter=name,John,age,37,nicknames,Joe,Joey&country=Belgium');
Expand Down Expand Up @@ -126,4 +139,16 @@ describe('Form Query Param testing', () => {
expect(req.request.method).toEqual('GET');
});

it('should separate the query parameter with comma (set only)', async () => {
service.searchNotExplode(undefined, undefined, undefined, tags).subscribe();
const req = httpTesting.expectOne('http://localhost/search_not_explode?tags=a,b');
expect(req.request.method).toEqual('GET');
});

it('should separate the query parameter with comma (all set including tags)', async () => {
service.searchNotExplode(ids, filter, country, tags).subscribe();
const req = httpTesting.expectOne('http://localhost/search_not_explode?ids=4,5&filter=name,John,age,37,nicknames,Joe,Joey&country=Belgium&tags=a,b');
expect(req.request.method).toEqual('GET');
});

});