swagger-core icon indicating copy to clipboard operation
swagger-core copied to clipboard

@ExampleObject description attribute not empty

Open fforfabio opened this issue 2 years ago • 0 comments

I'm facing this issue that also if the description attribute for the @ExampleObject (doc) annotation is empty, in the swagger online editor it is show, and it takes the name of the example.

Here my code

@ApiResponse(
	responseCode = "200", 
	description = "Book found", 
	content = { 
		@Content(
			mediaType = "application/json", 
			schema = @Schema(implementation = Book.class),
			examples = {
				@ExampleObject(
					name = "example 1", 
					value = "{\"id\": \"1\", \"title\":\"The Fellowship of the Ring\", \"author\": \"J.R.R. Tolkien\", \"publisher\": \"Allen & Unwin\"}"),
				@ExampleObject(
					name = "example 2",
					description = "",
					value = "{\"id\": \"1\", \"title\":\"The Fellowship of the Ring\", \"author\": \"J.R.R. Tolkien\", \"publisher\": null}")})

As you can see the description is not set for the example 1, so I'm expecting the default value (""), and is set to an empty string in the example 2.

Here the result in the swagger online editor for example 1 image

Also for the example 2 image

The editor will show me always the description, but I do not need it. What do I have to do?

I'm using:

  1. Java 8
  2. Spring Boot 2.7.16
  3. springdoc-openapi-ui 1.7.0

fforfabio avatar Jul 04 '23 07:07 fforfabio