springspring-bootopenapi-generatorspring-validatorspring-validation

openapi generates minimum and maximum which is not working properly


openapi minimum/maximum

put:
      summary: add
      operationId: add
      requestBody:
        description: value
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Value'
components:
  schemas:
    Value:
      type: object
      required:
        - value
      properties:
        value:
          type: integer
          format: int64
          minimum: 1
          maximum: 999

generates

@Min(1L) @Max(999L) 
  public Long getValue() {
    return value;
  }

Which is not working properly. I try

mockMvc.perform(
                        put(RESOURCE_URL + "/1/add")
                                .contentType(MediaType.APPLICATION_JSON)
                                .content("{\"value\":0}"))

I've no idea is it API problem or spring @Min(1L) @Max(999L) validator problem?


Solution

  • dependencies {
      ...
      implementation 'org.springframework.boot:spring-boot-starter-validation'
    }