-
Notifications
You must be signed in to change notification settings - Fork 6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Python] Example of providing API key does not work #7269
Comments
@cledoux Do you mind filing a PR to fix the sample code when you've time? |
I am having a similar issue. Is this issue solved? |
Managed to get it working like this:
|
I'm currently doing what @jacobweber is doing as well. Is there an intended way to set defaults for the configuration object so we don't have to set the values after initializing it? It would be nice to not have to pass around an |
I still can't get it to work. What is the semantics of 'my-key-name' in config.api_key['my-key-name'] = 'my-key-value' I also added: config.debug = True to see the http request, but there is no "x-api-key: xxxx" header added. I've found a work-around though: ...
api_client = my_api_name.ApiClient(config)
api_client.set_default_header(header_name='x-api-key', header_value=api_key)
api_instance = my_api_name.MySampleApi(api_client) |
@ensonic
In my configuration object, that looks like,
This produces a header |
Thanks. That definitely helps. Filed a new ticket #7847 - the global security setting is ignored :/ |
Description
The example of configuring an API in the generated README is broken for python.
The example code generated is:
However, the
configuration.py
file does not have anapi_key
attribute. All attributes are now inside theConfiguration
class and cannot be set at the module level.Swagger-codegen version
2.3.0
Swagger declaration file content or url
(This is just the petstore spec stripped down to only the necessary bits. It will not work if you use the full petstore spec because the example uses the OAuth instead of ApiKey.)
Command line used for generation
docker run --rm -v $(pwd):/local swaggerapi/swagger-codegen-cli generate -i swagger.yaml -l python -o /local/clients/python
Steps to reproduce
The text was updated successfully, but these errors were encountered: