swagger-codegen contains a template-driven engine to generate documentation, API clients and server stubs in different languages by parsing your OpenAPI / Swagger definition.
Generate harbor golang client sdk by harbor api swagger yaml
After the client sdk code generated, some code that can never be reached
Example in api_health.go :
if localVarHttpResponse.StatusCode >= 300 {
newErr := GenericSwaggerError{
body: localVarBody,
error: localVarHttpResponse.Status,
}
if localVarHttpResponse.StatusCode == 200 {
var v OverallHealthStatus
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHttpResponse, newErr
}
newErr.model = v
return localVarReturnValue, localVarHttpResponse, newErr
}
if localVarHttpResponse.StatusCode == 500 {
var v Errors
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHttpResponse, newErr
}
newErr.model = v
return localVarReturnValue, localVarHttpResponse, newErr
}
return localVarReturnValue, localVarHttpResponse, newErr
}
The condition localVarHttpResponse.StatusCode == 200 inside localVarHttpResponse.StatusCode >= 300 , it's never be reached.
Description
Generate harbor golang client sdk by harbor api swagger yaml After the client sdk code generated, some code that can never be reached Example in
api_health.go
:The condition
localVarHttpResponse.StatusCode == 200
insidelocalVarHttpResponse.StatusCode >= 300
, it's never be reached.Swagger-codegen version
2.4.21
Swagger declaration file content or url
https://github.com/goharbor/harbor/blob/master/api/v2.0/swagger.yaml Raw: https://raw.githubusercontent.com/goharbor/harbor/master/api/v2.0/swagger.yaml
Command line used for generation
Steps to reproduce
java -jar swagger-codegen-cli.jar generate -i https://raw.githubusercontent.com/goharbor/harbor/master/api/v2.0/swagger.yaml -l go -o ./harbor-api
cat ./harbor-api/api_health.go
Related issues/PRs
N/A
Suggest a fix/enhancement
N/A