Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Merge requests
  • !382

[Golang][client] fix undefined: localVarFile

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Administrator requested to merge github/fork/grokify/go-client/fix/formdata_required-file_undefined-localVarFile into master Jun 22, 2018
  • Overview 0
  • Commits 25
  • Pipelines 0
  • Changes 109

Created by: grokify

PR checklist

  • Read the contribution guidelines.
  • Ran the shell script under ./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\.
  • Filed the PR against the correct branch: master, 3.1.x, 4.0.x. Default: master.
  • Copied the technical committee to review the pull request if your PR is targeting a particular programming language.

@antihax @bvwells

Description of the PR

When building a Go client with a required formData parameter of file type, a undefined: 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:

  • defines localVarFile when a file is required
  • sets localVarFile to the variable name as defined in the function call

Known 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 of localVarFileName and localVarFileBytes parameters. A future enhancement could support multiple files, either with the same multipart/form-data name or different ones.

Tests

mvn package was successfully run in the samples/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

  • https://github.com/swagger-api/swagger-codegen/issues/7311
  • https://github.com/grokify/go-ringcentral/issues/27
Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/grokify/go-client/fix/formdata_required-file_undefined-localVarFile