Skip to content

Bean validation annotations are not generated for items of a response array #132

Closed
@schlagi123

Description

@schlagi123

Hi,

I have the following configuration:

mappings.yaml

openapi-processor-mapping: v2

options:
  package-name: test
  bean-validation: true
  model-name-suffix: Resource

map:
  types:
    - type: array => java.util.List

openapi.yaml

openapi: 3.0.2
info:
  title: title
  version: 1.0.0

paths:
  /foo:
    post:
      operationId: bar
      tags:
        - bar
      requestBody:
        content:
          application/json:
            schema:
              type: array
              items:
                type: string
                minLength: 2
                maxLength: 2
      responses:
        200:
          description: Description

The result is:

public interface BarApi {

    @PostMapping(
            path = "/foo",
            consumes = {"application/json"})
    void bar(@RequestBody(required = false) List<String> body);

}

I expect:

public interface BarApi {

    @PostMapping(
            path = "/foo",
            consumes = {"application/json"})
    void bar(@RequestBody(required = false) List<@Size(min = 2, max = 2) String> body);

}

It seems, as bean validation annotations is not generated in the generic type of a body list.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions