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

Chrome overrides User-Agent specified as parameter #5035

Open
pikazlou opened this issue Nov 16, 2018 · 4 comments
Open

Chrome overrides User-Agent specified as parameter #5035

pikazlou opened this issue Nov 16, 2018 · 4 comments

Comments

@pikazlou
Copy link

Q&A (please complete the following information)

  • OS: macOS
  • Browser: chrome
  • Browser Version: 70.0.3538.77
  • Method of installation: dist assets
  • Swagger-UI version: 3.19.5
  • Swagger/OpenAPI version: Swagger 2.0

Content & configuration

Example Swagger/OpenAPI definition:

      - name: "User-Agent"
        in: "header"
        description: "user agent"
        required: true
        type: "string"
        default: "CustomAgent"

Swagger-UI configuration options:

    window.onload = function() {
      // Begin Swagger UI call region
      const ui = SwaggerUIBundle({
        url: "swagger.yaml",
        dom_id: '#swagger-ui',
        deepLinking: true,
        presets: [
          SwaggerUIBundle.presets.apis,
          SwaggerUIStandalonePreset
        ],
        plugins: [
          SwaggerUIBundle.plugins.DownloadUrl
        ],
        layout: "StandaloneLayout"
      })
      // End Swagger UI call region

      window.ui = ui
    }

Describe the bug you're encountering

Browser always overrides User-Agent header and sends its own, no matter what value I type into parameter

To reproduce...

Steps to reproduce the behavior:

  1. Go to method with User-Agent parameter
  2. Click on Execute

Expected behavior

Request is sent with User-Agent equal to specified parameter

Actual behavior

Request is sent with standard browser User-Agent

@shockey
Copy link
Contributor

shockey commented Nov 21, 2018

Hey @pikazlou!

This is the same root cause as swagger-api/swagger-js#1163 - there are certain headers that the browser doesn't let us set.

For now, this is a limitation of Swagger UI - see the linked ticket for some possible solutions.

@pikazlou
Copy link
Author

pikazlou commented Nov 22, 2018

hi @shockey
Thanks for your reply!
I must note that User-Agent header does work in Safari: swagger successfully sends specified value.

@czxsj
Copy link

czxsj commented Aug 24, 2020

@shockey it certainly works in Safari.Thanks for the advice.

@matt1munich
Copy link

It also works properly in Windows Firefox -- not so much in Chrome & Edge.

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

No branches or pull requests

4 participants