Class OpenApiResponseTypes

java.lang.Object
ubic.gemma.rest.util.OpenApiResponseTypes

public final class OpenApiResponseTypes extends Object
Concrete response containers that exist only so the OpenAPI specification can name them.

Why these exist

An endpoint that supports both offset and cursor pagination returns Object and declares its two shapes with @Schema(oneOf = {...}). An annotation can only name a Class, and Java erases type arguments, so naming a raw generic container there — PaginatedResponseDataObject.class — hands swagger-core a container whose data is an array of bare object. The payload type is gone from the spec.

That is worse than a generator error. A generated client deserializes the untyped payload to raw camelCase dictionaries, and a wrapper that reads snake_case field names off them gets nulls for every column rather than a failure. gemmapy carried a private table of the missing item types for exactly this reason.

Binding the type argument in a named subclass restores it: swagger-core resolves the subclass to a schema of the subclass's own simple name, with data typed as an array of the bound value object.

Using them

Name the bound subclass in the oneOf, not the raw generic, and make sure it matches what the method actually returns — the return type is Object, so nothing else checks:
@ApiResponse(responseCode = "200",
        content = @Content(schema = @Schema(oneOf = {
                PaginatedResponseDataObjectGeneValueObject.class,
                CursorPaginatedResponseDataObjectGeneValueObject.class
        })))
public Object getGenes( ... )
OpenApiTest.testPaginatedResponsesDeclareTheirPayloadType fails the build when a response schema reachable from a path has lost its data item type, so a new raw-generic oneOf cannot reach the published spec.

These classes are never instantiated; the endpoints build the generic parent. The constructors mirror the parent's so the subclass compiles and stays usable as a real return type.

DatasetsWebService declares its own bound containers rather than using this class, because their generic parents (FilteredAndInferredAndPaginatedResponseDataObject and friends, which carry inferred ontology terms) are themselves nested there.

Author:
phase3
See Also: