Added dynamic swagger.json controller for Swagger UI based on yaml src.

Project: http://git-wip-us.apache.org/repos/asf/metamodel/repo
Commit: http://git-wip-us.apache.org/repos/asf/metamodel/commit/46b3cf83
Tree: http://git-wip-us.apache.org/repos/asf/metamodel/tree/46b3cf83
Diff: http://git-wip-us.apache.org/repos/asf/metamodel/diff/46b3cf83

Branch: refs/heads/feature/5.x/swagger-docs
Commit: 46b3cf83936c84665f74ee030930b3783e745718
Parents: 0dd9bd8
Author: Kasper Sørensen <[email protected]>
Authored: Tue Jul 26 22:31:02 2016 -0700
Committer: Kasper Sørensen <[email protected]>
Committed: Tue Jul 26 22:31:02 2016 -0700

----------------------------------------------------------------------
 pom.xml                                         |   5 +
 service-webapp/pom.xml                          |   4 +
 .../controllers/RootInformationController.java  |  10 +-
 .../controllers/SwaggerSpecController.java      |  64 +++
 service-webapp/src/main/resources/swagger.yaml  | 532 +++++++++++++++++++
 service-webapp/swagger.yaml                     | 530 ------------------
 6 files changed, 614 insertions(+), 531 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/metamodel/blob/46b3cf83/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index b771103..5bf3492 100644
--- a/pom.xml
+++ b/pom.xml
@@ -513,6 +513,11 @@ under the License.
                                <version>${jackson.version}</version>
                        </dependency>
                        <dependency>
+                               
<groupId>com.fasterxml.jackson.dataformat</groupId>
+                               <artifactId>jackson-dataformat-yaml</artifactId>
+                               <version>${jackson.version}</version>
+                       </dependency>
+                       <dependency>
                                <groupId>com.fasterxml.jackson.core</groupId>
                                <artifactId>jackson-annotations</artifactId>
                                <version>${jackson.version}</version>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/46b3cf83/service-webapp/pom.xml
----------------------------------------------------------------------
diff --git a/service-webapp/pom.xml b/service-webapp/pom.xml
index b452f55..fa56340 100644
--- a/service-webapp/pom.xml
+++ b/service-webapp/pom.xml
@@ -53,6 +53,10 @@ under the License.
                        <artifactId>jackson-databind</artifactId>
                </dependency>
                <dependency>
+                       <groupId>com.fasterxml.jackson.dataformat</groupId>
+                       <artifactId>jackson-dataformat-yaml</artifactId>
+               </dependency>
+               <dependency>
                        <groupId>com.google.guava</groupId>
                        <artifactId>guava</artifactId>
                </dependency>

http://git-wip-us.apache.org/repos/asf/metamodel/blob/46b3cf83/service-webapp/src/main/java/org/apache/metamodel/service/controllers/RootInformationController.java
----------------------------------------------------------------------
diff --git 
a/service-webapp/src/main/java/org/apache/metamodel/service/controllers/RootInformationController.java
 
b/service-webapp/src/main/java/org/apache/metamodel/service/controllers/RootInformationController.java
index 794f85a..e89a39d 100644
--- 
a/service-webapp/src/main/java/org/apache/metamodel/service/controllers/RootInformationController.java
+++ 
b/service-webapp/src/main/java/org/apache/metamodel/service/controllers/RootInformationController.java
@@ -59,12 +59,20 @@ public class RootInformationController {
         } catch (Exception e) {
             logger.info("Failed to get canonical-hostname", e);
         }
+        map.put("open-api", getOpenApi());
+        return map;
+    }
+
+    private Map<String, Object> getOpenApi() {
+        final Map<String, Object> map = new LinkedHashMap<>();
+        map.put("spec", servletContext.getContextPath() + "/swagger.json");
+        map.put("swagger-ui", servletContext.getContextPath() + "/swagger-ui");
         return map;
     }
 
     private Map<String, Object> getServerTime() {
         final ZonedDateTime now = ZonedDateTime.now();
-        final String dateFormatted = now.format( 
DateTimeFormatter.ISO_INSTANT);
+        final String dateFormatted = now.format(DateTimeFormatter.ISO_INSTANT);
 
         final Map<String, Object> map = new LinkedHashMap<>();
         map.put("timestamp", new Date().getTime());

http://git-wip-us.apache.org/repos/asf/metamodel/blob/46b3cf83/service-webapp/src/main/java/org/apache/metamodel/service/controllers/SwaggerSpecController.java
----------------------------------------------------------------------
diff --git 
a/service-webapp/src/main/java/org/apache/metamodel/service/controllers/SwaggerSpecController.java
 
b/service-webapp/src/main/java/org/apache/metamodel/service/controllers/SwaggerSpecController.java
new file mode 100644
index 0000000..1081519
--- /dev/null
+++ 
b/service-webapp/src/main/java/org/apache/metamodel/service/controllers/SwaggerSpecController.java
@@ -0,0 +1,64 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.metamodel.service.controllers;
+
+import java.io.InputStream;
+import java.util.Arrays;
+import java.util.Map;
+
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.metamodel.util.FileHelper;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.MediaType;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.RestController;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
+
+@RestController
+public class SwaggerSpecController {
+
+    @Autowired
+    ServletContext servletContext;
+
+    @RequestMapping(method = RequestMethod.GET, value = "/swagger.json", 
produces = MediaType.APPLICATION_JSON_VALUE)
+    @ResponseBody
+    public Map<String, Object> getSwaggerJson(HttpServletRequest req) throws 
Exception {
+        final String yaml;
+        try (final InputStream resource = 
getClass().getResourceAsStream("/swagger.yaml")) {
+            yaml = FileHelper.readInputStreamAsString(resource, 
FileHelper.UTF_8_ENCODING);
+        }
+
+        final ObjectMapper yamlReader = new ObjectMapper(new YAMLFactory());
+        @SuppressWarnings("unchecked")
+        final Map<String, Object> map = yamlReader.readValue(yaml, Map.class);
+
+        // add the base path, scheme and host
+        map.put("basePath", servletContext.getContextPath());
+        map.put("host", req.getServerName() + ":" + req.getServerPort());
+        map.put("schemes", Arrays.asList(req.getScheme()));
+
+        return map;
+    }
+}

http://git-wip-us.apache.org/repos/asf/metamodel/blob/46b3cf83/service-webapp/src/main/resources/swagger.yaml
----------------------------------------------------------------------
diff --git a/service-webapp/src/main/resources/swagger.yaml 
b/service-webapp/src/main/resources/swagger.yaml
new file mode 100644
index 0000000..55b5fe4
--- /dev/null
+++ b/service-webapp/src/main/resources/swagger.yaml
@@ -0,0 +1,532 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+swagger: '2.0'
+info:
+  title: Apache MetaModel RESTful API
+  description: Delivers 'MetaModel-as-a-Service' for unified data federation.
+  version: "5.0.0"
+consumes:
+  - application/json
+produces:
+  - application/json
+paths:
+  /:
+    get:
+      summary: Hello MetaModel
+      description: An endpoint that provides a confirmation that the system is 
operational
+      responses:
+        200:
+          description: The system is operational
+          schema:
+            type: object
+            properties:
+              ping:
+                type: string
+                description: Should return 'pong!' when the system is 
operational
+              application:
+                type: string
+                description: The name of the application running (Apache 
MetaModel)
+              version:
+                type: string
+                description: The version of the application running
+              server-time:
+                type: object
+                properties:
+                  timestamp:
+                    type: integer
+                    format: int64
+                    description: The server-time in timestamp format (millis 
since 1st of January 1970)
+                  iso8601:
+                    type: string
+                    description: The server-time in ISO-8601 format
+              canonical-hostname:
+                type: string
+                description: The canonical hostname of the server
+  /{tenant}:
+    parameters:
+      - name: tenant
+        in: path
+        type: string
+        description: The tenant name
+        required: true
+    put:
+      summary: Create new tenant
+      responses:
+        200:
+          description: Tenant created
+          schema:
+            properties:
+              type:
+                type: string
+                description: The type of entity (tenant)
+              name:
+                type: string
+                description: The tenant name/identifier
+        409:
+          description: Tenant already exist
+          schema:
+            $ref: "#/definitions/error"
+    get:
+      summary: Get tenant information
+      description: Provides basic information about a tenant of the system
+      responses:
+        404:
+          description: Tenant not found
+          schema:
+            $ref: "#/definitions/error"
+        200:
+          description: Tenant found
+          schema:
+            type: object
+            properties:
+              type:
+                type: string
+                description: The type of entity (tenant)
+              name:
+                type: string
+                description: The tenant name/identifier
+              datasources:
+                type: array
+                items:
+                  type: object
+                  properties:
+                    name:
+                      type: string
+                      description: The name of the datasource
+                    uri:
+                      type: string
+                      format: uri
+                      description: A link to the datasource information
+    delete:
+      summary: Delete tenant
+      description: Deletes a tenant from the system
+      responses:
+        200:
+          description: Tenant deleted
+          schema:
+            type: object
+            properties:
+              type:
+                type: string
+                description: The type of entity (tenant)
+              name:
+                type: string
+                description: The tenant name/identifier
+        404:
+          description: Tenant not found
+          schema:
+            $ref: "#/definitions/error"
+  /{tenant}/{datasource}:
+    parameters:
+      - name: tenant
+        in: path
+        type: string
+        description: The tenant name
+        required: true
+      - name: datasource
+        in: path
+        type: string
+        description: The datasource name
+        required: true
+    get:
+      responses:
+        200:
+          description: Datasource found
+          schema:
+            type: object
+            properties:
+              type:
+                type: string
+                description: The type of entity (datasource)
+              name:
+                type: string
+                description: The datasource name
+              tenant:
+                type: string
+                description: The tenant name
+              updateable:
+                type: boolean
+                description: Is this datasource updateable?
+              query_uri:
+                type: string
+                description: A link to the query endpoint for this datasource
+                format: uri
+              schemas:
+                type: array
+                description: The schemas of this datasource
+                items:
+                  type: object
+                  properties:
+                    name:
+                      type: string
+                      description: The schema name
+                    uri:
+                      type: string
+                      description: A link to the schema information
+                      format: uri
+        404:
+          description: Datasource not found
+          schema:
+            $ref: "#/definitions/error"
+    put:
+      parameters:
+        - name: inputData
+          in: body
+          description: The definition of the datasource using properties. The 
same properties as normally applied in MetaModel factories (e.g. 'type', 
'resource', 'url', 'driver-class' ,'hostname', 'port', 'catalog', 'database', 
'username', 'port', 'table-defs') are used here.
+          required: true
+          schema:
+            type: object
+      responses:
+        200:
+          description: Datasource created
+  /{tenant}/{datasource}/q:
+    parameters:
+      - name: tenant
+        in: path
+        type: string
+        description: The tenant name
+        required: true
+      - name: datasource
+        in: path
+        type: string
+        description: The datasource name
+        required: true
+    get:
+      description: Executes a query on the datasource
+      parameters:
+      - name: sql
+        in: query
+        type: string
+        description: The MetaModel-flavoured SQL query to execute
+        required: true
+      - name: offset
+        in: query
+        type: string
+        description: An offset / first-row flag to set on the query
+        required: false
+      - name: limit
+        in: query
+        type: string
+        description: A limit / max-rows flag to set on the query
+        required: false
+      responses:
+        200:
+          description: Query executed
+          schema:
+            $ref: "#/definitions/queryResponse"
+        400:
+          description: Failure while parsing query
+          schema:
+            $ref: "#/definitions/error"
+        404:
+          description: Datasource not found
+          schema:
+            $ref: "#/definitions/error"
+        500:
+          description: Failure while executing query
+          schema:
+            $ref: "#/definitions/error"
+  /{tenant}/{datasource}/s/{schema}:
+    parameters:
+      - name: tenant
+        in: path
+        type: string
+        description: The tenant name
+        required: true
+      - name: datasource
+        in: path
+        type: string
+        description: The datasource name
+        required: true
+      - name: schema
+        in: path
+        type: string
+        description: The schema name
+        required: true
+    get:
+      responses:
+        200:
+          description: Schema found
+          schema:
+            type: object
+            properties:
+              type:
+                type: string
+                description: The type of entity (schema)
+              name:
+                type: string
+                description: The schema name
+              datasource:
+                type: string
+                description: The datasource name
+              tables:
+                type: array
+                description: The names of the schema's tables
+                items:
+                  type: object
+                  properties:
+                    name:
+                      type: string
+                      description: The table name
+                    uri:
+                      type: string
+                      description: A link to the table information
+                      format: uri
+        404:
+          description: Schema not found
+          schema:
+            $ref: "#/definitions/error"
+  /{tenant}/{datasource}/s/{schema}/t/{table}:
+    parameters:
+      - name: tenant
+        in: path
+        type: string
+        description: The tenant name
+        required: true
+      - name: datasource
+        in: path
+        type: string
+        description: The datasource name
+        required: true
+      - name: schema
+        in: path
+        type: string
+        description: The schema name
+        required: true
+      - name: table
+        in: path
+        type: string
+        description: The table name
+        required: true
+    get:
+      responses:
+        200:
+          description: Table found
+          schema:
+            type: object
+            properties:
+              type:
+                type: string
+                description: The type of entity (table)
+              name:
+                type: string
+                description: The table name
+              schema:
+                type: string
+                description: The schema name
+              datasource:
+                type: string
+                description: The datasource name
+              tenant:
+                type: string
+                description: The tenant name
+              columns:
+                type: array
+                description: The names of the table's columns
+                items:
+                  type: object
+                  properties:
+                    name:
+                      type: string
+                      description: The column name
+                    uri:
+                      type: string
+                      description: A link to the column information
+                      format: uri
+        404:
+          description: Table not found
+          schema:
+            $ref: "#/definitions/error"
+  /{tenant}/{datasource}/s/{schema}/t/{table}/d:
+    parameters:
+      - name: tenant
+        in: path
+        type: string
+        description: The tenant name
+        required: true
+      - name: datasource
+        in: path
+        type: string
+        description: The datasource name
+        required: true
+      - name: schema
+        in: path
+        type: string
+        description: The schema name
+        required: true
+      - name: table
+        in: path
+        type: string
+        description: The table name
+        required: true
+    get:
+      description: Gets the data of the table
+      responses:
+        200:
+          description: Query executed
+          schema:
+            $ref: "#/definitions/queryResponse"
+        400:
+          description: Failure while parsing query
+          schema:
+            $ref: "#/definitions/error"
+        404:
+          description: Table not found
+          schema:
+            $ref: "#/definitions/error"
+        500:
+          description: Failure while executing query
+          schema:
+            $ref: "#/definitions/error"
+    post:
+      description: Inserts data to the table
+      parameters:
+        - name: inputData
+          in: body
+          description: The data to insert
+          required: true
+          schema:
+            type: array
+            items:
+              description: A record to insert where each key is expected to 
match a column name and each value is the value to put.
+              type: object
+      responses:
+        200:
+          description: Data inserted
+          #TODO
+        404:
+          description: Table not found
+          schema:
+            $ref: "#/definitions/error"
+  /{tenant}/{datasource}/s/{schema}/t/{table}/c/{column}:
+    parameters:
+      - name: tenant
+        in: path
+        type: string
+        description: The tenant name
+        required: true
+      - name: datasource
+        in: path
+        type: string
+        description: The datasource name
+        required: true
+      - name: schema
+        in: path
+        type: string
+        description: The schema name
+        required: true
+      - name: table
+        in: path
+        type: string
+        description: The table name
+        required: true
+      - name: column
+        in: path
+        type: string
+        description: The column name
+        required: true
+    get:
+      description: Gets information about a column
+      responses:
+        200:
+          description: Query executed
+          schema:
+            type: object
+            properties:
+              type:
+                type: string
+                description: The type of entity (column)
+              name:
+                type: string
+                description: The column name
+              table:
+                type: string
+                description: The table name
+              schema:
+                type: string
+                description: The schema name
+              datasource:
+                type: string
+                description: The datasource name
+              tenant:
+                type: string
+                description: The tenant name
+              metadata:
+                type: object
+                description: Metadata about the column
+                properties:
+                  number:
+                    type: integer
+                    description: The column number (0-based)
+                  size:
+                    type: integer
+                    description: The column size
+                  nullable:
+                    type: boolean
+                    description: Is the column nullable?
+                  primary-key:
+                    type: boolean
+                    description: Is the column a primary key?
+                  indexed:
+                    type: boolean
+                    description: Is the column indexed?
+                  column-type:
+                    type: string
+                    description: The column type (as interpreted/adapted by 
Apache MetaModel)
+                  native-type:
+                    type: string
+                    description: The native column type (as defined by the 
datasource itself)
+                  remarks:
+                    type: string
+                    description: Any remarks on the column
+        404:
+          description: Column not found
+          schema:
+            $ref: "#/definitions/error"
+definitions:
+  queryResponse:
+    description: Represents the result of a query - a dataset
+    type: object
+    properties:
+      type:
+        type: string
+        description: The type of entity (dataset)
+      headers:
+        type: array
+        description: The dataset header names
+        items:
+          type: string
+      data:
+        type: array
+        description: The actual data returned by the query
+        items:
+          type: array
+          items:
+            type: object
+  error:
+    description: Elaborates the error that occurred
+    type: object
+    properties:
+      code:
+        type: integer
+        description: The HTTP status code
+      message:
+        type: string
+        description: A humanly readable error message
+      additional_details:
+        type: object
+        description: Any auxilary details to further elaborate the error

http://git-wip-us.apache.org/repos/asf/metamodel/blob/46b3cf83/service-webapp/swagger.yaml
----------------------------------------------------------------------
diff --git a/service-webapp/swagger.yaml b/service-webapp/swagger.yaml
deleted file mode 100644
index 2db13b2..0000000
--- a/service-webapp/swagger.yaml
+++ /dev/null
@@ -1,530 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-# 
-#   http://www.apache.org/licenses/LICENSE-2.0
-# 
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-swagger: '2.0'
-info:
-  title: Apache MetaModel RESTful API
-  description: Delivers 'MetaModel-as-a-Service' for unified data federation.
-  version: "5.0.0"
-produces:
-  - application/json
-paths:
-  /:
-    get:
-      summary: Hello MetaModel
-      description: An endpoint that provides a confirmation that the system is 
operational
-      responses:
-        200:
-          description: The system is operational
-          schema:
-            type: object
-            properties:
-              ping:
-                type: string
-                description: Should return 'pong!' when the system is 
operational
-              application:
-                type: string
-                description: The name of the application running (Apache 
MetaModel)
-              version:
-                type: string
-                description: The version of the application running
-              server-time:
-                type: object
-                properties:
-                  timestamp:
-                    type: integer
-                    format: int64
-                    description: The server-time in timestamp format (millis 
since 1st of January 1970)
-                  iso8601:
-                    type: string
-                    description: The server-time in ISO-8601 format
-              canonical-hostname:
-                type: string
-                description: The canonical hostname of the server
-  /{tenant}:
-    parameters:
-      - name: tenant
-        in: path
-        type: string
-        description: The tenant name
-        required: true
-    put:
-      summary: Create new tenant
-      responses:
-        200:
-          description: Tenant created
-          schema:
-            properties:
-              type:
-                type: string
-                description: The type of entity (tenant)
-              name:
-                type: string
-                description: The tenant name/identifier
-        409:
-          description: Tenant already exist
-          schema:
-            $ref: "#/definitions/error"
-    get:
-      summary: Get tenant information
-      description: Provides basic information about a tenant of the system
-      responses:
-        404:
-          description: Tenant not found
-          schema:
-            $ref: "#/definitions/error"
-        200:
-          description: Tenant found
-          schema:
-            type: object
-            properties:
-              type:
-                type: string
-                description: The type of entity (tenant)
-              name:
-                type: string
-                description: The tenant name/identifier
-              datasources:
-                type: array
-                items:
-                  type: object
-                  properties:
-                    name:
-                      type: string
-                      description: The name of the datasource
-                    uri:
-                      type: string
-                      format: uri
-                      description: A link to the datasource information
-    delete:
-      summary: Delete tenant
-      description: Deletes a tenant from the system
-      responses:
-        200:
-          description: Tenant deleted
-          schema:
-            type: object
-            properties:
-              type:
-                type: string
-                description: The type of entity (tenant)
-              name:
-                type: string
-                description: The tenant name/identifier
-        404:
-          description: Tenant not found
-          schema:
-            $ref: "#/definitions/error"
-  /{tenant}/{datasource}:
-    parameters:
-      - name: tenant
-        in: path
-        type: string
-        description: The tenant name
-        required: true
-      - name: datasource
-        in: path
-        type: string
-        description: The datasource name
-        required: true
-    get:
-      responses:
-        200:
-          description: Datasource found
-          schema:
-            type: object
-            properties:
-              type:
-                type: string
-                description: The type of entity (datasource)
-              name:
-                type: string
-                description: The datasource name
-              tenant:
-                type: string
-                description: The tenant name
-              updateable:
-                type: boolean
-                description: Is this datasource updateable?
-              query_uri:
-                type: string
-                description: A link to the query endpoint for this datasource
-                format: uri
-              schemas:
-                type: array
-                description: The schemas of this datasource
-                items:
-                  type: object
-                  properties:
-                    name:
-                      type: string
-                      description: The schema name
-                    uri:
-                      type: string
-                      description: A link to the schema information
-                      format: uri
-        404:
-          description: Datasource not found
-          schema:
-            $ref: "#/definitions/error"
-    put:
-      parameters:
-        - name: inputData
-          in: body
-          description: The definition of the datasource using properties. The 
same properties as normally applied in MetaModel factories (e.g. 'type', 
'resource', 'url', 'driver-class' ,'hostname', 'port', 'catalog', 'database', 
'username', 'port', 'table-defs') are used here.
-          required: true
-          schema:
-            type: object
-      responses:
-        200:
-          description: Datasource created
-  /{tenant}/{datasource}/q:
-    parameters:
-      - name: tenant
-        in: path
-        type: string
-        description: The tenant name
-        required: true
-      - name: datasource
-        in: path
-        type: string
-        description: The datasource name
-        required: true
-    get:
-      description: Executes a query on the datasource
-      parameters:
-      - name: sql
-        in: query
-        type: string
-        description: The MetaModel-flavoured SQL query to execute
-        required: true
-      - name: offset
-        in: query
-        type: string
-        description: An offset / first-row flag to set on the query
-        required: false
-      - name: limit
-        in: query
-        type: string
-        description: A limit / max-rows flag to set on the query
-        required: false
-      responses:
-        200:
-          description: Query executed
-          schema:
-            $ref: "#/definitions/queryResponse"
-        400:
-          description: Failure while parsing query
-          schema:
-            $ref: "#/definitions/error"
-        404:
-          description: Datasource not found
-          schema:
-            $ref: "#/definitions/error"
-        500:
-          description: Failure while executing query
-          schema:
-            $ref: "#/definitions/error"
-  /{tenant}/{datasource}/s/{schema}:
-    parameters:
-      - name: tenant
-        in: path
-        type: string
-        description: The tenant name
-        required: true
-      - name: datasource
-        in: path
-        type: string
-        description: The datasource name
-        required: true
-      - name: schema
-        in: path
-        type: string
-        description: The schema name
-        required: true
-    get:
-      responses:
-        200:
-          description: Schema found
-          schema:
-            type: object
-            properties:
-              type:
-                type: string
-                description: The type of entity (schema)
-              name:
-                type: string
-                description: The schema name
-              datasource:
-                type: string
-                description: The datasource name
-              tables:
-                type: array
-                description: The names of the schema's tables
-                items:
-                  type: object
-                  properties:
-                    name:
-                      type: string
-                      description: The table name
-                    uri:
-                      type: string
-                      description: A link to the table information
-                      format: uri
-        404:
-          description: Schema not found
-          schema:
-            $ref: "#/definitions/error"
-  /{tenant}/{datasource}/s/{schema}/t/{table}:
-    parameters:
-      - name: tenant
-        in: path
-        type: string
-        description: The tenant name
-        required: true
-      - name: datasource
-        in: path
-        type: string
-        description: The datasource name
-        required: true
-      - name: schema
-        in: path
-        type: string
-        description: The schema name
-        required: true
-      - name: table
-        in: path
-        type: string
-        description: The table name
-        required: true
-    get:
-      responses:
-        200:
-          description: Table found
-          schema:
-            type: object
-            properties:
-              type:
-                type: string
-                description: The type of entity (table)
-              name:
-                type: string
-                description: The table name
-              schema:
-                type: string
-                description: The schema name
-              datasource:
-                type: string
-                description: The datasource name
-              tenant:
-                type: string
-                description: The tenant name
-              columns:
-                type: array
-                description: The names of the table's columns
-                items:
-                  type: object
-                  properties:
-                    name:
-                      type: string
-                      description: The column name
-                    uri:
-                      type: string
-                      description: A link to the column information
-                      format: uri
-        404:
-          description: Table not found
-          schema:
-            $ref: "#/definitions/error"
-  /{tenant}/{datasource}/s/{schema}/t/{table}/d:
-    parameters:
-      - name: tenant
-        in: path
-        type: string
-        description: The tenant name
-        required: true
-      - name: datasource
-        in: path
-        type: string
-        description: The datasource name
-        required: true
-      - name: schema
-        in: path
-        type: string
-        description: The schema name
-        required: true
-      - name: table
-        in: path
-        type: string
-        description: The table name
-        required: true
-    get:
-      description: Gets the data of the table
-      responses:
-        200:
-          description: Query executed
-          schema:
-            $ref: "#/definitions/queryResponse"
-        400:
-          description: Failure while parsing query
-          schema:
-            $ref: "#/definitions/error"
-        404:
-          description: Table not found
-          schema:
-            $ref: "#/definitions/error"
-        500:
-          description: Failure while executing query
-          schema:
-            $ref: "#/definitions/error"
-    post:
-      description: Inserts data to the table
-      parameters:
-        - name: inputData
-          in: body
-          description: The data to insert
-          required: true
-          schema:
-            type: array
-            items:
-              description: A record to insert where each key is expected to 
match a column name and each value is the value to put.
-              type: object
-      responses:
-        200:
-          description: Data inserted
-          #TODO
-        404:
-          description: Table not found
-          schema:
-            $ref: "#/definitions/error"
-  /{tenant}/{datasource}/s/{schema}/t/{table}/c/{column}:
-    parameters:
-      - name: tenant
-        in: path
-        type: string
-        description: The tenant name
-        required: true
-      - name: datasource
-        in: path
-        type: string
-        description: The datasource name
-        required: true
-      - name: schema
-        in: path
-        type: string
-        description: The schema name
-        required: true
-      - name: table
-        in: path
-        type: string
-        description: The table name
-        required: true
-      - name: column
-        in: path
-        type: string
-        description: The column name
-        required: true
-    get:
-      description: Gets information about a column
-      responses:
-        200:
-          description: Query executed
-          schema:
-            type: object
-            properties:
-              type:
-                type: string
-                description: The type of entity (column)
-              name:
-                type: string
-                description: The column name
-              table:
-                type: string
-                description: The table name
-              schema:
-                type: string
-                description: The schema name
-              datasource:
-                type: string
-                description: The datasource name
-              tenant:
-                type: string
-                description: The tenant name
-              metadata:
-                type: object
-                description: Metadata about the column
-                properties:
-                  number:
-                    type: integer
-                    description: The column number (0-based)
-                  size:
-                    type: integer
-                    description: The column size
-                  nullable:
-                    type: boolean
-                    description: Is the column nullable?
-                  primary-key:
-                    type: boolean
-                    description: Is the column a primary key?
-                  indexed:
-                    type: boolean
-                    description: Is the column indexed?
-                  column-type:
-                    type: string
-                    description: The column type (as interpreted/adapted by 
Apache MetaModel)
-                  native-type:
-                    type: string
-                    description: The native column type (as defined by the 
datasource itself)
-                  remarks:
-                    type: string
-                    description: Any remarks on the column
-        404:
-          description: Column not found
-          schema:
-            $ref: "#/definitions/error"
-definitions:
-  queryResponse:
-    description: Represents the result of a query - a dataset
-    type: object
-    properties:
-      type:
-        type: string
-        description: The type of entity (dataset)
-      headers:
-        type: array
-        description: The dataset header names
-        items:
-          type: string
-      data:
-        type: array
-        description: The actual data returned by the query
-        items:
-          type: array
-          items:
-            type: object
-  error:
-    description: Elaborates the error that occurred
-    type: object
-    properties:
-      code:
-        type: integer
-        description: The HTTP status code
-      message:
-        type: string
-        description: A humanly readable error message
-      additional_details:
-        type: object
-        description: Any auxilary details to further elaborate the error

Reply via email to