diff --git a/api_static/api/swagger.json b/api_static/api/swagger.json new file mode 100644 index 0000000000000000000000000000000000000000..d26e53a191a3fd0d0e8c3653e43c4e6e36b0237b --- /dev/null +++ b/api_static/api/swagger.json @@ -0,0 +1,106 @@ +{ + "openapi": "3.0.1", + "info": { + "title": "ordbok-cache", + "version": "2020-02-17T12:44:25Z" + }, + "servers": [], + "paths": { + "/article/{dict_id}/{art_id}": { + "get": { + "parameters": [ + { + "name": "dict_id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "art_id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "security": [ + { + "api_key": [] + } + ] + } + }, + "/article/{dict_id}/search": { + "get": { + "parameters": [ + { + "name": "dict_id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "q", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + } + ], + "security": [ + { + "api_key": [] + } + ] + } + }, + "/article/{dict_id}/suggest": { + "get": { + "parameters": [ + { + "name": "dict_id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "q", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + } + ], + "security": [ + { + "api_key": [] + } + ] + } + } + }, + "components": { + "schemas": { + "Empty": { + "title": "Empty Schema", + "type": "object" + } + }, + "securitySchemes": { + "api_key": { + "type": "apiKey", + "name": "x-api-key", + "in": "header" + } + } + } +} diff --git a/src/App.vue b/src/App.vue index 480bc89044d6a03b2697496a72e0eb0699c64b2a..77e0936155acb61b3acb099881714e8c16b83d1e 100644 --- a/src/App.vue +++ b/src/App.vue @@ -57,7 +57,7 @@ import SearchResults from './components/SearchResults.vue' import Autocomplete from '@trevoreyre/autocomplete-vue' import '@trevoreyre/autocomplete-vue/dist/style.css' -var api_endpoint = 'https://ordbok-dev.aws.uib.no/cache/article' +var api_endpoint = 'https://beta.ordbok.uib.no/api/article' axios.interceptors.request.use(function (config) { config.headers["x-api-key"] = "ZkYiyRVXxH86ijsvhx3cH4SY5Iik2ijI3BKVJGMm" @@ -90,18 +90,8 @@ export default { let self = this return function(q) { return new Promise(resolve => { - return axios.post(api_endpoint + '/' + self.lang + '/_search/', - { - "suggest": { - "suggest" : { - "prefix" : q, - "completion" : { - "field" : "suggest", - "size": 10 - } - } - } - }).then(function(response) { + return axios.get(api_endpoint + '/' + self.lang + '/suggest?q=' + q).then( + function(response) { let hits = q.length ? [{q: q}] : [] hits = hits.concat(response.data.suggest.suggest[0].options.sort((o1, o2) => o1.text.length - o2.text.length)) resolve(hits) @@ -129,7 +119,7 @@ export default { var self = this self.waiting = true self.article = {lemmas: [], body:{pronunciation: [], definitions: [], etymology: []}} - axios.get(api_endpoint + '/' + self.lang + '/_search?q=' + event.q + ' ' + event.q + '*&size=20') + axios.get(api_endpoint + '/' + self.lang + '/search?q=' + event.q + ' ' + event.q + '*&size=20') .then(function(response){ self.$router.push('/' + `/search?q=${event.q}&lang=${self.lang}`) self.search_results = response.data.hits.hits @@ -164,7 +154,7 @@ export default { this.lang = this.$route.params.lang || this.$route.query.lang || 'bob,nob' var self = this; if(this.$route.query.q) { - axios.get(api_endpoint + '/' + self.lang + '/_search?q=' + self.$route.query.q + ' ' + self.$route.query.q + '*&size=20') + axios.get(api_endpoint + '/' + self.lang + '/search?q=' + self.$route.query.q + ' ' + self.$route.query.q + '*&size=20') .then(function(response){ self.search_results = response.data.hits.hits self.waiting = false