I’ve been down the rabbit hole on this, and extracted the templates for Spring, i.e., open-api-generator author template -g spring
and combed though the mustache files.
What I’m trying to do is get OpenAPI to recognize application/vnd.api+json
as a superset of application/json
in the generation of examples, instead of getting:
...
if (mediaType.isCompatibleWith(MediaType.valueOf("application/vnd.api+json"))) {
String exampleString = "Custom MIME type example not yet supported: application/vnd.api+json";
ApiUtil.setExampleResponse(request, "application/vnd.api+json", exampleString);
...
Where the exampleString = "Custom MIME type example not yet supported: application/vnd.api+json"
, yet the OpenAPI Spec defines a JSON structure:
components:
responses:
Echo:
description: Test operation for pipelines
content:
'application/vnd.api+json':
schema:
$ref: '#/components/schema/Echo'
example:
data:
type: echo
id: 17d39399-c08c-499f-9e2c-d8b6e467e6aa
attributes:
message: Echo cho ho o
This feels to me something that has been encountered and my Google-fu is failing me. When I use application/json
the example is parsed as expected and used in the exampleString
. This seems to me something to configure or provide to the templates as a “Hey, when you see application/vnd.api+json
parse the example as application/json
like you would normally.”