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 @@ -45,7 +45,7 @@ export class BaseService {
httpParams,
);
} else if (paramStyle === QueryParamStyle.Json) {
return httpParams.append(key, JSON.stringify(value));
return httpParams.append(key, JSON.stringify(value, (_, v) => v instanceof Set ? Array.from(v) : v));
} else {
// Form-style, SpaceDelimited or PipeDelimited

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,17 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/Filter'
- in: query
name: tags
description: Tags
required: false
content:
application/json:
schema:
type: array
items:
type: string
uniqueItems: true

responses:
'200':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export class BaseService {
httpParams,
);
} else if (paramStyle === QueryParamStyle.Json) {
return httpParams.append(key, JSON.stringify(value));
return httpParams.append(key, JSON.stringify(value, (_, v) => v instanceof Set ? Array.from(v) : v));
} else {
// Form-style, SpaceDelimited or PipeDelimited

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export class BaseService {
httpParams,
);
} else if (paramStyle === QueryParamStyle.Json) {
return httpParams.append(key, JSON.stringify(value));
return httpParams.append(key, JSON.stringify(value, (_, v) => v instanceof Set ? Array.from(v) : v));
} else {
// Form-style, SpaceDelimited or PipeDelimited

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export class BaseService {
httpParams,
);
} else if (paramStyle === QueryParamStyle.Json) {
return httpParams.append(key, JSON.stringify(value));
return httpParams.append(key, JSON.stringify(value, (_, v) => v instanceof Set ? Array.from(v) : v));
} else {
// Form-style, SpaceDelimited or PipeDelimited

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export class BaseService {
httpParams,
);
} else if (paramStyle === QueryParamStyle.Json) {
return httpParams.append(key, JSON.stringify(value));
return httpParams.append(key, JSON.stringify(value, (_, v) => v instanceof Set ? Array.from(v) : v));
} else {
// Form-style, SpaceDelimited or PipeDelimited

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,15 @@ export class DefaultService extends BaseService {
/**
* @endpoint get /search
* @param filter 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 search(filter?: Filter, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<Response>;
public search(filter?: Filter, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<Response>>;
public search(filter?: Filter, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<Response>>;
public search(filter?: Filter, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<any> {
public search(filter?: Filter, tags?: Set<string>, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<Response>;
public search(filter?: Filter, tags?: Set<string>, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<Response>>;
public search(filter?: Filter, tags?: Set<string>, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<Response>>;
public search(filter?: Filter, 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 All @@ -60,6 +61,15 @@ export class DefaultService extends BaseService {
);


localVarQueryParameters = this.addToHttpParams(
localVarQueryParameters,
'tags',
<any>tags,
QueryParamStyle.Json,
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 @@ -37,4 +37,13 @@ describe('JSON Query Param testing', () => {
const req = httpTesting.expectOne(`http://localhost/search?filter=${filterJsonEncoded}`);
expect(req.request.method).toEqual('GET');
});

it('should serialize a Set query parameter as a JSON array', () => {
const tags = new Set(['a', 'b']);
const tagsJsonEncoded = encodeURIComponent('["a","b"]');

service.search(undefined, tags).subscribe();
const req = httpTesting.expectOne(`http://localhost/search?tags=${tagsJsonEncoded}`);
expect(req.request.method).toEqual('GET');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export class BaseService {
httpParams,
);
} else if (paramStyle === QueryParamStyle.Json) {
return httpParams.append(key, JSON.stringify(value));
return httpParams.append(key, JSON.stringify(value, (_, v) => v instanceof Set ? Array.from(v) : v));
} else {
// Form-style, SpaceDelimited or PipeDelimited

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export class BaseService {
httpParams,
);
} else if (paramStyle === QueryParamStyle.Json) {
return httpParams.append(key, JSON.stringify(value));
return httpParams.append(key, JSON.stringify(value, (_, v) => v instanceof Set ? Array.from(v) : v));
} else {
// Form-style, SpaceDelimited or PipeDelimited

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export class BaseService {
httpParams,
);
} else if (paramStyle === QueryParamStyle.Json) {
return httpParams.append(key, JSON.stringify(value));
return httpParams.append(key, JSON.stringify(value, (_, v) => v instanceof Set ? Array.from(v) : v));
} else {
// Form-style, SpaceDelimited or PipeDelimited

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export class BaseService {
httpParams,
);
} else if (paramStyle === QueryParamStyle.Json) {
return httpParams.append(key, JSON.stringify(value));
return httpParams.append(key, JSON.stringify(value, (_, v) => v instanceof Set ? Array.from(v) : v));
} else {
// Form-style, SpaceDelimited or PipeDelimited

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export class BaseService {
httpParams,
);
} else if (paramStyle === QueryParamStyle.Json) {
return httpParams.append(key, JSON.stringify(value));
return httpParams.append(key, JSON.stringify(value, (_, v) => v instanceof Set ? Array.from(v) : v));
} else {
// Form-style, SpaceDelimited or PipeDelimited

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export class BaseService {
httpParams,
);
} else if (paramStyle === QueryParamStyle.Json) {
return httpParams.append(key, JSON.stringify(value));
return httpParams.append(key, JSON.stringify(value, (_, v) => v instanceof Set ? Array.from(v) : v));
} else {
// Form-style, SpaceDelimited or PipeDelimited

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export class BaseService {
httpParams,
);
} else if (paramStyle === QueryParamStyle.Json) {
return httpParams.append(key, JSON.stringify(value));
return httpParams.append(key, JSON.stringify(value, (_, v) => v instanceof Set ? Array.from(v) : v));
} else {
// Form-style, SpaceDelimited or PipeDelimited

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export class BaseService {
httpParams,
);
} else if (paramStyle === QueryParamStyle.Json) {
return httpParams.append(key, JSON.stringify(value));
return httpParams.append(key, JSON.stringify(value, (_, v) => v instanceof Set ? Array.from(v) : v));
} else {
// Form-style, SpaceDelimited or PipeDelimited

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export class BaseService {
httpParams,
);
} else if (paramStyle === QueryParamStyle.Json) {
return httpParams.append(key, JSON.stringify(value));
return httpParams.append(key, JSON.stringify(value, (_, v) => v instanceof Set ? Array.from(v) : v));
} else {
// Form-style, SpaceDelimited or PipeDelimited

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export class BaseService {
httpParams,
);
} else if (paramStyle === QueryParamStyle.Json) {
return httpParams.append(key, JSON.stringify(value));
return httpParams.append(key, JSON.stringify(value, (_, v) => v instanceof Set ? Array.from(v) : v));
} else {
// Form-style, SpaceDelimited or PipeDelimited

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export class BaseService {
httpParams,
);
} else if (paramStyle === QueryParamStyle.Json) {
return httpParams.append(key, JSON.stringify(value));
return httpParams.append(key, JSON.stringify(value, (_, v) => v instanceof Set ? Array.from(v) : v));
} else {
// Form-style, SpaceDelimited or PipeDelimited

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export class BaseService {
httpParams,
);
} else if (paramStyle === QueryParamStyle.Json) {
return httpParams.append(key, JSON.stringify(value));
return httpParams.append(key, JSON.stringify(value, (_, v) => v instanceof Set ? Array.from(v) : v));
} else {
// Form-style, SpaceDelimited or PipeDelimited

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export class BaseService {
httpParams,
);
} else if (paramStyle === QueryParamStyle.Json) {
return httpParams.append(key, JSON.stringify(value));
return httpParams.append(key, JSON.stringify(value, (_, v) => v instanceof Set ? Array.from(v) : v));
} else {
// Form-style, SpaceDelimited or PipeDelimited

Expand Down
Loading