Skip to content

Close out #9 — Problem Details ruleset, three base APIs, and RFC 9457 across the catalog - #32

Merged
kinlane merged 1 commit into
gh-pagesfrom
problem-details-ruleset
Aug 17, 2026
Merged

kinlane merged 1 commit into
gh-pagesfrom
problem-details-ruleset

Conversation

@kinlane

@kinlane kinlane commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor

Everything issue #9 asked for, end to end. Closes #9.

"Add the schema from train travel API to standards collection on API Commons. Add the ruleset for them as well to help people apply to the schema. Then reuse across all the base APIs we are developing…"

1. The ruleset

New repo: api-commons/spectral-problem-details-ruleset — 16 grounded rules for RFC 9457, on the spectral-owasp-ruleset pattern. Built-in Spectral functions only, so it also runs in the browser validator.

Grounded in RFC 9457 read in full. The sentence it's built around is §3.1:

"If a member's value type does not match the specified type, the member MUST be ignored."

A status declared as a string doesn't throw at the consumer — it vanishes. The type rules guard against silent data loss, not style.

The two rules worth the install on their own: problem-details-allows-extension-members (additionalProperties: false forbids the §3.2 mechanism the format evolves through, and several generators emit it by default) and problem-details-status-is-number.

Two things deliberately not done, documented rather than faked: no check that status matches the response's HTTP status code (not expressible with built-in functions), and urn:ietf:rfc:7807 is not flagged — RFC 9457 Appendix B retained that XML namespace. clean.yaml carries it so the suite fails if the regex ever over-matches.

2. Reuse across the base APIs

accounts, images and videos were description-and-tags stubs with no OpenAPI and no repo. All three now exist:

Repo Covers
api-commons/accounts list, create, read, merge-patch, close
api-commons/images upload, metadata, renditions, deletion
api-commons/videos upload, transcoding, renditions, captions, webhooks

Each ships an OpenAPI 3.1, an APIs.json index, a README, and Apache-2.0.

The RFC 9457 error components are byte-identical across all three, composed from one shared block rather than written three times. Adopt more than one base and your clients parse a single error format. That is the reuse the issue asked for.

All three lint clean under the ruleset, and under spectral:oas apart from oas3-api-servers — deliberate, since a base template has no server and a placeholder would only trip oas3-server-not-example.com. Building them surfaced three real defects, now fixed: two operations missing descriptions, and a Conflict response in images that no operation could return.

Design choices carried into the bases rather than left implicit: merge-patch with the null-means-delete trap documented on the patch schema; conditional writes via ETag/If-Match/412; two-step upload so a failed upload doesn't lose metadata; renditions requested rather than enumerated; alt on images and captions as a first-class sub-resource on videos; webhooks on videos, because video isn't ready when the upload finishes.

3. RFC 7807 → RFC 9457

The catalog cited an RFC obsoleted in July 2023 22 times, with zero references to its replacement.

Fixed at the source — spotlight-validator/rules/all-rules.yaml and rules/spotlight-recommended.yaml — then regenerated with scripts/generate-spotlight.py, since _data/spotlight_rules.json is generated and a direct edit would be overwritten on the next build.

rules/sources/* was deliberately not touched. Those are harvested third-party rulesets (team-digitale and others). Rewriting them would misrepresent what those vendors actually publish.

Three 7807 mentions remain on purpose, in the phrasing "RFC 9457, which obsoleted RFC 7807" — history, not a stale citation.

Also: rules/index.html advertised 733 rules; the committed data has held 740 since the agentic-access rules landed.

4. Base OpenAPI + site

  • _base/problem-details-for-http-apis.md — url moves to RFC 9457, and a Spectral Ruleset entry joins the others
  • _base/accounts|images|videos.md — rebuilt from stubs, each pointing at its OpenAPI, APIs.json, repo, and the ruleset
  • _common/error-codes.md — three problem-details rules under governance_rules, ruleset and base under tools
  • README — the ruleset in the tools table, the three bases in the specs list

One layout fix, needed for any of it to render. _layouts/base.html rendered only GitHubGist and GitHubRepository, giving every repo the hard-coded text "Visit this Base on GitHub". The ruleset would have shown up as a second one, and OpenAPI/APIsJSON properties would have been dropped silently. Replaced with a Resources list. Same class of trap as the _common layout: the layout renders a fixed set, so new frontmatter is invisible until the layout learns it.

⚠️ One caveat to hand on

spotlight-validator has no live remote — its origin is recorded as origin-defunct. The source-side RFC fix exists only in the local checkout. The generated output is committed here, but the next person to regenerate from a fresh clone will reintroduce the 7807 text unless that repo gets a home.

Related

Verification

npm test on the ruleset asserts every declared rule fires on the noncompliant fixture, the clean fixture is silent, and no rule throws — that first assertion caught four rules that could never fire. It also caught a false positive in itself: the 7807 rule fired on a document correctly explaining the supersession, now scoped with a negative lookahead and a fixture proving it.

Site builds clean; all five base pages render their resources.

🤖 Generated with Claude Code

New repo: api-commons/spectral-problem-details-ruleset — 16 grounded Spectral
rules for RFC 9457, following the spectral-owasp-ruleset pattern.

- _base/problem-details-for-http-apis.md: url moves from RFC 7807 to RFC 9457,
  description explains that the retained urn:ietf:rfc:7807 XML namespace is
  deliberate (RFC 9457 Appendix B), and a Spectral Ruleset entry joins the
  OpenAPI and Repository entries.
- _common/error-codes.md: three problem-details rules under governance_rules,
  and the ruleset plus the base OpenAPI under tools.
- README: the ruleset in the tools table, and a pointer from the base entry.

Layout fix, needed for the above to render at all. _layouts/base.html rendered
only GitHubGist and GitHubRepository properties, and every GitHubRepository got
the hard-coded link text "Visit this Base on GitHub". That is wrong the moment a
base points at more than one repo — the ruleset would have rendered as a second
"Visit this Base on GitHub", and the Rules and Specification properties would
have been dropped silently. Replaced with a Resources list that renders every
non-gist property with its own label and type. train-travel is unchanged in
substance (one repository, now labelled); accounts, images and videos declare no
apis block and are unaffected.

Verified: site builds clean, all four links render on the base page, and the
other four base pages still render their gists.

Closes #9.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@kinlane
kinlane merged commit ce4fc7f into gh-pages Aug 17, 2026
@kinlane kinlane changed the title Wire the Problem Details ruleset into the site Close out #9 — Problem Details ruleset, three base APIs, and RFC 9457 across the catalog Aug 17, 2026
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.

Problem Details for HTTP APIs

1 participant