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

[BUG] [JAVA] [OKHTTP-GSON] Annotations added at invalid location since 7.13.0 regression

Open Viserius opened this issue 8 months ago • 0 comments

Bug Report Checklist

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

The openapi.yaml specification I used for 7.12.0 did not produce any compilation errors, whereas updating to 7.13.0 without any other change results in the following compile-time exception inside each of the fooApi.java: no annotations are allowed in the type of a class literal.

The exception occurs inside each getXXValidateBeforeCall on the following line: Method method = this.getClass().getMethod("getXXWithHttpInfo", @jakarta.annotation.Nonnull String.class, @jakarta.annotation.Nonnull String.class);

The error is caused by the @jakarta.annotation.Nonnull annotation on the type String.class. This annotation is probably applied in our case since we have a path parameter set with required: true

openapi-generator version

Since 7.13.0. This is a regression.

OpenAPI declaration file content or url
  /foo/{bar}:
    get:
      tags:
      - baz
      operationId: getXX
      parameters:
      - name: bar
        in: path
        required: true
        schema:
          type: string

-->

Generation Details

https://gist.github.com/Viserius/f1ecdd2e1d63669886aa5ee8a62c474c

Steps to reproduce

Should be evident from generation details and spec. Have a path parameter of type string set to required: true.

Related issues/PRs

None that I know of

Suggest a fix

Viserius avatar Jun 02 '25 06:06 Viserius