Skip to content

[BUG] [Go] api.mustache template change to use strings.replace for localVarPath not importing strings lib #6927

Open
@shylasrinivas

Description

@shylasrinivas
Description

Modified api.mustache template to replace localVarPath. In files where strings package is not already present by default, generator is not importing the lib for strings causing compilation failure. Manually adding the imports causes duplicate import error.

openapi-generator version

4.3.1

OpenAPI declaration file content or url

https://gist.github.com/shylasrinivas/ba6cc06dbc5a731b00f5d06d0bb6d8ee
Line in api.mustache causing this issue -
localVarPath = strings.Replace(localVarPath, "__", "?" , -1)

Command line used for generation

openapi-generator generate -g go -p enumClassPrefix=true -p structPrefix=true -t ~/bindings/templates -i hcl.yaml -o ~/bindings/hcl

Related issues/PRs

#5231

Suggest a fix

Used import alias functionality in go and added another import for strings Eg: strings and _strings. This fixes the compilation issue, however the code in the bindings does not look good.

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