openapi-generator icon indicating copy to clipboard operation
openapi-generator copied to clipboard

[BUG] openApiNullable=false is ignored by spring generator

Open pmconrad-dvag opened this issue 1 year ago • 4 comments

Bug Report Checklist

  • [ ] Have you provided a full/minimal spec to reproduce the issue?
  • [ ] Have you validated the input using an OpenAPI validator?
  • [ ] Have you tested with the latest master to confirm the issue still exists?
  • [ ] Have you searched for related issues/PRs?
  • [ ] What's the actual output vs expected output?
  • [ ] [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

Output with 7.13: @Parameter(name = "comment", description = "", in = ParameterIn.QUERY) @Valid @RequestParam(value = "comment", required = false) String comment

Output with 7.14: @Parameter(name = "comment", description = "", in = ParameterIn.QUERY) @Valid @RequestParam(value = "comment", required = false) @Nullable String comment

openapi-generator version

7.14

OpenAPI declaration file content or url
Generation Details
Steps to reproduce
Related issues/PRs

I believe the root of the problem was introduced here in nullableAnnotation.mustache, where @Nullable is added regardless of the openApiNullable setting. So far this hasn't caused problems for us, but through this commit since 7.14 this nullableAnnotation is being used in many places where it now causes a problem for us.

Suggest a fix

pmconrad-dvag avatar Jun 26 '25 12:06 pmconrad-dvag

openApiNullable is a different thing from the nullable annotations that have been introduced. As described here it is for "Enable OpenAPI Jackson Nullable library.".

Mattias-Sehlstedt avatar Jun 26 '25 20:06 Mattias-Sehlstedt

Same problem here. Working code with version 7.13 results in a compile error with 7.14: Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type 'Organization?'

PaKu5 avatar Jul 01 '25 13:07 PaKu5

The issue and its fix will most likely be tracked here.

Mattias-Sehlstedt avatar Jul 01 '25 13:07 Mattias-Sehlstedt

Fixed in 7.16. Thanks!

pmconrad-dvag avatar Sep 30 '25 09:09 pmconrad-dvag