Skip to content

Commit

Permalink
feat(specs): add validate endpoint (#3087)
Browse files Browse the repository at this point in the history
Co-authored-by: shortcuts <vannicattec@gmail.com>
  • Loading branch information
Fluf22 and shortcuts authored Jun 19, 2024
1 parent d55eee1 commit c91ca54
Show file tree
Hide file tree
Showing 6 changed files with 137 additions and 0 deletions.
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"
}
}
}
]

1 comment on commit c91ca54

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please # to comment.