It seems that there is no inherent way to do this with configs or standard OpenAPI conventions. What I found is that creating a vendor extension that holds a boolean as to whether to use that class response or not in each operation then using it in template files is a way to override this. Specifically, using JavaJaxRS, customize the returnTypes.mustache
template.
YAML Example:
openapi: 3.0.1
info:
servers:
paths:
/sample:
get:
x-response: true
returnTypes.mustache changes:
{{#vendorExtensions.x-response}}Response{{/vendorExtensions.x-response}}{{! non-generic response:}}
{{^vendorExtensions.x-response}}{{!
}}{{{returnType}}}{{!
}}{{/vendorExtensions.x-response}}
One thing to consider is that doing this will override the useGenericResponse
flag. If you want to continue having that option available, you'll have to account for that being set or not in the template.