-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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] : Make example code snippet compilable #3148
[python] : Make example code snippet compilable #3148
Conversation
…rator into fix/python/make-example-compilable
👍 Thanks for opening this issue! The team will review the labels and make any necessary changes. |
@@ -6,6 +6,7 @@ from {{{packageName}}}.rest import ApiException | |||
from pprint import pprint | |||
{{> python_doc_auth_partial}} | |||
{{#hasAuthMethods}} | |||
configuration.host = "{{{basePath}}}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@saigiridhar21 thanks for the PR. Please correct me if I'm wrong. I believe the default of configuration.host
is already set to {{{basePath}}}. Why do we need to do it again before passing to ApiClient?:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wing328 Yes. You are right. My reason might not be a strong one but it is more like a hint for users that they can update host
.
In our use case, we have a horizontally scaled system and we generate SDKs using one of the hosts. So, we don't specify host in the swagger spec. As a result, SDKs get generated with localhost url. A public DNS is there which load balances requests to all the hosts. So, it is expected that clients specify the host in their code.
Very good reason. What about also adding a 1 liner comment explaining it's
optional and default to {{{basePath}}} ?
|
Sure I will add a comment |
@wing328 Added the comment as suggested. Please take a look. |
Sorry that I wasn't clear in my reply. Can we add the comment 1 line above the code, which is more consistent with how the rest of the example code is documented? |
@wing328 Made the change as suggested. |
@wing328 Please take a look when you get a chance. I made the requested changes. Also, I made the first letter in each comment to capital letter to make it look consistent across all comments on example snippet. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@saigiridhar21 the change looks good. Thanks for the prompt update. |
PR checklist
./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.master
,4.1.x
,5.0.x
. Default:master
.Description of the PR
Making example code snippets compilable.
@taxpon (2017/07) @frol (2017/07) @mbohlool (2017/07) @cbornet (2017/09) @kenjones-cisco (2017/11) @tomplus (2018/10) @Jyhess (2019/01)