We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Swagger is generating a file with syntax errors when retrofit2 is used since v3.0.52. This seems to be caused by a duplicated if statement:
// 401/403 most likely indicates that access token has expired. Unless it happens two times in a row. if ( response != null && (response.code() == HTTP_UNAUTHORIZED || response.code() == HTTP_FORBIDDEN) && updateTokenAndRetryOnAuthorizationFailure ) { if ( response != null && (response.code() == HTTP_UNAUTHORIZED || response.code() == HTTP_FORBIDDEN) && updateTokenAndRetryOnAuthorizationFailure ) { try {
The second if should not have been inserted, so the { has no matching }.
if
{
}
Attempting to compile this file will print this error:
test\auth\OAuth.java:136: error: illegal start of expression public synchronized boolean updateAccessToken(String requestAccessToken) throws IOException { ^ 1 error
Because of this error, I am unable to use the generated code. Mitigation: staying in v3.0.51
Works in v3.0.51, fails in both v3.0.52 and in v3.0.62-20240826.194328-3 (latest snapshot, I think).
Issue can be replicated with:
openapi: 3.0.1 info: title: OpenAPI definition paths: '/foo': get: description: 'Foo' operationId: foo
java -jar <swagger-codegen-cli-jar-path> generate --model-package=test.models --api-package=test.api --library=retrofit2 -l java -o dist/ -i schema.yaml
Run the command above.
Inspect generated dist/src/main/java/test/auth/OAuth.java
Expected: file has no syntax errors
Actual: an if statement appears twice, leading to a syntax error.
I couldn't find anything.
Remove the duplicated if. I have no idea what puts it there.
The text was updated successfully, but these errors were encountered:
I see the same issue with v3.0.62
Sorry, something went wrong.
same here with v3.0.64 :(
My workaround is to apply a patch after the file generation to remove the extra line.
No branches or pull requests
Description
Swagger is generating a file with syntax errors when retrofit2 is used since v3.0.52.
This seems to be caused by a duplicated if statement:
The second
if
should not have been inserted, so the{
has no matching}
.Attempting to compile this file will print this error:
Because of this error, I am unable to use the generated code. Mitigation: staying in v3.0.51
Swagger-codegen version
Works in v3.0.51, fails in both v3.0.52 and in v3.0.62-20240826.194328-3 (latest snapshot, I think).
Swagger declaration file content or url
Issue can be replicated with:
Command line used for generation
Steps to reproduce
Run the command above.
Inspect generated dist/src/main/java/test/auth/OAuth.java
Expected: file has no syntax errors
Actual: an if statement appears twice, leading to a syntax error.
Related issues/PRs
I couldn't find anything.
Suggest a fix/enhancement
Remove the duplicated if. I have no idea what puts it there.
The text was updated successfully, but these errors were encountered: