2

I try to migrate from vertx 4.x to 5.0.2. In my project originally was creating a RouterFactory to create a Router using OpenAPI3RouterFactory.rxCreate using a spec.yaml file of OpenAPI v3.0.0. Now, I changed it to routerBuilder using OpenAPICtract.rxFrom using the same spec.yaml, mapping it later using RouterBuilder.create() to create RouterBuilder. The issue happens on OpenAPICtract.rxFrom() logging:

class java.lang.Long cannot be cast to class java.lang.Integer (java.lang.Long and java.lang.Integer are in module java.base of loader 'bootstrap') at io.vertx.json.schema.impl.SchemaValidatorImpl.validate(SchemaValidatorImpl.java:446) SchemaValidatorImpl.java:446 at io.vertx.json.schema.impl.SchemaValidatorImpl.validate(SchemaValidatorImpl.java:204)

This refers to the following code line:

if (schema.containsKey("minProperties") && keys.size() < schema.<Integer>get("minProperties")) 

more specifically schema.<Integer>get("minProperties") returns Long with value 1 and the cast fails. Initially thought that was a parcing error on the spec.yaml file so I created io.vertx.core.json.JsonObject from this YAML and later used OpenAPIContract.rxFrom(Vertx, JsonObject). I verified that JsonObject is created successfully and represents correctly the spec.yaml, but the error is the same.

All vertx artifacts that are used in my project are 5.0.2.

Seems that schema instance is vertx internal, so I am not sure how can I proceed to fix it.

asked Sep 5, 2025 at 9:56

1 Answer 1

0

Seems that Vert.x is delegating all JSON parsing to Jackson (com.fasterxml.jackson.databind.ObjectMapper under the hood).
Using the following before creating OpenAPIContract seems to fix the issue:


import com.fasterxml.jackson.databind.DeserializationFeature;import io.vertx.core.json.jackson.DatabindCodec;
// Disable using Long for integers so small numbers become IntegerDatabindCodec.mapper().configure(DeserializationFeature.USE_LONG_FOR_INTS, false);
answered Sep 10, 2025 at 13:55
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.