OpenAPITools / OpenAPITools/openapi-generator

[REQ] Make java-undertow-server generate subclassable Handlers

Open
#4,257 0 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.

The generated PathHandlerProvider.java doesn't provide a method using it as "lib". It isn't just something can generate, subclass and use without modifying the generated files, which means that all modifications will be overwritten as soon as the spec is changed.

Describe the solution you'd like

It would be great if the HttpHandlers used in PathHandlerProvider could be subclassed in custom code. What I'm thinking of is generating an abstract class OperationNameHttpHandler per operation that's subclassed in the same package, then imported and instantiated in PathHandlerProvider e.g

/pet:POST with the operationId addPet will generated the class org.apitools.handler.AddPetBaseHandler and PathHandlerProvider will use AddPetHandlerImpl.

The project won't build until an implementation for AddPetHandlerImpl is provided.

Describe alternatives you've considered

One could also provide a method PathHandlerProvider::addHandler(String operationId, HttpHandler handler) that adds handlers to a Map which are then used in the existing PathHandlerProvider::getHandler.

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 generated samples/server/petstore/java-undertow/.../PathHandlerProvider.java and the operation definition in openapi.yaml. Trace how the Java Undertow server output is assembled and determine how subclassable per-operation handlers would fit. Done means custom handler implementations can be supplied without editing generated files and the generated project builds as described.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, openapi
Domain
api, backend, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.