Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(specs): add validate endpoint #3087

Merged
merged 7 commits into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions specs/ingestion/common/schemas/source.yml
Original file line number Diff line number Diff line change
Expand Up @@ -524,3 +524,25 @@ sourceShopifyBase:
- shopURL
x-discriminator-fields:
- shopURL

SourceValidateResponse:
type: object
additionalProperties: false
properties:
runID:
$ref: './common.yml#/runID'
data:
type: array
description: depending on the source type, the validation returns sampling data of your source (JSON, CSV, BigQuery).
items:
type: object
events:
description: in case of error, observability events will be added to the response, if any.
type: array
items:
$ref: '../../common/schemas/event.yml#/Event'
message:
description: a message describing the outcome of a validate run.
type: string
required:
- message
26 changes: 26 additions & 0 deletions specs/ingestion/paths/sources/validate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
post:
tags:
- sources
summary: Validates a source payload
description: |
Validates a source payload to ensure it can be created and that the data source can be reached by Algolia.
operationId: validateSource
x-acl:
- addObject
- deleteIndex
- editSettings
requestBody:
description: ''
content:
application/json:
schema:
$ref: '../../common/schemas/source.yml#/SourceCreate'
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '../../common/schemas/source.yml#/SourceValidateResponse'
'400':
$ref: '../../../common/responses/BadRequest.yml'
28 changes: 28 additions & 0 deletions specs/ingestion/paths/sources/validateID.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
post:
tags:
- sources
summary: Validates an update of a source payload
description: |
Validates an update of a source payload to ensure it can be created and that the data source can be reached by Algolia.
operationId: validateSourceBeforeUpdate
x-acl:
- addObject
- deleteIndex
- editSettings
parameters:
- $ref: '../../common/parameters.yml#/pathSourceID'
requestBody:
content:
application/json:
schema:
$ref: '../../common/schemas/source.yml#/SourceUpdate'
required: true
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '../../common/schemas/source.yml#/SourceValidateResponse'
'400':
$ref: '../../../common/responses/BadRequest.yml'
4 changes: 4 additions & 0 deletions specs/ingestion/spec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,14 @@ paths:
# sources API.
/1/sources:
$ref: 'paths/sources/sources.yml'
/1/sources/validate:
$ref: 'paths/sources/validate.yml'
/1/sources/search:
$ref: 'paths/sources/searchSources.yml'
/1/sources/{sourceID}:
$ref: 'paths/sources/sourceID.yml'
/1/sources/{sourceID}/validate:
$ref: 'paths/sources/validateID.yml'
/1/sources/{sourceID}/discover:
$ref: 'paths/sources/discover.yml'

Expand Down
39 changes: 39 additions & 0 deletions tests/CTS/requests/ingestion/validateSource.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
[
{
"testName": "validateSource",
"parameters": {
"type": "commercetools",
"name": "sourceName",
"input": {
"storeKeys": [
"myStore"
],
"locales": [
"de"
],
"url": "http://commercetools.com",
"projectKey": "keyID"
},
"authenticationID": "6c02aeb1-775e-418e-870b-1faccd4b2c0f"
},
"request": {
"path": "/1/sources/validate",
"method": "POST",
"body": {
"type": "commercetools",
"name": "sourceName",
"input": {
"storeKeys": [
"myStore"
],
"locales": [
"de"
],
"url": "http://commercetools.com",
"projectKey": "keyID"
},
"authenticationID": "6c02aeb1-775e-418e-870b-1faccd4b2c0f"
}
}
}
]
18 changes: 18 additions & 0 deletions tests/CTS/requests/ingestion/validateSourceBeforeUpdate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[
{
"testName": "validateSourceBeforeUpdate",
"parameters": {
"sourceID": "6c02aeb1-775e-418e-870b-1faccd4b2c0f",
"sourceUpdate": {
"name": "newName"
}
},
"request": {
"path": "/1/sources/6c02aeb1-775e-418e-870b-1faccd4b2c0f/validate",
"method": "POST",
"body": {
"name": "newName"
}
}
}
]
Loading