[BUG] [SPRING] Missing Java Bean Validation annotations on RequestBody
Created by: Mintas
Description
We are unable to generate beanValidation annotations for RequestBody params. Looks like the feature was missing in revision 8952815b
Proposed changes should cover this bug and allow beanValidation annotations to be generated on RequestBody params too.
openapi-generator version
6.2.1 , current master
OpenAPI declaration file content or url
Provided configuration:
paths:
/add:
post:
requestBody:
content:
application/json:
schema:
type: integer
title: quantity
minimum: 2
required: true
responses:
'200':
description: OK
content:
application/json:
schema:
type: boolean
Generates:
@Operation(
operationId = "addPost",
responses = {
@ApiResponse(responseCode = "200", description = "OK", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Boolean.class)))
}
)
@RequestMapping(
method = RequestMethod.POST,
value = "/add",
produces = { "application/json" },
consumes = { "application/json" }
)
default ResponseEntity<Boolean> cartKekPost(
@Parameter(name = "body", description = "", required = true) @Valid @RequestBody Integer body
) {
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
}
Must have:
default ResponseEntity<Boolean> addPost(
@Min(2) @Parameter(name = "body", description = "", required = true) @Valid @RequestBody Integer body
) {
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
}
Command line used for generation
Plugin configuration: (beanValidation is enabled by default)
generatorName = 'spring' configOptions = [ dateLibrary: 'java8', interfaceOnly: 'true', openApiNullable: 'false', java8: 'false' ] importMappings = ['java.time.OffsetDateTime': 'java.time.Instant'] typeMappings = ['OffsetDateTime': 'Instant']
Steps to reproduce
./gradlew openApiGenerate
Related issues/PRs
https://github.com/OpenAPITools/openapi-generator/pull/13936
Suggest a fix/enhancement
will propose a solution as PR from fork repository https://github.com/Mintas/openapi-generator