Skip to content

Commit e52fb0f

Browse files
committed
Simplify springdoc/swagger-ui config
This comes with an updated springdoc config that disables package scanning so that we can solely rely on the merged API file
1 parent f88b866 commit e52fb0f

File tree

1 file changed

+3
-29
lines changed

1 file changed

+3
-29
lines changed

src/main/kotlin/com/cosmotech/api/config/CsmOpenAPIConfiguration.kt

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,15 @@ import io.swagger.v3.oas.models.security.OAuthFlows
88
import io.swagger.v3.oas.models.security.Scopes
99
import io.swagger.v3.parser.OpenAPIV3Parser
1010
import java.io.BufferedReader
11-
import org.springdoc.core.customizers.OperationCustomizer
1211
import org.springframework.beans.factory.annotation.Value
13-
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
1412
import org.springframework.context.annotation.Bean
1513
import org.springframework.context.annotation.Configuration
16-
import org.springframework.context.annotation.Primary
1714

1815
@Configuration
19-
@ConditionalOnProperty(name = ["csm.cliapplication"], havingValue = "false", matchIfMissing = true)
2016
open class CsmOpenAPIConfiguration(val csmPlatformProperties: CsmPlatformProperties) {
2117

2218
@Value("\${api.version:?}") private lateinit var apiVersion: String
2319

24-
// TODO For some reason, all operation IDs exposed are suffixed with "_1" by SpringDoc.
25-
// This removes such suffix dynamically, until we find a better strategy
26-
@Bean
27-
open fun csmOpenAPIOperationCustomizer(): OperationCustomizer {
28-
return OperationCustomizer { operation, _ ->
29-
if (operation.operationId?.endsWith("_1") == true) {
30-
operation.operationId = operation.operationId.substringBefore("_1")
31-
}
32-
operation
33-
}
34-
}
35-
36-
@Primary
3720
@Bean
3821
open fun csmOpenAPI(): OpenAPI {
3922
val openApiYamlInputStream =
@@ -55,20 +38,11 @@ open class CsmOpenAPIConfiguration(val csmPlatformProperties: CsmPlatformPropert
5538

5639
openAPI.info.version = apiVersion
5740

58-
if (openAPI.info.description.isNullOrBlank()) {
59-
openAPI.info.description = "Cosmo Tech Platform API"
41+
if (!csmPlatformProperties.vcsRef.isNullOrBlank()) {
42+
openAPI.info.description += " / ${csmPlatformProperties.vcsRef}"
6043
}
6144
if (!csmPlatformProperties.commitId.isNullOrBlank()) {
62-
if (csmPlatformProperties.vcsRef.isNullOrBlank()) {
63-
openAPI.info.description += " (${csmPlatformProperties.commitId})"
64-
} else {
65-
openAPI.info.description +=
66-
" (${csmPlatformProperties.vcsRef} / ${csmPlatformProperties.commitId})"
67-
}
68-
} else {
69-
if (!csmPlatformProperties.vcsRef.isNullOrBlank()) {
70-
openAPI.info.description += " (${csmPlatformProperties.vcsRef})"
71-
}
45+
openAPI.info.description += " / ${csmPlatformProperties.commitId}"
7246
}
7347

7448
// Remove any set of servers already defined in the input openapi.yaml,

0 commit comments

Comments
 (0)