openapi-processor/openapi-processor-spring

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

Closed this issue · 2 comments

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.

great, another bean validation round. ;-)

fixed in core 2021.5.1