armeria icon indicating copy to clipboard operation
armeria copied to clipboard

Support for inheritance and polymorphism in DocService

Open icepeppermint opened this issue 5 months ago • 2 comments

I'm using DocService to document our API. Currently, the response classes of the annotated HTTP service use inheritance and polymorphism. There doesn't seem to be any support for this case at the moment. It would be great if Armeria automatically detect annotations like @JsonSubTypes. Or, it's good to create a new annotation to specify it manually. Below is an example of a Discriminator in Swagger.

  • https://swagger.io/docs/specification/v3_0/data-models/inheritance-and-polymorphism/

icepeppermint avatar Jul 17 '25 02:07 icepeppermint

Hi! I’m interested in working on this feature and would like to confirm the preferred direction.

In springdoc-openapi, I’ve run into an issue where polymorphism
(oneOf / discriminator) is expressed twice when both Jackson annotations and @Schema are
introspected simultaneously (due to swagger-core processing both).

(My question/answer thread: link1, related issue: link2)

I also found an old discussion about Swagger support in Armeria (link3),
but I’m not sure what the final decision was.

For DocService, I see two possible approaches:

  1. Generate polymorphism strictly from Jackson annotations
    (@JsonTypeInfo, @JsonSubTypes, @JsonTypeName)

  2. Introduce Armeria-specific annotations
    as an explicit override or extension point.

I’d like to hear advice or the direction the Armeria team would prefer.
If nobody is currently working on this, I’d be happy to take it on.

YoungHoney avatar Aug 10 '25 06:08 YoungHoney

I prefer using Jackson annotations rather than introducing a new annotation for it.

ikhoon avatar Aug 11 '25 04:08 ikhoon