incubator-s2graph icon indicating copy to clipboard operation
incubator-s2graph copied to clipboard

S2GRAPH-253: Swagger Doc and UI support

Open woonsan opened this issue 6 years ago • 0 comments

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:

  1. Build the project with sbt package.

  2. Start the project in the target/apache-s2graph-0.2.1-SNAPSHOT-incubating-bin directory through bin/start-s2graph.sh command.

  3. Visit the Swagger UI at http://localhost:8000/api-docs/.

  4. 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".

  1. "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".

  1. "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".

  1. "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".

  1. "Try out" /admin/getLabel/{name} with name set to "friend". Check if the result is 200 with a JSON output.

woonsan avatar Apr 08 '19 22:04 woonsan