-
Notifications
You must be signed in to change notification settings - Fork 0
🐛 Fix link followers generation to avoid duplicate query params #149
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
Conversation
|
What is the reasoning for using the AST for code generation itself? In the generators we tend to use it for parsing the go code generated by the other tools, but for the generation, I think that templating the go code makes everything a lot more readable. You would avoid having to have a comment explaining what is happening (I always think that a comment for what indicates that the code is too complex and runs the risk of being unmaintainable). If there is a good reason for generating the go code with the AST stuff, then we can do it, but it would need to be a good reason and I currently can't see a reason for this over doing a parsing run and then generating code based on templates. |
joshjennings98
left a comment
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.
Can we have a discussion about what I mentioned in the comments. The code that is generated is good, but I am not sure we should do it via the AST library
|
The main reason I chose modifying the AST, is that this is modifying generated code that changes over time, this generator modifies code generated by the OpenAPI generator, although not perfect, this seems to me to be the most robust way of modifying code that changes over time. |
I see that for modifying the existing functions this makes a bit more sense, but I don't think this is more resilient as it highly dependent on the code as it exists now (there is nothing stopping them from checking However, I see the advantage vs just templates for this use case. But I think we need to do one of two things:
It is up to you since this is your change, but if you do stick with the full AST approach we need to make sure it is maintainable |
Description
Since we patch the link follower functions that are generated by OpenAPI Generator by changing the behaviour from following a hard-coded link to following a link argument, there was a recent patch by the generator that added default param values to
limit,offsetandembedif it was missing in the request, but the way we follow link, we follow already constructed links already with the params set up.Since we already have a link with the correct params, we don't need to add these params to the request, and the generator now appends default value params, which results in a duplication of these params.
Since the behaviour is patched by us to follow generic links, we have to patch this behavior as well.
This patch adds these statements at the beginning of follower functions
Then our generator searches for param checks
and wraps these blocks with our injected guard:
Test Coverage