-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Upgrade messages and gherkin to bring new 'jsonschema messages' #1544
Conversation
@aslakhellesoy I hadn't noticed that the change to the messages library had changed to exposing the messages as hashes instead of objects. It strikes me that it might be better to use wrap the bare message hashes in POROs, to give us an isolation layer so we don't need to make sweeping changes like this. Classes would also make it easier to document the messages with RDoc, and make the message protocol a bit more discoverable - hashes don't give good error messages if you typo a field name. It also might help prevent confusion like cucumber/common#1559. What do you think? Was the decision to use hashes over objects just a pragmatic one to get something released, or was there some more intent behind it? |
I like that suggestion @mattwynne. To make it a reality, someone would have to build a code generator for ruby, similar to the one we have for go and typescript. The reason I went with hashes? It didn’t occur to me that we’d need classes. My main motivation for doing code generation have been:
|
There is additional complexity with classes. If you want to maintain backwards compatibility with the Ruby API, all attributes would have to be snake_case, but the JSON representation needs to be camelCase. I’m not convinced adding classes is worth it for ruby messages, because there are so few libs depending on it (AFAIK). |
I would be in favor of DTOs to bring a more consistent public API over time, and to be more ruby-friendly too. Also, messages are consumed directly by formatters, so they may be used more than we could think of as I think custom formatters may be the first way to extend cucumber? |
Fair enough. The starting point would be to add a code generator for those DTOs as done here:
Then update code to use those DTO classes: |
I've created a ticket in the common repo about this: cucumber/common#1574 |
@aurelien-reeves this might be a blocker on getting my PR complete (As I would need a patched version of messages to the new 19.0.3 (Not yet created). Which seems from this PR to require lots of changes. |
In conjuction with So the question is:
I must say that I don't really have a favorite. If we go for 2. waiting for messages to have a release with DTOs, I can organize myself to be super-focus on that next week to try releasing it as quickly as possible. |
My vote is for number1. But at the same time I'm now going to be out of action until basically next weeks meeting. So I don't necessarily want to push urgently for something. At the same time it would be good to think about a timeline for getting my PR merged (As it enables a reasonable chunk of functionality, even though it's small). So ideally some time before end of june would be preferred. |
If we can get the DTOs done, most of the changes in this PR would not be necessary. I think it's probably better to delay merging this change until we have the DTOs done, to minimise churn in the code. |
Once cucumber/cucumber-ruby-wire#44 is merged, we can come back to the use of cucumber-ruby-wire main branch. |
I have to merge this in order to be able to release wire because wire depends on the main github branch. But I won't release cucumber-ruby without proper review |
No description provided.