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

How to add the custom request header #29

Closed
jayhuang75 opened this issue Jan 15, 2018 · 6 comments
Closed

How to add the custom request header #29

jayhuang75 opened this issue Jan 15, 2018 · 6 comments

Comments

@jayhuang75
Copy link

Hello,

I'm wondering how I can add the custom request header? for example JWT.

@jayhuang75
Copy link
Author

jayhuang75 commented Jan 16, 2018

I create a PR for this. #30
if merged. this will be the example
// @Param Authorization header string true "With the bearer started"

@easonlin404
Copy link
Member

Fix via #30. Thanks for your contributions. 👍

@bbriggs
Copy link

bbriggs commented Jun 16, 2018

I like the idea of this, but it seems incomplete to me. When attempting to post a request using the Authorization field defined this way, there doesn't seem to be an auth type specified.

Using comments like so:
// @Param Authorization header string true "Bearer"

Swag produces an auth field as expected in the documentation, but fails to specify an auth type in the request. Consider a check on the following test route:

curl -X GET "http://localhost:8080/api/v1/agent/heartbeat" -H "accept: application/json" -H "Authorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1MjkxOTE4MzYsImlkIjoiZTNkMDA2MjAtZmNlNi00YmMyLTg1N2QtMzc4ZWFmZjk3MGNiIiwib3JpZ19pYXQiOjE1MjkxODgyMzZ9.uZaO5kZcDLLkDBRR9PIBGlWCjnuxbRFhvR8rU0qfdKA"

Obviously this is missing a field and is a malformed auth header.

Any guidance here? Is there something elsewhere in Swag that I'm missing?

@randrusiak
Copy link

@bbriggs Did you find any workaround?

@ubogdan
Copy link
Contributor

ubogdan commented Mar 8, 2023

@bbriggs you need to paste
Bearer[space]eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1MjkxOTE4MzYsImlkIjoiZTNkMDA2MjAtZmNlNi00YmMyLTg1N2QtMzc4ZWFmZjk3MGNiIiwib3JpZ19pYXQiOjE1MjkxODgyMzZ9.uZaO5kZcDLLkDBRR9PIBGlWCjnuxbRFhvR8rU0qfdKA in the authorization field

@randrusiak
Copy link

@ubogdan Yes, it's obvious. I though that there is a method to add 'Bearer' automatically :) Thanks!

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

5 participants