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

Added feature to report header params in params block #393

Merged

Conversation

wleeper
Copy link
Contributor

@wleeper wleeper commented Apr 22, 2016

What's this PR do, and where should I start?

This PR address Issue #391

This PR changes the behavior by no longer output a header tag at the root level of an endpoint, and replaces that with parameters tagged with "in": "header", which is the correct Swagger 2.0 method.

See changes to spec/swagger_v2/simple_mounted_api_spec.rb to see how the behavior changed.

How should this be manually tested?

Fire up the example app and add some header variables using the proper grape syntax (note the example below is <= 0.14, not what is in the docs for 0.16.2:

        desc 'This returns something',
          failure: [{code: 400, model: Entities::ApiError}],
          headers:  {
            "X-Rate-Limit-Limit" => {
              "description" => "The number of allowed requests in the current period",
              "type" => "integer"
          }}
        get '/use_headers' do
          { "declared_params" => declared(params) }
        end

Any background context you want to provide?

Ran into this issue when I tried to add header params to our app.

@wleeper wleeper force-pushed the render-header-params-in-paramters-list branch from 5c7df40 to ad56e17 Compare April 22, 2016 03:53
@LeFnord
Copy link
Member

LeFnord commented Apr 22, 2016

@wleeper thanks for it, but to be consistent with your own proposal, I suggest a stronger distinction between request and response

  1. request related: all what is inside the params block
  2. response related: all from desc section

what did you mean?

@LeFnord
Copy link
Member

LeFnord commented Apr 22, 2016

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

what are your thoughts?

@LeFnord LeFnord merged commit ff42b8e into ruby-grape:master Apr 22, 2016
@wleeper
Copy link
Contributor Author

wleeper commented Apr 22, 2016

This just addresses the request parameters. I'm not even sure exactly where swagger puts response headers and how we would capture the documentation.

@LeFnord
Copy link
Member

LeFnord commented Apr 22, 2016

yeap, I know … swagger puts the response headers into the response object,
but how can we document it?

the header key from desc is now a parameter, that was the intention for my proposal above

LeFnord added a commit to LeFnord/grape-swagger that referenced this pull request Feb 9, 2019
…n-paramters-list

Added feature to report header params in params block
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

Successfully merging this pull request may close these issues.

2 participants