-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
[Golang][client] fix undefined: localVarFile #382
[Golang][client] fix undefined: localVarFile #382
Conversation
I don't see actual code changes? is this not in scope of the test file? |
That's right. Code changes exist in Adding new endpoints to the Petstore API via petstore-with-fake-endpoints-models-for-testing.yaml would let us see changes like this reflected in the generated clients. Let me look into adding a |
Updates:
|
@grokify thanks for the fix and the additional test cases to cover the issue moving forward. Given that there are new test cases, I wonder if you can run the following to update other Petstore samples as well so that the Shippable CI tests will pass:
|
Updated the samples and the Shippable CI tests now succeed but others are now failing. Any assistance to resolve these would be appreciated. CircleCI
It seems Travis CI
This particular issue doesn't appear to be an issue on the project master branch or my fork fix branch: |
@wing328 I ran into similar issues to this before where we wanted to add a test case but doing so broke other clients as they did not support part of the standard. What would be the best way to proceed in these cases? |
CircleCI Error: PetApiServiceImpl is not abstract... uploadFileWithRequiredFile The previous CircleCI error:
is due to Deleting the https://circleci.com/gh/grokify/openapi-generator/7 Full error line:
Building Samples Not Cleaning Output Directories On another note, it seems In both cases, it seems like having
Latest Build Errors
|
CircleCI ✔️ CircleCI is fixed in Shippable ❌ Shippable is failing with what looks like a race condition: Link: https://app.shippable.com/github/OpenAPITools/openapi-generator/runs/1078/1/console Error:
Rebuild on fork succeeds: https://app.shippable.com/github/grokify/openapi-generator/runs/22/1/console Local tests succeed via:
|
Primary changes are:
Verify in generated client: |
@@ -1,5 +1,9 @@ | |||
<?xml version="1.0" encoding="ISO-8859-1"?> | |||
<<<<<<< HEAD |
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 you please solve this merge conflict?
@@ -1,5 +1,9 @@ | |||
<?xml version="1.0" encoding="ISO-8859-1"?> | |||
<<<<<<< HEAD |
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 you please solve this merge conflict?
Now that we have merged Then please run:
And commit the results. This should fix the Shippable Build. |
Shippable — Run 1079 and other CIs were successful on eb1e146, but a number of merge conflicts were introduced after 9b909df. 1081 was an initial failed effort to resolve these. |
After merging Here's some info on the two runs: Log stopped after JSON dump following below:
Log stopped after the following:
|
All tests are passing with no conflicts e72745d. No changes were necessary to resolve Shippable timeouts and race conditions. These are not deterministic so a few more test runs were able to resolve them. |
FYI. Moved the new test under |
Added milestone here |
@antihax Rebuilding the samples should solve these issues, but it may require some debugging. In this particular case, some files that needed to get updated were not getting updated. This required following the log entries which I'll look into providing a PR for. If you let me know what test case you want to add, I can look into it ensuring tests for other clients pass. I'm generally interested in increasing the number of test cases for better coverage. |
* fix undefined: localVarFile * add required formData file endpoints to 2.0 and 3.0 specs * streamline api.mustache update * update sampels * update samples * update samples * update samples bin/jaxrs-cxf-client-petstore.sh * update samples * update samples * update samples run-all-petstore * update samples * update samples * Trigger CI due to race condition * update samples * update samples * Trigger CI due to previous timeout * Trigger CI due to previous Shippable timeout * Trigger CI due to previous Shippable race condition
PR checklist
./bin/
to update Petstore sample so that CIs can verify the change. (For instance, only need to run./bin/{LANG}-petstore.sh
and./bin/security/{LANG}-petstore.sh
if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in.\bin\windows\
.master
,3.1.x
,4.0.x
. Default:master
.@antihax
@bvwells
Description of the PR
When building a Go client with a required
formData
parameter offile
type, aundefined: localVarFile
error is countered when compiling the client.This happens because
localVarFile
is currently only defined when a file is optional. This fix does the following:localVarFile
when a file is requiredlocalVarFile
to the variable name as defined in the function callKnown Limitations
This approach can only handle a single file, but this is also a limitation of the current Go generator can as
APIClient.prepareRequest()
takes a single pair oflocalVarFileName
andlocalVarFileBytes
parameters. A future enhancement could support multiple files, either with the samemultipart/form-data
name
or different ones.Tests
mvn package
was successfully run in thesamples/client/petstore/go
directory.Additional Petstore tests were not added for this use case yet because an endpoint with a required
formData
file is not present in the Petstore spec. Adding this endpoint path to the Petstore spec will be a future project.This has been tested locally with the following Swagger spec with a successful required file upload.
https://github.com/grokify/go-ringcentral/blob/master/codegen/swagger_spec.yaml
References
undefined: localVarFile
problem in multipart/form-data file swagger-api/swagger-codegen#7311undefined: localVarFile
grokify/go-ringcentral-client#27