-
Notifications
You must be signed in to change notification settings - Fork 6k
[JavaSpring] Bug generating @Pattern regex #9509
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
Comments
I'm having the same problem now ... we have just updated to the version from 2.3.1 to 2.4.5 |
Facing the same issue, while working with https://github.com/jdegre/5GC_APIs/raw/master/TS29571_CommonData.yaml Mnc:
type: string
pattern: '^\d{2,3}$'
`
Generated output includes below error: java: **illegal escape character**
```java
@Pattern(regexp="^\d{2,3}$") public String getMnc() {
return mnc;
}
` |
Still a problem with 3.0.21 |
and also in 3.0.23. This is open since nearly 2 years. Does anyone have a workaround? |
Hi @volkerrichert , Yes, we're working on this, and any PR is always welcome |
Hello @HugoMario, I've run into the same problem (single forward slash instead of double, for my regex) while invoking the 3.0.24 jar on my own spec, but for jaxrs-jersey What is the progress on this issue for both spring and jaxrs-jersey? Thank you! |
I can confirm the same issue for version 2.4.19 |
Weird enough, if you provide an example in the definition then the pattern is correctly generated, unless you reference a scalar type with |
Is there any progress on this issue?
As a workaround we are using
This one gegerates the correct code |
Description
When generating from this yaml file:
https://raw.githubusercontent.com/OpenBankingUK/account-info-api-spec/master/dist/v2.0.0/account-info-swagger.yaml
Regex pattern like this '^\d{1,13}.\d{1,5}$' are not escape property and the generated java code does not compile.
To discuss: Should the code generation be responsible for escaping the regex properly for every language? or Should I modify the YAML to provide the appropriated escape?
Swagger-codegen version
3.0.8
Swagger declaration file content or url
Command line used for generation
swagger-codegen generate -i https://raw.githubusercontent.com/OpenBankingUK/account-info-api-spec/master/dist/v2.0.0/account-info-swagger.yaml -l spring -o api-server
Steps to reproduce
swagger-codegen generate -i https://raw.githubusercontent.com/OpenBankingUK/account-info-api-spec/master/dist/v2.0.0/account-info-swagger.yaml -l spring -o api-account
mvn install
Related issues/PRs
Suggest a fix/enhancement
Wrong java code generated:
Right code generated should be: \
The text was updated successfully, but these errors were encountered: