Skip to content

Resolver error occurs when use custom OpenApiCustomiser to GroupedOpenApi #1493

@doljae

Description

@doljae

Describe the bug

  • Resolver error occurs when use custom OpenApiCustomiser to GroupedOpenApi
  • without addOpenApiCustomiser(), it works well.

To Reproduce
Steps to reproduce the behavior:

  • What version of spring-boot you are using?, 2.6.3
  • What modules and versions of springdoc-openapi are you using?, latest
  • Provide with a sample code (HelloController) or Test that reproduces the problem
@Configuration
public class SwaggerOpenApiConfiguration {

    @Bean
    public GroupedOpenApi channelApiGroup() {
        // sample conditions for GroupedOpenApi
        String[] paths = { "/v1/pet/**" };
        return GroupedOpenApi.builder().group("channel-gateway")
                             .pathToMatch(paths)
                             // if comment out the line below, resolver error occurs
                             .addOpenApiCustomiser(globalOpenApiCustomer())
                             .build();
    }

    public static OpenApiCustomiser globalOpenApiCustomer() {
        return openApi ->
            openApi.info(new Info()
                             .title(TITLE)
                             .description(DESCRIPTION)
                             .license(new License().name(LICENSE).url(LICENSE_URL))
                             .termsOfService(TERMS_OF_SERVICE_URL)
                             .version(VERSION))
                    // plus the request header also invisible
                   .components(new Components()
                                   .addParameters("test",
                                                  new Parameter()
                                                      .name("testHeader")
                                                      .required(true)
                                                      .in("header")
                                                      .description("testDescription").
                                                      schema(new StringSchema())))
    }
}

Expected behavior

Screenshots
image

Additional context

  • Plus, I add custom headers for trying out swagger with parameters, it is invisible.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions