Skip to content

Commit 2f99608

Browse files
committed
Upgrade coverage.json schema to JSON Schema 2020-12
Draft-07 is from 2018. 2020-12 is the current published draft, supported by every modern validator (including json_schemer in the dev Gemfile) and by every IDE that auto-resolves $schema URLs. There is no compatibility reason to ship a 2018-era contract as the public schema. Update the meta-schema URI in both schema files (the versioned canonical and the unversioned alias) and switch the spec assertion from JSONSchemer.draft7 to JSONSchemer.draft202012. Retitle the README section to "JSON Schema for coverage.json" so it is searchable for someone looking for "JSON schema simplecov" rather than for the internal filename, and tighten the opening paragraph (the second bullet was redundant with the prose that followed).
1 parent aeaf820 commit 2f99608

4 files changed

Lines changed: 9 additions & 12 deletions

File tree

README.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1148,14 +1148,11 @@ SimpleCov.formatter = SimpleCov::Formatter::JSONFormatter
11481148

11491149
> The JSON formatter was originally a separate gem called [simplecov_json_formatter](https://github.com/codeclimate-community/simplecov_json_formatter). It is now built in and loaded by default. Existing code that does `require "simplecov_json_formatter"` will continue to work.
11501150
1151-
### `coverage.json` schema
1151+
### JSON Schema for `coverage.json`
11521152

1153-
The `coverage.json` payload is treated as a public contract. Every emitted file carries:
1153+
`coverage.json` is a public contract, described by a JSON Schema (2020-12) so downstream tools can validate it, generate types, or pin to a known shape. Every emitted document carries a top-level `$schema` URL pointing at the versioned canonical, plus a human-readable `meta.schema_version` (`"major.minor"`).
11541154

1155-
- a top-level `$schema` URL pointing at the exact versioned schema the document conforms to (machine-resolvable, so consumers like IDEs and validators auto-fetch the right contract),
1156-
- a `meta.schema_version` (`"major.minor"`) for human-readable inspection.
1157-
1158-
JSON Schema (draft-07) is published in the repo. The **versioned canonical** lives at [`schemas/coverage-v1.0.schema.json`](schemas/coverage-v1.0.schema.json) and is immutable per version: long-lived integrations should pin to it. A convenience alias at [`schemas/coverage.schema.json`](schemas/coverage.schema.json) always tracks the latest, and may shift when a new SimpleCov release bumps the schema.
1155+
The **versioned canonical** lives at [`schemas/coverage-v1.0.schema.json`](schemas/coverage-v1.0.schema.json) and is immutable per version, so long-lived integrations should pin to it. A convenience alias at [`schemas/coverage.schema.json`](schemas/coverage.schema.json) always tracks the latest and may shift when a new SimpleCov release bumps the schema.
11591156

11601157
The schema version is independent of the gem version:
11611158

schemas/coverage-v1.0.schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"$schema": "http://json-schema.org/draft-07/schema#",
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
33
"$id": "https://raw.githubusercontent.com/simplecov-ruby/simplecov/main/schemas/coverage-v1.0.schema.json",
44
"title": "SimpleCov coverage.json",
55
"description": "Schema for the coverage.json file emitted by SimpleCov's JSONFormatter. Versioned independently of the gem. Non-breaking additions bump the minor segment of schema_version, breaking changes bump the major segment. The versioned file at schemas/coverage-vX.Y.schema.json is the canonical artifact for that version, schemas/coverage.schema.json is a convenience alias for the latest.",

schemas/coverage.schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"$schema": "http://json-schema.org/draft-07/schema#",
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
33
"$id": "https://raw.githubusercontent.com/simplecov-ruby/simplecov/main/schemas/coverage.schema.json",
44
"title": "SimpleCov coverage.json (latest)",
55
"description": "Convenience alias for the latest coverage.json schema. Mirrors schemas/coverage-v1.0.schema.json except for the $id (which is the unversioned URL). For long-lived integrations, pin to the versioned canonical (schemas/coverage-vX.Y.schema.json) so the contract you validate against does not silently shift when a new SimpleCov release bumps the schema.",

spec/formatter/coverage_schema_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ def validate_against_schema(document)
2020
schemer.validate(document).map { |e| "#{e['data_pointer']}: #{e['error']}" }
2121
end
2222

23-
it "is itself a valid JSON Schema (draft-07)" do
24-
expect(JSONSchemer.draft7.validate(schema_doc).to_a).to be_empty
23+
it "is itself a valid JSON Schema (2020-12)" do
24+
expect(JSONSchemer.draft202012.validate(schema_doc).to_a).to be_empty
2525
end
2626

27-
it "declares draft-07 as its meta-schema" do
28-
expect(schema_doc.fetch("$schema")).to eq("http://json-schema.org/draft-07/schema#")
27+
it "declares 2020-12 as its meta-schema" do
28+
expect(schema_doc.fetch("$schema")).to eq("https://json-schema.org/draft/2020-12/schema")
2929
end
3030

3131
# The unversioned alias is a convenience pointer to the latest version.

0 commit comments

Comments
 (0)