Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework $ProtocolEventBody #192

Open
rmarx opened this issue Feb 19, 2022 · 2 comments · May be fixed by #401
Open

Rework $ProtocolEventBody #192

rmarx opened this issue Feb 19, 2022 · 2 comments · May be fixed by #401
Assignees
Labels

Comments

@rmarx
Copy link
Contributor

rmarx commented Feb 19, 2022

The new CDDL approach uses a CDDL extension point to be more strict about which values are allowed in the Event:data field.

Currently, it's defined as:

; The ProtocolEventBody is any key-value map (e.g., JSON object)
; only the optional trigger field is defined in this document
$ProtocolEventBody /= {
    ? trigger: text
    * text => any
}
; event documents are intended to extend this socket by using:
; NewProtocolSpecificEvents = EventType1 / EventType2 / ... / EventTypeN
; $ProtocolEventBody /= NewProtocolSpecificEvents

However, this effectively still allows just about any JSON object as ProtocolEventBody, as we're just extending the $ProtocolEventBody.

If we want to be (slightly) more strict, we could do something like this:

; main doc
ProtocolEventBodyPrototype = {
    ? trigger: text
    * text => any
}

ProtocolEventBody = ProtocolEventBodyPrototype / $ProtocolEventBodies

; event docs
NewProtocolSpecificEvents = EventType1 / EventType2 / ... / EventTypeN
$ProtocolEventBodies /= NewProtocolSpecificEvents

Alternatively, we can just NOT allow the general form (the ProtocolEventBodyPrototype) and just include that as an example and require event bodies to provide at least 1 defined event.

@rmarx rmarx self-assigned this Feb 19, 2022
@rmarx rmarx added design discuss needs further discussion high-level-schema labels Feb 19, 2022
@LPardue
Copy link
Member

LPardue commented Dec 9, 2023

I don't see any problem with the current level of extensibility. What benefit(s) would being more restrictive bring?

@LPardue
Copy link
Member

LPardue commented May 13, 2024

After understanding how to apply CDDL types better, I now support more rigidity in extensibility.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants