Skip to content

[Golang] Support multiple APIKeys#3210

Closed
nmuesch wants to merge 4 commits intoOpenAPITools:masterfrom
nmuesch:nick/fix_go_api_key
Closed

[Golang] Support multiple APIKeys#3210
nmuesch wants to merge 4 commits intoOpenAPITools:masterfrom
nmuesch:nick/fix_go_api_key

Conversation

@nmuesch
Copy link
Contributor

@nmuesch nmuesch commented Jun 24, 2019

PR checklist

  • Read the contribution guidelines.
  • Ran the shell script under ./bin/ to update Petstore sample so that CIs can verify the change. (For instance, only need to run ./bin/{LANG}-petstore.sh, ./bin/openapi3/{LANG}-petstore.sh if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in .\bin\windows\. If contributing template-only or documentation-only changes which will change sample output, be sure to build the project first.
  • Filed the PR against the correct branch: master, 4.1.x, 5.0.x. Default: master.
  • Copied the technical committee to review the pull request if your PR is targeting a particular programming language.

Description of the PR

This PR aims to address #797 by adding multiple values to the Context attribute passed to authentication. This allows us to use a unique key to reference the Context with to retrieve any number of values for ApiKey

@nmuesch nmuesch changed the title Nick/fix go api key [Golang] Support multiple APIKeys Jun 24, 2019
@wing328
Copy link
Member

wing328 commented Jun 25, 2019

@nmuesch thanks for the PR. I wonder if you can update the Go (XML) petstore sample:

 // BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth
Perform git status
On branch pull/3210
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

	modified:   samples/client/petstore/go/go-petstore-withXml/api_fake_classname_tags123.go
	modified:   samples/client/petstore/go/go-petstore-withXml/api_pet.go
	modified:   samples/client/petstore/go/go-petstore-withXml/api_store.go
	modified:   samples/client/petstore/go/go-petstore-withXml/configuration.go

Script: ./bin/go-petstore-withxml.sh

ContextAPIKey = contextKey("apikey")
{{#authMethods}}
{{#isApiKey}}
Context{{name}} = contextKey("{{name}}")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like this line is not indented correctly (1 additional tab)

Copy link
Member

@wing328 wing328 Jun 25, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And what about making ContextAPIKey a map instead as that's what we do in other languages?

@wing328
Copy link
Member

wing328 commented Jun 25, 2019

Also the current implementation will result in compilation errors if the security name contains space or dash (e.g. "api key", "api-key")

@nmuesch
Copy link
Contributor Author

nmuesch commented Jul 2, 2019

Thanks for the input and review! I plan on getting back to this shortly and will give it another iteration.

@wing328
Copy link
Member

wing328 commented Jul 4, 2019

@nmuesch just ping me via https://gitter.im if you need any help.

@wing328
Copy link
Member

wing328 commented Jul 6, 2019

Please submit the change (breaking) against go-experimental generator instead.

Closing this one for the time being.

@wing328 wing328 closed this Jul 6, 2019
@nmuesch nmuesch mentioned this pull request Jul 24, 2019
4 tasks
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.

3 participants

Comments