Behaviour SwRS-MDOKFSTUDIO-FMSCHEMA-046
x-okf-link annotations declare link fields and their syntax
When a schema annotates a property with `x-okf-link`, the extension SHALL find the annotation on top-level and nested properties, array items and prefixItems, patternProperties, additionalProperties, local `$ref`s, every allOf branch, the matching anyOf branches, the single matching oneOf branch and the selected if/then/else branch, mark the field with an E10 error when the annotation or a link value is invalid, and resolve a link target apart from its `?query` and `#fragment`.
Step 1 of path 1 in StRS-MDOKFSTUDIO-FMSCHEMA-014: from “A schema annotates a property with `x-okf-link`” to “The link target is checked against the files”.
Scenarios 7
The situations the tests check; open one to read it.
nominalArray items
Givena schema whose list property has items annotated with x-okf-link and a document listing two targets
Whenthe document is analysed
Thentwo link results are produced for the field, one per item, with their array indexes
nominalAnnotation positions
| Input | Outcome |
|---|---|
| a mapping field whose patternProperties entry ^k is annotated and a value with keys k1 and z | only k1 gets a link result |
| a mapping field whose additionalProperties schema is annotated and a value with the key k1 | k1 gets a link result |
| a list field whose first prefixItems entry is annotated and a value with two targets | the first item gets a link result |
| a property whose schema is `$ref: "#/$defs/lk"` and lk carries the annotation | the property gets a link result |
| a property annotated through an allOf branch, and one through the anyOf branch that matches its value | both properties get a link result |
| an anyOf branch that does not match its value | it contributes none |
| a then branch annotating a, a document where the if condition holds, then one where it does not | a gets a link result only in the first document |
boundaryoneOf with two matching branches
Givena schema whose oneOf has two branches that both match the value and carry annotations
Whenthe document is analysed
Thenno annotation of that oneOf is collected
refusalInvalid annotation
| Input | Outcome |
|---|---|
| an annotation with resolution nonsense | the field row carries the error [E10] x-okf-link resolution is invalid at 'ref' and counts in the badge |
| an annotation with a resolution and no syntax | the field row carries [E10] x-okf-link syntax is invalid at 'a' |
| an annotation that is not an object, a non-string marker, display field lists that are not lists of names, or a non-boolean show_line_number | the field is marked with an error "[E10] x-okf-link ... at '{field}'" |
boundaryAccepted annotation values
Givenannotations using each of document-relative, bundle-relative, bundle-relative-stem, project-relative and filename-stem with syntax plain or wikilink
Whenthe document is analysed
Thennone of them is reported as invalid
refusalInvalid link value
| Input | Outcome |
|---|---|
| an annotation with syntax wikilink and the value t.md without brackets | the field carries [E10] wikilink value has invalid syntax at 'ref' |
| an empty string value | the message reads file-link target is empty |
| a number value | the message reads file-link value must be a string |
nominalQuery and fragment
| Input | Outcome |
|---|---|
| a document-relative link value t.md#h next to an existing t.md | the link is valid and keeps the fragment h |
| a link value t.md?x=1#h | the link is valid with the query x=1 and the fragment h |
Implemented in 1
Tested by 3
Replaces
SwRS-MDOKFSTUDIO-FMSCHEMA-047An invalid x-okf-link annotation marks the field superseded superseded by SwRS-MDOKFSTUDIO-FMSCHEMA-046 Markdown file
SwRS-MDOKFSTUDIO-FMSCHEMA-048Link values are checked for type and syntax superseded superseded by SwRS-MDOKFSTUDIO-FMSCHEMA-046 Markdown file
SwRS-MDOKFSTUDIO-FMSCHEMA-049Query and fragment are split off a link target superseded superseded by SwRS-MDOKFSTUDIO-FMSCHEMA-046 Markdown file