Skip to content

Conversation

@rjalander
Copy link
Contributor

Adding DataContentType to the cloudevent builder.

Adding DataContentType to the cloudevent builder.
.withId(UUID.randomUUID().toString())
.withSource(URI.create("cdevents-sdk-java"))
.withType(eventType)
.withDataContentType("application/json; charset=UTF-8")
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it make sense to add a test that asserts all CDEvents created with the builder have a content type set?

Choose a reason for hiding this comment

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

"Soon" there will be json schemas published for the CDEvents protocol, se cdevents/spec#61. When that is done, and when the Java SDK is lifted to the latest CDEvents spec version, we should have tests in all SDKs that verify that the produced events validate towards the json schemas for the protocol. If/when we have that, is there still a reason to assert the content type?

Copy link
Contributor

Choose a reason for hiding this comment

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

Excuse my ignorance, I wasn't aware of that pull request. To answer your question: probably not, if the the json schemas enforce the content type to be specified.

Choose a reason for hiding this comment

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

Oups, now you must excuse me :) I was too quick in my reply previously. The data content type will not be part of the protocol itself, and therefore not part of the protocol schema. There will be "supported bindings", of which json is the main one, but that is on higher level than the schema itself.
So, it might be wise to actually assert that the content type is set within the Java SDK already now.

@e-backmark-ericsson
Copy link

See also the work on setting content type for the new customData field in the CDEvents spec here: cdevents/spec#63 (comment)

@afrittoli
Copy link
Member

@rjalander - given the recent refactor, is his PR still needed?

@rjalander
Copy link
Contributor Author

We don't need this change now, as we are giving an option to set only the CustomDataContent type and CloudEvent DataType id defaulted to application/json

@afrittoli afrittoli closed this May 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants