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

Return "minimal viable" search response #5

Merged
merged 1 commit into from
Sep 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion app/controllers/searches_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
class SearchesController < ApplicationController
def show
render json: {}
render json: {
results: [],
total: 0,
start: 0,
}
end
end
36 changes: 36 additions & 0 deletions docs/openapi/specification.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
openapi: '3.0.0'
info:
title: GOV.UK Search API
version: 2.0.0-alpha

paths:
/search:
get:
summary: Perform a search
description: Returns search results
responses:
'200':
description: Successful response
content:
application/json:
schema:
$ref: '#/components/schemas/SearchResponse'

components:
schemas:
SearchResponse:
type: object
properties:
results:
type: array
items:
type: string
default: []
maxItems: 0
description: 'The array of search results. Currently always empty (not yet implemented).'
total:
type: integer
description: 'The total number of items that match the search criteria.'
start:
type: integer
description: 'The starting index for the returned search results.'
8 changes: 6 additions & 2 deletions spec/requests/search_request_spec.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
RSpec.describe "Making a search request" do
describe "GET /search.json" do
it "returns HTTP 200 and an empty JSON object" do
it "successfully returns a minimally acceptable zero results response for finder-frontend" do
get "/search.json"

expect(response).to have_http_status(:ok)
expect(JSON.parse(response.body)).to eq({})
expect(JSON.parse(response.body)).to eq({
"results" => [],
"total" => 0,
"start" => 0,
})
end
end
end