qa 2.1.2 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1777c0add155a2c5df322774013eb12db6aca56f
4
- data.tar.gz: 7e00272eeda762b3e2ac64b4d80150264abcc75f
3
+ metadata.gz: df5c9bf343b632a9d00732c2ef08c7acafa4ae09
4
+ data.tar.gz: 679ac0966d2ef5b3b2c3275b677d71dc712bc0b4
5
5
  SHA512:
6
- metadata.gz: 90ae7ea98759c0db24b6111f946c17f8b5dca87a9dce80084d353226cbd11ab2a063047abbe3d22fea4988720487d4784624fdcbffe02d149a6752180cd8fd29
7
- data.tar.gz: 784739a68d9307ad8ac86624fe6f10dfcfe582684b73dde1501fa2b4a5fd35194f368321d51e1dcf4639bd52b3b18ed50313f67898f597537394a727d42a41c5
6
+ metadata.gz: b8bcd201ed589ef2f10a4b28740c0c5d16212c84a36d5f62df850973bb64351ffb694b9e12d065a3af3f8737de11aebd090e4a82ea8658e3f132a890e3a4a44d
7
+ data.tar.gz: 7b8093c874df52c808cb3ed44a83bded631324e4b8d0d304921ad099cc61bf02120cc3b645514e1049909964427689bdb6ab6a4e58e053631e4220e5f3d9da23
data/README.md CHANGED
@@ -313,7 +313,7 @@ This will create two tables/models Qa::LocalAuthority and Qa::LocalAuthorityEntr
313
313
  label: 'Uighur',
314
314
  uri: 'http://id.loc.gov/vocabulary/languages/uig')
315
315
 
316
- Unfortunately, Rails doesn't have a mechnism for adding functional indexes to tables, so if you have a lot of rows, you'll want to add an index:
316
+ Unfortunately, Rails doesn't have a mechanism for adding functional indexes to tables, so if you have a lot of rows, you'll want to add an index:
317
317
 
318
318
  CREATE INDEX "index_qa_local_authority_entries_on_lower_label" ON
319
319
  "qa_local_authority_entries" (local_authority_id, lower(label))
@@ -340,7 +340,7 @@ The entire list (up to the first 1000 terms) can also be returned using:
340
340
 
341
341
  #### Loading RDF data into database tables
342
342
 
343
- You can use the Qa::Services::RDFAuthorityParser to import rdf files into yopur database tables. See the class file, lib/qa/services/rdf_authority_parser.rb, for examples and more information.
343
+ You can use the Qa::Services::RDFAuthorityParser to import rdf files into your database tables. See the class file, lib/qa/services/rdf_authority_parser.rb, for examples and more information.
344
344
  To run the class in your local project you must include `gem 'linkeddata'` into your Gemfile and `require 'linkeddata'` into an initializer or your application.rb
345
345
 
346
346
  ### Medical Subject Headings (MeSH)
@@ -358,7 +358,7 @@ Then, create the tables in your database
358
358
 
359
359
  rake db:migrate
360
360
 
361
- Now that you've setup your application to use MeSH terms, you'll now need to load the tems into your
361
+ Now that you've setup your application to use MeSH terms, you'll now need to load the terms into your
362
362
  database so you can query them locally.
363
363
 
364
364
  To import the mesh terms into the local database, first download the MeSH descriptor dump in ASCII
@@ -625,7 +625,26 @@ NOTE: All predicates with the URI as the subject will be included under "predica
625
625
 
626
626
  See [Using with autocomplete in Sufia](https://github.com/samvera/questioning_authority/wiki/Using-with-autocomplete-in-Sufia) in the wiki documentation for QA.
627
627
 
628
+ If you are using jQueryUI >= 1.8 you can use the [autocomplete function](http://api.jqueryui.com/autocomplete/), for example:
628
629
 
630
+ ```
631
+ $(function(){
632
+ $('#some_input').autocomplete({
633
+ source: function (request, response) {
634
+ $.ajax({
635
+ url: "/qa/search/loc/subjects?q=" + request.term,
636
+ type: 'GET',
637
+ dataType: 'json',
638
+ complete: function (xhr, status) {
639
+ var results = $.parseJSON(xhr.responseText);
640
+ response(results);
641
+ }
642
+ });
643
+ },
644
+ autoFocus: true
645
+ });
646
+ });
647
+ ```
629
648
 
630
649
  # Developer Notes
631
650
 
@@ -2,9 +2,11 @@
2
2
  # out which linked data authority to query based on the 'vocab' param.
3
3
 
4
4
  class Qa::LinkedDataTermsController < ::ApplicationController
5
- before_action :check_authority, :init_authority
5
+ before_action :check_authority, :init_authority, except: [:list, :reload]
6
6
  before_action :check_search_subauthority, :check_query_param, only: :search
7
7
  before_action :check_show_subauthority, :check_id_param, only: :show
8
+ before_action :check_uri_param, only: :fetch
9
+ before_action :validate_auth_reload_token, only: :reload
8
10
 
9
11
  delegate :cors_allow_origin_header, to: Qa::ApplicationController
10
12
 
@@ -14,54 +16,85 @@ class Qa::LinkedDataTermsController < ::ApplicationController
14
16
  head :not_found
15
17
  end
16
18
 
19
+ # Return a list of supported authority names
20
+ # get "/list/linked_data/authorities"
21
+ # @see Qa::Authorities::LinkedData::AuthorityService#authority_names
22
+ def list
23
+ render json: Qa::Authorities::LinkedData::AuthorityService.authority_names.to_json
24
+ end
25
+
26
+ # Reload authority configurations
27
+ # get "/reload/linked_data/authorities?auth_token=YOUR_AUTH_TOKEN_DEFINED_HERE"
28
+ # @see Qa::Authorities::LinkedData::AuthorityService#load_authorities
29
+ def reload
30
+ Qa::Authorities::LinkedData::AuthorityService.load_authorities
31
+ list
32
+ end
33
+
17
34
  # Return a list of terms based on a query
35
+ # get "/search/linked_data/:vocab(/:subauthority)"
18
36
  # @see Qa::Authorities::LinkedData::SearchQuery#search
19
- def search # rubocop:disable Metrics/MethodLength
20
- begin
21
- terms = @authority.search(query, subauth: subauthority, language: language, replacements: replacement_params)
22
- rescue Qa::ServiceUnavailable
23
- logger.warn "Service Unavailable - Search query #{query} unsuccessful for#{subauth_warn_msg} authority #{vocab_param}"
24
- head :service_unavailable
25
- return
26
- rescue Qa::ServiceError
27
- logger.warn "Internal Server Error - Search query #{query} unsuccessful for#{subauth_warn_msg} authority #{vocab_param}"
28
- head :internal_server_error
29
- return
30
- rescue RDF::FormatError
31
- logger.warn "RDF Format Error - Results from search query #{query} for#{subauth_warn_msg} authority #{vocab_param} " \
32
- "was not identified as a valid RDF format. You may need to include the linkeddata gem."
33
- head :internal_server_error
34
- return
35
- end
37
+ def search
38
+ terms = @authority.search(query, subauth: subauthority, language: language, replacements: replacement_params)
36
39
  cors_allow_origin_header(response)
37
40
  render json: terms
41
+ rescue Qa::ServiceUnavailable
42
+ logger.warn "Service Unavailable - Search query #{query} unsuccessful for#{subauth_warn_msg} authority #{vocab_param}"
43
+ head :service_unavailable
44
+ rescue Qa::ServiceError
45
+ logger.warn "Internal Server Error - Search query #{query} unsuccessful for#{subauth_warn_msg} authority #{vocab_param}"
46
+ head :internal_server_error
47
+ rescue RDF::FormatError
48
+ logger.warn "RDF Format Error - Results from search query #{query} for#{subauth_warn_msg} authority #{vocab_param} " \
49
+ "was not identified as a valid RDF format. You may need to include the linkeddata gem."
50
+ head :internal_server_error
38
51
  end
39
52
 
40
- # Return all the information for a given term
53
+ # Return all the information for a given term given an id or URI
54
+ # get "/show/linked_data/:vocab/:id"
55
+ # get "/show/linked_data/:vocab/:subauthority/:id
41
56
  # @see Qa::Authorities::LinkedData::FindTerm#find
42
57
  def show # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
43
- begin
44
- term = @authority.find(id, subauth: subauthority, language: language, replacements: replacement_params)
45
- rescue Qa::TermNotFound
46
- logger.warn "Term Not Found - Fetch term #{id} unsuccessful for#{subauth_warn_msg} authority #{vocab_param}"
47
- head :not_found
48
- return
49
- rescue Qa::ServiceUnavailable
50
- logger.warn "Service Unavailable - Fetch term #{id} unsuccessful for#{subauth_warn_msg} authority #{vocab_param}"
51
- head :service_unavailable
52
- return
53
- rescue Qa::ServiceError
54
- logger.warn "Internal Server Error - Fetch term #{id} unsuccessful for#{subauth_warn_msg} authority #{vocab_param}"
55
- head :internal_server_error
56
- return
57
- rescue RDF::FormatError
58
- logger.warn "RDF Format Error - Results from fetch term #{id} for#{subauth_warn_msg} authority #{vocab_param} " \
59
- "was not identified as a valid RDF format. You may need to include the linkeddata gem."
60
- head :internal_server_error
61
- return
62
- end
58
+ term = @authority.find(id, subauth: subauthority, language: language, replacements: replacement_params, jsonld: jsonld?)
59
+ cors_allow_origin_header(response)
60
+ content_type = jsonld? ? 'application/ld+json' : 'application/json'
61
+ render json: term, content_type: content_type
62
+ rescue Qa::TermNotFound
63
+ logger.warn "Term Not Found - Fetch term #{id} unsuccessful for#{subauth_warn_msg} authority #{vocab_param}"
64
+ head :not_found
65
+ rescue Qa::ServiceUnavailable
66
+ logger.warn "Service Unavailable - Fetch term #{id} unsuccessful for#{subauth_warn_msg} authority #{vocab_param}"
67
+ head :service_unavailable
68
+ rescue Qa::ServiceError
69
+ logger.warn "Internal Server Error - Fetch term #{id} unsuccessful for#{subauth_warn_msg} authority #{vocab_param}"
70
+ head :internal_server_error
71
+ rescue RDF::FormatError
72
+ logger.warn "RDF Format Error - Results from fetch term #{id} for#{subauth_warn_msg} authority #{vocab_param} " \
73
+ "was not identified as a valid RDF format. You may need to include the linkeddata gem."
74
+ head :internal_server_error
75
+ end
76
+
77
+ # Return all the information for a given term given a URI
78
+ # get "/fetch/linked_data/:vocab"
79
+ # @see Qa::Authorities::LinkedData::FindTerm#find
80
+ def fetch # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
81
+ term = @authority.find(uri, subauth: subauthority, language: language, replacements: replacement_params, jsonld: jsonld?)
63
82
  cors_allow_origin_header(response)
64
- render json: term
83
+ content_type = jsonld? ? 'application/ld+json' : 'application/json'
84
+ render json: term, content_type: content_type
85
+ rescue Qa::TermNotFound
86
+ logger.warn "Term Not Found - Fetch term #{uri} unsuccessful for#{subauth_warn_msg} authority #{vocab_param}"
87
+ head :not_found
88
+ rescue Qa::ServiceUnavailable
89
+ logger.warn "Service Unavailable - Fetch term #{uri} unsuccessful for#{subauth_warn_msg} authority #{vocab_param}"
90
+ head :service_unavailable
91
+ rescue Qa::ServiceError
92
+ logger.warn "Internal Server Error - Fetch term #{uri} unsuccessful for#{subauth_warn_msg} authority #{vocab_param}"
93
+ head :internal_server_error
94
+ rescue RDF::FormatError
95
+ logger.warn "RDF Format Error - Results from fetch term #{uri} for#{subauth_warn_msg} authority #{vocab_param} " \
96
+ "was not identified as a valid RDF format. You may need to include the linkeddata gem."
97
+ head :internal_server_error
65
98
  end
66
99
 
67
100
  private
@@ -101,10 +134,20 @@ class Qa::LinkedDataTermsController < ::ApplicationController
101
134
  end
102
135
 
103
136
  def check_query_param
104
- if params[:q].nil? || !params[:q].size.positive? # rubocop:disable Style/GuardClause
105
- logger.warn "Required search param 'q' is missing or empty"
106
- head :bad_request
107
- end
137
+ missing_required_param('search', 'q') if params[:q].blank?
138
+ end
139
+
140
+ def check_id_param
141
+ missing_required_param('show', 'id') if id.blank?
142
+ end
143
+
144
+ def check_uri_param
145
+ missing_required_param('fetch', 'uri') if uri.blank?
146
+ end
147
+
148
+ def missing_required_param(action_name, param_name)
149
+ logger.warn "Required #{action_name} param '#{param_name}' is missing or empty"
150
+ head :bad_request
108
151
  end
109
152
 
110
153
  # converts wildcards into URL-encoded characters
@@ -112,11 +155,8 @@ class Qa::LinkedDataTermsController < ::ApplicationController
112
155
  params[:q].gsub("*", "%2A")
113
156
  end
114
157
 
115
- def check_id_param
116
- if params[:id].nil? || !params[:id].size.positive? # rubocop:disable Style/GuardClause
117
- logger.warn "Required show param 'id' is missing or empty"
118
- head :bad_request
119
- end
158
+ def uri
159
+ params[:uri]
120
160
  end
121
161
 
122
162
  def id
@@ -138,4 +178,23 @@ class Qa::LinkedDataTermsController < ::ApplicationController
138
178
  def subauth_warn_msg
139
179
  subauthority.nil? ? "" : " sub-authority #{subauthority} in"
140
180
  end
181
+
182
+ def format
183
+ return 'json' unless params.key?(:format)
184
+ return 'json' if params[:format].blank?
185
+ params[:format]
186
+ end
187
+
188
+ def jsonld?
189
+ format == 'jsonld'
190
+ end
191
+
192
+ def validate_auth_reload_token
193
+ token = params.key?(:auth_token) ? params[:auth_token] : nil
194
+ valid = Qa.config.valid_authority_reload_token?(token)
195
+ return true if valid
196
+ logger.warn "FAIL: unable to reload authorities; error_msg: Invalid token (#{token}) does not match expected token."
197
+ head :unauthorized
198
+ false
199
+ end
141
200
  end
@@ -1,17 +1 @@
1
- auth_cfg = {}
2
- # load QA configured linked data authorities
3
- Dir[File.join(Qa::Engine.root, 'config', 'authorities', 'linked_data', '*.json')].each do |fn|
4
- auth = File.basename(fn, '.json').upcase.to_sym
5
- json = File.read(File.expand_path(fn, __FILE__))
6
- cfg = JSON.parse(json).deep_symbolize_keys
7
- auth_cfg[auth] = cfg
8
- end
9
-
10
- # load app configured linked data authorities and overrides
11
- Dir[Rails.root.join('config', 'authorities', 'linked_data', '*.json')].each do |fn|
12
- auth = File.basename(fn, '.json').upcase.to_sym
13
- json = File.read(File.expand_path(fn, __FILE__))
14
- cfg = JSON.parse(json).deep_symbolize_keys
15
- auth_cfg[auth] = cfg
16
- end
17
- LINKED_DATA_AUTHORITIES_CONFIG = auth_cfg.freeze
1
+ Qa::Authorities::LinkedData::AuthorityService.load_authorities
@@ -1,5 +1,8 @@
1
1
  Qa::Engine.routes.draw do
2
+ get "/list/linked_data/authorities", controller: :linked_data_terms, action: :list
3
+ get "/reload/linked_data/authorities", controller: :linked_data_terms, action: :reload
2
4
  get "/search/linked_data/:vocab(/:subauthority)", controller: :linked_data_terms, action: :search
5
+ get "/fetch/linked_data/:vocab", controller: :linked_data_terms, action: :fetch
3
6
  get "/show/linked_data/:vocab/:id", controller: :linked_data_terms, action: :show
4
7
  get "/show/linked_data/:vocab/:subauthority/:id", controller: :linked_data_terms, action: :show
5
8
  get "/terms/:vocab(/:subauthority)", controller: :terms, action: :index
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "openapi": "3.0.1",
3
3
  "info": {
4
- "title": "QA 2.1 Linked Data API",
5
- "version": "2.1",
4
+ "title": "QA 2.2 Linked Data API",
5
+ "version": "2.2",
6
6
  "license": {
7
7
  "name": "Apache 2.0",
8
8
  "url": "http://www.apache.org/licenses/LICENSE-2.0.html"
@@ -11,7 +11,7 @@
11
11
  "servers": [
12
12
  {
13
13
  "url": "http://{site_host}/{apiBase}",
14
- "description": "QA v2.1 API Server",
14
+ "description": "QA v2.2 API Server",
15
15
  "variables": {
16
16
  "site_host": {
17
17
  "default": "localhost:3000",
@@ -24,6 +24,87 @@
24
24
  }
25
25
  ],
26
26
  "paths": {
27
+ "/list/linked_data/authorities": {
28
+ "get": {
29
+ "summary": "List currently loaded linked data authorities",
30
+ "operationId": "GET_listAuthorities",
31
+ "tags": [
32
+ "Authority Management"
33
+ ],
34
+ "responses": {
35
+ "200": {
36
+ "description": "Successfully accessed authority and received results.",
37
+ "headers": {
38
+ "Access-Control-Allow-Origin": {
39
+ "description": "CORS header will be * if cors_headers_enabled",
40
+ "schema": {
41
+ "type": "string"
42
+ }
43
+ }
44
+ },
45
+ "content": {
46
+ "application/json": {
47
+ "schema": {
48
+ "$ref": "#/components/schemas/linked_data_authorities_list_result"
49
+ }
50
+ }
51
+ }
52
+ }
53
+ }
54
+ }
55
+ },
56
+ "/reload/linked_data/authorities": {
57
+ "get": {
58
+ "summary": "Reload linked data authorities. Using this command avoids having to restart the rails server.",
59
+ "operationId": "GET_reloadAuthorities",
60
+ "tags": [
61
+ "Authority Management"
62
+ ],
63
+ "parameters": [
64
+ {
65
+ "description": "Security token which must be included for this command to execute.",
66
+ "in": "query",
67
+ "name": "auth_token",
68
+ "required": true,
69
+ "schema": {
70
+ "default": "",
71
+ "type": "string"
72
+ }
73
+ }
74
+ ],
75
+ "responses": {
76
+ "200": {
77
+ "description": "Successfully reloaded authorities.",
78
+ "headers": {
79
+ "Access-Control-Allow-Origin": {
80
+ "description": "CORS header will be * if cors_headers_enabled",
81
+ "schema": {
82
+ "type": "string"
83
+ }
84
+ }
85
+ },
86
+ "content": {
87
+ "application/json": {
88
+ "schema": {
89
+ "$ref": "#/components/schemas/linked_data_authorities_list_result"
90
+ }
91
+ }
92
+ }
93
+ },
94
+ "401": {
95
+ "description": "Unauthorized",
96
+ "content": {
97
+ "text/plain": {
98
+ "schema": {
99
+ "type": "string",
100
+ "example": ""
101
+ }
102
+ }
103
+ }
104
+ }
105
+ }
106
+ }
107
+ },
27
108
  "/search/linked_data/{vocab}": {
28
109
  "get": {
29
110
  "summary": "Send a query string to an authority and return search results. Parameters are typical examples. Actual parameters are driven by the authority's config file.",
@@ -38,7 +119,7 @@
38
119
  "name": "vocab",
39
120
  "required": true,
40
121
  "schema": {
41
- "default": "agrovoc",
122
+ "default": "oclc_fast",
42
123
  "type": "string"
43
124
  }
44
125
  },
@@ -48,14 +129,14 @@
48
129
  "name": "q",
49
130
  "required": true,
50
131
  "schema": {
51
- "default": "milk",
132
+ "default": "science",
52
133
  "type": "string"
53
134
  }
54
135
  },
55
136
  {
56
- "description": "Limit number of returned results",
137
+ "description": "Limit number of returned results. NOTE: Most authorities use maxRecords instead of maximumRecords for this parameter.",
57
138
  "in": "query",
58
- "name": "maxRecords",
139
+ "name": "maximumRecords",
59
140
  "required": false,
60
141
  "schema": {
61
142
  "default": 4,
@@ -92,8 +173,8 @@
92
173
  }
93
174
  }
94
175
  },
95
- "503": {
96
- "description": "Service Unavailable",
176
+ "400": {
177
+ "description": "Bad Request - occurs when required params are missing (e.g. q)",
97
178
  "content": {
98
179
  "text/plain": {
99
180
  "schema": {
@@ -104,7 +185,18 @@
104
185
  }
105
186
  },
106
187
  "500": {
107
- "description": "Internal Server Error",
188
+ "description": "Internal Server Error - can be raised while attempting to access the external authority OR during processing of results when results are not a valid RDF Format",
189
+ "content": {
190
+ "text/plain": {
191
+ "schema": {
192
+ "type": "string",
193
+ "example": ""
194
+ }
195
+ }
196
+ }
197
+ },
198
+ "503": {
199
+ "description": "Service Unavailable - can be raised while attempting to access the external authority",
108
200
  "content": {
109
201
  "text/plain": {
110
202
  "schema": {
@@ -129,7 +221,7 @@
129
221
  "name": "vocab",
130
222
  "required": true,
131
223
  "schema": {
132
- "default": "agrovoc",
224
+ "default": "oclc_fast",
133
225
  "type": "string"
134
226
  }
135
227
  }
@@ -252,8 +344,8 @@
252
344
  }
253
345
  }
254
346
  },
255
- "503": {
256
- "description": "Service Unavailable",
347
+ "400": {
348
+ "description": "Bad Request - occurs when required params are missing (e.g. q)",
257
349
  "content": {
258
350
  "text/plain": {
259
351
  "schema": {
@@ -264,7 +356,18 @@
264
356
  }
265
357
  },
266
358
  "500": {
267
- "description": "Internal Server Error",
359
+ "description": "Internal Server Error - can be raised while attempting to access the external authority OR during processing of results when results are not a valid RDF Format",
360
+ "content": {
361
+ "text/plain": {
362
+ "schema": {
363
+ "type": "string",
364
+ "example": ""
365
+ }
366
+ }
367
+ }
368
+ },
369
+ "503": {
370
+ "description": "Service Unavailable - can be raised while attempting to access the external authority",
268
371
  "content": {
269
372
  "text/plain": {
270
373
  "schema": {
@@ -358,7 +461,7 @@
358
461
  "name": "vocab",
359
462
  "required": true,
360
463
  "schema": {
361
- "default": "agrovoc",
464
+ "default": "oclc_fast",
362
465
  "type": "string"
363
466
  }
364
467
  },
@@ -368,9 +471,23 @@
368
471
  "name": "id",
369
472
  "required": true,
370
473
  "schema": {
371
- "default": "c_9513",
474
+ "default": "1914919",
372
475
  "type": "string"
373
476
  }
477
+ },
478
+ {
479
+ "description": "The format of the returned result.",
480
+ "in": "query",
481
+ "name": "format",
482
+ "required": false,
483
+ "schema": {
484
+ "default": "json",
485
+ "type": "string",
486
+ "enum": [
487
+ "json",
488
+ "jsonld"
489
+ ]
490
+ }
374
491
  }
375
492
  ],
376
493
  "responses": {
@@ -387,7 +504,23 @@
387
504
  "content": {
388
505
  "application/json": {
389
506
  "schema": {
390
- "$ref": "#/components/schemas/linked_data_term"
507
+ "$ref": "#/components/schemas/linked_data_term_json_result"
508
+ }
509
+ },
510
+ "application/ld+json": {
511
+ "schema": {
512
+ "$ref": "#/components/schemas/linked_data_term_jsonld_result"
513
+ }
514
+ }
515
+ }
516
+ },
517
+ "400": {
518
+ "description": "Bad Request - occurs when required params are missing (e.g. id)",
519
+ "content": {
520
+ "text/plain": {
521
+ "schema": {
522
+ "type": "string",
523
+ "example": ""
391
524
  }
392
525
  }
393
526
  }
@@ -403,8 +536,8 @@
403
536
  }
404
537
  }
405
538
  },
406
- "503": {
407
- "description": "Service Unavailable",
539
+ "500": {
540
+ "description": "Internal Server Error - can be raised while attempting to access the external authority OR during processing of results when results are not a valid RDF Format",
408
541
  "content": {
409
542
  "text/plain": {
410
543
  "schema": {
@@ -414,8 +547,8 @@
414
547
  }
415
548
  }
416
549
  },
417
- "500": {
418
- "description": "Internal Server Error",
550
+ "503": {
551
+ "description": "Service Unavailable - can be raised while attempting to access the external authority",
419
552
  "content": {
420
553
  "text/plain": {
421
554
  "schema": {
@@ -440,7 +573,7 @@
440
573
  "name": "vocab",
441
574
  "required": true,
442
575
  "schema": {
443
- "default": "agrovoc",
576
+ "default": "oclc_fast",
444
577
  "type": "string"
445
578
  }
446
579
  },
@@ -450,7 +583,7 @@
450
583
  "name": "id",
451
584
  "required": true,
452
585
  "schema": {
453
- "default": "c_9513",
586
+ "default": "1914919",
454
587
  "type": "string"
455
588
  }
456
589
  }
@@ -532,6 +665,20 @@
532
665
  "default": "n92016188",
533
666
  "type": "string"
534
667
  }
668
+ },
669
+ {
670
+ "description": "The format of the returned result.",
671
+ "in": "query",
672
+ "name": "format",
673
+ "required": false,
674
+ "schema": {
675
+ "default": "json",
676
+ "type": "string",
677
+ "enum": [
678
+ "json",
679
+ "jsonld"
680
+ ]
681
+ }
535
682
  }
536
683
  ],
537
684
  "responses": {
@@ -548,7 +695,23 @@
548
695
  "content": {
549
696
  "application/json": {
550
697
  "schema": {
551
- "$ref": "#/components/schemas/linked_data_term_result"
698
+ "$ref": "#/components/schemas/linked_data_term_json_result"
699
+ }
700
+ },
701
+ "application/ld+json": {
702
+ "schema": {
703
+ "$ref": "#/components/schemas/linked_data_term_jsonld_result"
704
+ }
705
+ }
706
+ }
707
+ },
708
+ "400": {
709
+ "description": "Bad Request - occurs when required params are missing (e.g. id)",
710
+ "content": {
711
+ "text/plain": {
712
+ "schema": {
713
+ "type": "string",
714
+ "example": ""
552
715
  }
553
716
  }
554
717
  }
@@ -564,8 +727,8 @@
564
727
  }
565
728
  }
566
729
  },
567
- "503": {
568
- "description": "Service Unavailable",
730
+ "500": {
731
+ "description": "Internal Server Error - can be raised while attempting to access the external authority OR during processing of results when results are not a valid RDF Format",
569
732
  "content": {
570
733
  "text/plain": {
571
734
  "schema": {
@@ -575,8 +738,8 @@
575
738
  }
576
739
  }
577
740
  },
578
- "500": {
579
- "description": "Internal Server Error",
741
+ "503": {
742
+ "description": "Service Unavailable - can be raised while attempting to access the external authority",
580
743
  "content": {
581
744
  "text/plain": {
582
745
  "schema": {
@@ -665,10 +828,398 @@
665
828
  }
666
829
  }
667
830
  }
831
+ },
832
+ "/fetch/linked_data/{vocab}": {
833
+ "get": {
834
+ "operationId": "GET_fetchURIFromAuthority",
835
+ "summary": "Get a single term from an authority given the term's URI. Generally there are no additional parameters. See the authority's configuration file to be sure. Some authorities support `lang` which can be used to filter the language of returned strings. NOTE: The authorities provided with QA do not support fetch by URI. See more authority configs at: https://github.com/LD4P/linked_data_authorities",
836
+ "tags": [
837
+ "Fetch Term"
838
+ ],
839
+ "parameters": [
840
+ {
841
+ "description": "Name of the authority's configuration file.",
842
+ "in": "path",
843
+ "name": "vocab",
844
+ "required": true,
845
+ "schema": {
846
+ "default": "loc",
847
+ "type": "string"
848
+ }
849
+ },
850
+ {
851
+ "description": "The URI for the term being retrieved.",
852
+ "in": "query",
853
+ "name": "uri",
854
+ "required": true,
855
+ "schema": {
856
+ "default": "http://id.loc.gov/authorities/genreForms/gf2011026141",
857
+ "type": "string"
858
+ }
859
+ },
860
+ {
861
+ "description": "The format of the returned result.",
862
+ "in": "query",
863
+ "name": "format",
864
+ "required": false,
865
+ "schema": {
866
+ "default": "json",
867
+ "type": "string",
868
+ "enum": [
869
+ "json",
870
+ "jsonld"
871
+ ]
872
+ }
873
+ }
874
+ ],
875
+ "responses": {
876
+ "200": {
877
+ "description": "Successfully accessed authority and received term.",
878
+ "headers": {
879
+ "Access-Control-Allow-Origin": {
880
+ "description": "CORS header will be * if CORS headers are enabled",
881
+ "schema": {
882
+ "type": "string"
883
+ }
884
+ }
885
+ },
886
+ "content": {
887
+ "application/json": {
888
+ "schema": {
889
+ "$ref": "#/components/schemas/linked_data_term_json_result"
890
+ }
891
+ },
892
+ "application/ld+json": {
893
+ "schema": {
894
+ "$ref": "#/components/schemas/linked_data_term_jsonld_result"
895
+ }
896
+ }
897
+ }
898
+ },
899
+ "400": {
900
+ "description": "Bad Request - occurs when required params are missing (e.g. uri)",
901
+ "content": {
902
+ "text/plain": {
903
+ "schema": {
904
+ "type": "string",
905
+ "example": ""
906
+ }
907
+ }
908
+ }
909
+ },
910
+ "404": {
911
+ "description": "Not Found",
912
+ "content": {
913
+ "text/plain": {
914
+ "schema": {
915
+ "type": "string",
916
+ "example": ""
917
+ }
918
+ }
919
+ }
920
+ },
921
+ "500": {
922
+ "description": "Internal Server Error - can be raised while attempting to access the external authority OR during processing of results when results are not a valid RDF Format",
923
+ "content": {
924
+ "text/plain": {
925
+ "schema": {
926
+ "type": "string",
927
+ "example": ""
928
+ }
929
+ }
930
+ }
931
+ },
932
+ "503": {
933
+ "description": "Service Unavailable - can be raised while attempting to access the external authority",
934
+ "content": {
935
+ "text/plain": {
936
+ "schema": {
937
+ "type": "string",
938
+ "example": ""
939
+ }
940
+ }
941
+ }
942
+ }
943
+ }
944
+ },
945
+ "options": {
946
+ "summary": "CORS preflight request",
947
+ "operationId": "OPTIONS_fetchFromAuthority",
948
+ "tags": [
949
+ "Fetch Term"
950
+ ],
951
+ "parameters": [
952
+ {
953
+ "description": "Name of the authority's configuration file.",
954
+ "in": "path",
955
+ "name": "vocab",
956
+ "required": true,
957
+ "schema": {
958
+ "default": "loc",
959
+ "type": "string"
960
+ }
961
+ },
962
+ {
963
+ "description": "The ID or URI for the term being retrieved.",
964
+ "in": "path",
965
+ "name": "id",
966
+ "required": true,
967
+ "schema": {
968
+ "default": "http://id.loc.gov/authorities/genreForms/gf2011026141",
969
+ "type": "string"
970
+ }
971
+ }
972
+ ],
973
+ "responses": {
974
+ "204": {
975
+ "description": "Perform CORS preflight for fetching a term from an authority",
976
+ "headers": {
977
+ "Access-Control-Allow-Origin": {
978
+ "description": "CORS header will be * if CORS headers are enabled",
979
+ "schema": {
980
+ "type": "string"
981
+ }
982
+ },
983
+ "Access-Control-Allow-Methods": {
984
+ "description": "Indicates which method a future CORS request to the same resource might use.",
985
+ "schema": {
986
+ "type": "string"
987
+ }
988
+ }
989
+ },
990
+ "content": {
991
+ "text/plain": {
992
+ "schema": {
993
+ "type": "string",
994
+ "example": ""
995
+ }
996
+ }
997
+ }
998
+ },
999
+ "501": {
1000
+ "description": "OPTIONS action is not implement when CORS headers are not enabled",
1001
+ "content": {
1002
+ "text/plain": {
1003
+ "schema": {
1004
+ "type": "string",
1005
+ "example": ""
1006
+ }
1007
+ }
1008
+ }
1009
+ }
1010
+ }
1011
+ }
1012
+ },
1013
+ "/fetch/linked_data/{vocab}/{subauthority}": {
1014
+ "get": {
1015
+ "operationId": "GET_fetchByURIFromSubauthority",
1016
+ "summary": "Get a single term from a subauthority in an authority given the term's URI. Generally there are no additional parameters. See the authority's configuration file to be sure. Some authorities support `lang` which can be used to filter the language of returned strings. NOTE: There currently aren't any authorities configured that support subauthorities and access terms using a URI instead of an ID. The default values in this example show what you might see but DO NOT WORK with the current LOC config.",
1017
+ "tags": [
1018
+ "Fetch Term"
1019
+ ],
1020
+ "parameters": [
1021
+ {
1022
+ "description": "Name of the authority's configuration file.",
1023
+ "in": "path",
1024
+ "name": "vocab",
1025
+ "required": true,
1026
+ "schema": {
1027
+ "default": "loc",
1028
+ "type": "string"
1029
+ }
1030
+ },
1031
+ {
1032
+ "description": "Name of the subauthority.",
1033
+ "in": "path",
1034
+ "name": "subauthority",
1035
+ "required": true,
1036
+ "schema": {
1037
+ "default": "names",
1038
+ "type": "string"
1039
+ }
1040
+ },
1041
+ {
1042
+ "description": "The URI for the term being retrieved.",
1043
+ "in": "query",
1044
+ "name": "uri",
1045
+ "required": true,
1046
+ "schema": {
1047
+ "default": "http://id.loc.gov/authorities/names/n92016188",
1048
+ "type": "string"
1049
+ }
1050
+ },
1051
+ {
1052
+ "description": "The format of the returned result.",
1053
+ "in": "query",
1054
+ "name": "format",
1055
+ "required": false,
1056
+ "schema": {
1057
+ "default": "json",
1058
+ "type": "string",
1059
+ "enum": [
1060
+ "json",
1061
+ "jsonld"
1062
+ ]
1063
+ }
1064
+ }
1065
+ ],
1066
+ "responses": {
1067
+ "200": {
1068
+ "description": "Successfully accessed subauthority in the authority and received term.",
1069
+ "headers": {
1070
+ "Access-Control-Allow-Origin": {
1071
+ "description": "CORS header will be * if CORS headers are enabled",
1072
+ "schema": {
1073
+ "type": "string"
1074
+ }
1075
+ }
1076
+ },
1077
+ "content": {
1078
+ "application/json": {
1079
+ "schema": {
1080
+ "$ref": "#/components/schemas/linked_data_term_json_result"
1081
+ }
1082
+ },
1083
+ "application/ld+json": {
1084
+ "schema": {
1085
+ "$ref": "#/components/schemas/linked_data_term_jsonld_result"
1086
+ }
1087
+ }
1088
+ }
1089
+ },
1090
+ "400": {
1091
+ "description": "Bad Request - occurs when required params are missing (e.g. uri)",
1092
+ "content": {
1093
+ "text/plain": {
1094
+ "schema": {
1095
+ "type": "string",
1096
+ "example": ""
1097
+ }
1098
+ }
1099
+ }
1100
+ },
1101
+ "404": {
1102
+ "description": "Not Found",
1103
+ "content": {
1104
+ "text/plain": {
1105
+ "schema": {
1106
+ "type": "string",
1107
+ "example": ""
1108
+ }
1109
+ }
1110
+ }
1111
+ },
1112
+ "500": {
1113
+ "description": "Internal Server Error - can be raised while attempting to access the external authority OR during processing of results when results are not a valid RDF Format",
1114
+ "content": {
1115
+ "text/plain": {
1116
+ "schema": {
1117
+ "type": "string",
1118
+ "example": ""
1119
+ }
1120
+ }
1121
+ }
1122
+ },
1123
+ "503": {
1124
+ "description": "Service Unavailable - can be raised while attempting to access the external authority",
1125
+ "content": {
1126
+ "text/plain": {
1127
+ "schema": {
1128
+ "type": "string",
1129
+ "example": ""
1130
+ }
1131
+ }
1132
+ }
1133
+ }
1134
+ }
1135
+ },
1136
+ "options": {
1137
+ "summary": "CORS preflight request",
1138
+ "operationId": "OPTIONS_fetchFromSubauthority",
1139
+ "tags": [
1140
+ "Fetch Term"
1141
+ ],
1142
+ "parameters": [
1143
+ {
1144
+ "description": "Name of the authority's configuration file.",
1145
+ "in": "path",
1146
+ "name": "vocab",
1147
+ "required": true,
1148
+ "schema": {
1149
+ "default": "loc",
1150
+ "type": "string"
1151
+ }
1152
+ },
1153
+ {
1154
+ "description": "Name of the subauthority.",
1155
+ "in": "path",
1156
+ "name": "subauthority",
1157
+ "required": true,
1158
+ "schema": {
1159
+ "default": "names",
1160
+ "type": "string"
1161
+ }
1162
+ },
1163
+ {
1164
+ "description": "The URI for the term being retrieved.",
1165
+ "in": "path",
1166
+ "name": "id",
1167
+ "required": true,
1168
+ "schema": {
1169
+ "default": "http://id.loc.gov/authorities/names/n92016188",
1170
+ "type": "string"
1171
+ }
1172
+ }
1173
+ ],
1174
+ "responses": {
1175
+ "204": {
1176
+ "description": "Perform CORS preflight for fetching a term from a subauthority in an authority",
1177
+ "headers": {
1178
+ "Access-Control-Allow-Origin": {
1179
+ "description": "CORS header will be * if CORS headers are enabled",
1180
+ "schema": {
1181
+ "type": "string"
1182
+ }
1183
+ },
1184
+ "Access-Control-Allow-Methods": {
1185
+ "description": "Indicates which method a future CORS request to the same resource might use.",
1186
+ "schema": {
1187
+ "type": "string"
1188
+ }
1189
+ }
1190
+ },
1191
+ "content": {
1192
+ "text/plain": {
1193
+ "schema": {
1194
+ "type": "string",
1195
+ "example": ""
1196
+ }
1197
+ }
1198
+ }
1199
+ },
1200
+ "501": {
1201
+ "description": "OPTIONS action is not implement when CORS headers are not enabled",
1202
+ "content": {
1203
+ "text/plain": {
1204
+ "schema": {
1205
+ "type": "string",
1206
+ "example": ""
1207
+ }
1208
+ }
1209
+ }
1210
+ }
1211
+ }
1212
+ }
668
1213
  }
669
1214
  },
670
1215
  "components": {
671
1216
  "schemas": {
1217
+ "linked_data_authorities_list_result": {
1218
+ "type": "array",
1219
+ "items": {
1220
+ "type": "string"
1221
+ }
1222
+ },
672
1223
  "linked_data_query_results": {
673
1224
  "type": "array",
674
1225
  "items": {
@@ -693,7 +1244,7 @@
693
1244
  }
694
1245
  }
695
1246
  },
696
- "linked_data_term": {
1247
+ "linked_data_term_json_result": {
697
1248
  "required": [
698
1249
  "id",
699
1250
  "uri",
@@ -737,10 +1288,28 @@
737
1288
  "type": "object",
738
1289
  }
739
1290
  }
1291
+ },
1292
+ "linked_data_term_jsonld_result": {
1293
+ "required": [
1294
+ "@context",
1295
+ "@graph"
1296
+ ],
1297
+ "properties": {
1298
+ "@context": {
1299
+ "type": "object"
1300
+ },
1301
+ "@graph": {
1302
+ "type": "object"
1303
+ }
1304
+ }
740
1305
  }
741
1306
  }
742
1307
  },
743
1308
  "tags": [
1309
+ {
1310
+ "name": "Authority Management",
1311
+ "description": "Services managing all authorities."
1312
+ },
744
1313
  {
745
1314
  "name": "Search Query",
746
1315
  "description": "Services sending a search query to an authority to retrieve multiple results."