-
-
Notifications
You must be signed in to change notification settings - Fork 762
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
Open spec file as binary and then handle problems with encoding. #252
Open spec file as binary and then handle problems with encoding. #252
Conversation
We should keep the old behaviour but receive the encoding as an optional
|
The old behaviour is kept with this PR and there is no need for one more option, IMHO. |
try: | ||
swagger_template = contents.decode() | ||
except UnicodeDecodeError: | ||
swagger_template = contents.decode('utf-8', 'replace') |
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 if it's an encoding that's completely incompatible with ASCII/UTF-8?
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.
Then the characters will be replaced by ?.
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.
Which would mean the yaml.load would fail for those encodings
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.
No, because the keys need to be valid by Swagger/OpenAPI spec anyway. Please check the test with a invalid character. The yaml.load does not fail.
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.
Could you please provide an "encoding that's completely incompatible with ASCII/UTF-8" so we can add a test case for that and adapt the code to handle this situation?
👍 |
7cc1102
to
cfcdfa7
Compare
👍 |
Fixes #249 .