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

Fix that sending messages with non-existing "value" was not possible via HTTP endpoints #875

Merged
merged 4 commits into from
Nov 23, 2020

Conversation

ffendt
Copy link
Contributor

@ffendt ffendt commented Nov 6, 2020

Add a content-type none/none as a means to send empty messages with OpenAPI (as OpenAPI doesn't support requests without any content-type).

The type none/none is actually used by akka-http as a fallback if a request without any content-type information reaches an endpoint. By explicitly using the content-type none/none, we therefore forward a similar message to/from a Thing (via OpenAPI) as if it were sent without a content-type:

{
	"topic": "org.eclipse.ditto:thing",
	"headers": {
		"response-required": false,
		"ditto-originator": "nginx:ditto",
		"correlation-id": "009fc0ec-0282-4fc4-a3d8-84e85fef7514",
		"content-type": "none/none",
		"version": 2,
		"timeout": "10",
		"accept": "*/*",
		"timestamp": "2020-11-06T13:45:01.664126345+01:00"
	},
	"path": "/inbox/messages/anyop",
	"value": ""
}

Signed-off-by: Florian Fendt <Florian.Fendt@bosch.io>
@thjaeckle
Copy link
Member

Hm, I guess what we really wanted here is that "value" is not present at all in the Ditto Protocol message created from this call.

This reverts commit f1e8bdd

Signed-off-by: Florian Fendt <Florian.Fendt@bosch.io>
… on the Ditto Protocol envelope, which had "value" as a required field. This differs from the actual implementation, as it is already possible to send protocol messages without a value.

Signed-off-by: Florian Fendt <Florian.Fendt@bosch.io>
Signed-off-by: Florian Fendt <Florian.Fendt@bosch.io>
@ffendt
Copy link
Contributor Author

ffendt commented Nov 11, 2020

You're absolutely right. The Ditto Protocol already allows sending messages without a value.
However, the messages route didn't correctly handle HTTP requests with a content-length of 0. With the latest commits, the route correctly deserializes HTTP requests with empty body to a missing value. This way, the OpenAPI documentation will work as is.
Also, value was documented as a required field in the Ditto Protocol (which was wrong and now is fixed).

@thjaeckle thjaeckle added this to the 1.5.0 milestone Nov 17, 2020
Copy link
Contributor

@DerSchwilk DerSchwilk left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@ffendt ffendt merged commit bef90cf into eclipse-ditto:master Nov 23, 2020
@ffendt ffendt deleted the feature/openapi_empty_messages branch November 23, 2020 07:17
@thjaeckle thjaeckle changed the title Allow sending empty "Messages" via the OpenAPI documentation Fix that sending messages with non-existing "value" was not possible via HTTP endpoints Dec 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants