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

Handling Binary Responses #21

Open
Rio517 opened this issue Jul 30, 2020 · 1 comment
Open

Handling Binary Responses #21

Rio517 opened this issue Jul 30, 2020 · 1 comment

Comments

@Rio517
Copy link

Rio517 commented Jul 30, 2020

At SuitePad, we have image endpoints that return image files. The generator actually dumps the binary data into the generated apib file. Perhaps we should just ignore that content and list the filename or something?

   + Body

            ------------XnJLe9ZIbbGUYtzPQJ16u1
            Content-Disposition: form-data; name="image[image]"; filename="logo.png"
            Content-Type: 
            Content-Length: 16868
            
            ?PNG
            �
            
@Rio517 Rio517 changed the title Handling Binary responses Handling Binary Responses Jul 30, 2020
@Rio517
Copy link
Author

Rio517 commented Aug 1, 2020

After the binary is inserted, it causes character encoding issues.

Failure/Error: file.write(data)

Encoding::UndefinedConversionError:
  "\x89" from ASCII-8BIT to UTF-8
# /usr/local/bundle/gems/rspec-apib-1.0.0/lib/rspec/apib/writer.rb:20:in `write'
# /usr/local/bundle/gems/rspec-apib-1.0.0/lib/rspec/apib/writer.rb:20:in `block in write_to_file'
# /usr/local/bundle/gems/rspec-apib-1.0.0/lib/rspec/apib/writer.rb:19:in `open'
# /usr/local/bundle/gems/rspec-apib-1.0.0/lib/rspec/apib/writer.rb:19:in `write_to_file'
# /usr/local/bundle/gems/rspec-apib-1.0.0/lib/rspec/apib/writer.rb:13:in `write'
# /usr/local/bundle/gems/rspec-apib-1.0.0/lib/rspec/apib.rb:47:in `write'
# /usr/local/bundle/gems/rspec-apib-1.0.0/lib/rspec/apib.rb:34:in `block (2 levels) in start'

These can be mitigated by opening the file with 'wb' instead of just 'w'.

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

No branches or pull requests

1 participant