Skip to content

Commit

Permalink
added gradle tasks to download oas.json and to generate OpenAPI code
Browse files Browse the repository at this point in the history
  • Loading branch information
rahelarnold98 committed Nov 30, 2023
1 parent 45854f4 commit 9b07f60
Show file tree
Hide file tree
Showing 3 changed files with 305 additions and 2 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,7 @@ v3c-minimal-example
thumbnails/

# DS_Store files
.DS_Store
.DS_Store

# OpenAPI generated code
openapi
34 changes: 33 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ plugins {
id 'java-library'
id 'idea'
id 'org.jetbrains.kotlin.plugin.serialization' version "$version_kotlin"
id 'org.openapi.generator' version '5.2.0'
id "de.undercouch.download" version "5.4.0"
}

allprojects {
Expand Down Expand Up @@ -92,4 +94,34 @@ subprojects {
implementation group: 'org.jetbrains.kotlinx', name: 'kotlinx-coroutines-core', version: version_kotlinx_coroutines
implementation group: 'org.jetbrains.kotlinx', name:'kotlinx-serialization-json', version: '1.6.0'
}
}
}

/* Define required variables. */
def fullOAS = 'http://localhost:7070/swagger-docs'
def oasFile = "${project.projectDir}/vitrivr-engine-server/doc/oas.json"

openApiGenerate {
generateApiTests = false
generateModelTests = false
validateSpec = false
skipValidateSpec = true

generatorName = 'typescript-angular'
inputSpec = oasFile
outputDir = file("${project.projectDir}/openapi/doc").toString()
configOptions = [
npmName: '@vitrivr-engine/api',
ngVersion: '13.2.3',
snapshot: 'true',
enumPropertyNaming: 'original'
]
}

/**
* Task to generate OAS. Requires backend to run on default port.
*/
tasks.register('generateOAS', Download) {
/* This requires a locally running backend */
src fullOAS
dest oasFile
}
268 changes: 268 additions & 0 deletions vitrivr-engine-server/doc/oas.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,268 @@
{
"openapi" : "3.0.3",
"info" : {
"title" : "vitrivr engine API",
"description" : "API for the vitrivr engine.",
"version" : "1.0.0"
},
"paths" : {
"/api/schema/list" : {
"get" : {
"tags" : [ "Schema Management" ],
"summary" : "Lists the names of all available schemas.",
"operationId" : "getListSchemas",
"parameters" : [ ],
"responses" : {
"200" : {
"description" : "OK",
"content" : {
"application/json" : {
"schema" : {
"type" : "array",
"items" : {
"type" : "string"
}
}
}
}
},
"400" : {
"description" : "Bad Request",
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/ErrorStatus"
}
}
}
}
},
"deprecated" : false,
"security" : [ ]
}
},
"/api/{schema}/fetch/{exporter}/{retrievableId}" : {
"get" : {
"tags" : [ "Content" ],
"summary" : "Fetch previously exported data.",
"operationId" : "getPreview",
"parameters" : [ ],
"responses" : {
"200" : {
"description" : "OK",
"content" : {
"image/jpeg" : { }
}
},
"400" : {
"description" : "Bad Request",
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/ErrorStatus"
}
}
}
}
},
"deprecated" : false,
"security" : [ ]
}
},
"/api/{schema}/index" : {
"post" : {
"tags" : [ "Ingest" ],
"summary" : "Indexes an item, adding it to the defined schema.",
"operationId" : "postExecuteIngest",
"parameters" : [ {
"name" : "schema",
"in" : "path",
"description" : "The name of the schema to execute a query for.",
"required" : true,
"deprecated" : false,
"allowEmptyValue" : false,
"schema" : {
"type" : "string"
}
} ],
"responses" : {
"200" : {
"description" : "OK",
"content" : {
"application/json" : {
"schema" : {
"type" : "object"
}
}
}
},
"400" : {
"description" : "Bad Request",
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/ErrorStatus"
}
}
}
}
},
"deprecated" : false,
"security" : [ ]
}
},
"/api/{schema}/index/{id}" : {
"get" : {
"tags" : [ "Ingest" ],
"summary" : "Indexes an item, adding it to the defined schema.",
"operationId" : "postExecuteIngest",
"parameters" : [ {
"name" : "schema",
"in" : "path",
"description" : "The name of the schema to execute a query for.",
"required" : true,
"deprecated" : false,
"allowEmptyValue" : false,
"schema" : {
"type" : "string"
}
}, {
"name" : "id",
"in" : "path",
"description" : "The id querying the state.",
"required" : true,
"deprecated" : false,
"allowEmptyValue" : false,
"schema" : {
"type" : "string"
}
} ],
"responses" : {
"200" : {
"description" : "OK",
"content" : {
"application/json" : {
"schema" : {
"type" : "object"
}
}
}
},
"400" : {
"description" : "Bad Request",
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/ErrorStatus"
}
}
}
}
},
"deprecated" : false,
"security" : [ ]
}
},
"/api/{schema}/query" : {
"post" : {
"tags" : [ "Retrieval" ],
"summary" : "Executes a query and returns the query's results.",
"operationId" : "postExecuteQuery",
"parameters" : [ {
"name" : "schema",
"in" : "path",
"description" : "The name of the schema to execute a query for.",
"required" : true,
"deprecated" : false,
"allowEmptyValue" : false,
"schema" : {
"type" : "string"
}
} ],
"responses" : {
"200" : {
"description" : "OK",
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/QueryResult"
}
}
}
},
"400" : {
"description" : "Bad Request",
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/ErrorStatus"
}
}
}
}
},
"deprecated" : false,
"security" : [ ]
}
}
},
"components" : {
"schemas" : {
"QueryResult" : {
"type" : "object",
"additionalProperties" : false,
"properties" : {
"retrievables" : {
"type" : "array",
"items" : {
"$ref" : "#/components/schemas/QueryResultRetrievable"
}
}
},
"required" : [ "retrievables" ]
},
"QueryResultRetrievable" : {
"type" : "object",
"additionalProperties" : false,
"properties" : {
"id" : {
"type" : "string"
},
"score" : {
"type" : "number",
"format" : "float"
},
"type" : {
"type" : "string"
},
"parts" : {
"type" : "array",
"items" : {
"type" : "string"
}
}
},
"required" : [ "id", "score", "type", "parts" ]
},
"ErrorStatus" : {
"type" : "object",
"additionalProperties" : false,
"properties" : {
"message" : {
"type" : "string"
}
},
"required" : [ "message" ]
}
},
"securitySchemes" : {
"CookieAuth" : {
"in" : "cookie",
"name" : "SESSIONID",
"type" : "apiKey"
}
}
},
"servers" : [ ],
"security" : [ ]
}

0 comments on commit 9b07f60

Please sign in to comment.