JSON response_body generated by rspec_api_documentation gem is empty (Rails)

371 Views Asked by At

I've successfully used rspec_api_documentation gem to generate docs for some other resources in an application.

But when I do the same for a new resource, the JSON file's response_body is empty (though the rest of the JSON exists). And I'm unsure why this is happening.

response_body in generated JSON:

"response_body": "{\n  \"data\": {\n    \"notes\": [\n\n    ]\n  },\n  \"status\": 200,\n  \"message\": \"Ok\"\n}"

Outputed API docs:

{
  "data": {
    "notes": [

    ]
  },
  "status": 200,
  "message": "Ok"
}

What I've done:

  • Tested the endpoint with a curl and can confirm it returns a full response (now I'm just trying to build the documentation)
  • Created note_factory.rb
  • Added @notes = create_list(:note, 1,...) in a before(:all) do block at beginning of notes_spec.rb (and printed to console to confirm it creates an object)

Also created below as the test.

get '/api/v1/notes' do

  example 'Return all notes' do
    explanation 'Return all notes within an account.'

    set_jwt_auth_headers(@api_reader)

    do_request

    expect(status).to eq 200
  end
end

I'm confused what I might be missing that causes the JSON response related to RAD to be empty.

Does anyone have any ideas what might cause this?

0

There are 0 best solutions below