Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refresh the browser each time, the global header is added in duplicate. #1820

Closed
doljae opened this issue Aug 30, 2022 · 4 comments
Closed
Labels
bug Something isn't working

Comments

@doljae
Copy link

doljae commented Aug 30, 2022

Describe the bug

  • Refresh the browser each time, the global header is added in duplicate.

To Reproduce
Steps to reproduce the behavior:

SwaggerConfiguration.kt

@Configuration
class SwaggerConfiguration {

    @Bean
    fun globalHeaders(): OpenApiCustomiser = OpenApiCustomiser { openApi ->
        openApi.paths.flatMap { it.value.readOperations() }
            .forEach {
                it.addParametersItem(HeaderParameter().name("Header1").required(true))
                it.addParametersItem(HeaderParameter().name("Header2").required(true))
            }
    }
}

Expected behavior

  • When I refresh the browser, it works properly without any duplicated headers.

Screenshots

After running Spring Boot application

image

Refresh browser once

image

Refresh browser twice

image

Additional context

  • Disabling the cache through the properties below does not cause duplicate headers.
springdoc.cache.disabled= true
  • I wonder if this is intended or if the configuration is wrong.

  • When I debug the code, it seems that AbstractOpenApiResource 's OpenApiCustomizer logic is related. If it's a bug, I want to send a PR after fixing it.

@doljae doljae changed the title Each time you refresh the browser, the global header is added in duplicate. Refresh the browser each time, the global header is added in duplicate. Aug 30, 2022
@bnasslahsen
Copy link
Contributor

@doljae,

There is no intention of such a behavior.
Please feel free to propose a PR.

@doljae
Copy link
Author

doljae commented Aug 30, 2022

@bnasslahsen ,
You already fixed it, I hope to make contribution 😭
Anyway, thanks for the quick fix.

bnasslahsen added a commit that referenced this issue Aug 30, 2022
@bnasslahsen
Copy link
Contributor

@doljae,

I have just reverted some old code. But if you had in mind a simpler PR, you still can propose it!

@doljae
Copy link
Author

doljae commented Aug 30, 2022

@bnasslahsen ,
I made PR with tiny adjustment. If you don't mind, please check 🙂

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants