Open robogeek opened 11 months ago
Hello, this is just a simple cli tool to automate https://github.com/StefanTerdell/json-schema-to-zod for all the components of an OpenAPI scheme after dereferencing them. If you think there is something at fault at parsing the schema, that repository is probably the place to address it.
However, I don't think OpenAPI allows unquoted regexes. Because they don't even get parsed by json parsers or yaml parsers as regex objects. They are just assumed strings.
The spec I'm using has specified some strings with a
pattern
field where the regular expression is delineated with slashes. For example:I was not able to find if this is legitimate OpenAPI. In the Swagger specification it shows a quoted string with no slashes, rather than an unquoted string with slashes like here.
The generated code for the above is:
This fails on recognizing the string I fed it. The RegExp object is defined (in MSDN) to take either a quoted string with no slashes, or an unquoted string with slashes. The latter is directly recognized in JavaScript as a regular expression.
QUESTION: Is an unquoted string with slashes allowed in OpenAPI to specify a regular expression?
If so, then this library should recognize that case, and pass through a RegExp literal.