Please point me on how to add new collection types (e.g. Vavr / Guava)
See original GitHub issueI’m trying to add the collection types ( Option, List, Tuple, etc.) from the vavr-library, but can’t seem to find where to plug them in (https://www.vavr.io/vavr-docs/). I already figured out on how to make the Future<T> type work here https://dominikdorn.com/2020/05/spring-doc-openapi-swagger-vavr-future/ but I’m a little lost on how to make the collections types work. It would be great if you could point me in the right direction!
This is what I tried so far:
- I’ve already tried creating a
io.swagger.v3.core.converter.ModelConverter
but this leads to NPEs when swagger tries to clone the schema. - I also tried
SpringDocUtils.getConfig().replaceWithClass(io.vavr.control.Option.class, java.util.Optional.class);
but this seems to be unable to handle generics. - I tried to register the VavrModule with the ObjectMapper of SpringDoc/Swagger, but this also doesn’t help (
Json.mapper().registerModule(new VavrModule());
)
Thx, Dominik
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Guide to Collections API in Vavr - Baeldung
In this article, we explore its powerful collections API. To get more information about this library, please read this article.
Read more >Java Collection Views - Blog - Vavr
Conversion to Java collections using the toJava*() methods requires to iterate the persistent collection and build a new Java collection by ...
Read more >Functional Programming in Java 8 with vavr - jOOQ blog
Guava is designed to be a toolset of missing types and extensions to existing Java types. It is superior in simplifying daily tasks,...
Read more >Using vavr to write more robust Java code - Stéphane Derosiaux
We'll work from a base solution and improve it using vavr and some of its functional types: Either, then a combination of Either...
Read more >Immutable Collections should be Your Default
Java's standard library has utilities for creating unmodifiable copies, which are better than nothing; · VAVR works well for Java; · Guava is...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
The post is supposed to be this one: https://dominikdorn.com/2020/05/spring-doc-openapi-swagger-vavr-future/ but apparently the github-gist plugin for wordpress fails for some reason… anyway, you’ve found the right gist 😃
@domdorn,
For collections, i assume you already have registred Jackson VavrModule. If you need to use the mapping of Java Collection instead of the one of Vavr Collection. You can declare in your application:
For
io.vavr.control.Option
, you can use a custom ModelConverter, as it is not available on ModelResolver._isOptionalType is only supporting com.google.common.base.Optional and java.util.Optional. Here is a sample code for a ModelConverter.