Skip to content

Docs generation fails image is returned as part of a spec #205

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

Closed
nicolo opened this issue Apr 7, 2015 · 7 comments
Closed

Docs generation fails image is returned as part of a spec #205

nicolo opened this issue Apr 7, 2015 · 7 comments

Comments

@nicolo
Copy link

nicolo commented Apr 7, 2015

I'm getting the following error when trying to create documentation for a route that returns a file.
write': "\xFF" from ASCII-8BIT to UTF-8 (Encoding::UndefinedConversionError) when trying to return a jpeg from my api.

This seems to be related
#39

@amedrz
Copy link

amedrz commented May 8, 2015

Same here, I have:

post "api/attachments" do                                      
  header 'Accept', '*/*'                                                          
  header 'Content-Type', 'multipart/form-data'                                    

  parameter :attachment, "Attachment", "Type" => "Multipart/Form-data"            

  example "add an attachment" do                                                  
    do_request(attachments: { attachment: attachment })
    expect(response_status).to eq(201)                                            
  end                                                                             
end

Where attachment is an instance of Rack::Test::UploadedFile

And I'm getting:

Failure/Error: do_request(attachments:
     Encoding::UndefinedConversionError:
       "\x89" from ASCII-8BIT to UTF-8

Any hints? @nicolo @oestrich

I'm on Rails 4.1.9 and rspec_api_documentation 4.4.0

Thanks!

@bforma
Copy link

bforma commented Jul 21, 2015

As a workaround, I've replaced the contents of binaries files with a string like "Contents of a JPEG image". This also documents quite well. Perhaps you can use this.

@risinglf
Copy link

Hi @bforma can I ask you have did you do that? Thank you so much.

@bforma
Copy link

bforma commented Aug 24, 2015

Hi @risinglf, just create a .jpg file with the following contents: Contents of a JPEG image. Hope this helps.

@risinglf
Copy link

thanks @bforma my problem is on the response, that it's a PDF file. Any ideas how to handle it? Thank you.

@oestrich
Copy link
Contributor

@risinglf Last week I pushed up changes that should sniff out binary data and replace it with [binary data], can you update your Gemfile to master and see if that fixes your problem? If it does I'll go ahead and release a new version.

@oestrich
Copy link
Contributor

oestrich commented Feb 1, 2016

Closing because this should be fixed in newer versions. See client_base.rb

@oestrich oestrich closed this as completed Feb 1, 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

No branches or pull requests

5 participants