···5555};
56565757/**
5858+ * Matches characters inside square brackets, including the brackets. Does not
5959+ * match if the opening bracket is preceded by "`1" which is a syntax for generics
6060+ * from C#.
6161+ *
6262+ * Hello[World] -> matches [World]
6363+ * Hello`1[World] -> no match
6464+ * string[] -> matches []
6565+ */
6666+export const hasSquareBracketsRegExp = /(?<!`1)\[.*\]$/g;
6767+6868+/**
5869 * Parse any string value into a type object.
5970 * @param type String or String[] value like "integer", "Link[Model]" or ["string", "null"].
6071 * @param format String value like "binary" or "date".
6172 */
6273export const getType = ({
6363- // eslint-disable-next-line @typescript-eslint/no-unused-vars
6474 debug,
6575 format,
6676 type = 'unknown',
···104114105115 const typeWithoutNamespace = decodeURIComponent(stripNamespace(type));
106116107107- if (/\[.*\]$/g.test(typeWithoutNamespace)) {
117117+ hasSquareBracketsRegExp.lastIndex = 0;
118118+ if (hasSquareBracketsRegExp.test(typeWithoutNamespace)) {
108119 const matches = typeWithoutNamespace.match(/(.*?)\[(.*)\]$/);
109120 if (matches?.length) {
110121 const match1 = getType({
122122+ debug,
111123 type: ensureValidTypeScriptJavaScriptIdentifier(matches[1]),
112124 });
113125 const match2 = getType({
126126+ debug,
114127 type: ensureValidTypeScriptJavaScriptIdentifier(matches[2]),
115128 });
116129