diff --git a/src/parser.ts b/src/parser.ts index 6add6efa..a52479fc 100644 --- a/src/parser.ts +++ b/src/parser.ts @@ -414,7 +414,7 @@ function parseSchema( map(schema.patternProperties, (value, key: string) => { const ast = parse(value, options, key, processed, usedNames) const comment = `This interface was referenced by \`${parentSchemaName}\`'s JSON-Schema definition -via the \`patternProperty\` "${key}".` +via the \`patternProperty\` "${key.replace('*/', '*\\/')}".` ast.comment = ast.comment ? `${ast.comment}\n\n${comment}` : comment return { ast, diff --git a/test/__snapshots__/test/test.ts.md b/test/__snapshots__/test/test.ts.md index c83bd491..43fcff5a 100644 --- a/test/__snapshots__/test/test.ts.md +++ b/test/__snapshots__/test/test.ts.md @@ -2437,6 +2437,46 @@ Generated by [AVA](https://avajs.dev). }␊ ` +## patternProperties.7.js + +> Expected output to match snapshot for e2e test: patternProperties.7.js + + `/* eslint-disable */␊ + /**␊ + * This file was automatically generated by json-schema-to-typescript.␊ + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,␊ + * and run json-schema-to-typescript to regenerate this file.␊ + */␊ + ␊ + export interface PatternProperties {␊ + /**␊ + * This interface was referenced by \`PatternProperties\`'s JSON-Schema definition␊ + * via the \`patternProperty\` "^[a-z][a-z0-9-]*\\/[a-z][a-z0-9-]*$".␊ + */␊ + [k: string]: string;␊ + }␊ + ` + +## patternProperties.8.js + +> Expected output to match snapshot for e2e test: patternProperties.8.js + + `/* eslint-disable */␊ + /**␊ + * This file was automatically generated by json-schema-to-typescript.␊ + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,␊ + * and run json-schema-to-typescript to regenerate this file.␊ + */␊ + ␊ + export interface PatternProperties {␊ + /**␊ + * This interface was referenced by \`PatternProperties\`'s JSON-Schema definition␊ + * via the \`patternProperty\` "^[a-z][a-z0-9-]/*[a-z][a-z0-9-]*$".␊ + */␊ + [k: string]: string;␊ + }␊ + ` + ## realWorld.awsQuicksight.js > Expected output to match snapshot for e2e test: realWorld.awsQuicksight.js diff --git a/test/__snapshots__/test/test.ts.snap b/test/__snapshots__/test/test.ts.snap index 4d3e02b7..cae91b34 100644 Binary files a/test/__snapshots__/test/test.ts.snap and b/test/__snapshots__/test/test.ts.snap differ diff --git a/test/e2e/patternProperties.7.ts b/test/e2e/patternProperties.7.ts new file mode 100644 index 00000000..a22a10f3 --- /dev/null +++ b/test/e2e/patternProperties.7.ts @@ -0,0 +1,9 @@ +// @see https://github.com/bcherny/json-schema-to-typescript/issues/546 +export const input = { + type: 'object', + patternProperties: { + '^[a-z][a-z0-9-]*/[a-z][a-z0-9-]*$': { + type: 'string', + }, + }, +} diff --git a/test/e2e/patternProperties.8.ts b/test/e2e/patternProperties.8.ts new file mode 100644 index 00000000..ddde28f1 --- /dev/null +++ b/test/e2e/patternProperties.8.ts @@ -0,0 +1,9 @@ +// @see https://github.com/bcherny/json-schema-to-typescript/issues/546 +export const input = { + type: 'object', + patternProperties: { + '^[a-z][a-z0-9-]/*[a-z][a-z0-9-]*$': { + type: 'string', + }, + }, +}