Get Jackson ObjectMapper in Quarkus

Viewed 235

I am writing a custom OpenApiConfigurator that adds some examples to my api dynamically.

When I add the examples using the value field of io.smallrye.openapi.api.models.examples.ExampleImpl, which is an object, the example is null in swagger-ui. It only works when I added the actual json.

To add the actual json I have to generate it from my response dto using Jackson. But how can I access the quarkus object mapper, for which I have some customisations using ObjectMapperCustomizer, if in the OpenApiConfigurator CDI is not available?

1 Answers

It's actually possible to access the CDI container statically with Arc.container().instance(ObjectMapper::class.java).get()

That solved it for me.

Related