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 @@ -137,14 +137,20 @@ export function concatHttpParamsObject(httpParams: OpenApiHttpParams, key: strin
let keyAndValues: string[] = [];

for (const k in item) {
keyAndValues.push(k);

const value = item[k];

if (value === null || value === undefined) {
continue;
}

if (Array.isArray(value)) {
keyAndValues.push(...value.map(convertToString));
const items = value.filter(v => v !== null && v !== undefined);

if (items.length > 0) {
keyAndValues.push(k, ...items.map(convertToString));
}
} else {
keyAndValues.push(convertToString(value));
keyAndValues.push(k, convertToString(value));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,20 @@ export function concatHttpParamsObject(httpParams: OpenApiHttpParams, key: strin
let keyAndValues: string[] = [];

for (const k in item) {
keyAndValues.push(k);

const value = item[k];

if (value === null || value === undefined) {
continue;
}

if (Array.isArray(value)) {
keyAndValues.push(...value.map(convertToString));
const items = value.filter(v => v !== null && v !== undefined);

if (items.length > 0) {
keyAndValues.push(k, ...items.map(convertToString));
}
} else {
keyAndValues.push(convertToString(value));
keyAndValues.push(k, convertToString(value));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,20 @@ export function concatHttpParamsObject(httpParams: OpenApiHttpParams, key: strin
let keyAndValues: string[] = [];

for (const k in item) {
keyAndValues.push(k);

const value = item[k];

if (value === null || value === undefined) {
continue;
}

if (Array.isArray(value)) {
keyAndValues.push(...value.map(convertToString));
const items = value.filter(v => v !== null && v !== undefined);

if (items.length > 0) {
keyAndValues.push(k, ...items.map(convertToString));
}
} else {
keyAndValues.push(convertToString(value));
keyAndValues.push(k, convertToString(value));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,20 @@ export function concatHttpParamsObject(httpParams: OpenApiHttpParams, key: strin
let keyAndValues: string[] = [];

for (const k in item) {
keyAndValues.push(k);

const value = item[k];

if (value === null || value === undefined) {
continue;
}

if (Array.isArray(value)) {
keyAndValues.push(...value.map(convertToString));
const items = value.filter(v => v !== null && v !== undefined);

if (items.length > 0) {
keyAndValues.push(k, ...items.map(convertToString));
}
} else {
keyAndValues.push(convertToString(value));
keyAndValues.push(k, convertToString(value));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,20 @@ export function concatHttpParamsObject(httpParams: OpenApiHttpParams, key: strin
let keyAndValues: string[] = [];

for (const k in item) {
keyAndValues.push(k);

const value = item[k];

if (value === null || value === undefined) {
continue;
}

if (Array.isArray(value)) {
keyAndValues.push(...value.map(convertToString));
const items = value.filter(v => v !== null && v !== undefined);

if (items.length > 0) {
keyAndValues.push(k, ...items.map(convertToString));
}
} else {
keyAndValues.push(convertToString(value));
keyAndValues.push(k, convertToString(value));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ import {DefaultService, Filter, provideApi} from '@swagger/typescript-angular-qu
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 filterWithUndefined: Filter = {name: 'John', age: undefined, nicknames: ['Joe']};
const filterAllUndefined: Filter = {name: undefined, age: undefined, nicknames: undefined};
const filterWithNullItems = {name: 'John', nicknames: ['Joe', null, undefined]} as unknown as Filter;
const filterWithOnlyNullItems = {name: 'John', nicknames: [null, undefined], age: 37} as unknown as Filter;
const filterWithEmptyArray: Filter = {name: 'John', nicknames: [], age: 37};
const country: string = "Belgium";
const tags: Set<string> = new Set(['a', 'b']);

Expand Down Expand Up @@ -75,6 +80,13 @@ describe('Form Query Param testing', () => {
expect(req.request.method).toEqual('GET');
});

it('should separate the query parameter with ampersands (object with undefined field)', async () => {
service.searchExplode(undefined, filterWithUndefined, undefined).subscribe();

const req = httpTesting.expectOne('http://localhost/search_explode?name=John&nicknames=Joe');
expect(req.request.method).toEqual('GET');
});

it('should separate the query parameter with ampersands (simple only)', async () => {
service.searchExplode(undefined, undefined, country).subscribe();
const req = httpTesting.expectOne('http://localhost/search_explode?country=Belgium');
Expand Down Expand Up @@ -133,6 +145,41 @@ describe('Form Query Param testing', () => {
expect(req.request.method).toEqual('GET');
});

it('should separate the query parameter with comma (object with undefined field)', async () => {
Comment thread
cubic-dev-ai[bot] marked this conversation as resolved.
Resolved
service.searchNotExplode(undefined, filterWithUndefined, undefined).subscribe();

const req = httpTesting.expectOne('http://localhost/search_not_explode?filter=name,John,nicknames,Joe');
expect(req.request.method).toEqual('GET');
});

it('should separate the query parameter with comma (object with all fields undefined)', async () => {
service.searchNotExplode(undefined, filterAllUndefined, undefined).subscribe();

const req = httpTesting.expectOne('http://localhost/search_not_explode?filter=');
expect(req.request.method).toEqual('GET');
});

it('should separate the query parameter with comma (object with null array items)', async () => {
service.searchNotExplode(undefined, filterWithNullItems, undefined).subscribe();

const req = httpTesting.expectOne('http://localhost/search_not_explode?filter=name,John,nicknames,Joe');
expect(req.request.method).toEqual('GET');
});

it('should separate the query parameter with comma (object with only null array items)', async () => {
service.searchNotExplode(undefined, filterWithOnlyNullItems, undefined).subscribe();

const req = httpTesting.expectOne('http://localhost/search_not_explode?filter=name,John,age,37');
expect(req.request.method).toEqual('GET');
});

it('should separate the query parameter with comma (object with empty array field)', async () => {
service.searchNotExplode(undefined, filterWithEmptyArray, undefined).subscribe();

const req = httpTesting.expectOne('http://localhost/search_not_explode?filter=name,John,age,37');
expect(req.request.method).toEqual('GET');
});

it('should separate the query parameter with comma (simple only)', async () => {
service.searchNotExplode(undefined, undefined, country).subscribe();
const req = httpTesting.expectOne('http://localhost/search_not_explode?country=Belgium');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,20 @@ export function concatHttpParamsObject(httpParams: OpenApiHttpParams, key: strin
let keyAndValues: string[] = [];

for (const k in item) {
keyAndValues.push(k);

const value = item[k];

if (value === null || value === undefined) {
continue;
}

if (Array.isArray(value)) {
keyAndValues.push(...value.map(convertToString));
const items = value.filter(v => v !== null && v !== undefined);

if (items.length > 0) {
keyAndValues.push(k, ...items.map(convertToString));
}
} else {
keyAndValues.push(convertToString(value));
keyAndValues.push(k, convertToString(value));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,20 @@ export function concatHttpParamsObject(httpParams: OpenApiHttpParams, key: strin
let keyAndValues: string[] = [];

for (const k in item) {
keyAndValues.push(k);

const value = item[k];

if (value === null || value === undefined) {
continue;
}

if (Array.isArray(value)) {
keyAndValues.push(...value.map(convertToString));
const items = value.filter(v => v !== null && v !== undefined);

if (items.length > 0) {
keyAndValues.push(k, ...items.map(convertToString));
}
} else {
keyAndValues.push(convertToString(value));
keyAndValues.push(k, convertToString(value));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,20 @@ export function concatHttpParamsObject(httpParams: OpenApiHttpParams, key: strin
let keyAndValues: string[] = [];

for (const k in item) {
keyAndValues.push(k);

const value = item[k];

if (value === null || value === undefined) {
continue;
}

if (Array.isArray(value)) {
keyAndValues.push(...value.map(convertToString));
const items = value.filter(v => v !== null && v !== undefined);

if (items.length > 0) {
keyAndValues.push(k, ...items.map(convertToString));
}
} else {
keyAndValues.push(convertToString(value));
keyAndValues.push(k, convertToString(value));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,20 @@ export function concatHttpParamsObject(httpParams: OpenApiHttpParams, key: strin
let keyAndValues: string[] = [];

for (const k in item) {
keyAndValues.push(k);

const value = item[k];

if (value === null || value === undefined) {
continue;
}

if (Array.isArray(value)) {
keyAndValues.push(...value.map(convertToString));
const items = value.filter(v => v !== null && v !== undefined);

if (items.length > 0) {
keyAndValues.push(k, ...items.map(convertToString));
}
} else {
keyAndValues.push(convertToString(value));
keyAndValues.push(k, convertToString(value));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,20 @@ export function concatHttpParamsObject(httpParams: OpenApiHttpParams, key: strin
let keyAndValues: string[] = [];

for (const k in item) {
keyAndValues.push(k);

const value = item[k];

if (value === null || value === undefined) {
continue;
}

if (Array.isArray(value)) {
keyAndValues.push(...value.map(convertToString));
const items = value.filter(v => v !== null && v !== undefined);

if (items.length > 0) {
keyAndValues.push(k, ...items.map(convertToString));
}
} else {
keyAndValues.push(convertToString(value));
keyAndValues.push(k, convertToString(value));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,20 @@ export function concatHttpParamsObject(httpParams: OpenApiHttpParams, key: strin
let keyAndValues: string[] = [];

for (const k in item) {
keyAndValues.push(k);

const value = item[k];

if (value === null || value === undefined) {
continue;
}

if (Array.isArray(value)) {
keyAndValues.push(...value.map(convertToString));
const items = value.filter(v => v !== null && v !== undefined);

if (items.length > 0) {
keyAndValues.push(k, ...items.map(convertToString));
}
} else {
keyAndValues.push(convertToString(value));
keyAndValues.push(k, convertToString(value));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,20 @@ export function concatHttpParamsObject(httpParams: OpenApiHttpParams, key: strin
let keyAndValues: string[] = [];

for (const k in item) {
keyAndValues.push(k);

const value = item[k];

if (value === null || value === undefined) {
continue;
}

if (Array.isArray(value)) {
keyAndValues.push(...value.map(convertToString));
const items = value.filter(v => v !== null && v !== undefined);

if (items.length > 0) {
keyAndValues.push(k, ...items.map(convertToString));
}
} else {
keyAndValues.push(convertToString(value));
keyAndValues.push(k, convertToString(value));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,20 @@ export function concatHttpParamsObject(httpParams: OpenApiHttpParams, key: strin
let keyAndValues: string[] = [];

for (const k in item) {
keyAndValues.push(k);

const value = item[k];

if (value === null || value === undefined) {
continue;
}

if (Array.isArray(value)) {
keyAndValues.push(...value.map(convertToString));
const items = value.filter(v => v !== null && v !== undefined);

if (items.length > 0) {
keyAndValues.push(k, ...items.map(convertToString));
}
} else {
keyAndValues.push(convertToString(value));
keyAndValues.push(k, convertToString(value));
}
}

Expand Down
Loading
Loading