Skip to content

Commit

Permalink
[API docs] Add Dpul, Findingaids, Pulmap
Browse files Browse the repository at this point in the history
part of #50
  • Loading branch information
christinach committed Sep 22, 2023
1 parent 8ff67e5 commit 52d0119
Show file tree
Hide file tree
Showing 5 changed files with 151 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ RSpec/MultipleExpectations:

RSpec/EmptyExampleGroup:
Exclude:
- 'spec/requests/api/catalog_spec.rb'
- 'spec/requests/api/*'

Style/Documentation:
Enabled: false
Expand Down
34 changes: 34 additions & 0 deletions spec/requests/api/dpul_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# frozen_string_literal: true

require 'swagger_helper'

RSpec.describe 'dpul' do
before do
stub_request(:get, 'http://lib-solr8-prod.princeton.edu:8983/solr/dpul-production/select?facet=false&fl=id,readonly_title_ssim,readonly_creator_ssim,readonly_publisher_ssim,readonly_format_ssim,readonly_collections_tesim&q=cats&rows=3&sort=score%20desc')
.to_return(status: 200, body: file_fixture('solr/dpul/cats.json'))
end

path '/search/dpul?query={query}' do
parameter name: 'query', in: :path, type: :string, description: 'A string to query Dpul'

get('/search/dpul?query={query}') do
tags 'Dpul'
consumes 'application/json'
produces 'application/json'
description 'Searches Dpul using a query term'

response(200, 'successful') do
let(:query) { 'cats' }
after do |example|
example.metadata[:response][:content] = {
'application/json' => {
example: JSON.parse(response.body, symbolize_names: true)
}
}
end

run_test!
end
end
end
end
34 changes: 34 additions & 0 deletions spec/requests/api/findingaids_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# frozen_string_literal: true

require 'swagger_helper'

RSpec.describe 'findingaids' do
before do
stub_request(:get, 'http://lib-solr8-prod.princeton.edu:8983/solr/pulfalight-production/select?facet=false&fl=id,collection_ssm,creator_ssm,level_sim,scopecontent_ssm,repository_ssm,extent_ssm,accessrestrict_ssm&q=cats&rows=3&sort=score%20desc,%20title_sort%20asc&fq=level_sim:Collection')
.to_return(status: 200, body: file_fixture('solr/findingaids/cats.json'))
end

path '/search/findingaids?query={query}' do
parameter name: 'query', in: :path, type: :string, description: 'A string to query Findingaids'

get('/search/findingaids?query={query}') do
tags 'Findingaids'
consumes 'application/json'
produces 'application/json'
description 'Searches Findingaids using a query term'

response(200, 'successful') do
let(:query) { 'cats' }
after do |example|
example.metadata[:response][:content] = {
'application/json' => {
example: JSON.parse(response.body, symbolize_names: true)
}
}
end

run_test!
end
end
end
end
34 changes: 34 additions & 0 deletions spec/requests/api/pulmap_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# frozen_string_literal: true

require 'swagger_helper'

RSpec.describe 'pulmap' do
before do
stub_request(:get, 'http://lib-solr8-prod.princeton.edu:8983/solr/pulmap/select?facet=false&fl=uuid,dc_title_s,dc_creator_sm,dc_publisher_s,dc_format_s,dc_description_s,dc_rights_s,layer_geom_type_s&q=scribner&rows=3&sort=score%20desc')
.to_return(status: 200, body: file_fixture('solr/pulmap/scribner.json'))
end

path '/search/pulmap?query={query}' do
parameter name: 'query', in: :path, type: :string, description: 'A string to query Pulmap'

get('/search/pulmap?query={query}') do
tags 'Pulmap'
consumes 'application/json'
produces 'application/json'
description 'Searches Pulmap using a query term'

response(200, 'successful') do
let(:query) { 'scribner' }
after do |example|
example.metadata[:response][:content] = {
'application/json' => {
example: JSON.parse(response.body, symbolize_names: true)
}
}
end

run_test!
end
end
end
end
48 changes: 48 additions & 0 deletions swagger/v1/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,54 @@ paths:
responses:
'200':
description: successful
"/search/dpul?query={query}":
parameters:
- name: query
in: path
description: A string to query Dpul
required: true
schema:
type: string
get:
summary: "/search/dpul?query={query}"
tags:
- Dpul
description: Searches Dpul using a query term
responses:
'200':
description: successful
"/search/findingaids?query={query}":
parameters:
- name: query
in: path
description: A string to query Findingaids
required: true
schema:
type: string
get:
summary: "/search/findingaids?query={query}"
tags:
- Findingaids
description: Searches Findingaids using a query term
responses:
'200':
description: successful
"/search/pulmap?query={query}":
parameters:
- name: query
in: path
description: A string to query Pulmap
required: true
schema:
type: string
get:
summary: "/search/pulmap?query={query}"
tags:
- Pulmap
description: Searches Pulmap using a query term
responses:
'200':
description: successful
servers:
- url: https://{defaultHost}
variables:
Expand Down

0 comments on commit 52d0119

Please sign in to comment.