Skip to content

Commit 40e36f9

Browse files
committed
feat: remove @preserveLineBreaks tag
Ticket: DX-2755 This commit removes the support for the @preserveLineBreaks tag. We will no longer support this tag as line breaks are now preserved by default
1 parent c05e5fa commit 40e36f9

3 files changed

Lines changed: 0 additions & 176 deletions

File tree

packages/openapi-generator/README.md

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -472,9 +472,6 @@ These are some tags that you can use in your schema JSDocs are custom to this ge
472472
will have `x-internal: true` for schemas with the `@private` tag.
473473
- `@deprecated` allows to mark any field in any schema as deprecated. The final spec
474474
will include `deprecated: true` in the final specificaiton.
475-
- `@preserveLineBreaks` preserves line breaks in descriptions. By default, multiline
476-
descriptions are collapsed into a single line. Use this tag when you need to preserve
477-
formatting, such as for markdown lists or structured text.
478475

479476
```typescript
480477
import * as t from 'io-ts';
@@ -485,16 +482,6 @@ const Schema = t.type({
485482
/** @deprecated */
486483
deprecatedField: t.string,
487484
publicNonDeprecatedField: t.string,
488-
/**
489-
* @preserveLineBreaks
490-
* This description spans multiple lines
491-
* and will preserve its line breaks.
492-
*
493-
* Available options:
494-
* - `option1` - First option
495-
* - `option2` - Second option
496-
*/
497-
fieldWithFormattedDescription: t.string,
498485
});
499486
```
500487

packages/openapi-generator/src/comments.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,6 @@ export function leadingComment(
7070
}
7171
}
7272

73-
const shouldPreserveLineBreaks = commentString.includes('@preserveLineBreaks');
74-
if (shouldPreserveLineBreaks) {
75-
// This handles both inline and separate line cases
76-
commentString = commentString.replace(/^\s*\*\s*@preserveLineBreaks\s*$/gm, '');
77-
commentString = commentString.replace(/@preserveLineBreaks\s*/g, '');
78-
}
79-
8073
const parsedComment = parseComment(commentString, { spacing: 'preserve' });
8174

8275
for (const block of parsedComment) {

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

Lines changed: 0 additions & 156 deletions
Original file line numberDiff line numberDiff line change
@@ -1658,162 +1658,6 @@ testCase(
16581658
},
16591659
);
16601660

1661-
const ROUTE_WITH_MARKDOWN_LIST_AND_PRESERVE_LINE_BREAKS = `
1662-
import * as t from 'io-ts';
1663-
import * as h from '@api-ts/io-ts-http';
1664-
1665-
/**
1666-
* A route with a list in the comment
1667-
*
1668-
* @operationId api.v1.list
1669-
* @tag Test Routes
1670-
*/
1671-
export const route = h.httpRoute({
1672-
path: '/list',
1673-
method: 'GET',
1674-
request: h.httpRequest({
1675-
query: {
1676-
/**
1677-
* @preserveLineBreaks
1678-
* The permissions granted by this access token.
1679-
*
1680-
* - \`all\` - Access all actions in the test environment.
1681-
* - \`crypto_compare\` - Call CryptoCompare API.
1682-
*/
1683-
permissions: t.string,
1684-
},
1685-
}),
1686-
response: {
1687-
200: t.string
1688-
},
1689-
});
1690-
`;
1691-
1692-
testCase(
1693-
'route with markdown list in comment and @preserveLineBreaks tag',
1694-
ROUTE_WITH_MARKDOWN_LIST_AND_PRESERVE_LINE_BREAKS,
1695-
{
1696-
openapi: '3.0.3',
1697-
info: {
1698-
title: 'Test',
1699-
version: '1.0.0',
1700-
},
1701-
paths: {
1702-
'/list': {
1703-
get: {
1704-
summary: 'A route with a list in the comment',
1705-
operationId: 'api.v1.list',
1706-
tags: ['Test Routes'],
1707-
parameters: [
1708-
{
1709-
name: 'permissions',
1710-
in: 'query',
1711-
required: true,
1712-
schema: {
1713-
type: 'string',
1714-
},
1715-
description:
1716-
'The permissions granted by this access token.\n\n- `all` - Access all actions in the test environment.\n- `crypto_compare` - Call CryptoCompare API.',
1717-
},
1718-
],
1719-
responses: {
1720-
200: {
1721-
description: 'OK',
1722-
content: {
1723-
'application/json': {
1724-
schema: {
1725-
type: 'string',
1726-
},
1727-
},
1728-
},
1729-
},
1730-
},
1731-
},
1732-
},
1733-
},
1734-
components: {
1735-
schemas: {},
1736-
},
1737-
},
1738-
);
1739-
1740-
const ROUTE_WITH_INLINE_PRESERVE_LINE_BREAKS = `
1741-
import * as t from 'io-ts';
1742-
import * as h from '@api-ts/io-ts-http';
1743-
1744-
/**
1745-
* A route with inline preserveLineBreaks tag
1746-
*
1747-
* @operationId api.v1.inline
1748-
* @tag Test Routes
1749-
*/
1750-
export const route = h.httpRoute({
1751-
path: '/inline',
1752-
method: 'GET',
1753-
request: h.httpRequest({
1754-
query: {
1755-
/**
1756-
* @preserveLineBreaks This tag is inline with other text
1757-
* This is a long description that
1758-
* spans multiple lines in the source.
1759-
*/
1760-
field1: t.string,
1761-
},
1762-
}),
1763-
response: {
1764-
200: t.string
1765-
},
1766-
});
1767-
`;
1768-
1769-
testCase(
1770-
'route with inline @preserveLineBreaks tag',
1771-
ROUTE_WITH_INLINE_PRESERVE_LINE_BREAKS,
1772-
{
1773-
openapi: '3.0.3',
1774-
info: {
1775-
title: 'Test',
1776-
version: '1.0.0',
1777-
},
1778-
paths: {
1779-
'/inline': {
1780-
get: {
1781-
summary: 'A route with inline preserveLineBreaks tag',
1782-
operationId: 'api.v1.inline',
1783-
tags: ['Test Routes'],
1784-
parameters: [
1785-
{
1786-
name: 'field1',
1787-
in: 'query',
1788-
required: true,
1789-
schema: {
1790-
type: 'string',
1791-
},
1792-
description:
1793-
'This tag is inline with other text\nThis is a long description that\nspans multiple lines in the source.',
1794-
},
1795-
],
1796-
responses: {
1797-
200: {
1798-
description: 'OK',
1799-
content: {
1800-
'application/json': {
1801-
schema: {
1802-
type: 'string',
1803-
},
1804-
},
1805-
},
1806-
},
1807-
},
1808-
},
1809-
},
1810-
},
1811-
components: {
1812-
schemas: {},
1813-
},
1814-
},
1815-
);
1816-
18171661
const ROUTE_WITH_ENUM_DEPRECATED = `
18181662
import * as t from 'io-ts';
18191663
import * as h from '@api-ts/io-ts-http';

0 commit comments

Comments
 (0)