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

Header is not displaying in Swagger UI #391

Closed
brahamshakti opened this issue Apr 19, 2016 · 9 comments
Closed

Header is not displaying in Swagger UI #391

brahamshakti opened this issue Apr 19, 2016 · 9 comments

Comments

@brahamshakti
Copy link

This Code is not displaying header field in swagger UI

desc "Return super-secret information", {
  headers: {
    "XAuthToken" => {
      description: "Valdates your identity",
      required: true
    },
   "XOptionalHeader" => {
     description: "Not really needed",
     required: false
   }
 }
}

Earlier It used to be like
xauthtoken

But now it is showing no header field with above Code

noxauthtoken

How do I fix this issue.

@LeFnord
Copy link
Member

LeFnord commented Apr 19, 2016

would be cool to write a spec (similar to this one: api_swagger_v2_headers_spec.rb

so it could be reproduced

and which version did you using?

@brahamshakti
Copy link
Author

brahamshakti commented Apr 20, 2016

I am using version 0.20.1. Also My swagger doc looks like this

    {
    "get": {
        "description": "Get all rodeos",
        "headers": {
            "XAuthToken": {
                "description": "Valdates your identity",
                "required": true
            }
        },
        "produces": [
            "application/json"
        ],
        "responses": {
            "200": {
                "description": "Get all rodeos"
            }
        },
        "tags": [
            "rodeos"
        ],
        "operationId": "getV1Rodeos"
    }
}

But this is not creating header field.

@LeFnord
Copy link
Member

LeFnord commented Apr 20, 2016

ok, I see …
the so defined header should go into the response object,
to define header parameters, take a parameter and set the param_type to header
see: api_swagger_v2_param_type_spec.rb

@brahamshakti
Copy link
Author

It would be better if you could provide an alternative solution in form of some patch. Sorry but I think modifying 100s of apis to add just one extra parameter does not look a good approach. Can I accept some sort of patch in near future from you

@dblock
Copy link
Member

dblock commented Apr 20, 2016

@brahamshakti What exactly are you proposing? What would you like to write in your API? We'll accept patches from you, thanks.

I think you want to reuse parameters as described in https://github.com/ruby-grape/grape#helpers.

@wleeper
Copy link
Contributor

wleeper commented Apr 21, 2016

doing from the referenced test case

        params do
          optional :in_query, type: String, documentation: { param_type: 'query' }
          optional :in_header, type: String, documentation: { param_type: 'header' }
        end

does not really work. It will make valid swagger spec, but the grape code is looking for the in_header parameter in the params list not in the header. If it were a required field it would fail if you actually put the parameter in the header.

@LeFnord
Copy link
Member

LeFnord commented Apr 22, 2016

should be solved with @wleeper PR

but the question is always, how to differ between stuff for request and stuff for response for documentation …

what are your thoughts?

@LeFnord
Copy link
Member

LeFnord commented Apr 22, 2016

@brahamshakti give it a try, and close the issue

@brahamshakti
Copy link
Author

Thanks to @wleeper, my issue is resolved with this pull request. I am closing this issue for now. Thanks to all.

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