Skip to content

Commit 2b94c0d

Browse files
authored
Implements SwaggerUI Redirect & example on how to deactivate (#732)
* Implements SwaggerUI Redirect & example on how to deactivate * Adds missing line break on eof
1 parent a26b3c2 commit 2b94c0d

8 files changed

Lines changed: 98 additions & 5 deletions

File tree

basyx.aasdiscoveryservice/basyx.aasdiscoveryservice.component/src/main/resources/application.properties

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,10 @@ basyx.backend=InMemory
2828
#basyx.feature.authorization.type = rbac
2929
#basyx.feature.authorization.jwtBearerTokenProvider = keycloak
3030
#basyx.feature.authorization.rbac.file = classpath:rbac_rules.json
31-
#spring.security.oauth2.resourceserver.jwt.issuer-uri= http://localhost:9096/realms/BaSyx
31+
#spring.security.oauth2.resourceserver.jwt.issuer-uri= http://localhost:9096/realms/BaSyx
32+
33+
####################################################################################
34+
# Disable the Swagger UI
35+
####################################################################################
36+
#springdoc.swagger-ui.enabled=false
37+
#springdoc.api-docs.enabled=false

basyx.aasenvironment/basyx.aasenvironment.component/src/main/resources/application.properties

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,4 +94,10 @@ basyx.backend = InMemory
9494
#basyx.aasrepository.feature.discoveryintegration.authorization.token-endpoint=http://localhost/realms/BaSyx/protocol/openid-connect/token
9595
#basyx.aasrepository.feature.discoveryintegration.authorization.grant-type = CLIENT_CREDENTIALS
9696
#basyx.aasrepository.feature.discoveryintegration.authorization.client-id=workstation-1
97-
#basyx.aasrepository.feature.discoveryintegration.authorization.client-secret=nY0mjyECF60DGzNmQUjL81XurSl8etom
97+
#basyx.aasrepository.feature.discoveryintegration.authorization.client-secret=nY0mjyECF60DGzNmQUjL81XurSl8etom
98+
99+
####################################################################################
100+
# Disable the Swagger UI
101+
####################################################################################
102+
#springdoc.swagger-ui.enabled=false
103+
#springdoc.api-docs.enabled=false

basyx.aasrepository/basyx.aasrepository.component/src/main/resources/application.properties

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,10 @@ basyx.backend = InMemory
6060
#basyx.aasrepository.feature.discoveryintegration.authorization.token-endpoint=http://localhost/realms/BaSyx/protocol/openid-connect/token
6161
#basyx.aasrepository.feature.discoveryintegration.authorization.grant-type = CLIENT_CREDENTIALS
6262
#basyx.aasrepository.feature.discoveryintegration.authorization.client-id=workstation-1
63-
#basyx.aasrepository.feature.discoveryintegration.authorization.client-secret=nY0mjyECF60DGzNmQUjL81XurSl8etom
63+
#basyx.aasrepository.feature.discoveryintegration.authorization.client-secret=nY0mjyECF60DGzNmQUjL81XurSl8etom
64+
65+
####################################################################################
66+
# Disable the Swagger UI
67+
####################################################################################
68+
#springdoc.swagger-ui.enabled=false
69+
#springdoc.api-docs.enabled=false

basyx.aasxfileserver/basyx.aasxfileserver.component/src/main/resources/application.properties

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,9 @@ basyx.aasxfileserver.name = aasx-fileserver
6969

7070
#spring.servlet.multipart.max-file-size=200MB
7171
#spring.servlet.multipart.max-request-size=215MB
72+
73+
####################################################################################
74+
# Disable the Swagger UI
75+
####################################################################################
76+
#springdoc.swagger-ui.enabled=false
77+
#springdoc.api-docs.enabled=false
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*******************************************************************************
2+
* Copyright (C) 2025 the Eclipse BaSyx Authors
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining
5+
* a copy of this software and associated documentation files (the
6+
* "Software"), to deal in the Software without restriction, including
7+
* without limitation the rights to use, copy, modify, merge, publish,
8+
* distribute, sublicense, and/or sell copies of the Software, and to
9+
* permit persons to whom the Software is furnished to do so, subject to
10+
* the following conditions:
11+
*
12+
* The above copyright notice and this permission notice shall be
13+
* included in all copies or substantial portions of the Software.
14+
*
15+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19+
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20+
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21+
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22+
*
23+
* SPDX-License-Identifier: MIT
24+
******************************************************************************/
25+
26+
package org.eclipse.digitaltwin.basyx.http;
27+
28+
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
29+
import org.springframework.stereotype.Controller;
30+
import org.springframework.web.bind.annotation.GetMapping;
31+
import org.springframework.web.bind.annotation.RequestMapping;
32+
33+
/**
34+
* Redirects the root URL to the Swagger UI page if Swagger UI is enabled.
35+
* @author fried
36+
*/
37+
@Controller
38+
@RequestMapping("/")
39+
@ConditionalOnProperty(
40+
name = "springdoc.swagger-ui.enabled",
41+
havingValue = "true",
42+
matchIfMissing = true
43+
)
44+
public class HomeRedirectController {
45+
46+
@GetMapping({"", "/"})
47+
public String redirectToSwaggerUi() {
48+
return "redirect:/swagger-ui/index.html";
49+
}
50+
}

basyx.submodelrepository/basyx.submodelrepository.component/src/main/resources/application-integration.properties

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,9 @@ basyx.externalurl=http://localhost:8081
3333
#basyx.feature.authorization.jwtBearerTokenProvider = keycloak
3434
#basyx.feature.authorization.rbac.file = classpath:rbac_rules.json
3535
#spring.security.oauth2.resourceserver.jwt.issuer-uri= http://localhost:9096/realms/BaSyx
36+
37+
####################################################################################
38+
# Disable the Swagger UI
39+
####################################################################################
40+
#springdoc.swagger-ui.enabled=false
41+
#springdoc.api-docs.enabled=false

basyx.submodelrepository/basyx.submodelrepository.component/src/main/resources/application.properties

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,10 @@ basyx.backend = InMemory
3838
####################################################################################
3939
# This feature is enabled by default
4040

41-
#basyx.submodelrepository.feature.operation.delegation.enabled = false
41+
#basyx.submodelrepository.feature.operation.delegation.enabled = false
42+
43+
####################################################################################
44+
# Disable the Swagger UI
45+
####################################################################################
46+
#springdoc.swagger-ui.enabled=false
47+
#springdoc.api-docs.enabled=false

basyx.submodelservice/basyx.submodelservice.component/src/main/resources/application.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,11 @@ basyx:
1515
java:
1616
sources:
1717
classes: classes
18-
additionalClasspath: []
18+
additionalClasspath: []
19+
20+
# Disable the Swagger UI - enabled by default
21+
#springdoc:
22+
# swagger-ui:
23+
# enabled: false
24+
# api-docs:
25+
# enabled: false

0 commit comments

Comments
 (0)