-
-
Notifications
You must be signed in to change notification settings - Fork 7k
[python] Add option to skip client validations #4137
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
Conversation
👍 Thanks for opening this issue! The team will review the labels and make any necessary changes. |
@@ -215,10 +229,13 @@ class {{classname}}(object): | |||
if not isinstance(other, {{classname}}): | |||
return False | |||
|
|||
return self.__dict__ == other.__dict__ | |||
return self.to_dict() == other.to_dict() |
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.
What's the reason to use to_dict()
instead of __dict__
?
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.
So far configuration was not part of the model, now configuration is. So if the user does not provide configuration. The configuration is initialized since two objects have different configuration self.dict == other.dict will return false even though its the same object.
Test("abc") will not be equal to Test("abc") since configuration objects inside both are different. This change is required to prevent this behaviour
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.
@slash-arun thanks for the explanation. I wonder if you can add test cases to https://github.com/OpenAPITools/openapi-generator/tree/master/samples/client/petstore/python/tests to cover the issue moving forward.
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.
Sure, will work on the test cases
|
||
def __ne__(self, other): | ||
"""Returns true if both objects are not equal""" | ||
return not self == other |
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.
Performance would not self == other
be better?
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.
This again relates to the configuration object. Since Test("abc") will not be equal to Test("abc") because config is initialized separately for both the objects.
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.
@slash-arun thanks for the explanation. I wonder if you can add test cases to https://github.com/OpenAPITools/openapi-generator/tree/master/samples/client/petstore/python/tests to cover the issue moving forward.
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.
Sure, will work on the test cases
@slash-arun can you describe the use case here more in depth? |
Hi @spacether, The reason is we would want to run integration tests, similar to swagger-api/swagger-codegen#5530 but for python client |
Yup, that's a use case we've encounterd previously. Ruby client generator (and another one I forgot) supports similar option to disable client side validation so that one can use it to test the API backend |
I've created #4168 for tracking instead. |
@@ -149,6 +149,8 @@ class Configuration(six.with_metaclass(TypeWithDefault, object)): | |||
self.retries = None | |||
"""Adding retries to override urllib3 default value 3 | |||
""" | |||
# Disable client side validation |
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 typo? Shouldn't this be "Enable"
Can this option only be set in the code, or via the CLI also? |
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
Adds option to skip client side validations