Repository navigation
Closed
Milestone
Description
Hello,
when I generate code from the following OpenAPI schema, I get inconsistent Bean Validation annotations depending on the array mapping.
OpenAPI schema
ValidationRequest:
type: object
required:
- openApiFile
additionalProperties: false
properties:
openApiFile:
type: object
additionalProperties: true
description: OpenAPI file content.
required:
- openapi
environment:
type: string
enum: [ local, dev]
default: "dev"
description: Target environment for the validation.
rules:
type: array
description: Optional list of specific rules to validate against. If not provided, the default ruleset will be used.
maxItems: 1000
items:
type: string
maxLength: 500
pattern: "^[a-zA-Z0-9_-]+$"mapping.yaml
openapi-processor-mapping: v18
options:
package-name: service_api
model-name-suffix: Model
model-type: record
bean-validation: true
generated: true
generated-date: true
format-code: false
javadoc: true
json-property-annotation: auto
package-name-from-path: true
model-unreferenced: true
map:
types:
- type: array => java.util.List
- type: string:uuid => java.util.UUID
- type: ValidationRequestOpenApiFile => java.util.Map<java.lang.String, java.lang.Object>
- type: ValidationRegexRequestOpenApiFile => java.util.Map<java.lang.String, java.lang.Object>
logging:
mapping: true
mapping-target: stdoutActual result (with type: array => java.util.List)
import java.util.List;
import java.util.Map;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
/**
* @param openApiFile OpenAPI file content.
* @param environment Target environment for the validation.
* @param rules Optional list of specific Spectral rules to validate against. If not provided, the default ruleset will be used.
*/
@Generated(value = "openapi-processor-spring", version = "2026.3", date = "2026-06-30T13:01:10.636288300+02:00")
public record ValidationRequestModel(
@Valid
@NotNull
Map<String, Object> openApiFile,
ValidationRequestEnvironmentModel environment,
List<@Size(max = 500) @Pattern(regexp = "^[a-zA-Z0-9_-]+$") String> rules
) {}Issue: the container constraint @SiZe(max = 1000) (from maxItems) is missing.
Actual result (without type: array => java.util.List)
import java.util.Map;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
/**
* @param openApiFile OpenAPI file content.
* @param environment Target environment for the validation.
* @param rules Optional list of specific Spectral rules to validate against. If not provided, the default ruleset will be used.
*/
@Generated(value = "openapi-processor-spring", version = "2026.3", date = "2026-06-30T13:10:50.099920200+02:00")
public record ValidationRequestModel(
@Valid
@NotNull
Map<String, Object> openApiFile,
ValidationRequestEnvironmentModel environment,
@Size(max = 1000)
String[] rules
) {}Issue: now the item-level string constraints are missing (@SiZe(max = 500) and @pattern(...)).
Expected result
import java.util.List;
import java.util.Map;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
/**
* @param openApiFile OpenAPI file content.
* @param environment Target environment for the validation.
* @param rules Optional list of specific Spectral rules to validate against. If not provided, the default ruleset will be used.
*/
@Generated(value = "openapi-processor-spring", version = "2026.3", date = "2026-06-30T13:11:52.615243800+02:00")
public record ValidationRequestModel(
@Valid
@NotNull
Map<String, Object> openApiFile,
ValidationRequestEnvironmentModel environment,
@Size(max = 1000)
List<@Size(max = 500) @Pattern(regexp = "^[a-zA-Z0-9_-]+$") String> rules
) {}Question
Is this currently supported (possibly via configuration), or is this a bug/limitation in annotation generation for mapped arrays (List)?
Metadata
Metadata
Assignees
Labels
No labels
Activity
hauner commentedon Jun 30, 2026
I have to look at this.
I don't remember any specific option for it. It may be possible to use annotation mapping as workaround, just a guess though.
This stuff is a bit tricky so it is probably a limitation of the current implementation.
Razvanmatis commentedon Jul 2, 2026
@hauner thanks for your reply! then i will wait for your next comment as i'm not really aware of how to use annotation mapping to solve this issue
hauner commentedon Jul 5, 2026
here is a (somewhat obscure ;-) workaround by adding an extension property
x-maxItemsto the propertyand mapping the x-tension property to the wanted annotation:
Let's see If I can make it work without that workaround.
call Class.forName() without generic parameters in the class name (o…
call Class.forName() without generic parameters in the class name (o…
hauner commentedon Jul 7, 2026
fixed in openapi-processor-spring 2026.3.2
Razvanmatis commentedon Jul 15, 2026
thanks a lot for your support @hauner ! works as expected now :)