How to Set a Description and an Example in Swagger With Swagger Annotations

How to set description to a field using swagger OpenAPI annotations

solution in kotlin:

data class Pet(
@field:Schema(description = "Pet status in the store")
val status: String
)

How to show multiple example in swagger documentation?

I have added example at entry point with help of schema

@Parameter(description = "Update User", required = true, schema = @Schema (example = "{\n  "
+ "\"operationList\": [\n "
+ "{\n \"op\": \"replace\",\n \"path\": \"/username\",\n \"value\": \"john1991\"\n },\n "
+ "{\n \"op\": \"replace\",\n \"path\": \"/description\",\n \"value\": \"NewDescription\"\n },\n "
+ "{\n \"op\": \"add\",\n \"path\": \"/memberships\",\n "
+ "\"value\":[\"1234\",\"6789\"]\n "
+ "{\n \"op\": \"remove\",\n \"path\": \"/privileges\",\n \"value\":[\"148\",\"155\"]\n "
+ "}\n ]\n}")) @Valid PatchOperations<UserPatchOperation> operationList) throws RestException

springdoc-openapi-ui swagger 3 change API description

Simply use following annotations :

In application launcher class(Configuration class):

@OpenAPIDefinition(info=@Info(title="Name of project"))

In Controller

import io.swagger.v3.oas.annotations.*

Calss level:

@OpenAPIDefinition()

Or

@Tag(name = "", description = "")

Method level :

 @Operation()

@ApiResponses()

Swagger - describe JSON payload fields

Look at annotation @ApiModelProperty, check swagger wiki for all annotations swagger-annotations



Related Topics



Leave a reply



Submit