This repository was archived by the owner on Nov 30, 2024. It is now read-only.
[BUG] Regex patterns without trailing slashes break Python client generation #11
Closed
5 of 6 tasks
Uh oh!
There was an error while loading. Please reload this page.
Bug Report Checklist
Description
When trying to generate a Python client SDK for a simple openAPI spec with an id with a given regex pattern, the generation fails with error
Caused by: com.github.curiousoddman.rgxgen.parsing.dflt.RgxGenParseException: Unbalanced '{' - missing '}' at 'F0-9]{12'
and (partial) stack traceThis is not specific to the regex expression in my example and should happen with any regex that does not have ah extra char at the end that can be stripped without compromising the check that should be done.
openapi-generator version
6.0.0
OpenAPI declaration file content or url
Generation Details
Regular maven plugin generation with
<generatorName>python</generatorName>
Steps to reproduce
<inputSpec>
linking to the file created in 1Unbalanced '{' - missing '}' at 'F0-9]{12'
Related issues/PRs
Suggest a fix
The problem seems to be with the REGEX in https://github.com/OpenAPITools/openapi-generator/blame/0c825ad3019e76b9d85e9883ef960a4643277c54/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientCodegen.java#L1179 where it should only strip of leading
/
, trailing/
or trailing/i
.However, this REGEX is placing ANY final char into the second group, which means that in the case represented in this issue the main group will be
[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12
, because the final}
is being captured as part of group 2.Examples here: https://regex101.com/r/4YqK9h/1
I think what we want is something like
^/?(.+?)/?(i?)$
as shown in https://regex101.com/r/RAxPJU/1, where we really only capture trailing/
or/i
, not any last character that might be in the pattern.The text was updated successfully, but these errors were encountered: