generated from febus982/bootstrap-python-package
-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
According to the spec, optional attributes, if included in the serialization, MUST be valid values, e.g., for subject:
* Constraints:
* OPTIONAL
* If present, MUST be a non-empty string
Yet, when creating an event and serializing, I'm seeing missing optional values show up as null values in the serialization:
from cloudevents_pydantic.bindings.http import HTTPHandler
from cloudevents_pydantic.events import CloudEvent
event = CloudEvent.event_factory(type='foo', source='bar', data={"answer": 42})
handler = HTTPHandler()
headers, as_json = handler.to_json(event)
print(as_json)
# output:
#
# {"data":{"answer":42},"source":"bar","id":"01K7F9H4T1Q5MVXK9QY4QQQ2WD","type":"foo","specversion":"1.0","time":"2025-10-13T17:22:45.185845+00:00","subject":null,"datacontenttype":null,"dataschema":null}In the above example, subject, datacontenttype, and dataschema should not appear in the serialization as null.
Metadata
Metadata
Assignees
Labels
No labels