ruby-grape / ruby-grape/grape-swagger

How to add custom headers to all apis in swagger doc

Open
#812 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
1.1k
Forks
479
Avg merge
2d 14h
Merged PRs (30d)
6

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 in all apis under certain resources or namespace?

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 Grape API example in the issue and trace how headers are represented in the generated Swagger documentation. Determine whether headers can be applied at a resource or namespace level; the issue is complete only when the supported behavior and its configuration are clearly established.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
api
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.