Skip to content

Commit 25abca2

Browse files
committed
Add standards authoring support (backwards-compatible)
Four additions to support OGC standards-as-building-blocks authoring: - bblock.schema.yaml: new itemClass values (requirements-class, clause, terms, references) and new resource roles (requirements, terms, references) - tests.schema.yaml: new optional id and method fields on test entries, allowing requirements.yaml to reference tests by id and ATS entries to carry an explicit test method description - postprocess.py: compile testResources from tests.yaml into bblock metadata, resolving relative refs to absolute URLs (same base-URL logic as other fields) - entrypoint.py: detect standards.yaml at repo root and embed its standards array into register.json for consumption by bblocks-specgen
1 parent 3703489 commit 25abca2

4 files changed

Lines changed: 43 additions & 2 deletions

File tree

ogc/bblocks/entrypoint.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,12 @@
248248
)
249249
local_url_mappings = bb_local_config.get('url-mappings')
250250

251+
standards_file = Path('standards.yaml')
252+
if standards_file.is_file():
253+
standards_config = load_yaml(filename=standards_file) or {}
254+
if standards := standards_config.get('standards'):
255+
register_additional_metadata['standards'] = standards
256+
251257
register_additional_metadata['modified'] = datetime.datetime.now().isoformat()
252258

253259
if os.environ.get('BBP_GIT_INFO_FILE'):

ogc/bblocks/postprocess.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
from ogc.bblocks.generate_docs import DocGenerator
2626
from ogc.bblocks.oas30 import oas31_to_oas30
2727
from ogc.bblocks.util import write_jsonld_context, CustomJSONEncoder, \
28-
PathOrUrl, get_git_repo_url
28+
PathOrUrl, get_git_repo_url, load_yaml
2929
from ogc.bblocks.schema import annotate_schema, resolve_all_schema_references, write_annotated_schema
3030
from ogc.bblocks.models import BuildingBlock, BuildingBlockRegister, ImportedBuildingBlocks, BuildingBlockError
3131
from ogc.bblocks.validate import validate_test_resources, write_report
@@ -194,6 +194,27 @@ def do_postprocess(bblock: BuildingBlock, light: bool = False) -> bool:
194194
base_url, cwd if base_url else output_file_root
195195
)
196196

197+
tests_yaml_path = bblock.files_path / 'tests.yaml'
198+
if tests_yaml_path.exists():
199+
tests_entries = load_yaml(tests_yaml_path) or []
200+
compiled_tests = []
201+
for test in tests_entries:
202+
ref = test.get('ref')
203+
entry = {}
204+
if test_id := test.get('id'):
205+
entry['id'] = test_id
206+
if method := test.get('method'):
207+
entry['method'] = method
208+
if test.get('require-fail'):
209+
entry['require-fail'] = True
210+
if ref:
211+
entry['url'] = PathOrUrl(bblock.files_path / ref).with_base_url(
212+
base_url, cwd if base_url else output_file_root
213+
) if not is_url(ref) else ref
214+
compiled_tests.append(entry)
215+
if compiled_tests:
216+
bblock.metadata['testResources'] = compiled_tests
217+
197218
if not light:
198219
if not steps or 'tests' in steps:
199220
logger.info("Running tests")

ogc/bblocks/schemas/bblock.schema.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ properties:
6161
- response # OpenAPI response object
6262
- api # Partial or full OpenAPI document
6363
- model # Ontology or data model
64+
- requirements-class # ModSpec requirements class (standard authoring)
65+
- clause # Prose-only clause (scope, conventions, informative annex)
66+
- terms # Terms and definitions clause
67+
- references # Normative/informative references clause
6468
register:
6569
description: Register to which this Building Block belongs.
6670
type: string
@@ -250,7 +254,7 @@ properties:
250254
role:
251255
description: Role or relationship of this resource to the Building Block. Can be a well-known role name or a URI.
252256
oneOf:
253-
- enum: [constraints, example, guidance, mapping, schema, specification, validation, vocabulary, data]
257+
- enum: [constraints, example, guidance, mapping, schema, specification, validation, vocabulary, data, requirements, terms, references]
254258
- type: string
255259
format: uri
256260
pattern: ^https?://.*

ogc/bblocks/schemas/tests.schema.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,13 @@ items:
2121
Name for the output file name that will be used when generating uplifted versions of the test resource.
2222
If not provided, the file name from "ref" will be used.
2323
type: string
24+
id:
25+
description: |
26+
A logical identifier for this test entry. Used by requirements.yaml 'tested-by' fields to
27+
reference tests by id rather than by filename.
28+
type: string
29+
method:
30+
description: |
31+
Explicit ATS test method description. When absent, the standard generator infers the method
32+
from the file extension. When present, this text is used verbatim in the generated ATS entry.
33+
type: string

0 commit comments

Comments
 (0)