Skip to content

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

Open
@Viserius

Description

@Viserius

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

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions