Skip to content

Commit 277532e

Browse files
authored
Merge pull request #4 from algolia/feat/spec-sample
2 parents 097acb7 + 4966251 commit 277532e

14 files changed

+1096
-7
lines changed

openapi_spec/parameters.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
AppId:
2+
name: X-Algolia-Application-Id
3+
in: header
4+
description: Algolia appID
5+
required: true
6+
schema:
7+
type: string
8+
pattern: '^(?:beta|testing)?[A-Z0-9]{10}$'
9+
example: 'DJNVGS47DK'
10+
ApiKey:
11+
name: X-Algolia-API-Key
12+
in: header
13+
description: Algolia API key
14+
required: true
15+
schema:
16+
type: string
17+
pattern: '^[a-f0-9]{32}$'
18+
example: '43b15df305339e827f0ac0bdc5ebcaa7'
19+
IndexName:
20+
name: indexName
21+
in: path
22+
description: The index in which to perform the request
23+
required: true
24+
schema:
25+
type: string
26+
example: 'myIndexName'

openapi_spec/paths/indexes/batch.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
post:
2+
tags:
3+
- search
4+
operationId: batch
5+
summary: Performs multiple write operations in a single API call
6+
parameters:
7+
- $ref: '../../parameters.yml#/AppId'
8+
- $ref: '../../parameters.yml#/ApiKey'
9+
- $ref: '../../parameters.yml#/IndexName'
10+
requestBody:
11+
required: true
12+
content:
13+
application/json:
14+
schema:
15+
type: object
16+
properties:
17+
requests:
18+
type: array
19+
items:
20+
title: operation
21+
type: object
22+
additionalProperties: false
23+
properties:
24+
action:
25+
type: string
26+
enum:
27+
- 'addObject'
28+
- 'updateObject'
29+
- 'partialUpdateObject'
30+
- 'partialUpdateObjectNoCreate'
31+
- 'deleteObject'
32+
- 'delete'
33+
- 'clear'
34+
description: type of operation
35+
body:
36+
type: object
37+
# this could be a long oneOf with every possibilities
38+
additionalProperties: true
39+
description: arguments to the operation (depends on the type of the operation)
40+
responses:
41+
'200':
42+
description: OK
43+
content:
44+
application/json:
45+
schema:
46+
type: object
47+
additionalProperties: false
48+
properties:
49+
taskID:
50+
$ref: '../../responses/common.yml#/taskID'
51+
objectIDs:
52+
$ref: '../../responses/common.yml#/objectIDs'
53+
'400':
54+
$ref: '../../responses/BadRequest.yml'
55+
'404':
56+
$ref: '../../responses/IndexNotFound.yml'
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
post:
2+
tags:
3+
- search
4+
operationId: multipleQueries
5+
summary: Get search results for the given requests.
6+
parameters:
7+
- $ref: '../../parameters.yml#/AppId'
8+
- $ref: '../../parameters.yml#/ApiKey'
9+
requestBody:
10+
required: true
11+
content:
12+
application/json:
13+
schema:
14+
type: object
15+
additionalProperties: false
16+
properties:
17+
requests:
18+
type: array
19+
items:
20+
title: multipleQueries
21+
type: object
22+
additionalProperties: false
23+
properties:
24+
indexName:
25+
type: string
26+
example: products
27+
description: The Algolia index name
28+
query:
29+
type: string
30+
description: The query to search for
31+
type:
32+
type: string
33+
enum: [default, facet]
34+
default: default
35+
description: Perform a search query with `default`, will search for facet values if `facet` is given
36+
facet:
37+
type: string
38+
description: The `facet` name
39+
params:
40+
type: string
41+
description: A query string of search parameters
42+
required:
43+
- indexName
44+
strategy:
45+
type: string
46+
enum: ['none', 'stopIfEnoughMatches']
47+
required:
48+
- requests
49+
responses:
50+
'200':
51+
description: OK
52+
content:
53+
application/json:
54+
schema:
55+
title: multipleQueriesResponse
56+
type: object
57+
additionalProperties: false
58+
properties:
59+
results:
60+
type: array
61+
items:
62+
type: object
63+
additionalProperties: false
64+
properties:
65+
hits:
66+
type: array
67+
items:
68+
type: object
69+
additionalProperties: false
70+
properties:
71+
objectID:
72+
$ref: '../../responses/common.yml#/objectID'
73+
nbHits:
74+
type: integer
75+
queryID:
76+
$ref: '../../responses/common.yml#/queryID'
77+
'400':
78+
$ref: '../../responses/BadRequest.yml'
79+
'404':
80+
$ref: '../../responses/IndexNotFound.yml'
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
post:
2+
tags:
3+
- object
4+
operationId: saveObject
5+
summary: Save object
6+
description: Add an object to the index, automatically assigning it an object ID
7+
parameters:
8+
- $ref: '../../parameters.yml#/AppId'
9+
- $ref: '../../parameters.yml#/ApiKey'
10+
- $ref: '../../parameters.yml#/IndexName'
11+
requestBody:
12+
required: true
13+
content:
14+
application/json:
15+
schema:
16+
type: object
17+
additionalProperties: true
18+
responses:
19+
'200':
20+
description: OK
21+
content:
22+
application/json:
23+
schema:
24+
type: object
25+
additionalProperties: false
26+
properties:
27+
createdAt:
28+
type: string
29+
taskID:
30+
$ref: '../../responses/common.yml#/taskID'
31+
objectID:
32+
$ref: '../../responses/common.yml#/objectID'
33+
'400':
34+
$ref: '../../responses/BadRequest.yml'
35+
'404':
36+
$ref: '../../responses/IndexNotFound.yml'

openapi_spec/paths/indexes/search.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
post:
2+
tags:
3+
- search
4+
operationId: search
5+
summary: Get search results
6+
parameters:
7+
- $ref: '../../parameters.yml#/AppId'
8+
- $ref: '../../parameters.yml#/ApiKey'
9+
- $ref: '../../parameters.yml#/IndexName'
10+
requestBody:
11+
$ref: '../../schemas/SearchParams.yml'
12+
responses:
13+
'200':
14+
description: OK
15+
content:
16+
application/json:
17+
schema:
18+
title: singleQueryResponse
19+
type: object
20+
additionalProperties: false
21+
properties:
22+
hits:
23+
type: array
24+
items:
25+
type: object
26+
additionalProperties: false
27+
properties:
28+
objectID:
29+
$ref: '../../responses/common.yml#/objectID'
30+
nbHits:
31+
type: integer
32+
queryID:
33+
type: string
34+
pattern: '^[a-f0-9]{32}$'
35+
example: 43b15df305339e827f0ac0bdc5ebcaa7
36+
'400':
37+
$ref: '../../responses/BadRequest.yml'
38+
'404':
39+
$ref: '../../responses/IndexNotFound.yml'

openapi_spec/responses/BadRequest.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
description: Bad request or request arguments
2+
content:
3+
application/json:
4+
schema:
5+
$ref: '../schemas/Error.yml'
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
description: Index not found
2+
content:
3+
application/json:
4+
schema:
5+
$ref: '../schemas/Error.yml'

openapi_spec/responses/common.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
taskID:
2+
type: integer
3+
description: taskID of the indexing task to wait for.
4+
objectID:
5+
type: string
6+
description: Unique identifier of the object
7+
objectIDs:
8+
type: array
9+
items:
10+
type: string
11+
description: List of objectID
12+
queryID:
13+
type: string
14+
pattern: '^[a-f0-9]{32}$'
15+
example: 43b15df305339e827f0ac0bdc5ebcaa7

openapi_spec/schemas/Error.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
description: Error
2+
type: object
3+
additionalProperties: true
4+
properties:
5+
message:
6+
type: string
7+
example: 'Invalid Application-Id or API-Key'

0 commit comments

Comments
 (0)