Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions draft-vasters-json-structure-core.md
Original file line number Diff line number Diff line change
Expand Up @@ -1051,6 +1051,36 @@ schema definition, including in type unions.
`$ref` is NOT permitted in other attributes and MUST NOT be used inside the
`type` of the root object.

### `id` Keyword {#object-id-keyword}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"identity" will be clearer


The `id` keyword is only applicable on objects and states the properties that
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

objects and tuples.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The `id` keyword is only applicable on objects and states the properties that
The `id` keyword is only applicable on objects and tuples. It states the properties that

make up the primary ID(s) of the object. Providing more than one ID indicates
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lists the properties, in the role of identifiers, that establish an unambiguous identity of an instance. Providing more than one property reference indicates a composite identity, not a list of alternate identifiers.

a composite primary ID, not a list of alternative IDs.

Example:

~~~ json
{
"$schema": "https://json-structure.org/meta/core/v0/#",
"$id": "https://schemas.vasters.com/TypeName",
"definitions": {
"Namespace": {
"TypeName": {
"name": "TypeName",
"type": "object",
"id": ["ID"],
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe more explicit:

Suggested change
"id": ["ID"],
"primaryid": ["ID"],

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"identity " should be clear.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"id": ["ID"],
"identity": ["ID"],

"properties": {
"ID": { "type": "string" }
}
}
}
}
}
~~~

The `id` MUST only be used on objects.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Identity SHOULD be used on object and tuple declarations. I assume the reason why you want to make it mandatory is the association feature, but I think that will just not work when there is no identity and that might be okay.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I only wanted to make the statement that they must only be used on objects, but there they would be optional.

I agree, they should be optional. Not every object may need an identity, e.g. value objects.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The `id` MUST only be used on objects.
Adding `identity` is optional, but only applicable on objects and tuples.

The value MUST be an array of property names of the current object.

### Cross-references {#cross-references}

In JSON Structure documents, the `$schema` keyword references the meta-schema of
Expand Down