Skip to content

[BUG][Golang][client] README.md example wrong return value #2795

Open
@bkabrda

Description

@bkabrda

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • What's the version of OpenAPI Generator used?
  • Have you search for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Bounty to sponsor the fix (example)
Description

All my operations are generated with a return signature that is a 3-tuple, for example:

func (a *UserApiService) Create(ctx context.Context, userCreatePayload UserCreatePayload) (UserCreateResponse, *http.Response, error) {

README.md however lists this as an example:

r, err := client.Service.Operation(auth, args)

This is wrong as it suggests that the return value is a 2-tuple.

openapi-generator version

Happens both in 4.0.0-beta3 and 3.3.4

OpenAPI declaration file content or url

I'm honestly not sure how to find a reproducer for this. It happens with openapi-generator installed through npm, but I can't reproduce it on the petstore example, where the generated operations really do seem to return 2-tuples.

The template go/api.mustache does have this:

func (a *{{{classname}}}Service) {{{nickname}}}(ctx context.Context{{#hasParams}}, {{/hasParams}}{{#allParams}}{{#required}}{{paramName}} {{{dataType}}}{{#hasMore}}, {{/hasMore}}{{/required}}{{/allParams}}{{#hasOptionalParams}}localVarOptionals *{{{nickname}}}Opts{{/hasOptionalParams}}) ({{#returnType}}{{{returnType}}}, {{/returnType}}*http.Response, error) {

which suggests that the first return value only gets rendered if {{returnType}} is defined, but the README doesn't take this into account. However I'm not sure where this value comes from and why I can't reproduce on the petstore example.

Command line used for generation

openapi-generator generate -g go -c config/languages/go.json -i spec/full_spec.yaml -o generated/myclient

Steps to reproduce

For me, the reproducer is just running the above command.

Related issues/PRs

I haven't found any.

Suggest a fix

I think that taking the {{returnValue}} variable into account in the README example should fix this.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions