You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
NOTE: That the out of the box templates do NOT use the pattern field. For my needs I have adjusted the mustache templates to include them. So to reproduce you might have to do the same.
Actual vs. Expected output:
{{{pattern}}} is /^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)$/
{{{pattern}}} should be /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/
Apply the same patch that was done for typescript-axios and override the toRegularExpression method in TypeScriptAngularClientCodegen.java
A full fix for all typescript based client (as all typescript generators will eventually face the same problem)
Override the toRegularExpression method in the AbstractTypeScriptClientCodegen.java abstract base class.
The implementation will be the same regardless of the option choosen (just the location would change). Here is that code:
/** * Overriding toRegularExpression() to avoid escapeText() being called, * as it would return a broken regular expression if any escaped character / metacharacter were present. */@OverridepublicStringtoRegularExpression(Stringpattern) {
returnaddRegularExpressionDelimiter(pattern);
}
The text was updated successfully, but these errors were encountered:
Bug Report Checklist
Description
This issue has been raised and fixed years ago for the
typescript-axios
client:I feel like the problem it is sufficiently described, so not adding any more details here.
Example:
{{{pattern}}}
is/^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)$/
{{{pattern}}}
should be/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/
openapi-generator version
Steps to reproduce
Include this pattern in your OpenAPI spec
Run the
typescript-angular
generatormustache
templates to include them. So to reproduce you might have to do the same.Actual vs. Expected output:
{{{pattern}}}
is/^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)$/
{{{pattern}}}
should be/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/
Related issues/PRs
Suggest a fix
Two options here:
typescript-angular
onlytoRegularExpression
method inTypeScriptAngularClientCodegen.java
typescript
based client (as all typescript generators will eventually face the same problem)toRegularExpression
method in theAbstractTypeScriptClientCodegen.java
abstract base class.The implementation will be the same regardless of the option choosen (just the location would change). Here is that code:
The text was updated successfully, but these errors were encountered: