-
Notifications
You must be signed in to change notification settings - Fork 753
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
'ballerina swagger client|mock' generates syntactically incorrect ballerina code #11461
Comments
I was able to track it down to the following issues:
ad.1 Typos in generated ClientConfig ad.2 Missing support of content type 'application/x-www-form-urlencoded': ad.3 Different arguments for endpoint methods
Here we have two problems:
I may be able to provide a pull request for the 3rd issue (both problems) but I guess I will need some help for the 2nd one (support for content type 'application/x-www-form-urlencoded') since it will touch deeper parts of the swagger code generation. Maybe somebody with deeper insights into the swagger code generation (@praminda ?) can have a look at the options? Last but not least, it would be great to add tests for the swagger code generation functionality to be able to spot problems earlier. Any pointers, where the right place for this kind of tests would be? |
Thank you very much for reporting the issue. We were able to recreate the issue and we are working on a fix for it. |
@DimalChandrasiri thanks for confirming :). I am already working on a fix by adjusting the mustache templates only but there are some things I don't quite understand:
Thanks for any feedback, |
@ahochsteger 1st Q:
2nd Q:
3rd Q:
4th Q:
|
@NipunaMarcus I've tested Ballerina v0.990.0 and can still see some issues with a simplified version of the pestore example that produces only application/json instead of both xml+json since this is not yet supported. Generated Mocks:
The first error message is in the following code (note the missing data type at _updatePetWithFormBody):
The second error is in this function (again note the missing data type):
I guess both still have to do with the unsupported content type 'application/x-www-form-urlencoded'. Generated Clients
Here is an example of an affected code snippet (the first error of the list above; problematic lines are marked with comments):
It seems to be related to the variable name 'client' that produces errors. If I change that e.g. to 'xclient' many of those errors are gone. Is 'client' a reserved word in the Ballerina language? I did not find anything related in the Ballerina Language Specification. I hope, this helps to further fix the remaining issues to improve the out-of-the-box experience with ballerina and swagger code generation :-). Regards, |
thank you @ahochsteger Will address these with the next release. |
@NipunaMarcus, I just retested the code generation with version 0.990.3-rc2 and could see some good progress :-).
Another example:
I guess this is what most of the generated code from more complex APIs causes to fail. |
@ahochsteger Thank you very much for testing the swagger tooling .... Yes there are bugs related to the operation parameters when generating the code and there are still some unsupported types... This missing comma is happening due to a mustache template issue ... In this week we are to have a review and usability test on swagger tooling ... Aim of those is to capture functionality and usability issues in swagger tooling. We are planning to fix as much as possible .... I will reference this issue when we start fixing issues you mentioned ... |
Related Issue: #13588 |
As we revisited the design of the OpenAPI tooling and the annotation structure, which you can refer from specification available here, we are closing this issue and attaching it to the newly created issue to track the progress and evaluation purpose. |
Hi, I get similar issues in Ballerina 0.991.0, where this https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v3.0/link-example.yaml, causes the following errors when building. Is this something that is fixed now?.
|
@lafernando This is happening due to a generating wrong syntax ... we fixed this in the current milestones and there are few major changes. Anyway we will check this .yaml and let you know ... |
The service generation process for the file link_example gets generated successfully in ballerina version 1.0 Beta. Hence closing the issue. |
Description:
When generating client or mock modules from a valid swagger spec (e.g. https://petstore.swagger.io/v2/swagger.json) there's generated invalid ballerina code.
Example of the invalid generated code in petstore-mock:
The reason seems to be that "application/x-www-form-urlencoded" is not supprted for the consumed body. Similar errors as in petstore-mock occur in the generated petstore-client code.
Example of the invalid generated code in petstore-client:
Steps to reproduce:
Affected Versions:
Ballerina 0.983.0
OS, DB, other environment details and versions:
Suggested Labels (optional):
The text was updated successfully, but these errors were encountered: