Hi, I have multiple APIs returning data with same structure, just like examples underneath:
CatResponse:
type: object
properties:
counts:
type: integer
value:
type: array
items:
$ref: '#/definitions/Cat'
DogResponse:
type: object
properties:
counts:
type: integer
value:
type: array
items:
$ref: '#/definitions/Dog'
How can I represent them in swagger so that I can generateEntityResponse<T>, when I refer to them, I just replace T with Cat or Dog.
So that I just need to define one response object.
Thx.
There's no support for templating of responses (or message wrappers).
You mean that no definition can generate Java generic type likeEntityResponse<T>,
and thus I have to define ten response objects if I have ten kinds of animal entities.
How it translates to code in a specific language is out of scope. You can use composition and inheritance, but not templating.
Maybe this thread can be useful? Take a look at the last message
https://github.com/swagger-api/swagger-core/issues/498