mirror of
https://github.com/ferdikoomen/openapi-typescript-codegen.git
synced 2025-12-08 20:16:21 +00:00
- Added testcases for query parsing
This commit is contained in:
parent
4c21c5107d
commit
facfe1666b
@ -6,6 +6,7 @@ All notable changes to this project will be documented in this file.
|
||||
- Updated dependencies
|
||||
### Added
|
||||
- Added test cases for CLI commands
|
||||
- Added test cases for query parsing
|
||||
|
||||
## [0.18.1] - 2022-01-31
|
||||
### Fixed
|
||||
|
||||
@ -3541,6 +3541,7 @@ export type { ModelWithPattern } from './models/ModelWithPattern';
|
||||
export type { ModelWithProperties } from './models/ModelWithProperties';
|
||||
export type { ModelWithReference } from './models/ModelWithReference';
|
||||
export type { ModelWithString } from './models/ModelWithString';
|
||||
export type { Pageable } from './models/Pageable';
|
||||
export type { SimpleBoolean } from './models/SimpleBoolean';
|
||||
export type { SimpleFile } from './models/SimpleFile';
|
||||
export type { SimpleInteger } from './models/SimpleInteger';
|
||||
@ -3601,6 +3602,7 @@ export { $ModelWithPattern } from './schemas/$ModelWithPattern';
|
||||
export { $ModelWithProperties } from './schemas/$ModelWithProperties';
|
||||
export { $ModelWithReference } from './schemas/$ModelWithReference';
|
||||
export { $ModelWithString } from './schemas/$ModelWithString';
|
||||
export { $Pageable } from './schemas/$Pageable';
|
||||
export { $SimpleBoolean } from './schemas/$SimpleBoolean';
|
||||
export { $SimpleFile } from './schemas/$SimpleFile';
|
||||
export { $SimpleInteger } from './schemas/$SimpleInteger';
|
||||
@ -4525,6 +4527,19 @@ export type ModelWithString = {
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`v3 should generate: ./test/generated/v3/models/Pageable.ts 1`] = `
|
||||
"/* istanbul ignore file */
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
|
||||
export type Pageable = {
|
||||
page?: number;
|
||||
size?: number;
|
||||
sort?: Array<string>;
|
||||
};
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`v3 should generate: ./test/generated/v3/models/SimpleBoolean.ts 1`] = `
|
||||
"/* istanbul ignore file */
|
||||
/* tslint:disable */
|
||||
@ -5612,6 +5627,31 @@ export const $ModelWithString = {
|
||||
} as const;"
|
||||
`;
|
||||
|
||||
exports[`v3 should generate: ./test/generated/v3/schemas/$Pageable.ts 1`] = `
|
||||
"/* istanbul ignore file */
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
export const $Pageable = {
|
||||
properties: {
|
||||
page: {
|
||||
type: 'number',
|
||||
format: 'int32',
|
||||
},
|
||||
size: {
|
||||
type: 'number',
|
||||
format: 'int32',
|
||||
minimum: 1,
|
||||
},
|
||||
sort: {
|
||||
type: 'array',
|
||||
contains: {
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
},
|
||||
} as const;"
|
||||
`;
|
||||
|
||||
exports[`v3 should generate: ./test/generated/v3/schemas/$SimpleBoolean.ts 1`] = `
|
||||
"/* istanbul ignore file */
|
||||
/* tslint:disable */
|
||||
@ -6305,6 +6345,7 @@ exports[`v3 should generate: ./test/generated/v3/services/ParametersService.ts 1
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
import type { ModelWithString } from '../models/ModelWithString';
|
||||
import type { Pageable } from '../models/Pageable';
|
||||
|
||||
import type { CancelablePromise } from '../core/CancelablePromise';
|
||||
import { OpenAPI } from '../core/OpenAPI';
|
||||
@ -6427,7 +6468,7 @@ export class ParametersService {
|
||||
* @throws ApiError
|
||||
*/
|
||||
public static postCallWithOptionalParam(
|
||||
parameter: string,
|
||||
parameter: Pageable,
|
||||
requestBody?: ModelWithString,
|
||||
): CancelablePromise<void> {
|
||||
return __request(OpenAPI, {
|
||||
|
||||
@ -138,4 +138,14 @@ describe('v3.axios', () => {
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
it('it should parse query params', async () => {
|
||||
const { ParametersService } = require('./generated/v3/axios/index.js');
|
||||
const result = (await ParametersService.postCallWithOptionalParam({
|
||||
page: 0,
|
||||
size: 1,
|
||||
sort: ['location'],
|
||||
})) as Promise<any>;
|
||||
expect((result as any).query).toStrictEqual({ parameter: { page: '0', size: '1', sort: 'location' } });
|
||||
});
|
||||
});
|
||||
|
||||
@ -164,4 +164,18 @@ describe('v3.babel', () => {
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
it('it should parse query params', async () => {
|
||||
const result = await browser.evaluate(async () => {
|
||||
const { ParametersService } = (window as any).api;
|
||||
return (await ParametersService.postCallWithOptionalParam({
|
||||
parameter: {
|
||||
page: 0,
|
||||
size: 1,
|
||||
sort: ['location'],
|
||||
},
|
||||
})) as Promise<any>;
|
||||
});
|
||||
expect(result.query).toStrictEqual({ parameter: { page: '0', size: '1', sort: 'location' } });
|
||||
});
|
||||
});
|
||||
|
||||
@ -158,4 +158,16 @@ describe('v3.fetch', () => {
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
it('it should parse query params', async () => {
|
||||
const result = await browser.evaluate(async () => {
|
||||
const { ParametersService } = (window as any).api;
|
||||
return (await ParametersService.postCallWithOptionalParam({
|
||||
page: 0,
|
||||
size: 1,
|
||||
sort: ['location'],
|
||||
})) as Promise<any>;
|
||||
});
|
||||
expect(result.query).toStrictEqual({ parameter: { page: '0', size: '1', sort: 'location' } });
|
||||
});
|
||||
});
|
||||
|
||||
@ -138,4 +138,14 @@ describe('v3.node', () => {
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
it('it should parse query params', async () => {
|
||||
const { ParametersService } = require('./generated/v3/node/index.js');
|
||||
const result = (await ParametersService.postCallWithOptionalParam({
|
||||
page: 0,
|
||||
size: 1,
|
||||
sort: ['location'],
|
||||
})) as Promise<any>;
|
||||
expect((result as any).query).toStrictEqual({ parameter: { page: '0', size: '1', sort: 'location' } });
|
||||
});
|
||||
});
|
||||
|
||||
@ -157,4 +157,16 @@ describe('v3.xhr', () => {
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
it('it should parse query params', async () => {
|
||||
const result = await browser.evaluate(async () => {
|
||||
const { ParametersService } = (window as any).api;
|
||||
return (await ParametersService.postCallWithOptionalParam({
|
||||
page: 0,
|
||||
size: 1,
|
||||
sort: ['location'],
|
||||
})) as Promise<any>;
|
||||
});
|
||||
expect(result.query).toStrictEqual({ parameter: { page: '0', size: '1', sort: 'location' } });
|
||||
});
|
||||
});
|
||||
|
||||
@ -339,7 +339,7 @@
|
||||
"in": "query",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
"$ref": "#/components/schemas/Pageable"
|
||||
}
|
||||
}
|
||||
],
|
||||
@ -2400,6 +2400,27 @@
|
||||
"format": "uri"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Pageable": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"page": {
|
||||
"minimum": 0,
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
},
|
||||
"size": {
|
||||
"minimum": 1,
|
||||
"type": "integer",
|
||||
"format": "int32"
|
||||
},
|
||||
"sort": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user