Skip to content

Commit

Permalink
Exclude swagger spec from rubocop empty example
Browse files Browse the repository at this point in the history
Describe catalog api
  • Loading branch information
christinach committed Sep 22, 2023
1 parent 5bda0b6 commit 7d3d5f1
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ RSpec/ExampleLength:
RSpec/MultipleExpectations:
Enabled: false

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

Style/Documentation:
Enabled: false

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ Documentation lives in `https://allsearch-api.princeton.edu/api-docs`
To update the api documentation for a service:
* create a spec in: `spec/requests/api/`
* `./bin/rails generate rspec:swagger CatalogController --spec_path requests/api/`
* Do the necessary changes to create the swagger doc based on the spec.
* Generate the docs by running:
* `bundle exec rake rswag:specs:swaggerize`.
* This will generate the file `swagger/v1/swagger.yaml`.
Expand Down
31 changes: 31 additions & 0 deletions spec/requests/api/catalog_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,34 @@
# frozen_string_literal: true

require 'swagger_helper'

RSpec.describe 'catalog' do
before do
stub_request(:get, 'http://lib-solr8-prod.princeton.edu:8983/solr/catalog-alma-production/select?facet=false&fl=id,title_display,author_display,pub_created_display,format,holdings_1display&q=rubix&rows=3&sort=score%20desc,%20pub_date_start_sort%20desc,%20title_sort%20asc')
.to_return(status: 200, body: file_fixture('solr/catalog/rubix.json'))
end

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

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

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

run_test!
end
end
end
end
5 changes: 4 additions & 1 deletion swagger/v1/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@ paths:
parameters:
- name: query
in: path
description: A string to query the catalog
description: A query to search the Catalog
required: true
schema:
type: string
get:
summary: "/search/catalog?query={query}"
tags:
- Catalog
description: Searches the Catalog using a query term
responses:
'200':
description: successful
Expand Down

0 comments on commit 7d3d5f1

Please sign in to comment.