You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Fast Healthcare Interoperability Resources (FHIR) R4 or R5. #11
Done — api-commons/spectral-fhir-ruleset, public, Apache-2.0. 15 rules, following the spectral-owasp-ruleset pattern: built-in Spectral functions only, a stable id and a section-level documentationUrl per rule, clean and noncompliant fixtures, and a harness that gates on both.
The gap between returns Patient objects and is a FHIR server. Grounded in hl7.org/fhir/R4/http.html read in full, plus the search, OperationOutcome, CapabilityStatement and SMART App Launch pages.
The three that catch the most:
fhir-resource-type-path-segment — resource types are case-sensitive PascalCase singular names from a closed list. /patients and /Patients are both wrong, and both are what a team writes when bolting FHIR-shaped payloads onto REST conventions. The ruleset embeds the 178-type R4 ∪ R5 union, harvested from the published resource lists.
fhir-error-operationoutcome — OperationOutcome is FHIR's problem-details equivalent. A bespoke {"error": "..."} forces every client to carry two error parsers.
fhir-read-etag / fhir-etag-weak / fhir-update-if-match — the concurrency contract, where the versionId is a weak validator (W/"3141"). A strong-ETag example in a FHIR description is wrong and gets copied.
Plus the /metadata CapabilityStatement a server SHALL expose, searchset Bundles instead of bare arrays, application/fhir+json, and SMART v1/v2 scope syntax.
Validated against a real server
The public HAPI FHIR R4 server's own generated OpenAPI — 2,973 paths. The first run returned 64 resource-type findings and every one was a bug in this ruleset, not in HAPI: Bundle wrongly excluded, three real types (EffectEvidenceSynthesis, Parameters, Requirements) silently dropped when I typed the pattern by hand, the root path / not allowed, and vendor operations containing dots not matching. The pattern is now generated from the harvested list rather than typed. Zero false positives on resource types.
The 584 findings that remain there are real: HAPI's generated OpenAPI never documents the ETag / If-Match / 409-412 contract, even though the running server implements it. Expect that on any server-generated FHIR OpenAPI.
Scope, stated rather than implied
It governs the HTTP surface, not resource instances. Profile and IG conformance needs StructureDefinitions, terminology servers and the resource graph — none of which exist inside an OpenAPI. The HL7 validator remains the tool for that; this checks what the validator doesn't.
One residual: the resource list is the R4 ∪ R5 union, so flagging a valid R5 type on an R5 API can't happen — at the cost that an R4 API using an R5-only type passes. Pin the release in info.description and review by hand.
Activity
kinlane commentedon Aug 28, 2024
Reference - https://developer.community.nhs.uk/t/automating-api-style-guides-linting-with-spectral-for-fhir/179/7
Add the FHIR ruleset to the tools table
kinlane commentedon Aug 17, 2026
Done — api-commons/spectral-fhir-ruleset, public, Apache-2.0. 15 rules, following the
spectral-owasp-rulesetpattern: built-in Spectral functions only, a stable id and a section-leveldocumentationUrlper rule, clean and noncompliant fixtures, and a harness that gates on both.Registered in Ruleset Commons (ruleset-commons#2) and added to the tools table (api-commons#33).
What it checks
The gap between returns Patient objects and is a FHIR server. Grounded in
hl7.org/fhir/R4/http.htmlread in full, plus the search, OperationOutcome, CapabilityStatement and SMART App Launch pages.The three that catch the most:
fhir-resource-type-path-segment— resource types are case-sensitive PascalCase singular names from a closed list./patientsand/Patientsare both wrong, and both are what a team writes when bolting FHIR-shaped payloads onto REST conventions. The ruleset embeds the 178-type R4 ∪ R5 union, harvested from the published resource lists.fhir-error-operationoutcome— OperationOutcome is FHIR's problem-details equivalent. A bespoke{"error": "..."}forces every client to carry two error parsers.fhir-read-etag/fhir-etag-weak/fhir-update-if-match— the concurrency contract, where the versionId is a weak validator (W/"3141"). A strong-ETag example in a FHIR description is wrong and gets copied.Plus the
/metadataCapabilityStatement a server SHALL expose, searchset Bundles instead of bare arrays,application/fhir+json, and SMART v1/v2 scope syntax.Validated against a real server
The public HAPI FHIR R4 server's own generated OpenAPI — 2,973 paths. The first run returned 64 resource-type findings and every one was a bug in this ruleset, not in HAPI:
Bundlewrongly excluded, three real types (EffectEvidenceSynthesis,Parameters,Requirements) silently dropped when I typed the pattern by hand, the root path/not allowed, and vendor operations containing dots not matching. The pattern is now generated from the harvested list rather than typed. Zero false positives on resource types.The 584 findings that remain there are real: HAPI's generated OpenAPI never documents the ETag / If-Match / 409-412 contract, even though the running server implements it. Expect that on any server-generated FHIR OpenAPI.
Scope, stated rather than implied
It governs the HTTP surface, not resource instances. Profile and IG conformance needs StructureDefinitions, terminology servers and the resource graph — none of which exist inside an OpenAPI. The HL7 validator remains the tool for that; this checks what the validator doesn't.
One residual: the resource list is the R4 ∪ R5 union, so flagging a valid R5 type on an R5 API can't happen — at the cost that an R4 API using an R5-only type passes. Pin the release in
info.descriptionand review by hand.