OpenAPITools / OpenAPITools/openapi-generator

Make RestApplication class generation configurable

Open
#20,408 13 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

https://github.com/OpenAPITools/openapi-generator/pull/17646
made the generation of a RestApplication class mandatory. This causes an issue when an application has more than one OpenAPI defined endpoint.

For example, with multiple OpenAPI defined endpoints and an existing @ApplicationPath annotated class intended to group those endpoints under a common '/rest' path prefix, using openapi-generator-maven-plugin 7.3.0 or greater will fail to deploy because there will be multiple generated RestApplication class conflicting with the existing @ApplicationPath annotated class:

6-Aug-2024 21:09:58.596 SEVERE [http-nio-8080-exec-4] org.apache.openejb.observer.ObserverManager$MethodInvocation.invoke error invoking org.apache.tomee.webservices.TomeeJaxRsService@2fb68ec6
org.apache.cxf.service.factory.ServiceConstructionException
...
Caused by: org.apache.cxf.service.factory.ServiceConstructionException: There is an endpoint already running on http://localhost:8080/rest.

The mandatory generation of a RestApplication implies a single OpenAPI defined endpoint, and this solipsistic approach means to continue to use an endpoint common path prefix requires one and only one of the defined endpoints to be nominated as the 'chosen one' to define the path prefix;

servers:
  - url: /rest

This is clumsy and non-obvious.
It would be cleaner and more flexible to simply provide a configuration option to disable the RestApplication generation.

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 tracing RestApplication generation in the openapi-generator-maven-plugin, using the behavior introduced by PR 17646 and the 7.3.0 change as context. Determine where generation is configured and how multiple OpenAPI endpoints interact with an existing @ApplicationPath class; done means a configuration option can disable generation so those endpoints deploy without conflicting RestApplication classes.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.