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
SecuritySchemenameStringSecurity Scheme name
typeSecuritySchemeTypeType of the security scheme (http, apiKey, oauth2, openIdConnect)
descriptionStringDescription of the scheme
inSecuritySchemeInLocation of the API key (query, header, cookie)
schemeStringHTTP Authorization scheme (e.g., bearer, basic)
bearerFormatStringA hint to the client to identify how the bearer token is formatted
openIdConnectUrlStringOpenId Connect URL to discover OAuth2 configuration values
SecurityRequirementnameStringSecurity Requirement name
scopesString[]Array of scopes required for the security requirement

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");
}

@SecurityScheme(name = "bearerAuth", type = SecuritySchemeType.HTTP, bearerFormat = "JWT", scheme = "bearer")
@SecurityRequirement(name = "bearerAuth")
@RestController
@RequestMapping("/api/v1/recipes")
public class SecurityAnnotationResource {

@GetMapping
public String getRecipes() {
return "Recipes";
}

@SecurityRequirement(name = "basicAuth")
@GetMapping("/basic")
public String getRecipesBasicAuth() {
return "Recipes";
}
}
info

The @SecurityScheme annotation can also be placed on standalone configuration classes (such as Spring's @Configuration or custom security configuration classes), even if they do not contain any REST endpoints. The plugin will scan the classpath and automatically pick them up!


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;
}