Supported OpenAPI (Off-chain Kernel)
The table below explains the OpenAPI schemas that KRNL currently supports.
To read more about OpenAPI, visit this page:
Example
Important Notes
1. Using AI Tools
One important note here is that if you are generating OpenAPI Specification by using AI, the schema might be misaligned.
Be careful and make sure the schema matches with this guide. This is to avoid paying gas fees for registration of the wrong schema.
2. Single API Endpoint
With KRNL's current architecture, Web APIs that can be registered as off-chain kernels must be single API Endpoint.
3. HTTP Request Method
Currently we only support GET and POST as methods for calling off-chain kernels.
4. JSON
The current architecture of kOS supports only JSON format. YAML is currently supported.
There are various approaches to constructing and writing OpenAPI schema specifications. While some schemas are compatible with our technology, others may require small modifications.
Schemata that are not defined in this page may not work with our architecture.
null value
//...
"type": "string",
"nullable": true
//...
This is the only correct way to handle null value on OpenAPI 3.0 Specification.
Other methods might be from the older version.
There is a caveat when working with null value, please check the "anyOf" section.
allOf
not supported at the moment
-
anyOf
Supported Schema
When it comes to the schemas that use the "anyOf" element, the KRNL node can support some specific cases.
anyOf with null under "components"
// ...
"components": {
"schemas": {
"Foo": {
"properties": {
"address": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
}
}
}
}
}
// ...
anyOf with null under "responses"
// ...
"responses": {
"200": {
"description": "Successful response",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"age": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
]
}
}
}
}
}
}
}
// ...
Unsupported Schema
anyOf in array of objects and null
// ...
"responses": {
"200": {
"description": "Successful response",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"anyOf": [
{
"type": "object",
"properties": {
"age": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"example": 10
},
"name": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"example": "robot"
}
}
}
]
}
}
}
}
}
}
// ...
oneOf
Supported Schema
// ...
"responses": {
"200": {
"description": "Successful response",
"content": {
"application/json": {
"schema": {
"oneOf": [
{
"$ref": "#/components/schemas/AlphaResponse"
},
{
"$ref": "#/components/schemas/BetaResponse"
}
]
}
}
}
}
}
// ...
"components": {
"schemas": {
"AlphaResponse": {
"type": "object",
"properties": {
"statustext": {
"type": "string"
},
"good": {
"type": "boolean"
}
}
},
"BetaResponse": {
"type": "object",
"properties": {
"numbervalue": {
"type": "integer"
}
}
}
}
}
// ...
Unsupported Schema
Discriminator
// ...
"discriminator": {
"propertyName": "event_type",
"mapping": {
"temperature_alert": "#/components/schemas/TemperatureEvent",
"motion_detection": "#/components/schemas/MotionEvent",
"battery_status": "#/components/schemas/BatteryEvent"
}
},
"oneOf": [
{
"$ref": "#/components/schemas/TemperatureEvent"
},
{
"$ref": "#/components/schemas/MotionEvent"
},
{
"$ref": "#/components/schemas/BatteryEvent"
}
]
// ...
Enumeration
Supported Schemas
// ...
"components": {
"schemas": {
"StatusEnum": {
"enum": [
"PROCESSING",
"BULK_PROCESSING",
"ERROR",
"DONE"
],
"title": "StatusEnum",
"type": "string"
}
}
}
// ...
Last updated
Was this helpful?