S2GRAPH-253: Swagger Doc and UI support
As an initial PR, I've added swagger doc and UI support, and added API docs for the "admin" services for now; mutate and query services will come later.
How to test:
-
Build the project with
sbt package. -
Start the project in the target/apache-s2graph-0.2.1-SNAPSHOT-incubating-bin directory through
bin/start-s2graph.shcommand. -
Visit the Swagger UI at http://localhost:8000/api-docs/.
-
Expand "/admin/createService" and click on "Try it out" button. Replace the body with the following and click on "Execute" button.
{
"serviceName": "s2graph"
}
Check if the result is 201 with a JSON output and the status is "ok".
- "Try out" /admin/createLabel with body set to the following:
{
"label": "user_article_liked",
"srcServiceName": "s2graph",
"srcColumnName": "user_id",
"srcColumnType": "long",
"tgtServiceName": "s2graph",
"tgtColumnName": "article_id",
"tgtColumnType": "string",
"indices": [],
"props": [],
"serviceName": "s2graph"
}
Check if the result is 201 with a JSON output and the status is "ok".
- "Try out" /admin/createLabel with body set to the following:
{
"label": "friends",
"srcServiceName": "s2graph",
"srcColumnName": "user_id",
"srcColumnType": "long",
"tgtServiceName": "s2graph",
"tgtColumnName": "user_id",
"tgtColumnType": "long",
"indices": [
{"name": "idx_affinity_timestamp", "propNames": ["affinity_score", "_timestamp"]}
],
"props": [
{"name": "affinity_score", "dataType": "float", "defaultValue": 0.0},
{"name": "_timestamp", "dataType": "long", "defaultValue": 0},
{"name": "is_hidden", "dataType": "boolean", "defaultValue": false},
{"name": "is_blocked", "dataType": "boolean", "defaultValue": true},
{"name": "error_code", "dataType": "integer", "defaultValue": 500}
],
"serviceName": "s2graph",
"consistencyLevel": "strong"
}
Check if the result is 201 with a JSON output and the status is "ok".
- "Try out" /admin/addIndex with body set to the following:
{
"label": "friends",
"indices": [
{"name": "idx_3rd", "propNames": ["is_blocked", "_timestamp"]}
]
}
Check if the result is 201 with a JSON output and the status is "ok".
- "Try out" /admin/getLabel/{name} with name set to "friend". Check if the result is 200 with a JSON output.