Skip to content

Commit 3683a2c

Browse files
committed
RFC #30: update the $id URL format.
1 parent 511cf1c commit 3683a2c

File tree

1 file changed

+26
-9
lines changed

1 file changed

+26
-9
lines changed

text/0000-component-metadata.md

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,10 @@ An `Annotation` class has a name (e.g. `"org.amaranth-lang.amaranth-soc.memory-m
178178

179179
```python3
180180
class AsyncSerialAnnotation(Annotation):
181-
name = "com.example.serial"
181+
name = "com.example.foo.serial"
182182
schema = {
183183
"$schema": "https://json-schema.org/draft/2020-12/schema",
184-
"$id": "https://example.com/schema/serial/1.0.json",
184+
"$id": "https://example.com/schema/foo/1.0/serial.json",
185185
"type": "object",
186186
"properties": {
187187
"data_bits": {
@@ -307,11 +307,11 @@ The JSON object returned by ``serial.metadata.as_json()`` will now use this anno
307307
"dir": "out",
308308
"width": 1,
309309
"signed": false,
310-
"reset": 0
310+
"reset": "0"
311311
}
312312
},
313313
"annotations": {
314-
"com.example.serial": {
314+
"com.example.foo.serial": {
315315
"data_bits": 8,
316316
"parity": "none"
317317
}
@@ -322,13 +322,30 @@ The JSON object returned by ``serial.metadata.as_json()`` will now use this anno
322322

323323
#### Annotation names and schema URLs
324324

325-
Annotation names must be prefixed by a reversed domain name (e.g. "com.example") that belongs to the person or entity defining the annotation. Annotation names are obtainable from their schema URL (provided by the `"$id"` key of `Annotation.schema`). To ensure this, schema URLs must have the following structure: `"<protocol>://<domain>/schema/<path>/<version>.json"`. The version of an annotation schema should match the Python package that implements it.
325+
An `Annotation` schema must have a `"$id"` property, which holds an URL that serves as its unique identifier. This URL must have the following format:
326+
327+
`<protocol>://<domain>/schema/<package>/<version>/<path>.json`
328+
329+
where:
330+
331+
* `<domain>` is a domain name registered to the person or entity defining the annotation;
332+
* `<package>` is the name of the Python package providing the `Annotation` subclass;
333+
* `<version>` is the version of the aforementioned package;
334+
* `<path>` is a non-empty string.
335+
336+
An `Annotation` name should be retrievable from the `"$id"` property of its schema. Its name is the concatenation of the following parts, separated by `"."`:
337+
338+
* `<domain>`, reversed (e.g. "com.example");
339+
* `<package>`;
340+
* `<path>`, split using `"/"` as separator.
326341

327342
Some examples of valid schema URLs:
328343

329-
- "https://example.github.io/schema/serial/1.0.json" for the "io.github.example.serial" annotation;
330-
- "https://amaranth-lang.org/schema/amaranth/fifo/4.0.json" for "org.amaranth-lang.amaranth.fifo";
331-
- "https://amaranth-lang.org/schema/amaranth-soc/memory-map/1.0.json" for "org.amaranth-lang.amaranth-soc.memory-map".
344+
- "https://example.github.io/schema/foo/1.0/serial.json" for the "io.github.example.foo.serial" annotation;
345+
- "https://amaranth-lang.org/schema/amaranth/0.4/fifo.json" for "org.amaranth-lang.amaranth.fifo";
346+
- "https://amaranth-lang.org/schema/amaranth-soc/0.1/memory-map.json" for "org.amaranth-lang.amaranth-soc.memory-map".
347+
348+
Changes to schema definitions hosted at https://amaranth-lang.org should follow the [RFC process](https://github.com/amaranth-lang/rfcs).
332349

333350
## Reference-level explanation
334351
[reference-level-explanation]: #reference-level-explanation
@@ -367,7 +384,7 @@ class ComponentMetadata(Annotation):
367384
name = "org.amaranth-lang.amaranth.component"
368385
schema = {
369386
"$schema": "https://json-schema.org/draft/2020-12/schema",
370-
"$id": "https://amaranth-lang.org/schema/amaranth/component/0.4.json",
387+
"$id": "https://amaranth-lang.org/schema/amaranth/0.5/component.json",
371388
"type": "object",
372389
"properties": {
373390
"interface": {

0 commit comments

Comments
 (0)