Skip to content
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

[Go] 2.3.0 undefined: localVarFile problem in multipart/form-data file #7311

Closed
grokify opened this issue Jan 4, 2018 · 1 comment · Fixed by #8051
Closed

[Go] 2.3.0 undefined: localVarFile problem in multipart/form-data file #7311

grokify opened this issue Jan 4, 2018 · 1 comment · Fixed by #8051
Milestone

Comments

@grokify
Copy link

grokify commented Jan 4, 2018

Description

The auto-generated function parameter name for a file is set to the file's parameter name property while the code within the function expects localVarFile. This occurs in a multipart/form-data request with the type file parameter.

Swagger-codegen version

2.3.0

Swagger declaration file content or url

The following file property:

https://github.com/grokify/ringcentral-sdk-go-scg/blob/master/codegen/swagger_ringcentral_v1.0.32.json#L4291

          {
            "name": "body",
            "in": "formData",
            "type": "file",
            "required": true,
            "description": "The file to upload"
          }

Results in:

func (a *GlipApiService) CreateGlipFile(ctx context.Context, body *os.File, localVarOptionals map[string]interface{}) (PostGlipFile, *http.Response, error) {

Renaming body to localVarFile fixes the issue in multiple instances.

func (a *GlipApiService) CreateGlipFile(ctx context.Context, localVarFile *os.File, localVarOptionals map[string]interface{}) (PostGlipFile, *http.Response, error) {
Command line used for generation

$ java -jar swagger-codegen-cli.jar generate -c swagger_ringcentral_config.json -i swagger_ringcentral_v1.0.32.json -l go -o .

Steps to reproduce

Build the SDK, run this example code:

https://github.com/grokify/go-ringcentral/blob/master/examples/get_me/get_me.go

Related issues/PRs

grokify/go-ringcentral-client#4

Suggest a fix/enhancement

In the RingCentral SDK, this is manifested using the body, attachment, and image parameter names. Renaming all of these to localVarFile solves the issues when the property type is file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants