OpenAPITools / OpenAPITools/openapi-generator

[Java] Add `SuppressWarnings("all")` to all generated Java source files

Open
#16,067 4 comments 16 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.

I'm seeing tons of warnings in the Eclipse IDE for the generated files. Part of these can be resolved by having generators include a SuppressWarnings("all") annotation, but IMHO, all generated sources should always carry this by default.

Describe the solution you'd like

When generating a source file, include this annotation on the class, for all files generated, always and by default.

Describe alternatives you've considered

Configuring the generator, for example for Spring:

                    <configuration>
                        <inputSpec>m2m-connector-contract/openapi.yaml</inputSpec>
                        <generatorName>spring</generatorName>
                        <configOptions>
                            <additionalModelTypeAnnotations>
                                @SuppressWarnings("all")
                            </additionalModelTypeAnnotations>
                            <additionalOneOfTypeAnnotations>
                                @SuppressWarnings("all")
                            </additionalOneOfTypeAnnotations>
                            <additionalEnumTypeAnnotations>
                                @SuppressWarnings("all")
                            </additionalEnumTypeAnnotations>
                        </configOptions>
                    </configuration>

Unfortunately, this doesn't cover the *Api interfaces it generates, nor the ApiUtil class (but that one is warning free).

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 configuration and the generated *Api interfaces, comparing them with the model, enum, and oneOf annotation options described in the issue. Check how generated Java classes and the ApiUtil class are emitted. Done means every generated Java source file, including *Api interfaces, carries SuppressWarnings("all") by default without requiring additional configuration.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, openapi, spring
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.