New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Regular expression string pattern in OAS yield uncompilable typescript due to unnecessary escaping #195
Comments
/
Here is a pull request containing a failing test showing this behavior: |
good catch ! if you do want to fix that, please add a changeset 🙏 |
I haven't used changeset before, but I attempted to do that. |
I see that you merged #197. I'm interested in trying it out, but it looks like there was not a new patch version published. Was that intentional? |
yes, a release only happens when merging the PR that the changeset CLI creates this one for example you can still try the PR by going on the branch, i'll wait for your confirmation before merging the release PR |
@astahmer it looks like you merged the PRs without my confirmation. I think there should be a handful of tests containing regular expressions both escaping and not escaping different slashes and using character groups etc. I also think part of the test condition should be making sure the resultant code compiles. |
my bad, shouldnt have merged this PR initially. I had to merge cause it was blocking the main changeset PR in the meantime* thought you were done after this message but I misnterpreted:
|
I haven't had time to go back to this, but I'm confident that there is still a bug in the current version around this behavior. |
With the current version (1.11.1), this particular pattern in the spec is incorrectly generated (the escapes are not added to the generated code): Pattern in spec: |
@astahmer would you be able to fix this bug with regular expression translation? |
@astahmer I spent a good amount of time trying to understand what's going on and in the end I corrected the test and reverted the change you merged: I think this PR is a better outcome for most user situations and in the description and in-line comments I describe what's going on and what happened. String escaping is tedious to think about carefully! |
Minimal spec with a regex that has an escape character:
Output:
This does not compile. Compile errors:
Probably the right output for the
regexmatch
would be:Probably this is implemented here or maybe here.
The text was updated successfully, but these errors were encountered: