OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
22.01k stars 6.6k forks source link

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

Open hjohn opened 1 year ago

hjohn commented 1 year ago

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).

jdimeo commented 1 month ago

Just to add why this is needed: Eclipse now has the ability to ignore warnings for a generated-sources folder, but this toggle is "lost" when m2e refreshes the project settings from pom.xml, so the warnings (in the thousands) keep coming back. Solving this in the generated files wouldn't rely on IDE behavior or complex configuration.