Reputation: 1460
I'm using swagger-codegen-maven
(3.0.29
) plugin to generate code. However, I see that boolean
is generated with isXXX
instead of getXXX
. Is there a way to generate getXXX
.
swagger code
Data:
required:
- id
properties:
verified:
description: >-
Id
example: true
pattern: ^true|false$
type: boolean
generated code
@NotNull
@Schema(example = "true", required = true)
public Boolean isVerified() {
return verified;
}
public void setVerified(Boolean verified) {
this.verified = verified;
}
}
Upvotes: 1
Views: 4031
Reputation: 41
The author of the question asked a solution for "swagger-codegen-maven" which is not the openAPI generator. Actually, the openAPI variation for code generation fixed this specific issue, while swagger codegen still did not:
https://github.com/swagger-api/swagger-codegen-generators/pull/599
I used a shell script command on the generated files:
sed -i'' -e 's/Boolean is/Boolean get/g' $(find generated-sources/src/main/java/com/company//module/openapi/ -type f)
Upvotes: 0
Reputation: 60
According to their github issues, that enhancement is available on 3.1.x of OpenAPI-generator and that will have to be implemented on swagger-codegen-maven which currently seems to be not implemented.
Version 3.1.0 is the first minor version of OpenAPI-Generator, in comparison to 3.0.3 it contains some breaking changes, but with the possibility to fallback to the old behavior. The default value of some options might change. Projects relying on generated code might need to be adapted.
Please, check out the issues.
Upvotes: 1