Skip to content

[BUG] x-field-extra-annotation for spring generator produces invalid Java source #19953

@wilx

Description

@wilx

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • 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?
Description

The Java Spring generator produces invalid Java source. The documentation suggests that the x-field-extra-annotation parameter is a list of extra annotations:

List of custom annotations to be added to property

However, in generated code it outputs the annotations between [] and also multiple times when there are multiple annotations in the list, e.g.:

[@MyAnnotation, @My2ndAnnotation] [@MyAnnotation, @My2ndAnnotation] @Parameter(name = "status", description = "", in = ParameterIn.QUERY) @Valid @RequestParam(value = "status", required = false) String status
openapi-generator version

7.9.0

OpenAPI declaration file content or url
openapi: 3.0.3
info:
  title: Test
  version: 0.0.1
tags:
  - name: Test
paths:
  /pet/findByStatus:
    get:
      tags:
        - Test
      operationId: findPetsByStatus
      parameters:
        - name: status
          x-field-extra-annotation:
            - '@MyAnnotation'
            - '@My2ndAnnotation'
          in: query
          required: false
          schema:
            type: string
      responses:
        '204':
          description: successful operation
Generation Details
Steps to reproduce

Run with the OpenAPI document above.

java -jar openapi-generator-cli.jar generate -i min.yml -g spring
Related issues/PRs
Suggest a fix

The list of the annotations should be concatenated with a space.

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