Skip to content

Commit 446f929

Browse files
authored
Schema config file (#253)
- Added `--schema-config` option to specify a YAML or JSON configuration file that maps remote schema URLs to local file paths, making it easier to validate against multiple local schemas, allowing offline validation and improved performance
1 parent 47c2921 commit 446f929

File tree

17 files changed

+1560
-17
lines changed

17 files changed

+1560
-17
lines changed

CHANGELOG.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ The format is (loosely) based on [Keep a Changelog](http://keepachangelog.com/)
66

77
## [Unreleased]
88

9+
## [v3.8.0] - 2025-06-03
10+
11+
### Added
12+
13+
- Added `--schema-config` option to specify a YAML or JSON configuration file that maps remote schema URLs to local file paths, making it easier to validate against multiple local schemas, allowing offline validation and improved performance [#253](https://github.com/stac-utils/stac-validator/pull/253)
14+
915
## [v3.7.0] - 2025-05-30
1016

1117
### Added
@@ -62,7 +68,7 @@ The format is (loosely) based on [Keep a Changelog](http://keepachangelog.com/)
6268

6369
- Development dependencies removed from runtime dependency list
6470
([#228](https://github.com/stac-utils/stac-check/pull/109))
65-
- Remove jsonschema RefResolver ([#228](https://github.com/stac-utils/stac-check/pull/109))
71+
- Remove jsonschema RefResolver ([#228](https://github.com/stac-utils/stac-check/pull/109)
6672

6773
## [v3.3.1] - 2022-12-16
6874

@@ -245,7 +251,8 @@ The format is (loosely) based on [Keep a Changelog](http://keepachangelog.com/)
245251
- With the newest version - 1.0.0-beta.2 - items will run through jsonchema validation before the PySTAC validation. The reason for this is that jsonschema will give more informative error messages. This should be addressed better in the future. This is not the case with the --recursive option as time can be a concern here with larger collections.
246252
- Logging. Various additions were made here depending on the options selected. This was done to help assist people to update their STAC collections.
247253

248-
[Unreleased]: https://github.com/sparkgeo/stac-validator/compare/v3.7.0..main
254+
[Unreleased]: https://github.com/sparkgeo/stac-validator/compare/v3.8.0..main
255+
[v3.8.0]: https://github.com/sparkgeo/stac-validator/compare/v3.7.0..v3.8.0
249256
[v3.7.0]: https://github.com/sparkgeo/stac-validator/compare/v3.6.0..v3.7.0
250257
[v3.6.0]: https://github.com/sparkgeo/stac-validator/compare/v3.5.0..v3.6.0
251258
[v3.5.0]: https://github.com/sparkgeo/stac-validator/compare/v3.4.0..v3.5.0

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
- [Item Collection Validation](#--item-collection)
3232
- [Using Headers](#--header)
3333
- [Schema Mapping](#--schema-map)
34+
- [Schema Config](#--schema-config)
3435
- [Pydantic Validation](#--pydantic)
3536
- [Deployment](#deployment)
3637
- [Docker](#docker)
@@ -177,6 +178,7 @@ Options:
177178
(local filepath).
178179
--pydantic Validate using stac-pydantic models for enhanced
179180
type checking and validation.
181+
--schema-config TEXT Path to a YAML or JSON schema config file.
180182
--help Show this message and exit.
181183
```
182184
@@ -461,6 +463,25 @@ $ stac-validator tests/test_data/v100/extended-item-local.json --custom tests/te
461463
]
462464
```
463465
466+
### --schema-config
467+
468+
The `--schema-config` option allows you to specify a YAML or JSON configuration file that maps remote schema URLs to local file paths. This is useful when you need to validate against multiple local schemas and want to avoid using multiple `--schema-map` arguments.
469+
470+
Example schema config file (YAML):
471+
```yaml
472+
schemas:
473+
"https://schemas.stacspec.org/v1.0.0/collection-spec/json-schema/collection.json": "local_schemas/v1.0.0/collection.json"
474+
"https://schemas.stacspec.org/v1.0.0/item-spec/json-schema/item.json": "local_schemas/v1.0.0/item.json"
475+
"https://stac-extensions.github.io/eo/v1.0.0/schema.json": "local_schemas/v1.0.0/eo.json"
476+
```
477+
478+
Usage:
479+
```bash
480+
$ stac-validator https://raw.githubusercontent.com/radiantearth/stac-spec/v1.0.0/examples/extended-item.json --schema-config path/to/schema_config.yaml
481+
```
482+
483+
The paths in the config file can be absolute or relative to the config file's location.
484+
464485
### --pydantic
465486
466487
The `--pydantic` option provides enhanced validation using stac-pydantic models, which offer stronger type checking and more detailed error messages. To use this feature, you need to install the optional dependency:

local_schemas/v1.0.0/catalog.json

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"$id": "https://schemas.stacspec.org/v1.0.0/catalog-spec/json-schema/catalog.json#",
4+
"title": "STAC Catalog Specification",
5+
"description": "This object represents Catalogs in a SpatioTemporal Asset Catalog.",
6+
"allOf": [
7+
{
8+
"$ref": "#/definitions/catalog"
9+
}
10+
],
11+
"definitions": {
12+
"catalog": {
13+
"title": "STAC Catalog",
14+
"type": "object",
15+
"required": [
16+
"stac_version",
17+
"type",
18+
"id",
19+
"description",
20+
"links"
21+
],
22+
"properties": {
23+
"stac_version": {
24+
"title": "STAC version",
25+
"type": "string",
26+
"const": "1.0.0"
27+
},
28+
"stac_extensions": {
29+
"title": "STAC extensions",
30+
"type": "array",
31+
"uniqueItems": true,
32+
"items": {
33+
"title": "Reference to a JSON Schema",
34+
"type": "string",
35+
"format": "iri"
36+
}
37+
},
38+
"type": {
39+
"title": "Type of STAC entity",
40+
"const": "Catalog"
41+
},
42+
"id": {
43+
"title": "Identifier",
44+
"type": "string",
45+
"minLength": 1
46+
},
47+
"title": {
48+
"title": "Title",
49+
"type": "string"
50+
},
51+
"description": {
52+
"title": "Description",
53+
"type": "string",
54+
"minLength": 1
55+
},
56+
"links": {
57+
"title": "Links",
58+
"type": "array",
59+
"items": {
60+
"$ref": "#/definitions/link"
61+
}
62+
}
63+
}
64+
},
65+
"link": {
66+
"type": "object",
67+
"required": [
68+
"rel",
69+
"href"
70+
],
71+
"properties": {
72+
"href": {
73+
"title": "Link reference",
74+
"type": "string",
75+
"format": "iri-reference",
76+
"minLength": 1
77+
},
78+
"rel": {
79+
"title": "Link relation type",
80+
"type": "string",
81+
"minLength": 1
82+
},
83+
"type": {
84+
"title": "Link type",
85+
"type": "string"
86+
},
87+
"title": {
88+
"title": "Link title",
89+
"type": "string"
90+
}
91+
}
92+
}
93+
}
94+
}

0 commit comments

Comments
 (0)