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

Last-modified response header date-time wrongly formatted in Response headers box #8178

Open
tomeksamcik opened this issue Sep 9, 2022 · 1 comment

Comments

@tomeksamcik
Copy link

tomeksamcik commented Sep 9, 2022

Q&A

  • OS: macOS Monterey 12.4
  • Browser: Chrome
  • Version: 105.0.5195.102 (arm64)
  • Method of installation: docker
  • Swagger-UI version: 4.14.0
  • OpenAPI version: OpenAPI 3.0.0

Content & configuration

Example Swagger/OpenAPI definition:

(...)
  200:
     description: (...)
     headers:
        Last-Modified:
           description: (...)
           schema:
              type: string
              format: HTTP-date
              example: Fri, 27 Sep 2019 11:00:00 GMT
(...)  

Swagger-UI is in it's default configuration.

Describe the bug you're encountering

When testing an endpoint that is returning http Last-modified header, in the swagger Response headers box, instead of having them displayed raw as they are returned from the server, headers are lowercased (not an issue) and Last-modified is reformatted in a way that it no longer conforms to HTTP-date format (RFC2616)

Sending it in this format in If-Modified-Since header may then result in ignoring it as that's what http protocol tells to do (RFC7232).

To reproduce...

Nothing special:

  1. Go to swagger-ui
  2. Click on Try it out and Execute request returning Last-modified
  3. Scroll down to Response headers
  4. See how Last-modified is wrongly formatted

Expected behavior

Instead of Fri,20 Jul 2018 20:23:07 GMT, it should be Fri, 20 Jul 2018 20:23:07 GMT

Screenshots

Server response headers:

Zrzut ekranu 2022-09-9 o 12 31 14

Swagger response headers box:

Zrzut ekranu 2022-09-9 o 12 31 27

@tomeksamcik tomeksamcik changed the title Last-modified response header date-time reformatted in Response headers box Last-modified response header date-time wrongly formatted in Response headers box Sep 9, 2022
@vidaritos
Copy link

vidaritos commented Jun 25, 2024

This also happens with the Date and Expires response headers (and most likely other date response fields, if any)
{"swaggerUI":{"version":"5.17.10","gitRevision":"gb5c84f44","gitDirty":true,"buildTimestamp":"Wed, 15 May 2024 14:13:17 GMT"}}

I was playing around with conditional requests and wasted a lot of time to figure this bug out because I copied the Last-Modified response header value into the If-Modified-Since input field and the server failed to parse the date and gave me HTTP 200 when I expected HTTP 304

Edit: Think it's this line
https://github.com/swagger-api/swagger-ui/blob/0ce792c9d0965a8b6b5d75f5e1341ff6936a4cb0/src/core/components/live-response.jsx#L66C33-L66C40

It's not really about dates, but rather that the header value contains ", " (comma space)
Ex response:
Server: X-Header: A, B, C, D, , , , test, test
Swagger UI: x-header: A,B,C,D,,,,test, test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants