Skip to content

[Go] Replace .Username with .UserName in generated API methods.#3573

Merged
wing328 merged 1 commit intoswagger-api:masterfrom
ivucica:ivucica_go_fix-username-capitalization
Aug 11, 2016
Merged

[Go] Replace .Username with .UserName in generated API methods.#3573
wing328 merged 1 commit intoswagger-api:masterfrom
ivucica:ivucica_go_fix-username-capitalization

Conversation

@ivucica
Copy link
Copy Markdown
Contributor

@ivucica ivucica commented Aug 10, 2016

Right now, any generated code where the http basic authentication is
required is broken, as it tries to access nonexistent field in the
generated Configuration struct.

The alternative is to fix configuration.mustache to replace the
UserName field with Username field.

Right now, any generated code where the http basic authentication is
required is broken, as it tries to access nonexistent field in the
generated `Configuration` struct.

The alternative is to fix `configuration.mustache` to replace the
`UserName` field with `Username` field.
@ivucica
Copy link
Copy Markdown
Contributor Author

ivucica commented Aug 10, 2016

It would be great if some Go code would be built as part of CI tests, covering this type of change. What would be a good way of tackling this?

@wing328 wing328 modified the milestones: v2.2.1, v2.2.2 Aug 11, 2016
@wing328
Copy link
Copy Markdown
Contributor

wing328 commented Aug 11, 2016

@ivucica totally agree leveraging the CI and Go Petstore API client to catch the issue moving forward.

I'll submit a PR to update the test spec.

@wing328 wing328 merged commit f41264c into swagger-api:master Aug 11, 2016
@wing328
Copy link
Copy Markdown
Contributor

wing328 commented Aug 11, 2016

I've added test cases via #3574 to cover the issue and got the following error before your fix:

[INFO] --- exec-maven-plugin:1.2.1:exec (go-get-resty) @ Goswagger ---
[INFO] 
[INFO] --- exec-maven-plugin:1.2.1:exec (go-test) @ Goswagger ---
# _/Users/williamcheng/Code/jul2016/swagger-codegen/samples/client/petstore/go/go-petstore
go-petstore/fake_api.go:137: a.Configuration.Username undefined (type Configuration has no field or method Username)
FAIL    _/Users/williamcheng/Code/jul2016/swagger-codegen/samples/client/petstore/go [build failed]

@wing328 wing328 changed the title Go: Replace .Username with .UserName in generated API methods. [Go] Replace .Username with .UserName in generated API methods. Feb 20, 2017
@wing328
Copy link
Copy Markdown
Contributor

wing328 commented Feb 20, 2017

@ivucica FYI. There's a PR to undo the change: #4245.

Let me know if you've concern.

@ivucica
Copy link
Copy Markdown
Contributor Author

ivucica commented Feb 20, 2017

This is fine. #4245 seems to also be covering my comment:

The alternative is to fix configuration.mustache to replace the
UserName field with Username field.

I do not understand what @paulvollmer's "the UserName variable does not work in CamelCase" means, i.e. why this is necessary, but it seems like a clean fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants