Coder Social home page Coder Social logo

How to add the custom request header about swag HOT 6 CLOSED

swaggo avatar swaggo commented on August 15, 2024
How to add the custom request header

from swag.

Comments (6)

jayhuang75 avatar jayhuang75 commented on August 15, 2024 8

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

from swag.

bbriggs avatar bbriggs commented on August 15, 2024 8

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?

from swag.

easonlin404 avatar easonlin404 commented on August 15, 2024

Fix via #30. Thanks for your contributions. 👍

from swag.

randrusiak avatar randrusiak commented on August 15, 2024

@bbriggs Did you find any workaround?

from swag.

ubogdan avatar ubogdan commented on August 15, 2024

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

from swag.

randrusiak avatar randrusiak commented on August 15, 2024

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

from swag.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.