OpenAPITools / OpenAPITools/openapi-generator

[REQ] [Spring] Configure different collection types.

Open
#17,041 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Enhancement: Feature
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Is your feature request related to a problem? Please describe.

Spring have support of Vavr and we make use of it in our project. Recently we want to change our model to generate base Spring API to delegate the generation to openapi-generator.

If I try to use the mappings declared in the Spring generator documentation:

It almost work, problem is that in the mustache templates for api or model, the java.util.List and java.util.Map are hardcoded. That makes this feature impossible to use with Vavr as the io.vavr.collection.List import collides with the Java one.

Describe the solution you'd like

I would like to be able to configure the collection mappings and imports with vavr and generate a valid code.

Describe alternatives you've considered

Why are hardcoded these imports while in the other hand we should have the flexibility to change the types? I have tested removing the hardcoded imports and it does not seems to be needed. I suggest to use FQN for the calls to the collections whenever it is needed for the generated code.

Additional context

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Spring generator's mustache templates for APIs and models, then review the Spring generator documentation for import-mapping and instantiation-types. Done means collection types and imports can be configured for Vavr without collisions and the generated code is valid.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
Domain
backend-api-design, tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
40/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.