You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am writing a custom spring boot starter that i want to reuse among several projects.
for this purpose i want to dynamically configure grouped open apis.
when i add a bean that returns GroupedOpenApi it works, but when i add bean that returns List<GroupedOpenApi> it does nothing. is there an option to configure a list of GroupedOpenApi dynamically?
api-title: "My Custom API"api-version: "2.0.0"api-groups:
- name: Greeting-API-V1path: "/api/greeting/v1/hello/**"packages: "com.tsi.dv.backend.controller.greeting"
- name: Some Other Apipath: "/api/some-other/**"
- name: Even Another Apipackages: "com.tsi.dv.example.foobar"
my beans:
constvalSWAGGER_SECURITY_SCHEME_NAME="Bearer Authentication"privateconstvalDV_APIDOC_PROPERTY_PREFIX="dv.swagger"
@ConditionalOnWebApplication
@ConditionalOnProperty(prefix =DV_APIDOC_PROPERTY_PREFIX, name = ["enabled"], havingValue ="true")
@AutoConfiguration
@EnableConfigurationProperties(DvSwaggerConfigurationProperties::class)
@SecurityScheme(
name =SWAGGER_SECURITY_SCHEME_NAME,
type =SecuritySchemeType.HTTP,
bearerFormat ="JWT",
scheme ="bearer"
)
openclassDvSwaggerConfig(
privatevalproperties:DvSwaggerConfigurationProperties
) {
init {
logger.info { "----> DvSwaggerConfig loaded" }
}
@Bean("dvOpenAPI")
openfuncustomOpenAPI(): OpenAPI {
returnOpenAPI()
.components(Components())
.info(Info().title(properties.apiTitle).version(properties.apiVersion))
}
// NOT WORKING
@Bean("dvSwaggerApiGroups")
openfunapiGroups(): List<GroupedOpenApi> {
return properties.apiGroups.map { group ->GroupedOpenApi.builder().group(group.name).let {
if (group.path !=null) {
it.pathsToMatch(group.path)
}
if (group.packages !=null) {
it.packagesToScan(group.packages)
} else {
it.packagesToScan("com.tsi.dv")
}.build()
}
}
}
// WORKS
@Bean("dvSwaggerApiGroup")
openfunapiGroup(): GroupedOpenApi {
val group = properties.apiGroups.first()
returnGroupedOpenApi.builder()
.group(group.name)
.pathsToMatch(group.path)
.packagesToScan(group.packages)
.build()
}
}
@ConfigurationProperties(prefix =DV_APIDOC_PROPERTY_PREFIX)
data classDvSwaggerConfigurationProperties(
varenabled:Boolean = true,
varapiTitle:String = "API Doc",
varapiVersion:String = "v1",
varapiGroups:List<ApiGroup> = listOf()
)
data classApiGroup(
varname:String,
varpath:String? = null,
varpackages:String? = null
)
Expected behavior
i would expect that "dvSwaggerApiGroups" bean would create groups based on the List properties.
Screenshots
// introducing group by "dvSwaggerApiGroup" works, "dvSwaggerApiGroups" not.
this also happens if i remove "dvSwaggerApiGroup".
The text was updated successfully, but these errors were encountered:
Describe the bug
I am writing a custom spring boot starter that i want to reuse among several projects.
for this purpose i want to dynamically configure grouped open apis.
when i add a bean that returns
GroupedOpenApi
it works, but when i add bean that returnsList<GroupedOpenApi>
it does nothing. is there an option to configure a list of GroupedOpenApi dynamically?To Reproduce
Steps to reproduce the behavior:
the properties i pass:
my beans:
Expected behavior
Screenshots
// introducing group by "dvSwaggerApiGroup" works, "dvSwaggerApiGroups" not.
this also happens if i remove "dvSwaggerApiGroup".
The text was updated successfully, but these errors were encountered: