Skip to content

Commit 70af7dc

Browse files
authored
Merge pull request #1394 from json-schema-org/gregsdennis/adr-sva-prefix
Create ADR for SVA support
2 parents d4306a9 + e3c0398 commit 70af7dc

File tree

1 file changed

+101
-0
lines changed

1 file changed

+101
-0
lines changed

adr/2023-04-sva-prefix.md

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# Supporting Single-Value Annotations via a Defined Prefix
2+
3+
* Status: accepted
4+
* Deciders: @relequestual, @gregsdennis, @jdesrosiers, @karenetheridge, @awwright, @julian
5+
* Date: 2023-04-04
6+
7+
Related:
8+
9+
- Discussions:
10+
- Disallow Unknown Keywords - https://github.com/orgs/json-schema-org/discussions/241
11+
- Support SVAs - https://github.com/orgs/json-schema-org/discussions/329
12+
- PRs:
13+
- https://github.com/json-schema-org/json-schema-spec/pull/1387 (proposal)
14+
15+
## Context and Problem Statement
16+
17+
Dropping support for unknown keywords was a necessary step toward providing stability guarantees. However, the community's reaction to this news was not encouraging. How can we still support keywords that are merely collected as annotations and provide no functionality (single-value annotations, or SVAs)?
18+
19+
## Decision Drivers <!-- optional -->
20+
21+
* Future-proofing - We want to ensure that we can still add keywords to the spec without breaking existing schemas.
22+
* Implementation supportability - Is the proposal feasible to implement?
23+
* Community preference
24+
25+
## Considered Options
26+
27+
1. A defined prefix or other convention for SVAs
28+
1. Optionally defined by a new `$sigil` keyword
29+
1. Inlined vocabularies that can define SVAs
30+
1. A new core keyword that lists SVAs, e.g. `$ignored`
31+
1. A defined configuration option to allow/forbid unknown keywords
32+
1. A new core keyword designed for "extra" data
33+
34+
## Decision Outcome
35+
36+
Chosen option: A defined prefix or other convention.
37+
38+
This option was chosen because it solves the problem in a clean way that can be easily implemented. It was also the favorite solution among the team members as well as the community.
39+
40+
Specifically, the prefix `x-` has been selected.
41+
42+
### Positive Consequences <!-- optional -->
43+
44+
* It solves the problem by allowing users to include custom data in their schemas.
45+
* Many developers will be familiar with using `x-` for custom data.
46+
* It's a simple way to differentiate SVAs from other keywords.
47+
48+
### Negative Consequences <!-- optional -->
49+
50+
* Some people preferred a different prefix as `x-` in some other contexts denotes "experimental" behavior.
51+
52+
## Pros and Cons of the Options <!-- optional -->
53+
54+
### Option 1 - A defined prefix or other convention for SVAs
55+
56+
[Discussion](https://github.com/orgs/json-schema-org/discussions/329#discussioncomment-4988859)
57+
58+
* Good, because it's simple and easy to understand.
59+
* Good, because `x-` specifically is familiar to many developers as an identifying prefix for custom data.
60+
* Good, because it's easily supportable by the meta-schema (i.e. `patternProperties`)
61+
* Bad, because `x-` in some other contexts can denote "experimental" behavior, which is not our meaning.
62+
63+
#### Option 1a - Optionally defined by a new `$sigil` keyword
64+
65+
[Discussion](https://github.com/orgs/json-schema-org/discussions/329#discussioncomment-5357549)
66+
67+
* Good, because it can give users flexibility for the prefix that they want to use.
68+
* Bad, because it cannot be supported by the meta-schema without other changes, which may be difficult to define and/or implement.
69+
70+
High level of effort
71+
72+
### Option 2 - Inlined vocabularies that can define SVAs
73+
74+
[Discussion](https://github.com/orgs/json-schema-org/discussions/329#discussioncomment-4988882)
75+
76+
* Good, because it defines the SVAs in a vocabulary which means they are regarded as "known."
77+
* Bad, because we don't have any support for inlined vocabularies at the moment and would have to build that.
78+
79+
### Option 3 - A new core keyword that lists SVAs, e.g. `$ignored`
80+
81+
[Discussion](https://github.com/orgs/json-schema-org/discussions/329#discussioncomment-4988904)
82+
83+
* Good, because it provides a way to define SVAs.
84+
* Bad, because it cannot be supported by the meta-schema without other changes, which may be difficult to define and/or implement.
85+
86+
High level of effort
87+
88+
### Option 4 - A defined configuration option to allow/forbid unknown keywords
89+
90+
[Discussion](https://github.com/orgs/json-schema-org/discussions/329#discussioncomment-4999789)
91+
92+
* Good, because it returns previous functionality (i.e. allowing unknown keywords) to the user.
93+
* Bad, because that previous functionality removes/circumvents stability guarantees.
94+
95+
### Option 5 - A new core keyword designed for "extra" data
96+
97+
[Discussion](https://github.com/orgs/json-schema-org/discussions/329#discussioncomment-5374873)
98+
99+
* Good, because it provides a place for users to add extra data.
100+
* Bad, because it's an extra depth level that users need to create.
101+
* Bad, because it can only generate a single annotation instead of multiple.

0 commit comments

Comments
 (0)