openapi-processor / openapi-processor-spring

an OpenAPI 3.0 & 3.1 interface & model java code generator for Spring Boot
https://docs.openapiprocessor.io
Apache License 2.0
40 stars 9 forks source link

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

Closed schlagi123 closed 3 years ago

schlagi123 commented 3 years ago

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.

hauner commented 3 years ago

great, another bean validation round. ;-)

hauner commented 3 years ago

fixed in core 2021.5.1