Description
Describe the bug
I'm developing HTTP JSON API based on SpringDoc OpenAPI3, but to avoid JSON example formating issues, I prefer to externalize them and reference them like that:
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Blabla", content = {
@Content(schema = @Schema(implementation = SearchResults.class), examples = @ExampleObject(ref = "#/components/examples/http200SearchCharacteristicsExample")) }) })
public ResponseEntity<SearchResults> searchCharacteristics(){
...
}
And in a @configuration class, I use a OpenApiCustomiser to provide these examples.
The issue is that if I don't provide @example's name, it doesn't appears in generated swagger.
And if I provide a name like:
@ExampleObject(name = "http200SearchCharacteristicsExample", ref = "#/components/examples/http200SearchCharacteristicsExample")) }) })
public ResponseEntity<SearchResults> searchCharacteristics(){
...
}
It appears but with a description attribute:
examples:
200GetCharacteristics:
description: 200GetCharacteristics
$ref: '#/components/examples/http200GetCharacteristicsExample'
which make a warning using https://editor.swagger.io/ saying "Sibling values are not allowed alongside $refs". If I remove manually "description" attribute I have no more this warning.
Indeed this description is redundant with one from '#/components/examples/http200GetCharacteristicsExample'.
When analyzing I see an issue in org.springdoc.core.SpringDocAnnotationsUtils.setExamples(MediaType, ExampleObject[])
which don't consider ref when a single example is provided without name but consider it as an embedded example.