-
Notifications
You must be signed in to change notification settings - Fork 89
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
show: handle [@printer] in polymorphic variants #267
base: master
Are you sure you want to change the base?
Conversation
Code generated by openapi-generator-cli for ocaml uses custom printers for polymorphic variant branches as a way of supporting jsonschema enum types in generated client library code. I would have expected (and the openapi-generator-cli authors did, too) that the annotations would work the same way as for regular variants, but instead, the custom printers are silently ignored. The fix in this PR would be very helpful. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the ping! I reviewed the PR. There is a comment on code style, which is optional, but the lack of wrap_printer
is probably a bug.
@ghuysmans apologies for the delay in reviewing this. Would you by chance be able to tell if you want to take care of your PR despite the long wait, or if you have moved to other things and would rather have someone else adopt it?
| Some printer, Rtag(label, true (*empty*), []) -> | ||
let label = label.txt in | ||
Exp.case (Pat.variant label None) | ||
[%expr [%e printer] fmt ()] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be easier to factorize the two cases better, the code is identical except for the second argument of Exp.case
that depends on the optional printer attribute.
| Some printer, Rtag(label, true (*empty*), []) -> | ||
let label = label.txt in | ||
Exp.case (Pat.variant label None) | ||
[%expr [%e printer] fmt ()] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am worried about the use of printer
directly when all other such patterns in the code use wrap_printer quoter printer
. I don't remember the details of how this works, but I would follow the rest of the code here.
| Some printer, Rtag(label, false, [typ]) -> | ||
let label = label.txt in | ||
Exp.case (Pat.variant label (Some [%pat? x])) | ||
[%expr [%e printer] fmt x] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same remarks: you could share more code (but not doing so is okay), and printer
should be wrapped.
No description provided.