Closed boyi01 closed 7 months ago
@boyi01 feel free to send a PR to fix this initialization procedure for non-required fields.
@ricardozanini Before i go deeply into this problem, is my assumption correct that the quarkus-openapi-generator is using the openapi java generator or do we use the javajxRS or some other generator?
We use the openapi java generator under the hood, but with our own configurations and templates to match Quarkus ecosystem. The idea is to change to apicurio generator in the future.
@ricardozanini Thank you, now i found the place of the Problem.
The critical question now is, how to fix Problem, because in my opinion there two options:
I prefer option 1, cause it's similar to openapi. I'm not sure if a parameter is needed, because it should not break anything...
I'd go for option 1 too, shouldn't break anything :)
Hello
I tried to use our openapi Generator with this version, because it fits our needs very well and we use Quarkus.
When in the model there is a field, that is for example a list and is not diffined as requierd in the yaml, then in the add method there is no initialization, if this field is null.
For requierd fields this no problem because the default openapi-generator paramter for the config containerDefaultToNull is false, which results in a default initialization. For non requierd fields this is not happening.
I'm surprised because in all openapi java pojo.mustache the template is (in the microprofile too) somehow like this
public {{classname}} add{{nameInCamelCase}}Item({{{items.datatypeWithEnum}}} {{name}}Item) { if (this.{{name}} == null) { this.{{name}} = {{{defaultValue}}}{{^defaultValue}}new {{#uniqueItems}}LinkedHashSet{{/uniqueItems}}{{^uniqueItems}}ArrayList{{/uniqueItems}}<>(){{/defaultValue}}; } this.{{name}}.add({{name}}Item); return this; }
I'm kind of confused why the initialization part can't be found in the generated code.Can somebody give a hint?
I'm open to constribute a solution, if this bevaivor is an error.