Skip to content

Commit

Permalink
[DX-981] Update data-graphs-api.md (#3960)
Browse files Browse the repository at this point in the history
fixed order 
added sample request
---------
  • Loading branch information
letzya authored Jan 23, 2024
1 parent 530e6b5 commit 52e159f
Showing 1 changed file with 44 additions and 21 deletions.
65 changes: 44 additions & 21 deletions tyk-docs/content/tyk-apis/tyk-dashboard-api/data-graphs-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ menu:
weight: 1
---

Currently `/api/data-graphs/` has only one endpoint called `/data-sources` with only `POST` HTTP method.
Currently `/api/data-graphs/` has only one endpoint called `/data-sources` with only a `POST` HTTP method.

## Import an AsyncAPI Document

The Dashboard exposes the `/api/data-graphs/data-sources/import` Dashboard API which allows you to import an [AsyncAPI](https://www.asyncapi.com/docs/reference/specification/v3.0.0) or [OpenAPI](https://swagger.io/specification/) document.

### Request structure

| **Property** | **Description** |
|--------------|-------------------------------------------------------|
| Resource URL | `/api/data-graphs/data-sources/import` |
Expand All @@ -25,6 +27,47 @@ As shown in the table above, you should provide a JSON payload ("body") with the
* `type` - document type, valid document types are `asyncapi` and `openapi`.
* `data` - AsyncAPI or OpenAPI document. Note: This string of characters needs to be "[stringified](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify)" (converting an object to its JSON (JavaScript Object Notation) string representation).

####
```curl
curl --location '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>}"
}'
```

### Supported AsyncAPI versions
* 2.0.0
* 2.1.0
* 2.3.0
* 2.4.0

### Supported OpenAPI versions
* 3.0.0

### 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

```json
{
"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.

Expand All @@ -50,23 +93,3 @@ console.log(pm.environment.get("asyncapi_document"))
```
"{ \n \"apisync\": \"v3.0.0\",\n \"info\": {}\n }"
```


### Supported AsyncAPI versions
* 2.0.0
* 2.1.0
* 2.3.0
* 2.4.0

### Supported OpenAPI versions
* 3.0.0

### Sample Response

```json
{
"Status": "OK",
"Message": "Data source imported",
"Meta": "64102568f2c734bd2c0b8f99"
}
```

0 comments on commit 52e159f

Please sign in to comment.