Skip to content
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

Merged
merged 4 commits into from
Jun 28, 2016

Conversation

rafaelcaricio
Copy link
Collaborator

Fixes #249 .

@rafaelcaricio rafaelcaricio changed the title Opens spec file as binary and then handle problems with encoding. Open spec file as binary and then handle problems with encoding. Jun 25, 2016
@coveralls
Copy link

coveralls commented Jun 25, 2016

Coverage Status

Coverage remained the same at 100.0% when pulling 98e99ed on rafaelcaricio:fix-encoding-problem into 15586f0 on zalando:master.

@tech-cd
Copy link

tech-cd commented Jun 25, 2016

We should keep the old behaviour but receive the encoding as an optional
argument (with utf8 as default).
On 25 Jun 2016 20:36, "Rafael Carício" notifications@github.com wrote:

Fixes #249 #249 .

You can view, comment on, or merge this pull request online at:

#252
Commit Summary

  • Opens spec file as binary and then handle problems with encoding.

File Changes

Patch Links:


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#252, or mute the thread
https://github.com/notifications/unsubscribe/ALLL_841NssZJMMqLp_XKr-aQmCHoVTrks5qPXUtgaJpZM4I-Zyf
.

@coveralls
Copy link

coveralls commented Jun 25, 2016

Coverage Status

Coverage remained the same at 100.0% when pulling d7a8880 on rafaelcaricio:fix-encoding-problem into 15586f0 on zalando:master.

@rafaelcaricio
Copy link
Collaborator Author

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')
Copy link
Contributor

@jmcs jmcs Jun 27, 2016

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?

Copy link
Collaborator Author

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 ?.

Copy link
Contributor

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

Copy link
Collaborator Author

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.

Copy link
Collaborator Author

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?

@jmcs
Copy link
Contributor

jmcs commented Jun 28, 2016

👍

@coveralls
Copy link

coveralls commented Jun 28, 2016

Coverage Status

Coverage decreased (-0.1%) to 99.894% when pulling 7cc1102 on rafaelcaricio:fix-encoding-problem into 15586f0 on zalando:master.

@coveralls
Copy link

coveralls commented Jun 28, 2016

Coverage Status

Coverage remained the same at 100.0% when pulling 0ac6721 on rafaelcaricio:fix-encoding-problem into 15586f0 on zalando:master.

@coveralls
Copy link

coveralls commented Jun 28, 2016

Coverage Status

Coverage remained the same at 100.0% when pulling 0ac6721 on rafaelcaricio:fix-encoding-problem into 15586f0 on zalando:master.

@jmcs
Copy link
Contributor

jmcs commented Jun 28, 2016

👍

@rafaelcaricio rafaelcaricio merged commit 25fa0ce into spec-first:master Jun 28, 2016
@rafaelcaricio rafaelcaricio deleted the fix-encoding-problem branch June 28, 2016 09:29
@jmcs jmcs removed the in progress label Jun 28, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants