Data Graphs API
Last updated: 2 minutes read.
Currently /api/data-graphs/
has only one endpoint called /data-sources
with only a POST
HTTP method.
Import AsyncAPI or OpenAPI Documents
The Dashboard exposes the /api/data-graphs/data-sources/import
Dashboard API which allows you to import an AsyncAPI or OpenAPI document.
Supported AsyncAPI versions
- 2.0.0
- 2.1.0
- 2.3.0
- 2.4.0
Supported OpenAPI versions
- 3.0.0
Request structure
Property | Description |
---|---|
Resource URL | /api/data-graphs/data-sources/import |
Method | POST |
Body | { "type": "<openapi | asyncapi>", "data": "<THE-DOCUMENT>" } |
As shown in the table above, you should provide a JSON payload (“body”) with the following data:
type
- document type, valid document types areasyncapi
andopenapi
.data
- AsyncAPI or OpenAPI document. Note: This string of characters needs to be stringified (i.e. converting an object to its JSON (JavaScript Object Notation) string representation).
Sample Request
curl 'http://tyk-dashboard.localhost:3000/api/data-graphs/data-sources/import' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: <API KAY>' \
--data '{
"type": "asyncapi",
"data": "{\"apisync\": \"v3.0.0\", \"info\": {} ...
<TO SIMPLIFY, WE SHOW ONLY THE FIRST FEW LINES FROM THE ASYNC API DOCUMENT>}"
}'
Response structure
The same as in other endpoints
Property | Description |
---|---|
Status | Error or OK |
Message | Verbal explanation |
Meta | API Id for success and null with error (not in use) |
Sample Response
{
"Status": "OK",
"Message": "Data source imported",
"Meta": "64102568f2c734bd2c0b8f99"
}
Suggestion for “stringifying” with Postman
If you use Postman, you can write a little Javascript code in the “Pre-request Script” and stringify the document.
1. The “Pre-request Script”:
Screenshot from Postman’s “Pre-request Script” tab:
“Pre-request Script” code to copy
In the sample code, we put only a small part of the AsyncAPI documents, so you can quickly see and copy the code
pm.environment.set("asyncapi_document", JSON.stringify(
`{
"apisync": "v3.0.0",
"info": {}
}`
))
console.log(pm.environment.get("asyncapi_document"))
2. The Body
Screenshot from Postman’s “Body” tab"
The “Body” code to copy
{
"type": "asyncapi",
"data": {{asyncapi_document}}
}
3. Make the API call
Hit send
4. The log result as seen in Postman Console:
In the console log, you should see the output of your “stringified” document, to make sure it was stringified it as expected:
"{ \n \"apisync\": \"v3.0.0\",\n \"info\": {}\n }"