Skip to content

Commit

Permalink
Merge pull request #4 from algolia/feat/spec-sample
Browse files Browse the repository at this point in the history
  • Loading branch information
millotp authored Nov 10, 2021
2 parents 097acb7 + 4966251 commit 277532e
Show file tree
Hide file tree
Showing 14 changed files with 1,096 additions and 7 deletions.
26 changes: 26 additions & 0 deletions openapi_spec/parameters.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
AppId:
name: X-Algolia-Application-Id
in: header
description: Algolia appID
required: true
schema:
type: string
pattern: '^(?:beta|testing)?[A-Z0-9]{10}$'
example: 'DJNVGS47DK'
ApiKey:
name: X-Algolia-API-Key
in: header
description: Algolia API key
required: true
schema:
type: string
pattern: '^[a-f0-9]{32}$'
example: '43b15df305339e827f0ac0bdc5ebcaa7'
IndexName:
name: indexName
in: path
description: The index in which to perform the request
required: true
schema:
type: string
example: 'myIndexName'
56 changes: 56 additions & 0 deletions openapi_spec/paths/indexes/batch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
post:
tags:
- search
operationId: batch
summary: Performs multiple write operations in a single API call
parameters:
- $ref: '../../parameters.yml#/AppId'
- $ref: '../../parameters.yml#/ApiKey'
- $ref: '../../parameters.yml#/IndexName'
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
requests:
type: array
items:
title: operation
type: object
additionalProperties: false
properties:
action:
type: string
enum:
- 'addObject'
- 'updateObject'
- 'partialUpdateObject'
- 'partialUpdateObjectNoCreate'
- 'deleteObject'
- 'delete'
- 'clear'
description: type of operation
body:
type: object
# this could be a long oneOf with every possibilities
additionalProperties: true
description: arguments to the operation (depends on the type of the operation)
responses:
'200':
description: OK
content:
application/json:
schema:
type: object
additionalProperties: false
properties:
taskID:
$ref: '../../responses/common.yml#/taskID'
objectIDs:
$ref: '../../responses/common.yml#/objectIDs'
'400':
$ref: '../../responses/BadRequest.yml'
'404':
$ref: '../../responses/IndexNotFound.yml'
80 changes: 80 additions & 0 deletions openapi_spec/paths/indexes/multipleQueries.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
post:
tags:
- search
operationId: multipleQueries
summary: Get search results for the given requests.
parameters:
- $ref: '../../parameters.yml#/AppId'
- $ref: '../../parameters.yml#/ApiKey'
requestBody:
required: true
content:
application/json:
schema:
type: object
additionalProperties: false
properties:
requests:
type: array
items:
title: multipleQueries
type: object
additionalProperties: false
properties:
indexName:
type: string
example: products
description: The Algolia index name
query:
type: string
description: The query to search for
type:
type: string
enum: [default, facet]
default: default
description: Perform a search query with `default`, will search for facet values if `facet` is given
facet:
type: string
description: The `facet` name
params:
type: string
description: A query string of search parameters
required:
- indexName
strategy:
type: string
enum: ['none', 'stopIfEnoughMatches']
required:
- requests
responses:
'200':
description: OK
content:
application/json:
schema:
title: multipleQueriesResponse
type: object
additionalProperties: false
properties:
results:
type: array
items:
type: object
additionalProperties: false
properties:
hits:
type: array
items:
type: object
additionalProperties: false
properties:
objectID:
$ref: '../../responses/common.yml#/objectID'
nbHits:
type: integer
queryID:
$ref: '../../responses/common.yml#/queryID'
'400':
$ref: '../../responses/BadRequest.yml'
'404':
$ref: '../../responses/IndexNotFound.yml'
36 changes: 36 additions & 0 deletions openapi_spec/paths/indexes/saveObject.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
post:
tags:
- object
operationId: saveObject
summary: Save object
description: Add an object to the index, automatically assigning it an object ID
parameters:
- $ref: '../../parameters.yml#/AppId'
- $ref: '../../parameters.yml#/ApiKey'
- $ref: '../../parameters.yml#/IndexName'
requestBody:
required: true
content:
application/json:
schema:
type: object
additionalProperties: true
responses:
'200':
description: OK
content:
application/json:
schema:
type: object
additionalProperties: false
properties:
createdAt:
type: string
taskID:
$ref: '../../responses/common.yml#/taskID'
objectID:
$ref: '../../responses/common.yml#/objectID'
'400':
$ref: '../../responses/BadRequest.yml'
'404':
$ref: '../../responses/IndexNotFound.yml'
39 changes: 39 additions & 0 deletions openapi_spec/paths/indexes/search.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
post:
tags:
- search
operationId: search
summary: Get search results
parameters:
- $ref: '../../parameters.yml#/AppId'
- $ref: '../../parameters.yml#/ApiKey'
- $ref: '../../parameters.yml#/IndexName'
requestBody:
$ref: '../../schemas/SearchParams.yml'
responses:
'200':
description: OK
content:
application/json:
schema:
title: singleQueryResponse
type: object
additionalProperties: false
properties:
hits:
type: array
items:
type: object
additionalProperties: false
properties:
objectID:
$ref: '../../responses/common.yml#/objectID'
nbHits:
type: integer
queryID:
type: string
pattern: '^[a-f0-9]{32}$'
example: 43b15df305339e827f0ac0bdc5ebcaa7
'400':
$ref: '../../responses/BadRequest.yml'
'404':
$ref: '../../responses/IndexNotFound.yml'
5 changes: 5 additions & 0 deletions openapi_spec/responses/BadRequest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
description: Bad request or request arguments
content:
application/json:
schema:
$ref: '../schemas/Error.yml'
5 changes: 5 additions & 0 deletions openapi_spec/responses/IndexNotFound.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
description: Index not found
content:
application/json:
schema:
$ref: '../schemas/Error.yml'
15 changes: 15 additions & 0 deletions openapi_spec/responses/common.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
taskID:
type: integer
description: taskID of the indexing task to wait for.
objectID:
type: string
description: Unique identifier of the object
objectIDs:
type: array
items:
type: string
description: List of objectID
queryID:
type: string
pattern: '^[a-f0-9]{32}$'
example: 43b15df305339e827f0ac0bdc5ebcaa7
7 changes: 7 additions & 0 deletions openapi_spec/schemas/Error.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
description: Error
type: object
additionalProperties: true
properties:
message:
type: string
example: 'Invalid Application-Id or API-Key'
Loading

0 comments on commit 277532e

Please sign in to comment.