Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | Last revision Both sides next revision | ||
devel:documentation:architecture:dev:swagger [2018/06/13 05:11] cirkval |
devel:documentation:architecture:dev:swagger [2023/10/19 10:43] chalupat [#3330] Replace Springfox with springdoc |
||
---|---|---|---|
Line 72: | Line 72: | ||
public Docket exampleApi() { | public Docket exampleApi() { | ||
return api(" | return api(" | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | springdoc version (13.1.0+) | ||
+ | <code java> | ||
+ | /** | ||
+ | * Example module swagger configuration | ||
+ | */ | ||
+ | @Configuration | ||
+ | @ConditionalOnProperty(prefix = " | ||
+ | public class ExampleSwaggerConfig extends AbstractSwaggerConfig { | ||
+ | |||
+ | @Autowired private ExampleModuleDescriptor moduleDescriptor; | ||
+ | |||
+ | @Override | ||
+ | protected ModuleDescriptor getModuleDescriptor() { | ||
+ | return moduleDescriptor; | ||
+ | } | ||
+ | |||
+ | @Bean | ||
+ | public GroupedOpenApi exampleApi() { | ||
+ | return api(" | ||
} | } | ||
} | } | ||
Line 106: | Line 129: | ||
) { | ) { | ||
return new ResponseEntity<> | return new ResponseEntity<> | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | For springdoc version (13.1.0+) add [[https:// | ||
+ | |||
+ | <code java> | ||
+ | |||
+ | /** | ||
+ | * Ping pong example controller | ||
+ | */ | ||
+ | @RestController | ||
+ | @Enabled(ExampleModuleDescriptor.MODULE_ID) | ||
+ | @RequestMapping(value = BaseController.BASE_PATH + "/ | ||
+ | @Tag(name = ExampleController.TAG, | ||
+ | |||
+ | public class ExampleController { | ||
+ | |||
+ | protected static final String TAG = " | ||
+ | @Autowired private ExampleService service; | ||
+ | |||
+ | @ResponseBody | ||
+ | @RequestMapping(method = RequestMethod.GET, | ||
+ | @Operation( | ||
+ | summary = "Ping - Pong operation", | ||
+ | description= " | ||
+ | operationId = " | ||
+ | tags={ ExampleController.TAG } | ||
+ | responses = @ApiResponse( | ||
+ | responseCode = " | ||
+ | content = { | ||
+ | @Content( | ||
+ | mediaType = BaseController.APPLICATION_HAL_JSON_VALUE, | ||
+ | schema = @Schema( | ||
+ | implementation = Pong.class | ||
+ | ) | ||
+ | ) | ||
+ | } | ||
+ | )) | ||
+ | @SecurityRequirements({ | ||
+ | @SecurityRequirement(name = SwaggerConfig.AUTHENTICATION_BASIC), | ||
+ | @SecurityRequirement(name = SwaggerConfig.AUTHENTICATION_CIDMST) | ||
+ | }) | ||
+ | public ResponseEntity< | ||
+ | @Parameter(description = "In / out message", | ||
+ | @RequestParam(required = false, defaultValue = " | ||
+ | ) { | ||
+ | return new ResponseEntity<> | ||
} | } | ||
} | } | ||
Line 129: | Line 200: | ||
@ApiModelProperty(required = true, notes = " | @ApiModelProperty(required = true, notes = " | ||
private DateTime created; | private DateTime created; | ||
+ | |||
+ | // ... getters, setters | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | For springdoc version (13.1.0+) add [[https:// | ||
+ | |||
+ | <code java> | ||
+ | /** | ||
+ | * Example ping - pong response dto | ||
+ | */ | ||
+ | @Schema(description = "Ping - Pong response" | ||
+ | public class Pong implements BaseDto { | ||
+ | |||
+ | private static final long serialVersionUID = 1L; | ||
+ | // | ||
+ | @Schema(requiredMode = Schema.RequiredMode.REQUIRED, | ||
+ | private UUID id; | ||
+ | @Schema(description = "Ping - Pong response message" | ||
+ | private String message; | ||
+ | @Schema(requiredMode = Schema.RequiredMode.REQUIRED, | ||
+ | private ZonedDateTime created; | ||
// ... getters, setters | // ... getters, setters |