ruby-grape / ruby-grape/grape

API version format in Accept header

Open
#1,078 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Hi,

The Versioning middleware specifies the syntax for the HTTP Accept header as follows:

module Grape
  module Middleware
    module Versioner
      # This middleware sets various version related rack environment variables
      # based on the HTTP Accept header with the pattern:
      # application/vnd.:vendor-:version+:format

In particular, "vnd.vendor-version" with a dash "-" between vendor and version. I've been trying to understand the origin of this syntax.

Is it possible to support dot "." version in addition to dash "-" version?

Such as:

vnd.vendor.version+format

Github, for example, uses this format. From https://developer.github.com/v3/:

Current Version

By default, all requests receive the v3 version of the API. We encourage you to explicitly request this version via the Accept header.

Accept: application/vnd.github.v3+json

A client that specifies the Accept header in this way, cannot be validated using the default versioning middleware in grape, with grape as the backend.

Thanks!

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 by locating the Grape::Middleware::Versioner implementation and the tests covering Accept-header version parsing. Trace how the existing vnd.vendor-version+format syntax is validated, then verify that vnd.vendor.version+format is accepted without breaking the dash form. Done means both formats are covered by tests and the GitHub-style header validates successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
api
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.