Skip to main content

Tegral OpenAPI

Tegral OpenAPI is a collection of libraries that allow you to:

Tegral OpenAPI provides a concise Kotlin syntax for (most of) your OpenAPI needs.

Example

Here's an example of using the Tegral OpenAPI toolchain. Using tegral-openapi-dsl and tegral-openapi-scriptdef, we can write the following script file...

myapi.openapi.kts
title = "My API document"
version = "1.0.0"

"/hello" get {
description = "Returns a greeting"
200 response {
plainText { schema("Hello World!") }
}
}

... which we can then turn into a JSON or YAML file using tegral-openapi-cli and tegral-openapi-scripthost:

$ ./tegral-openapi-cli myapi.openapi.kts -f yaml -o myapi.yaml
[i] openapi.dump - Compiling script...
[i] openapi.dump - Evaluating script...
[i] openapi.dump - Output written to myapi.yaml

... which gives us the following output:

openapi: 3.0.1
info:
title: My API document
version: 1.0.0
paths:
/hello:
get:
description: Returns a greeting
responses:
"200":
description: A greeting
content:
text/plain:
schema:
type: string
example: Hello World!

Packages

Package information
Package nameCatalog dependencyFull Gradle name
tegral-openapi-clitegralLibs.openapi.cliguru.zoroark.tegral:tegral-openapi-cli:VERSION
tegral-openapi-dsltegralLibs.openapi.dslguru.zoroark.tegral:tegral-openapi-dsl:VERSION
tegral-openapi-featuretegralLibs.openapi.featureguru.zoroark.tegral:tegral-openapi-feature:VERSION
tegral-openapi-ktortegralLibs.openapi.ktorguru.zoroark.tegral:tegral-openapi-ktor:VERSION
tegral-openapi-ktor-resourcestegralLibs.openapi.ktor.resourcesguru.zoroark.tegral:tegral-openapi-ktor-resources:VERSION
tegral-openapi-ktoruitegralLibs.openapi.ktoruiguru.zoroark.tegral:tegral-openapi-ktorui:VERSION
tegral-openapi-scriptdeftegralLibs.openapi.scriptdefguru.zoroark.tegral:tegral-openapi-scriptdef:VERSION
tegral-openapi-scripthosttegralLibs.openapi.scripthostguru.zoroark.tegral:tegral-openapi-scripthost:VERSION

Hierarchy