Description
While going through the github source code I noticed the SpringDocSpecPropertiesConfiguration
and SpecPropertiesCustomizer
which state:
Allows externalizing strings in generated openapi schema via properties that follow conventional naming similar or identical to openapi schema
To set value of a string in schema, define an application property that matches the target node with springdoc.spec-properties prefix.
Sample supported properties for api-info customization:
springdoc.spec-properties.info.title - to set title of api-info
springdoc.spec-properties.info.description - to set description of api-info
springdoc.spec-properties.info.version - to set version of api-info
This seemed quite useful as I'm doing that now in a custom OpenApiCustomizer.
However the springdocs docs say nothing about this in https://springdoc.org/#properties
I gave it a try but unfortunately it was not working...
Debugging a bit, the SpringDocSpecPropertiesConfiguration
itself is created as uncondionalClass
but it's beans are never created.
@Lazy(false)
@Configuration(proxyBeanMethods = false)
@ConditionalOnBean(SpringDocConfiguration.class)
@Conditional(SpecPropertiesCondition.class)
public class SpringDocSpecPropertiesConfiguration {
The SpecPropertiesCondition
seems to return false...
@Override
public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
final BindResult<SpringDocConfigProperties> result = Binder.get(context.getEnvironment())
.bind(SPRINGDOC_PREFIX, SpringDocConfigProperties.class);
if (result.isBound()) {
SpringDocConfigProperties springDocConfigProperties = result.get();
if (springDocConfigProperties.getOpenApi() != null)
return true;
Set<GroupConfig> groupConfigs = springDocConfigProperties.getGroupConfigs();
return groupConfigs.stream().anyMatch(config -> config.getOpenApi() != null);
}
return false;
}
The springDocConfigProperties.getOpenApi()
is null
...
and as I have no groups also the later statement will not match.
Is this supposed to work, and if so how?