Skip to main content

🔌 Swagger Core v3 annotations supports

Supported annotations and fields

Supported annotations and fields currently are:

AnnotationFieldTypeDescription
OperationoperationIdStringUnique identifier of the operation
summaryStringShort summary of the operation
descriptionStringDetailed description of the operation
parametersParameter[]List of operation parameters
responsesApiResponse[]List of possible responses
ApiResponseresponseCodeStringHTTP response code
descriptionStringDescription of the response
contentContent[]Response content definitions
ContentschemaSchemaSchema of the content
SchemaimplementationClass<?>Implementation class of the schema
descriptionStringDescription of the schema
exampleStringExample value
ParametersvalueParameter[]List of parameters
ParameternameStringParameter name
inParameterInParameter location (query, path, header, etc.)
descriptionStringParameter description
requiredbooleanWhether the parameter is required
schemaSchemaParameter schema
exampleStringExample value

Examples

@Operation(summary = "Swagger summary",
operationId = "my-operation-id",
responses = {
@ApiResponse(description = "This is a successful operation"),
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(schema = @Schema(implementation = ErrorEntity.class))),
@ApiResponse(responseCode = "500", description = "Internal server error", content = @Content(schema = @Schema(implementation = ErrorEntity.class)))
})
@GetMapping("/some-api")
public ResponseEntity<String> myFunction() {
return ResponseEntity.ok("returnValue");
}

public class ErrorDto {

@Schema(description = "Timestamp of the error", example = "2023-10-01T12:00:00")
private LocalDateTime timestamp;
@Schema(description = "Session ID associated with the error", example = "session-12345")
private String sessionId;
}