Skip to content

Commit 41e5abf

Browse files
committed
fix quote issue in path
1 parent fb2e371 commit 41e5abf

File tree

4 files changed

+51
-4
lines changed

4 files changed

+51
-4
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`serializeOperation serializes operation with path parameters inside () 1`] = `
4+
"/**
5+
* Create a request builder for execution of get requests to the 'test('{id}')' endpoint.
6+
* @param id - Path parameter.
7+
* @returns The request builder, use the \`execute()\` method to trigger the request.
8+
*/
9+
getFn: (id: string) => new OpenApiRequestBuilder<Record<string, any>>(
10+
'get',
11+
"test('{id}')",
12+
{
13+
pathParameters: { id }
14+
}
15+
)"
16+
`;

packages/openapi-generator/src/file-serializer/operation.spec.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,33 @@ describe('serializeOperation', () => {
101101
`);
102102
});
103103

104+
it('serializes operation with path parameters inside ()', () => {
105+
const operation: OpenApiOperation = {
106+
operationId: 'getFn',
107+
method: 'get',
108+
tags: [],
109+
pathParameters: [
110+
{
111+
in: 'path',
112+
name: 'id',
113+
originalName: 'id',
114+
schema: { type: 'string' },
115+
required: true,
116+
schemaProperties: {}
117+
}
118+
],
119+
queryParameters: [],
120+
responses: { 200: { description: 'some response description' } },
121+
response: {
122+
additionalProperties: { type: 'any' },
123+
properties: []
124+
},
125+
pathPattern: 'test(\'{id}\')'
126+
};
127+
128+
expect(serializeOperation(operation)).toMatchSnapshot();
129+
});
130+
104131
it('serializes operation with only query parameters', () => {
105132
const operation: OpenApiOperation = {
106133
operationId: 'getFn',

packages/openapi-generator/src/file-serializer/operation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { serializeSchema } from './schema';
1515
export function serializeOperation(operation: OpenApiOperation): string {
1616
const requestBuilderParams = [
1717
`'${operation.method}'`,
18-
`'${operation.pathPattern}'`
18+
`"${operation.pathPattern}"`
1919
];
2020

2121
const bodyAndQueryParams = serializeParamsForRequestBuilder(operation);

packages/openapi/src/openapi-request-builder.spec.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,9 +234,13 @@ describe('openapi-request-builder', () => {
234234
});
235235

236236
it('encodes path parameters', async () => {
237-
const requestBuilder = new OpenApiRequestBuilder('get', '/test/{id}', {
238-
pathParameters: { id: '^test' }
239-
});
237+
const requestBuilder = new OpenApiRequestBuilder(
238+
'get',
239+
"/test('{someId}')/{id}",
240+
{
241+
pathParameters: { someId: 'value', id: '^test' }
242+
}
243+
);
240244
const response = await requestBuilder.executeRaw(destination);
241245
expect(httpSpy).toHaveBeenCalledWith(
242246
sanitizeDestination(destination),

0 commit comments

Comments
 (0)