-
Notifications
You must be signed in to change notification settings - Fork 436
issue-9509 adding support to v3. Escaping for ref defined patterns #1346
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
base: master
Are you sure you want to change the base?
Conversation
@@ -3185,7 +3185,7 @@ private void addVars(CodegenModel codegenModel, List<CodegenProperty> vars, Map< | |||
if (this.openAPI == null) { | |||
LOGGER.warn("open api utility object was not properly set."); | |||
} else { | |||
OpenAPIUtil.addPropertiesFromRef(this.openAPI, propertySchema, codegenProperty); | |||
OpenAPIUtil.addPropertiesFromRef(this.openAPI, propertySchema, codegenProperty, this::toRegularExpression); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we want to use toRegularExpression
defined in child classes like AbstractJavaCodegen
or TypeScriptAxiosClientCodegen
.
Thus, we pass it as a Function<T,T>
(UnaryOperator<String>
) instead of implementing it in OpenAPIUtil
CodegenProperty urlProperty = codegenModel.vars.get(0); | ||
Assert.assertEquals(urlProperty.getName(), "url"); | ||
//verifying java pattern is properly escaped | ||
Assert.assertEquals(urlProperty.getPattern(), SSN_ESCAPED_PATTERN); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so basically we verify that ^\d{3}-\d{2}-\d{4}$
pattern is transformed to ^\\d{3}-\\d{2}-\\d{4}$
when AbstractJavaCodegen
is used
@frantuma Hey Francesco, may I ask you to check this one, once you have time. |
as was already stated in swagger-api/swagger-codegen#9509
tho, it was fixed in v2 of swagger-codegen
#1100
swagger-api/swagger-codegen#12038
it remains broken for swagger v3,
This change is intended to fix it in v3 as well, since v3 swagger-codegen uses
DefaultCodegenConfig
defined in this library