swagger-api / swagger-api/swagger-core

[Feature]: kotlin support for swagger-maven-plugin-jakarta

Open
#5,268 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

backlog Feature
Dominant language
Java
Stars
7.5k
Forks
2.3k
Avg merge
18h 1m
Merged PRs (30d)
10

Description

Feature Description

(This issue may apply equally to plain swagger-maven-plugin, I haven't tested)

By default the plugin does not understand Kotlin well:

  • non-nullable fields are not automatically listed as required.
  • field names starting with 'is' will lose their prefix in the doc, which is simply wrong.
  • there may be other discrepancies

I would like a solution to this that requires as little effort and awareness as possible of the developer.

Use Case

I want to write my endpoints and dtos in standard kotlin, with as little though as possible to the quirks of my documentation tool, and for the plugin to extract as much knowledge as possible from the code before needing annotations.

Suggested Solution (optional)

The solution should leverage jackson's kotlin module, which understands all the problematic cases well.

Some implementation alternatives - in order of prefence:

  1. The plugin uses kotlin-module by default for Kotlin classes
  2. A separate plugin is provided that supports Kotlin
  3. A simple config option for enabling Kotlin support
  4. Include a ready-made KotlinAwareObjectMapperProcessor that just needs to be configured i the pom

Alternatives Considered

  • The standard solution is to provide the plugin with a custom objectMapperProcessorClass that registers jackson's kotlin module to the mapper. This is a small task and works well, but feels unnecessary (especially writing the processor yourself), and more importantly:
    • You get no hint that you need to do this, until someone discovers the docs are wrong.
  • Explicit tagging can fix it, but it is not intuitive that you need to, since the information is right there in the code. Even when you know, it is easy to forget, and the resulting error is hard to spot.

Checklist

  • I have searched the existing issues to ensure this is not a duplicate.
  • This feature would be useful to more than just my use case.
  • I have provided enough detail for the maintainers to understand the scope of the request.

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 by reviewing the plugin's objectMapperProcessorClass extension point and how Jackson handles Kotlin classes. Compare the default behavior with the Jackson Kotlin module for non-nullable fields and names beginning with “is.” Done means the plugin supports these cases with minimal developer configuration, with the chosen approach and any remaining discrepancies documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, kotlin
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.