mirror of
https://github.com/ferdikoomen/openapi-typescript-codegen.git
synced 2025-12-08 20:16:21 +00:00
Backquote/backtick symbol (`) is not escaped correctly
This commit is contained in:
parent
5559a15d2a
commit
df9e447aa3
9
src/openApi/v2/parser/escapeDescription.spec.ts
Normal file
9
src/openApi/v2/parser/escapeDescription.spec.ts
Normal file
@ -0,0 +1,9 @@
|
||||
import { escapeDescription } from './escapeDescription';
|
||||
|
||||
describe('escapeDescription', () => {
|
||||
it('should escape', () => {
|
||||
expect(escapeDescription('')).toEqual('');
|
||||
expect(escapeDescription('fooBar')).toEqual('fooBar');
|
||||
expect(escapeDescription('foo `test` bar')).toEqual('foo \\`test\\` bar');
|
||||
});
|
||||
});
|
||||
3
src/openApi/v2/parser/escapeDescription.ts
Normal file
3
src/openApi/v2/parser/escapeDescription.ts
Normal file
@ -0,0 +1,3 @@
|
||||
export function escapeDescription(value: string): string {
|
||||
return value.replace(/`/g, '\\`');
|
||||
}
|
||||
@ -1,5 +1,6 @@
|
||||
import type { OperationError } from '../../../client/interfaces/OperationError';
|
||||
import type { OperationResponse } from '../../../client/interfaces/OperationResponse';
|
||||
import { escapeDescription } from './escapeDescription';
|
||||
|
||||
export function getOperationErrors(operationResponses: OperationResponse[]): OperationError[] {
|
||||
return operationResponses
|
||||
@ -8,6 +9,6 @@ export function getOperationErrors(operationResponses: OperationResponse[]): Ope
|
||||
})
|
||||
.map(response => ({
|
||||
code: response.code,
|
||||
description: response.description!,
|
||||
description: escapeDescription(response.description!),
|
||||
}));
|
||||
}
|
||||
|
||||
9
src/openApi/v3/parser/escapeDescription.spec.ts
Normal file
9
src/openApi/v3/parser/escapeDescription.spec.ts
Normal file
@ -0,0 +1,9 @@
|
||||
import { escapeDescription } from './escapeDescription';
|
||||
|
||||
describe('escapeDescription', () => {
|
||||
it('should escape', () => {
|
||||
expect(escapeDescription('')).toEqual('');
|
||||
expect(escapeDescription('fooBar')).toEqual('fooBar');
|
||||
expect(escapeDescription('foo `test` bar')).toEqual('foo \\`test\\` bar');
|
||||
});
|
||||
});
|
||||
3
src/openApi/v3/parser/escapeDescription.ts
Normal file
3
src/openApi/v3/parser/escapeDescription.ts
Normal file
@ -0,0 +1,3 @@
|
||||
export function escapeDescription(value: string): string {
|
||||
return value.replace(/`/g, '\\`');
|
||||
}
|
||||
@ -1,5 +1,6 @@
|
||||
import type { OperationError } from '../../../client/interfaces/OperationError';
|
||||
import type { OperationResponse } from '../../../client/interfaces/OperationResponse';
|
||||
import { escapeDescription } from './escapeDescription';
|
||||
|
||||
export function getOperationErrors(operationResponses: OperationResponse[]): OperationError[] {
|
||||
return operationResponses
|
||||
@ -8,6 +9,6 @@ export function getOperationErrors(operationResponses: OperationResponse[]): Ope
|
||||
})
|
||||
.map(response => ({
|
||||
code: response.code,
|
||||
description: response.description!,
|
||||
description: escapeDescription(response.description!),
|
||||
}));
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user