Skip to content

wsdl2openapi: numeric minOccurs/maxOccurs bounds are lost (no minItems/maxItems) #3165

Description

@predic8

Found while reviewing the wsdl2openapi interceptor for OpenAPI specification correctness.

XsdToSchema.applyMaxOccurs(...) wraps a repeating element in an ArraySchema but never sets minItems or maxItems:

if (UNBOUNDED.equals(maxOccurs) || isMoreThanOne(maxOccurs)) {
    return new ArraySchema().items(fieldSchema);
}

So maxOccurs="3" and maxOccurs="unbounded" produce identical schemas, and minOccurs="2" only marks the property required without stating that at least two items are expected. Both are constraints with exact JSON Schema equivalents, and the converter otherwise makes a point of carrying XSD constraints over (facets, fixed, required).

Suggested fix

In the same method: maxItems from a numeric maxOccurs, minItems from minOccurs where it is greater than 1. Note both describe the list, unlike nillable and default, which the code correctly applies to each occurrence before the wrapping.

Location

core/src/main/java/com/predic8/membrane/core/interceptor/wsdl2openapi/XsdToSchema.javaapplyMaxOccurs, addField

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions