Skip to content

2.8.0 /swagger-resource/configuration/ui does not set Accept header properly #2461

Closed

Description

@OverDrone

Hello!
springfox-swagger-ui-2.8.0\META-INF\resources\webjars\springfox-swagger-ui\springfox.js has the following code:
const configUIResponse = await fetch(baseUrl + "/swagger-resources/configuration/ui");
browser translates into HTTP request with request header Accept=/.
Swagger controller which handles "/swagger-resources/configuration/ui" does not define "produces".
My Web MVC configuration uses default produces=text/html (if set to application/json then other swagger static resources stop working).
Tomcat replies to /swagger-resources/configuration/ui having Accept=/ with 401 or 406 (depends on tomcat version).
Problem is that spring can't select representation for returned object in this configuration. It can't present it in default representation (test/html) and client didn't provide any hints (accept=/)
Previous version 2.7.0 used different javascript call $.ajax(...) which by default sets Accept="application/json,..."

Possible fix:
include content type in request:
fetch("...",
{
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
...
})

I have 18.3.1.1232 Yandex browser.

Activity

  1. dilipkrish commented on Jun 7, 2018

    @dilipkrish
    Member

    @OverDrone that is a great suggestion. Would you be able to create a PR?

  2. added this to the 2.9.1 milestone on Jun 19, 2018
  3. added a commit that references this issue on Mar 4, 2024
    20412a0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions