- Updated parsing of comments

This commit is contained in:
Ferdi Koomen 2022-01-24 17:47:03 +01:00
parent 3dde57a8ec
commit 9049afd509
37 changed files with 388 additions and 227 deletions

View File

@ -34,6 +34,8 @@ const handlebarsPlugin = () => ({
union: true,
intersection: true,
enumerator: true,
escapeComment: true,
escapeDescription: true,
},
});
return `export default ${templateSpec};`;

View File

@ -1,14 +0,0 @@
import { escapeDescription } from './escapeDescription';
describe('escapeDescription', () => {
it('should escape', () => {
expect(escapeDescription('foo `test` bar')).toEqual('foo \\`test\\` bar');
});
it('should not escape', () => {
expect(escapeDescription('')).toEqual('');
expect(escapeDescription('fooBar')).toEqual('fooBar');
expect(escapeDescription('foo \\`test\\` bar')).toEqual('foo \\`test\\` bar');
expect(escapeDescription('foo */bar/*')).toEqual('foo *_/bar/*');
});
});

View File

@ -1,3 +0,0 @@
export function escapeDescription(value: string): string {
return value.replace(/([^\\])`/g, '$1\\`').replace(/(\*\/)/g, '*_/');
}

View File

@ -1,28 +0,0 @@
import { EOL } from 'os';
import { getComment } from './getComment';
describe('getComment', () => {
it('should parse comments', () => {
const multiline =
'Testing multiline comments.' +
EOL +
' * This must go to the next line.' +
EOL +
' * ' +
EOL +
' * This will contain a break.';
expect(getComment('')).toEqual(null);
expect(getComment('Hello')).toEqual('Hello');
expect(getComment('Hello World!')).toEqual('Hello World!');
expect(getComment('Testing */escape/*')).toEqual('Testing *_/escape/*');
expect(
getComment('Testing multiline comments.\nThis must go to the next line.\n\nThis will contain a break.')
).toEqual(multiline);
expect(
getComment(
'Testing multiline comments.\r\nThis must go to the next line.\r\n\r\nThis will contain a break.'
)
).toEqual(multiline);
});
});

View File

@ -1,13 +0,0 @@
import { EOL } from 'os';
/**
* Cleanup comment and prefix multiline comments with "*",
* so they look a bit nicer when used in the generated code.
* @param comment
*/
export function getComment(comment?: string): string | null {
if (comment) {
return comment.replace(/(\*\/)/g, '*_/').replace(/\r?\n(.*)/g, (_, w) => `${EOL} * ${w.trim()}`);
}
return null;
}

View File

@ -3,7 +3,6 @@ import { getPattern } from '../../../utils/getPattern';
import type { OpenApi } from '../interfaces/OpenApi';
import type { OpenApiSchema } from '../interfaces/OpenApiSchema';
import { extendEnum } from './extendEnum';
import { getComment } from './getComment';
import { getEnum } from './getEnum';
import { getEnumFromDescription } from './getEnumFromDescription';
import { getModelComposition } from './getModelComposition';
@ -23,7 +22,7 @@ export function getModel(
base: 'any',
template: null,
link: null,
description: getComment(definition.description),
description: definition.description || null,
isDefinition,
isReadOnly: definition.readOnly === true,
isNullable: definition['x-nullable'] === true,

View File

@ -3,7 +3,6 @@ import { getPattern } from '../../../utils/getPattern';
import type { OpenApi } from '../interfaces/OpenApi';
import type { OpenApiSchema } from '../interfaces/OpenApiSchema';
import { escapeName } from './escapeName';
import { getComment } from './getComment';
import type { getModel } from './getModel';
import { getType } from './getType';
@ -25,7 +24,7 @@ export function getModelProperties(openApi: OpenApi, definition: OpenApiSchema,
base: model.base,
template: model.template,
link: null,
description: getComment(property.description),
description: property.description || null,
isDefinition: false,
isReadOnly: property.readOnly === true,
isRequired: propertyRequired,
@ -58,7 +57,7 @@ export function getModelProperties(openApi: OpenApi, definition: OpenApiSchema,
base: model.base,
template: model.template,
link: model.link,
description: getComment(property.description),
description: property.description || null,
isDefinition: false,
isReadOnly: property.readOnly === true,
isRequired: propertyRequired,

View File

@ -2,7 +2,6 @@ import type { Operation } from '../../../client/interfaces/Operation';
import type { OperationParameters } from '../../../client/interfaces/OperationParameters';
import type { OpenApi } from '../interfaces/OpenApi';
import type { OpenApiOperation } from '../interfaces/OpenApiOperation';
import { getComment } from './getComment';
import { getOperationErrors } from './getOperationErrors';
import { getOperationName } from './getOperationName';
import { getOperationParameters } from './getOperationParameters';
@ -30,8 +29,8 @@ export function getOperation(
const operation: Operation = {
service: serviceName,
name: operationName,
summary: getComment(op.summary),
description: getComment(op.description),
summary: op.summary || null,
description: op.description || null,
deprecated: op.deprecated === true,
method: method.toUpperCase(),
path: operationPath,

View File

@ -1,7 +1,10 @@
import type { OperationError } from '../../../client/interfaces/OperationError';
import type { OperationResponse } from '../../../client/interfaces/OperationResponse';
import { escapeDescription } from './escapeDescription';
/**
*
* @param operationResponses
*/
export function getOperationErrors(operationResponses: OperationResponse[]): OperationError[] {
return operationResponses
.filter(operationResponse => {
@ -9,6 +12,6 @@ export function getOperationErrors(operationResponses: OperationResponse[]): Ope
})
.map(response => ({
code: response.code,
description: escapeDescription(response.description!),
description: response.description!,
}));
}

View File

@ -4,7 +4,6 @@ import type { OpenApi } from '../interfaces/OpenApi';
import type { OpenApiParameter } from '../interfaces/OpenApiParameter';
import type { OpenApiSchema } from '../interfaces/OpenApiSchema';
import { extendEnum } from './extendEnum';
import { getComment } from './getComment';
import { getEnum } from './getEnum';
import { getEnumFromDescription } from './getEnumFromDescription';
import { getModel } from './getModel';
@ -23,7 +22,7 @@ export function getOperationParameter(openApi: OpenApi, parameter: OpenApiParame
base: 'any',
template: null,
link: null,
description: getComment(parameter.description),
description: parameter.description || null,
isDefinition: false,
isReadOnly: false,
isRequired: parameter.required === true,

View File

@ -3,7 +3,6 @@ import { getPattern } from '../../../utils/getPattern';
import type { OpenApi } from '../interfaces/OpenApi';
import type { OpenApiResponse } from '../interfaces/OpenApiResponse';
import type { OpenApiSchema } from '../interfaces/OpenApiSchema';
import { getComment } from './getComment';
import { getModel } from './getModel';
import { getRef } from './getRef';
import { getType } from './getType';
@ -17,7 +16,7 @@ export function getOperationResponse(
in: 'response',
name: '',
code: responseCode,
description: getComment(response.description)!,
description: response.description || null,
export: 'generic',
type: 'any',
base: 'any',
@ -35,8 +34,8 @@ export function getOperationResponse(
// If this response has a schema, then we need to check two things:
// if this is a reference then the parameter is just the 'name' of
// this reference type. Otherwise it might be a complex schema and
// then we need to parse the schema!
// this reference type. Otherwise, it might be a complex schema,
// and then we need to parse the schema!
let schema = response.schema;
if (schema) {
if (schema.$ref?.startsWith('#/responses/')) {

View File

@ -1,14 +0,0 @@
import { escapeDescription } from './escapeDescription';
describe('escapeDescription', () => {
it('should escape', () => {
expect(escapeDescription('foo `test` bar')).toEqual('foo \\`test\\` bar');
});
it('should not escape', () => {
expect(escapeDescription('')).toEqual('');
expect(escapeDescription('fooBar')).toEqual('fooBar');
expect(escapeDescription('foo \\`test\\` bar')).toEqual('foo \\`test\\` bar');
expect(escapeDescription('foo */bar/*')).toEqual('foo *_/bar/*');
});
});

View File

@ -1,3 +0,0 @@
export function escapeDescription(value: string): string {
return value.replace(/([^\\])`/g, '$1\\`').replace(/(\*\/)/g, '*_/');
}

View File

@ -1,28 +0,0 @@
import { EOL } from 'os';
import { getComment } from './getComment';
describe('getComment', () => {
it('should parse comments', () => {
const multiline =
'Testing multiline comments.' +
EOL +
' * This must go to the next line.' +
EOL +
' * ' +
EOL +
' * This will contain a break.';
expect(getComment('')).toEqual(null);
expect(getComment('Hello')).toEqual('Hello');
expect(getComment('Hello World!')).toEqual('Hello World!');
expect(getComment('Testing */escape/*')).toEqual('Testing *_/escape/*');
expect(
getComment('Testing multiline comments.\nThis must go to the next line.\n\nThis will contain a break.')
).toEqual(multiline);
expect(
getComment(
'Testing multiline comments.\r\nThis must go to the next line.\r\n\r\nThis will contain a break.'
)
).toEqual(multiline);
});
});

View File

@ -1,13 +0,0 @@
import { EOL } from 'os';
/**
* Cleanup comment and prefix multiline comments with "*",
* so they look a bit nicer when used in the generated code.
* @param comment
*/
export function getComment(comment?: string): string | null {
if (comment) {
return comment.replace(/(\*\/)/g, '*_/').replace(/\r?\n(.*)/g, (_, w) => `${EOL} * ${w.trim()}`);
}
return null;
}

View File

@ -3,7 +3,6 @@ import { getPattern } from '../../../utils/getPattern';
import type { OpenApi } from '../interfaces/OpenApi';
import type { OpenApiSchema } from '../interfaces/OpenApiSchema';
import { extendEnum } from './extendEnum';
import { getComment } from './getComment';
import { getEnum } from './getEnum';
import { getEnumFromDescription } from './getEnumFromDescription';
import { getModelComposition } from './getModelComposition';
@ -24,7 +23,7 @@ export function getModel(
base: 'any',
template: null,
link: null,
description: getComment(definition.description),
description: definition.description || null,
isDefinition,
isReadOnly: definition.readOnly === true,
isNullable: definition.nullable === true,

View File

@ -4,7 +4,6 @@ import { getPattern } from '../../../utils/getPattern';
import type { OpenApi } from '../interfaces/OpenApi';
import type { OpenApiSchema } from '../interfaces/OpenApiSchema';
import { escapeName } from './escapeName';
import { getComment } from './getComment';
import type { getModel } from './getModel';
import { getType } from './getType';
@ -37,7 +36,7 @@ export function getModelProperties(
| 'properties'
> = {
name: escapeName(propertyName),
description: getComment(property.description),
description: property.description || null,
isDefinition: false,
isReadOnly: property.readOnly === true,
isRequired: propertyRequired,

View File

@ -3,7 +3,6 @@ import type { OperationParameters } from '../../../client/interfaces/OperationPa
import type { OpenApi } from '../interfaces/OpenApi';
import type { OpenApiOperation } from '../interfaces/OpenApiOperation';
import type { OpenApiRequestBody } from '../interfaces/OpenApiRequestBody';
import { getComment } from './getComment';
import { getOperationErrors } from './getOperationErrors';
import { getOperationName } from './getOperationName';
import { getOperationParameters } from './getOperationParameters';
@ -33,8 +32,8 @@ export function getOperation(
const operation: Operation = {
service: serviceName,
name: operationName,
summary: getComment(op.summary),
description: getComment(op.description),
summary: op.summary || null,
description: op.description || null,
deprecated: op.deprecated === true,
method: method.toUpperCase(),
path: operationPath,

View File

@ -1,6 +1,5 @@
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
@ -9,6 +8,6 @@ export function getOperationErrors(operationResponses: OperationResponse[]): Ope
})
.map(response => ({
code: response.code,
description: escapeDescription(response.description!),
description: response.description!,
}));
}

View File

@ -3,7 +3,6 @@ import { getPattern } from '../../../utils/getPattern';
import type { OpenApi } from '../interfaces/OpenApi';
import type { OpenApiParameter } from '../interfaces/OpenApiParameter';
import type { OpenApiSchema } from '../interfaces/OpenApiSchema';
import { getComment } from './getComment';
import { getModel } from './getModel';
import { getModelDefault } from './getModelDefault';
import { getOperationParameterName } from './getOperationParameterName';
@ -20,7 +19,7 @@ export function getOperationParameter(openApi: OpenApi, parameter: OpenApiParame
base: 'any',
template: null,
link: null,
description: getComment(parameter.description),
description: parameter.description || null,
isDefinition: false,
isReadOnly: false,
isRequired: parameter.required === true,

View File

@ -2,7 +2,6 @@ import type { OperationParameter } from '../../../client/interfaces/OperationPar
import { getPattern } from '../../../utils/getPattern';
import type { OpenApi } from '../interfaces/OpenApi';
import type { OpenApiRequestBody } from '../interfaces/OpenApiRequestBody';
import { getComment } from './getComment';
import { getContent } from './getContent';
import { getModel } from './getModel';
import { getType } from './getType';
@ -17,7 +16,7 @@ export function getOperationRequestBody(openApi: OpenApi, body: OpenApiRequestBo
base: 'any',
template: null,
link: null,
description: getComment(body.description),
description: body.description || null,
default: undefined,
isDefinition: false,
isReadOnly: false,

View File

@ -3,7 +3,6 @@ import { getPattern } from '../../../utils/getPattern';
import type { OpenApi } from '../interfaces/OpenApi';
import type { OpenApiResponse } from '../interfaces/OpenApiResponse';
import type { OpenApiSchema } from '../interfaces/OpenApiSchema';
import { getComment } from './getComment';
import { getContent } from './getContent';
import { getModel } from './getModel';
import { getRef } from './getRef';
@ -18,7 +17,7 @@ export function getOperationResponse(
in: 'response',
name: '',
code: responseCode,
description: getComment(response.description)!,
description: response.description || null,
export: 'generic',
type: 'any',
base: 'any',

View File

@ -19,20 +19,20 @@ export class {{{name}}}{{{@root.postfix}}} {
* @deprecated
{{/if}}
{{#if summary}}
* {{{summary}}}
* {{{escapeComment summary}}}
{{/if}}
{{#if description}}
* {{{description}}}
* {{{escapeComment description}}}
{{/if}}
{{#unless @root.useOptions}}
{{#if parameters}}
{{#each parameters}}
* @param {{{name}}} {{{description}}}
* @param {{{name}}} {{#if description}}{{{escapeComment description}}}{{/if}}
{{/each}}
{{/if}}
{{/unless}}
{{#each results}}
* @returns {{{type}}} {{{description}}}
* @returns {{{type}}} {{#if description}}{{{escapeComment description}}}{{/if}}
{{/each}}
* @throws ApiError
*/

View File

@ -1,6 +1,6 @@
{{#if description}}
/**
* {{{description}}}
* {{{escapeComment description}}}
*/
{{/if}}
export type {{{name}}} = {{>type parent=name}};
@ -12,7 +12,7 @@ export namespace {{{name}}} {
{{#each enums}}
{{#if description}}
/**
* {{{description}}}
* {{{escapeComment description}}}
*/
{{/if}}
export enum {{{name}}} {

View File

@ -1,13 +1,13 @@
{{#if description}}
/**
* {{{description}}}
* {{{escapeComment description}}}
*/
{{/if}}
export enum {{{name}}} {
{{#each enum}}
{{#if description}}
/**
* {{{description}}}
* {{{escapeComment description}}}
*/
{{/if}}
{{#containsSpaces name}}

View File

@ -1,13 +1,13 @@
{{#if description}}
/**
* {{{description}}}
* {{{escapeComment description}}}
*/
{{/if}}
export type {{{name}}} = {
{{#each properties}}
{{#if description}}
/**
* {{{description}}}
* {{{escapeComment description}}}
*/
{{/if}}
{{>isReadOnly}}{{{name}}}{{>isRequired}}: {{>type parent=../name}};
@ -21,7 +21,7 @@ export namespace {{{name}}} {
{{#each enums}}
{{#if description}}
/**
* {{{description}}}
* {{{escapeComment description}}}
*/
{{/if}}
export enum {{{name}}} {

View File

@ -1,6 +1,6 @@
{{#if description}}
/**
* {{{description}}}
* {{{escapeComment description}}}
*/
{{/if}}
export type {{{name}}} = {{>type}};

View File

@ -7,7 +7,7 @@
}: {
{{#each parameters}}
{{#if description}}
/** {{{description}}} **/
/** {{{escapeComment description}}} **/
{{/if}}
{{{name}}}{{>isRequired}}: {{>type}},
{{/each}}

View File

@ -1,7 +1,7 @@
{
type: '{{export}}',
{{#if description}}
description: `{{{description}}}`,
description: `{{{escapeDescription description}}}`,
{{/if}}
contains: [{{#each properties}}{{>schema}}{{#unless @last}}, {{/unless}}{{/each}}],
{{#if isReadOnly}}

View File

@ -3,7 +3,7 @@
type: '{{{type}}}',
{{/if}}
{{#if description}}
description: `{{{description}}}`,
description: `{{{escapeDescription description}}}`,
{{/if}}
{{#if isReadOnly}}
isReadOnly: {{{isReadOnly}}},

View File

@ -1,6 +1,6 @@
{
{{#if description}}
description: `{{{description}}}`,
description: `{{{escapeDescription description}}}`,
{{/if}}
properties: {
{{#if properties}}

View File

@ -3,7 +3,7 @@
{{#each properties}}
{{#if description}}
/**
* {{{description}}}
* {{{escapeComment description}}}
*/
{{/if}}
{{#if ../parent}}

View File

@ -17,5 +17,7 @@ describe('registerHandlebarHelpers', () => {
expect(helpers).toContain('union');
expect(helpers).toContain('intersection');
expect(helpers).toContain('enumerator');
expect(helpers).toContain('escapeComment');
expect(helpers).toContain('escapeDescription');
});
});

View File

@ -1,4 +1,5 @@
import Handlebars from 'handlebars/runtime';
import { EOL } from 'os';
import { Enum } from '../client/interfaces/Enum';
import { Model } from '../client/interfaces/Model';
@ -79,4 +80,15 @@ export function registerHandlebarHelpers(root: {
);
}
);
Handlebars.registerHelper('escapeComment', function (value: string): string {
return value
.replace(/\*\//g, '*')
.replace(/\/\*/g, '*')
.replace(/\r?\n(.*)/g, (_, w) => `${EOL} * ${w.trim()}`);
});
Handlebars.registerHelper('escapeDescription', function (value: string): string {
return value.replace(/\\/g, '\\\\').replace(/`/g, '\\`').replace(/\${/g, '\\${');
});
}

View File

@ -524,6 +524,12 @@ export type { ArrayWithNumbers } from './models/ArrayWithNumbers';
export type { ArrayWithProperties } from './models/ArrayWithProperties';
export type { ArrayWithReferences } from './models/ArrayWithReferences';
export type { ArrayWithStrings } from './models/ArrayWithStrings';
export type { CommentWithBackticks } from './models/CommentWithBackticks';
export type { CommentWithBreaks } from './models/CommentWithBreaks';
export type { CommentWithExpressionPlaceholders } from './models/CommentWithExpressionPlaceholders';
export type { CommentWithQuotes } from './models/CommentWithQuotes';
export type { CommentWithReservedCharacters } from './models/CommentWithReservedCharacters';
export type { CommentWithSlashes } from './models/CommentWithSlashes';
export type { Date } from './models/Date';
export type { DictionaryWithArray } from './models/DictionaryWithArray';
export type { DictionaryWithDictionary } from './models/DictionaryWithDictionary';
@ -553,7 +559,6 @@ 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 { MultilineComment } from './models/MultilineComment';
export type { SimpleBoolean } from './models/SimpleBoolean';
export type { SimpleFile } from './models/SimpleFile';
export type { SimpleInteger } from './models/SimpleInteger';
@ -567,6 +572,12 @@ export { $ArrayWithNumbers } from './schemas/$ArrayWithNumbers';
export { $ArrayWithProperties } from './schemas/$ArrayWithProperties';
export { $ArrayWithReferences } from './schemas/$ArrayWithReferences';
export { $ArrayWithStrings } from './schemas/$ArrayWithStrings';
export { $CommentWithBackticks } from './schemas/$CommentWithBackticks';
export { $CommentWithBreaks } from './schemas/$CommentWithBreaks';
export { $CommentWithExpressionPlaceholders } from './schemas/$CommentWithExpressionPlaceholders';
export { $CommentWithQuotes } from './schemas/$CommentWithQuotes';
export { $CommentWithReservedCharacters } from './schemas/$CommentWithReservedCharacters';
export { $CommentWithSlashes } from './schemas/$CommentWithSlashes';
export { $Date } from './schemas/$Date';
export { $DictionaryWithArray } from './schemas/$DictionaryWithArray';
export { $DictionaryWithDictionary } from './schemas/$DictionaryWithDictionary';
@ -596,7 +607,6 @@ export { $ModelWithPattern } from './schemas/$ModelWithPattern';
export { $ModelWithProperties } from './schemas/$ModelWithProperties';
export { $ModelWithReference } from './schemas/$ModelWithReference';
export { $ModelWithString } from './schemas/$ModelWithString';
export { $MultilineComment } from './schemas/$MultilineComment';
export { $SimpleBoolean } from './schemas/$SimpleBoolean';
export { $SimpleFile } from './schemas/$SimpleFile';
export { $SimpleInteger } from './schemas/$SimpleInteger';
@ -694,6 +704,75 @@ exports[`v2 should generate: ./test/generated/v2/models/ArrayWithStrings.ts 1`]
export type ArrayWithStrings = Array<string>;"
`;
exports[`v2 should generate: ./test/generated/v2/models/CommentWithBackticks.ts 1`] = `
"/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
/**
* Testing backticks in string: \`backticks\` and \`\`\`multiple backticks\`\`\` should work
*/
export type CommentWithBackticks = number;"
`;
exports[`v2 should generate: ./test/generated/v2/models/CommentWithBreaks.ts 1`] = `
"/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
/**
* Testing multiline comments in string: First line
* Second line
*
* Fourth line
*/
export type CommentWithBreaks = number;"
`;
exports[`v2 should generate: ./test/generated/v2/models/CommentWithExpressionPlaceholders.ts 1`] = `
"/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
/**
* Testing expression placeholders in string: \${expression} should work
*/
export type CommentWithExpressionPlaceholders = number;"
`;
exports[`v2 should generate: ./test/generated/v2/models/CommentWithQuotes.ts 1`] = `
"/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
/**
* Testing quotes in string: 'single quote''' and \\"double quotes\\"\\"\\" should work
*/
export type CommentWithQuotes = number;"
`;
exports[`v2 should generate: ./test/generated/v2/models/CommentWithReservedCharacters.ts 1`] = `
"/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
/**
* Testing reserved characters in string: * inline * and ** inline ** should work
*/
export type CommentWithReservedCharacters = number;"
`;
exports[`v2 should generate: ./test/generated/v2/models/CommentWithSlashes.ts 1`] = `
"/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
/**
* Testing slashes in string: \\\\backwards\\\\\\\\\\\\ and /forwards/// should work
*/
export type CommentWithSlashes = number;"
`;
exports[`v2 should generate: ./test/generated/v2/models/Date.ts 1`] = `
"/* istanbul ignore file */
/* tslint:disable */
@ -1225,20 +1304,6 @@ export type ModelWithString = {
"
`;
exports[`v2 should generate: ./test/generated/v2/models/MultilineComment.ts 1`] = `
"/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
/**
* Testing multiline comments.
* This must go to the next line.
*
* This will contain a break.
*/
export type MultilineComment = number;"
`;
exports[`v2 should generate: ./test/generated/v2/models/SimpleBoolean.ts 1`] = `
"/* istanbul ignore file */
/* tslint:disable */
@ -1389,6 +1454,69 @@ export const $ArrayWithStrings = {
} as const;"
`;
exports[`v2 should generate: ./test/generated/v2/schemas/$CommentWithBackticks.ts 1`] = `
"/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
export const $CommentWithBackticks = {
type: 'number',
description: \`Testing backticks in string: \\\\\`backticks\\\\\` and \\\\\`\\\\\`\\\\\`multiple backticks\\\\\`\\\\\`\\\\\` should work\`,
} as const;"
`;
exports[`v2 should generate: ./test/generated/v2/schemas/$CommentWithBreaks.ts 1`] = `
"/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
export const $CommentWithBreaks = {
type: 'number',
description: \`Testing multiline comments in string: First line
Second line
Fourth line\`,
} as const;"
`;
exports[`v2 should generate: ./test/generated/v2/schemas/$CommentWithExpressionPlaceholders.ts 1`] = `
"/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
export const $CommentWithExpressionPlaceholders = {
type: 'number',
description: \`Testing expression placeholders in string: \\\\\${expression} should work\`,
} as const;"
`;
exports[`v2 should generate: ./test/generated/v2/schemas/$CommentWithQuotes.ts 1`] = `
"/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
export const $CommentWithQuotes = {
type: 'number',
description: \`Testing quotes in string: 'single quote''' and \\"double quotes\\"\\"\\" should work\`,
} as const;"
`;
exports[`v2 should generate: ./test/generated/v2/schemas/$CommentWithReservedCharacters.ts 1`] = `
"/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
export const $CommentWithReservedCharacters = {
type: 'number',
description: \`Testing reserved characters in string: /* inline */ and /** inline **/ should work\`,
} as const;"
`;
exports[`v2 should generate: ./test/generated/v2/schemas/$CommentWithSlashes.ts 1`] = `
"/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
export const $CommentWithSlashes = {
type: 'number',
description: \`Testing slashes in string: \\\\\\\\backwards\\\\\\\\\\\\\\\\\\\\\\\\ and /forwards/// should work\`,
} as const;"
`;
exports[`v2 should generate: ./test/generated/v2/schemas/$Date.ts 1`] = `
"/* istanbul ignore file */
/* tslint:disable */
@ -1936,19 +2064,6 @@ export const $ModelWithString = {
} as const;"
`;
exports[`v2 should generate: ./test/generated/v2/schemas/$MultilineComment.ts 1`] = `
"/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
export const $MultilineComment = {
type: 'number',
description: \`Testing multiline comments.
* This must go to the next line.
*
* This will contain a break.\`,
} as const;"
`;
exports[`v2 should generate: ./test/generated/v2/schemas/$SimpleBoolean.ts 1`] = `
"/* istanbul ignore file */
/* tslint:disable */
@ -3251,6 +3366,12 @@ export type { ArrayWithNumbers } from './models/ArrayWithNumbers';
export type { ArrayWithProperties } from './models/ArrayWithProperties';
export type { ArrayWithReferences } from './models/ArrayWithReferences';
export type { ArrayWithStrings } from './models/ArrayWithStrings';
export type { CommentWithBackticks } from './models/CommentWithBackticks';
export type { CommentWithBreaks } from './models/CommentWithBreaks';
export type { CommentWithExpressionPlaceholders } from './models/CommentWithExpressionPlaceholders';
export type { CommentWithQuotes } from './models/CommentWithQuotes';
export type { CommentWithReservedCharacters } from './models/CommentWithReservedCharacters';
export type { CommentWithSlashes } from './models/CommentWithSlashes';
export type { CompositionBaseModel } from './models/CompositionBaseModel';
export type { CompositionExtendedModel } from './models/CompositionExtendedModel';
export type { CompositionWithAllOfAndNullable } from './models/CompositionWithAllOfAndNullable';
@ -3292,7 +3413,6 @@ 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 { MultilineComment } from './models/MultilineComment';
export type { SimpleBoolean } from './models/SimpleBoolean';
export type { SimpleFile } from './models/SimpleFile';
export type { SimpleInteger } from './models/SimpleInteger';
@ -3306,6 +3426,12 @@ export { $ArrayWithNumbers } from './schemas/$ArrayWithNumbers';
export { $ArrayWithProperties } from './schemas/$ArrayWithProperties';
export { $ArrayWithReferences } from './schemas/$ArrayWithReferences';
export { $ArrayWithStrings } from './schemas/$ArrayWithStrings';
export { $CommentWithBackticks } from './schemas/$CommentWithBackticks';
export { $CommentWithBreaks } from './schemas/$CommentWithBreaks';
export { $CommentWithExpressionPlaceholders } from './schemas/$CommentWithExpressionPlaceholders';
export { $CommentWithQuotes } from './schemas/$CommentWithQuotes';
export { $CommentWithReservedCharacters } from './schemas/$CommentWithReservedCharacters';
export { $CommentWithSlashes } from './schemas/$CommentWithSlashes';
export { $CompositionBaseModel } from './schemas/$CompositionBaseModel';
export { $CompositionExtendedModel } from './schemas/$CompositionExtendedModel';
export { $CompositionWithAllOfAndNullable } from './schemas/$CompositionWithAllOfAndNullable';
@ -3347,7 +3473,6 @@ export { $ModelWithPattern } from './schemas/$ModelWithPattern';
export { $ModelWithProperties } from './schemas/$ModelWithProperties';
export { $ModelWithReference } from './schemas/$ModelWithReference';
export { $ModelWithString } from './schemas/$ModelWithString';
export { $MultilineComment } from './schemas/$MultilineComment';
export { $SimpleBoolean } from './schemas/$SimpleBoolean';
export { $SimpleFile } from './schemas/$SimpleFile';
export { $SimpleInteger } from './schemas/$SimpleInteger';
@ -3449,6 +3574,75 @@ exports[`v3 should generate: ./test/generated/v3/models/ArrayWithStrings.ts 1`]
export type ArrayWithStrings = Array<string>;"
`;
exports[`v3 should generate: ./test/generated/v3/models/CommentWithBackticks.ts 1`] = `
"/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
/**
* Testing backticks in string: \`backticks\` and \`\`\`multiple backticks\`\`\` should work
*/
export type CommentWithBackticks = number;"
`;
exports[`v3 should generate: ./test/generated/v3/models/CommentWithBreaks.ts 1`] = `
"/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
/**
* Testing multiline comments in string: First line
* Second line
*
* Fourth line
*/
export type CommentWithBreaks = number;"
`;
exports[`v3 should generate: ./test/generated/v3/models/CommentWithExpressionPlaceholders.ts 1`] = `
"/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
/**
* Testing expression placeholders in string: \${expression} should work
*/
export type CommentWithExpressionPlaceholders = number;"
`;
exports[`v3 should generate: ./test/generated/v3/models/CommentWithQuotes.ts 1`] = `
"/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
/**
* Testing quotes in string: 'single quote''' and \\"double quotes\\"\\"\\" should work
*/
export type CommentWithQuotes = number;"
`;
exports[`v3 should generate: ./test/generated/v3/models/CommentWithReservedCharacters.ts 1`] = `
"/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
/**
* Testing reserved characters in string: * inline * and ** inline ** should work
*/
export type CommentWithReservedCharacters = number;"
`;
exports[`v3 should generate: ./test/generated/v3/models/CommentWithSlashes.ts 1`] = `
"/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
/**
* Testing slashes in string: \\\\backwards\\\\\\\\\\\\ and /forwards/// should work
*/
export type CommentWithSlashes = number;"
`;
exports[`v3 should generate: ./test/generated/v3/models/CompositionBaseModel.ts 1`] = `
"/* istanbul ignore file */
/* tslint:disable */
@ -4201,20 +4395,6 @@ export type ModelWithString = {
"
`;
exports[`v3 should generate: ./test/generated/v3/models/MultilineComment.ts 1`] = `
"/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
/**
* Testing multiline comments.
* This must go to the next line.
*
* This will contain a break.
*/
export type MultilineComment = number;"
`;
exports[`v3 should generate: ./test/generated/v3/models/SimpleBoolean.ts 1`] = `
"/* istanbul ignore file */
/* tslint:disable */
@ -4365,6 +4545,69 @@ export const $ArrayWithStrings = {
} as const;"
`;
exports[`v3 should generate: ./test/generated/v3/schemas/$CommentWithBackticks.ts 1`] = `
"/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
export const $CommentWithBackticks = {
type: 'number',
description: \`Testing backticks in string: \\\\\`backticks\\\\\` and \\\\\`\\\\\`\\\\\`multiple backticks\\\\\`\\\\\`\\\\\` should work\`,
} as const;"
`;
exports[`v3 should generate: ./test/generated/v3/schemas/$CommentWithBreaks.ts 1`] = `
"/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
export const $CommentWithBreaks = {
type: 'number',
description: \`Testing multiline comments in string: First line
Second line
Fourth line\`,
} as const;"
`;
exports[`v3 should generate: ./test/generated/v3/schemas/$CommentWithExpressionPlaceholders.ts 1`] = `
"/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
export const $CommentWithExpressionPlaceholders = {
type: 'number',
description: \`Testing expression placeholders in string: \\\\\${expression} should work\`,
} as const;"
`;
exports[`v3 should generate: ./test/generated/v3/schemas/$CommentWithQuotes.ts 1`] = `
"/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
export const $CommentWithQuotes = {
type: 'number',
description: \`Testing quotes in string: 'single quote''' and \\"double quotes\\"\\"\\" should work\`,
} as const;"
`;
exports[`v3 should generate: ./test/generated/v3/schemas/$CommentWithReservedCharacters.ts 1`] = `
"/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
export const $CommentWithReservedCharacters = {
type: 'number',
description: \`Testing reserved characters in string: /* inline */ and /** inline **/ should work\`,
} as const;"
`;
exports[`v3 should generate: ./test/generated/v3/schemas/$CommentWithSlashes.ts 1`] = `
"/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
export const $CommentWithSlashes = {
type: 'number',
description: \`Testing slashes in string: \\\\\\\\backwards\\\\\\\\\\\\\\\\\\\\\\\\ and /forwards/// should work\`,
} as const;"
`;
exports[`v3 should generate: ./test/generated/v3/schemas/$CompositionBaseModel.ts 1`] = `
"/* istanbul ignore file */
/* tslint:disable */
@ -5239,19 +5482,6 @@ export const $ModelWithString = {
} as const;"
`;
exports[`v3 should generate: ./test/generated/v3/schemas/$MultilineComment.ts 1`] = `
"/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
export const $MultilineComment = {
type: 'number',
description: \`Testing multiline comments.
* This must go to the next line.
*
* This will contain a break.\`,
} as const;"
`;
exports[`v3 should generate: ./test/generated/v3/schemas/$SimpleBoolean.ts 1`] = `
"/* istanbul ignore file */
/* tslint:disable */

View File

@ -856,8 +856,28 @@
}
},
"definitions": {
"MultilineComment": {
"description": "Testing multiline comments.\nThis must go to the next line.\n\nThis will contain a break.",
"CommentWithBreaks": {
"description": "Testing multiline comments in string: First line\nSecond line\n\nFourth line",
"type": "integer"
},
"CommentWithBackticks": {
"description": "Testing backticks in string: `backticks` and ```multiple backticks``` should work",
"type": "integer"
},
"CommentWithSlashes": {
"description": "Testing slashes in string: \\backwards\\\\\\ and /forwards/// should work",
"type": "integer"
},
"CommentWithExpressionPlaceholders": {
"description": "Testing expression placeholders in string: ${expression} should work",
"type": "integer"
},
"CommentWithQuotes": {
"description": "Testing quotes in string: 'single quote''' and \"double quotes\"\"\" should work",
"type": "integer"
},
"CommentWithReservedCharacters": {
"description": "Testing reserved characters in string: /* inline */ and /** inline **/ should work",
"type": "integer"
},
"SimpleInteger": {

View File

@ -1429,8 +1429,28 @@
}
},
"schemas": {
"MultilineComment": {
"description": "Testing multiline comments.\nThis must go to the next line.\n\nThis will contain a break.",
"CommentWithBreaks": {
"description": "Testing multiline comments in string: First line\nSecond line\n\nFourth line",
"type": "integer"
},
"CommentWithBackticks": {
"description": "Testing backticks in string: `backticks` and ```multiple backticks``` should work",
"type": "integer"
},
"CommentWithSlashes": {
"description": "Testing slashes in string: \\backwards\\\\\\ and /forwards/// should work",
"type": "integer"
},
"CommentWithExpressionPlaceholders": {
"description": "Testing expression placeholders in string: ${expression} should work",
"type": "integer"
},
"CommentWithQuotes": {
"description": "Testing quotes in string: 'single quote''' and \"double quotes\"\"\" should work",
"type": "integer"
},
"CommentWithReservedCharacters": {
"description": "Testing reserved characters in string: /* inline */ and /** inline **/ should work",
"type": "integer"
},
"SimpleInteger": {
@ -1873,7 +1893,7 @@
},
"radius": {
"type": "number"
}
}
}
},
"ModelSquare": {