ruby-grape / ruby-grape/grape

Add custom headers to all apis in swagger doc

Open
#2,119 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature request
Dominant language
Ruby
Stars
10k
Forks
1.2k
Avg merge
14h 38m
Merged PRs (30d)
92

Description

there is a way to add headers field in one api as document mentions, like below

class API::V1::Teachers < Grape::API
  resource :teachers do
    desc "get all teachers information" do
      headers XAuthToken: {
            description: 'Validates your identity',
            required: true
          },
          XOptionalHeader: {
            description: 'Not really needed',
            required: false
          }
    end
    success: API::V1::Entities::Teachers::Base
    get '' do
      teachers = Teacher.all

      present :teachers, teachers, with: API::V1::Entities::Teachers::Base
    end
  end
end

but is there a way to add same headers to all apis under certain resources or namespace or all of them?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the existing headers option in the desc block and the API::V1::Teachers resource example. Investigate whether headers can be applied at the resource, namespace, or API scope; done means establishing a supported approach and documenting or implementing the selected scope.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
api, backend-api-design
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.