Tune Swagger doc (#2436)
Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.ddi.rest.resource;
|
||||
|
||||
import io.swagger.v3.oas.models.info.Info;
|
||||
import io.swagger.v3.oas.models.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.models.security.SecurityScheme;
|
||||
import org.eclipse.hawkbit.rest.OpenApiConfiguration;
|
||||
@@ -24,7 +25,7 @@ import org.springframework.context.annotation.Configuration;
|
||||
matchIfMissing = true)
|
||||
public class DdiOpenApiConfiguration {
|
||||
|
||||
private static final String DDI_TOKEN_SEC_SCHEME_NAME = "DDI Target/GatewayToken Authentication";
|
||||
private static final String DDI_TOKEN_SEC_SCHEME_NAME = "Token";
|
||||
|
||||
@Bean
|
||||
@ConditionalOnProperty(
|
||||
@@ -38,16 +39,20 @@ public class DdiOpenApiConfiguration {
|
||||
.pathsToMatch("/{tenant}/controller/**")
|
||||
.addOpenApiCustomizer(openApi ->
|
||||
openApi
|
||||
.info(new Info()
|
||||
.title("Direct Device Integration API")
|
||||
.version("v1")
|
||||
.description("The Direct Device Integration (DDI) API provides a way for devices to interact directly with the hawkBit."))
|
||||
.addSecurityItem(new SecurityRequirement().addList(DDI_TOKEN_SEC_SCHEME_NAME))
|
||||
.components(
|
||||
openApi
|
||||
.getComponents()
|
||||
.addSecuritySchemes(DDI_TOKEN_SEC_SCHEME_NAME,
|
||||
new SecurityScheme()
|
||||
.name("Authorization")
|
||||
.name(DDI_TOKEN_SEC_SCHEME_NAME)
|
||||
.description("Format: (Target|Gateway)Token <token>")
|
||||
.type(SecurityScheme.Type.APIKEY)
|
||||
.in(SecurityScheme.In.HEADER)
|
||||
.description("Format: (Target|Gateway)Token <token>"))))
|
||||
.in(SecurityScheme.In.HEADER))))
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.mgmt.rest.resource;
|
||||
|
||||
import io.swagger.v3.oas.models.info.Info;
|
||||
import io.swagger.v3.oas.models.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.models.security.SecurityScheme;
|
||||
import org.eclipse.hawkbit.rest.OpenApiConfiguration;
|
||||
@@ -24,8 +25,8 @@ import org.springframework.context.annotation.Configuration;
|
||||
matchIfMissing = true)
|
||||
public class MgmtOpenApiConfiguration {
|
||||
|
||||
private static final String BASIC_AUTH_SEC_SCHEME_NAME = "Basic Authentication";
|
||||
private static final String BEARER_AUTH_SEC_SCHEME_NAME = "Bearer Authentication";
|
||||
private static final String BASIC_AUTH_SEC_SCHEME_NAME = "Basic";
|
||||
private static final String BEARER_AUTH_SEC_SCHEME_NAME = "Bearer";
|
||||
|
||||
@Bean
|
||||
@ConditionalOnProperty(
|
||||
@@ -36,9 +37,15 @@ public class MgmtOpenApiConfiguration {
|
||||
return GroupedOpenApi
|
||||
.builder()
|
||||
.group("Management API")
|
||||
.pathsToMatch("/rest/v*/**")
|
||||
.pathsToMatch("/rest/v*/**", "/{tenant}/rest/v*/**")
|
||||
.addOpenApiCustomizer(openApi ->
|
||||
openApi
|
||||
.info(new Info()
|
||||
.title("Management API")
|
||||
.description("""
|
||||
The Management API provides access to the management features of the hawkBit.
|
||||
It allows for managing devices, deployments, and other.
|
||||
"""))
|
||||
.addSecurityItem(new SecurityRequirement()
|
||||
.addList(BASIC_AUTH_SEC_SCHEME_NAME)
|
||||
.addList(BEARER_AUTH_SEC_SCHEME_NAME))
|
||||
@@ -48,12 +55,14 @@ public class MgmtOpenApiConfiguration {
|
||||
.addSecuritySchemes(BASIC_AUTH_SEC_SCHEME_NAME,
|
||||
new SecurityScheme()
|
||||
.name(BASIC_AUTH_SEC_SCHEME_NAME)
|
||||
.description(BASIC_AUTH_SEC_SCHEME_NAME + " Authentication")
|
||||
.type(SecurityScheme.Type.HTTP)
|
||||
.in(SecurityScheme.In.HEADER)
|
||||
.scheme("basic"))
|
||||
.addSecuritySchemes(BEARER_AUTH_SEC_SCHEME_NAME,
|
||||
new SecurityScheme()
|
||||
.name(BEARER_AUTH_SEC_SCHEME_NAME)
|
||||
.description(BEARER_AUTH_SEC_SCHEME_NAME + " Authentication")
|
||||
.type(SecurityScheme.Type.HTTP)
|
||||
.in(SecurityScheme.In.HEADER)
|
||||
.bearerFormat("JWT")
|
||||
|
||||
Reference in New Issue
Block a user