Skip to content

Documentation on passing the springdoc properties #1485

@vojkny

Description

@vojkny

Is your feature request related to a problem? Please describe.

I am trying to pass the springdoc java properties programmatically. I am following the documentation in:

https://springdoc.org/#swagger-ui-properties

And official swagger doc:

https://swagger.io/docs/open-source-tools/swagger-ui/usage/configuration/

It seems that setting the parameters programmatically as:

@Configuration
@ComponentScan(basePackages = ["org.springdoc"])
@Import(OpenApiSecurityConfig::class)
open class OpenApiConfig(
    @Value("#{systemEnvironment['SERVICE_NAME']?:''}")
    private val serviceName: String,
) : WebMvcConfigurer {
    init {
        // For details, see https://springdoc.org/#swagger-ui-properties
        System.setProperty("springdoc.swagger-ui.path", "/services/$serviceName")
        System.setProperty("springdoc.swagger-ui.url", "/services/$serviceName/v3/api-docs")
        System.setProperty("springdoc.swagger-ui.configUrl", "/services/$serviceName/v3/api-docs/swagger-config")
        System.setProperty("springdoc.swagger-ui.showCommonExtensions", "true")
    }
}

Is too late and therefore ignored. I cannot use static parameters file as I need to take into account the SERVICE_NAME variable.

Describe the solution you'd like
It would be great to add description programmatically setting the springdoc java properties.

Describe alternatives you've considered
I couldn't find any other solution.

Additional context
🙏 🙏 🙏 🙏 🙏

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions