Skip to content

Commit c05e5fa

Browse files
authored
Merge pull request #1112 from BitGo/DX-2753-preserve-line-breaks
feat: default to preserving line breaks
2 parents 3cb64a2 + e0f9a56 commit c05e5fa

2 files changed

Lines changed: 75 additions & 4 deletions

File tree

packages/openapi-generator/src/comments.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,7 @@ export function leadingComment(
7777
commentString = commentString.replace(/@preserveLineBreaks\s*/g, '');
7878
}
7979

80-
const parsedComment = parseComment(
81-
commentString,
82-
shouldPreserveLineBreaks ? { spacing: 'preserve' } : undefined,
83-
);
80+
const parsedComment = parseComment(commentString, { spacing: 'preserve' });
8481

8582
for (const block of parsedComment) {
8683
block.description = block.description.trim();

packages/openapi-generator/test/openapi/comments.test.ts

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2111,3 +2111,77 @@ testCase('route with multibyte chars', ROUTE_WITH_MULTIBYTE_CHARS, {
21112111
},
21122112
},
21132113
});
2114+
2115+
const ROUTE_WITH_MARKDOWN_LIST = `
2116+
import * as t from 'io-ts';
2117+
import * as h from '@api-ts/io-ts-http';
2118+
2119+
/**
2120+
* A route with a list in the comment
2121+
*
2122+
* @operationId api.v1.list
2123+
* @tag Test Routes
2124+
*/
2125+
export const route = h.httpRoute({
2126+
path: '/list',
2127+
method: 'GET',
2128+
request: h.httpRequest({
2129+
query: {
2130+
/**
2131+
* The permissions granted by this access token.
2132+
*
2133+
* - \`all\` - Access all actions in the test environment.
2134+
* - \`crypto_compare\` - Call CryptoCompare API.
2135+
*/
2136+
permissions: t.string,
2137+
},
2138+
}),
2139+
response: {
2140+
200: t.string
2141+
},
2142+
});
2143+
`;
2144+
2145+
testCase('route with markdown list in comment', ROUTE_WITH_MARKDOWN_LIST, {
2146+
openapi: '3.0.3',
2147+
info: {
2148+
title: 'Test',
2149+
version: '1.0.0',
2150+
},
2151+
paths: {
2152+
'/list': {
2153+
get: {
2154+
summary: 'A route with a list in the comment',
2155+
operationId: 'api.v1.list',
2156+
tags: ['Test Routes'],
2157+
parameters: [
2158+
{
2159+
name: 'permissions',
2160+
in: 'query',
2161+
required: true,
2162+
schema: {
2163+
type: 'string',
2164+
},
2165+
description:
2166+
'The permissions granted by this access token.\n\n- `all` - Access all actions in the test environment.\n- `crypto_compare` - Call CryptoCompare API.',
2167+
},
2168+
],
2169+
responses: {
2170+
200: {
2171+
description: 'OK',
2172+
content: {
2173+
'application/json': {
2174+
schema: {
2175+
type: 'string',
2176+
},
2177+
},
2178+
},
2179+
},
2180+
},
2181+
},
2182+
},
2183+
},
2184+
components: {
2185+
schemas: {},
2186+
},
2187+
});

0 commit comments

Comments
 (0)