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?
3.0.8
definitions:
Amount:
type: string
pattern: '^\d{1,13}\.\d{1,5}$'
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
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
Wrong java code generated:
@Pattern(regexp="^\d{1,13}\.\d{1,5}$")
Right code generated should be: \
@Pattern(regexp="^\\d{1,13}\\.\\d{1,5}$")
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
``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
Most helpful comment
Still a problem with 3.0.21