Skip to content

Fix README typos, remove obsolete Fixnum section, and clarify optional + values#2700

Merged
ericproulx merged 1 commit intomasterfrom
docs/readme-typos-and-fixnum-cleanup
May 8, 2026
Merged

Fix README typos, remove obsolete Fixnum section, and clarify optional + values#2700
ericproulx merged 1 commit intomasterfrom
docs/readme-typos-and-fixnum-cleanup

Conversation

@ericproulx
Copy link
Copy Markdown
Contributor

@ericproulx ericproulx commented May 8, 2026

Summary

Spelling/grammar:

  • "given on an `configuration`" → "based on a `configuration`"
  • "Accept` head" → "Accept` header"
  • "won't affects" → "won't affect"
  • "`with' blocks" → "`with` blocks" (mismatched quote)
  • `required :beer` / `:wine` / `:blah` → `requires` — the DSL method is `requires` (lib/grape/dsl/parameters.rb:125); the samples as written would raise `NoMethodError`
  • "the the [grape-entity]" → "the [grape-entity]"

Accuracy:

  • §"Accept-Version Header": strict-mode sentence said `406 Not Acceptable` was raised when no correct `Accept` header was supplied; the middleware checks `HTTP_ACCEPT_VERSION` (lib/grape/middleware/versioner/accept_version_header.rb:22), corrected to "Accept-Version"
  • `Rack::Etag` → `Rack::ETag` (correct class name)
  • Removed the "Integer/Fixnum and Coercions" section comparing Ruby 2.4 vs. earlier versions — `grape.gemspec` requires Ruby `>= 3.2`, where `Fixnum` no longer exists

Replaces incorrect `values + allow_blank` note (closes #2631):

The old note claimed:

Note that `allow_blank` validator applies while using `:values`. In the following example the absence of `:allow_blank` does not prevent `:state` from receiving blank values because `:allow_blank` defaults to `true`.

Both claims are wrong:

  • `@allow_blank` defaults to `nil`, not `true` (lib/grape/validations/validators/base.rb:62)
  • With `requires :state, type: Symbol, values: [...]`, sending `nil` produces a 400 — the values validator rejects it

The real quirk is with `optional + :values`, where missing key, `nil`, and `""` (coerced to `nil` for Symbol) all pass. `ValuesValidator#validate_param!` short-circuits on `nil` for optional root-scope params (lib/grape/validations/validators/values_validator.rb:30) before `@allow_blank` is consulted. The new note documents that and shows `allow_blank: false` as the opt-out, with a behavior matrix verified end-to-end:

`params` block omitted `nil` `""` invalid valid
`requires :state, type: Symbol, values: [...]` 400 400 400 400 201
`optional :state, type: Symbol, values: [...]` 201 201 201 400 201
`optional :state, ..., allow_blank: false` 201 400 400 400 201

Test plan

  • No code changes; README only
  • Inspected against current code/gemspec for each accuracy claim
  • Verified `optional + :values` behavior matrix end-to-end with a runnable Rack-based repro

🤖 Generated with Claude Code

@ericproulx ericproulx force-pushed the docs/readme-typos-and-fixnum-cleanup branch from 79e240d to 5c14346 Compare May 8, 2026 11:58
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 8, 2026

Danger Report

No issues found.

View run

…l + values

Spelling and grammar:
- "given on an `configuration`" → "based on a `configuration`"
- "Accept` head" → "Accept` header"
- "won't affects" → "won't affect"
- "with' blocks" → "with` blocks" (mismatched quote)
- `required :beer` / `:wine` / `:blah` → `requires` (the DSL method
  is `requires`; the samples as written would raise NoMethodError)
- "the the [grape-entity]" → "the [grape-entity]"

Accuracy:
- §"Accept-Version Header": the strict-mode sentence said the 406 was
  raised when no correct `Accept` header was supplied; the middleware
  checks `HTTP_ACCEPT_VERSION`, so corrected to "Accept-Version".
- "Rack::Etag" → "Rack::ETag" (correct class name).
- Removed the "Integer/Fixnum and Coercions" section comparing Ruby
  2.4 vs. earlier — `grape.gemspec` requires Ruby >= 3.2, where
  `Fixnum` no longer exists.

Replaces an incorrect note about `requires + values + allow_blank`
(closes #2631) with a correct note covering `optional + values`. The
deleted note claimed `:allow_blank` defaults to `true` and that
absence of `:allow_blank` does not prevent `:state` from receiving
blank values — both wrong: `@allow_blank` defaults to `nil`, and
`requires` already rejects `nil` via the values validator. The real
quirk is `optional + values`: `ValuesValidator#validate_param!`
short-circuits on `nil` whenever the param is optional at the root
scope, so missing/`nil`/`""`-coerced-to-`nil` all pass. The new note
documents that and shows `allow_blank: false` as the way to opt out
while still allowing the key to be absent.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@ericproulx ericproulx force-pushed the docs/readme-typos-and-fixnum-cleanup branch from 5c14346 to a8929f5 Compare May 8, 2026 15:34
@ericproulx ericproulx changed the title Fix README typos and remove obsolete Ruby 2.4 / Fixnum section Fix README typos, remove obsolete Fixnum section, and clarify optional + values May 8, 2026
@ericproulx ericproulx merged commit a83fd7e into master May 8, 2026
80 checks passed
@dblock dblock deleted the docs/readme-typos-and-fixnum-cleanup branch May 8, 2026 22:54
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.

1 participant