We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Hey :) I get this linting error with an endpoint that receives an uploaded file: unknown tag !<!ruby/object:File>
unknown tag !<!ruby/object:File>
The spec is structured in this way:
let(:valid_attributes) do { look_media_attachment: { visible: true, caption: 'This is the caption text', image: fixture_file_upload("#{Rails.root}/spec/fixtures/images/test_image.jpg", 'image/jpeg') } } end it do post "/api/v1/look_media_attachments.json", params: valid_attributes, headers: auth_credentials # ... end
The failing output is the following (the error is pointing to the line tmpfile: &1 !ruby/object:File {} below):
tmpfile: &1 !ruby/object:File {}
# ... requestBody: content: multipart/form-data: schema: type: object properties: look_media_attachment: type: object properties: visible: type: string caption: type: string image: type: string format: binary example: look_media_attachment: visible: 'true' caption: This is the caption text image: !ruby/object:ActionDispatch::Http::UploadedFile tempfile: !ruby/object:Tempfile unlinked: true mode: 2562 tmpfile: &1 !ruby/object:File {} opts: :perm: 384 delegate_dc_obj: *1 original_filename: test_image.jpg content_type: image/jpeg headers: "Content-Disposition: form-data; name=\"look_media_attachment[image]\"; filename=\"test_image.jpg\"\r\nContent-Type: image/jpeg\r\nContent-Length: 74165\r\n" # ...
Investigating a bit...
I think that the problem is here: schema_builder.rb:161 In my example value includes another level look_media_attachment:
value
look_media_attachment
{"look_media_attachment"=> {"visible"=>"true", "caption"=>"This is the caption text", "image"=> #<ActionDispatch::Http::UploadedFile:0x00007ff2b647c088 @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"look_media_attachment[image]\"; filename=\"test_image.jpg\"\r\nContent-Type: image/jpeg\r\nContent-Length: 74165\r\n", @original_filename="test_image.jpg", @tempfile=#<File:/var/folders/vm/jtxmp1t120b57cfnv0q322kr0000gn/T/RackMultipart20220326-18892-dzbg74.jpg (closed)>>}}
Perhaps in build_example the value hash should be traversed recursively.
build_example
The text was updated successfully, but these errors were encountered:
Same as #44 (comment); could you try preparing a repository that reproduces the issue?
Sorry, something went wrong.
Ok, here it is: https://github.com/blocknotes/rspec-openapi/commit/7e357dbd87ddf60380a64f479a711ddaa89a0630
Reproduced with:
OPENAPI=1 bundle exec rspec spec/requests/rails_spec.rb grep 'ruby/object' spec/rails/doc/openapi.yaml # data: !ruby/object:ActionDispatch::Http::UploadedFile # tempfile: !ruby/object:Tempfile # tmpfile: &1 !ruby/object:File {}
Successfully merging a pull request may close this issue.
Hey :)
I get this linting error with an endpoint that receives an uploaded file:
unknown tag !<!ruby/object:File>
The spec is structured in this way:
The failing output is the following (the error is pointing to the line
tmpfile: &1 !ruby/object:File {}
below):Investigating a bit...
I think that the problem is here: schema_builder.rb:161
In my example
value
includes another levellook_media_attachment
:Perhaps in
build_example
thevalue
hash should be traversed recursively.The text was updated successfully, but these errors were encountered: