OpenAPITools / OpenAPITools/openapi-generator

[REQ][Go] Check for and do not wrap reflect.Value in parameterAddToHeaderOrQuery function

Open
#16,614 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Enhancement: Feature
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Is your feature request related to a problem? Please describe.

There was a bug where a reflect.Value was wrapped into another reflect.Value, which led to invalid url queries: #14798 .
Though the commit 117e5118b1817c7769784e677c453beac42d789e solves this problem in a straightforward manner, by unwrapping the reflect.Value to interface{}, it does not seem very "future proof", in the meaning that any other future used reflect.Value, also needs unwrapping.

Describe the solution you'd like

Modify the parameterAddToHeaderOrQuery function in the client golang template to always check if the value to wrap is of reflect.Value and skipping if its true:

        // previously: var v = reflect.ValueOf(obj)
	var v reflect.Value
	if refValue, ok := obj.(reflect.Value); ok {
		v = refValue
	} else {
		v = reflect.ValueOf(obj)
	}

Describe alternatives you've considered

Not doing anything, as the bug itself is fixed and does not warrant any further action.

Additional context

None

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in the client golang template and locate the parameterAddToHeaderOrQuery function. Read the existing reflect.Value handling and the related fix for issue #14798, then update the function so reflect.Value inputs are not wrapped again and verify the generated client query and header behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
api, tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.