Skip to content

Open API ​

Menu: Development → Open API
Deep link: /_Admin/development/openapis?SiteId={siteGuid}

Import external OpenAPI (Swagger) documents into the site, configure auth credentials and response cache, and call remote HTTP APIs in KScript via k.openApi.{name}. Unlike Swagger generated for this site in Code (codeOpenApi): this feature aggregates third-party APIs.

Permissions

List: openApi (view). Create, edit definitions and authorizations, Update document (URL type) require openApi·edit; multi-select Delete requires openApi·delete.

vs k.net

ApproachUse when
Open API (this page)Existing OpenAPI spec, OAuth/API Key, call by operation name, cacheable
k.net.httpClientHand-written URL, headers, no spec document

How to Open ​

  1. In Edit Menu, enable Development → Open API.
  2. Open Development → Open API in the left sidebar.
Open API list overview

Definition list ​

Toolbar ​

ButtonPermissionDescription
CreateopenApi·editEnter edit Open API (new)
Open API toolbar

List table ​

ColumnDescription
NameUnique id; cannot rename after save; maps to k.openApi.{name} in scripts
Typeurl / code / template (see edit page types)
URLSpec source address or template detail link
Last modifiedSave time
ActionsSee table below
IconConditionDescription
Update documentType urlRe-download OpenAPI JSON from URL and write to site
AuthorizeAlwaysEnter authorization config
EditAlwaysEnter edit Open API

Supports multi-select Delete (openApi·delete); also deletes all authorization records for that definition.

Open API list

Edit Open API ​

Path: /_Admin/development/openapi/edit?SiteId=... (new without id; edit with id={OpenApiId})

Footer Save / Return; unsaved leave prompts. New save returns to list.

Edit Open API

Common fields ​

FieldDescription
NameRequired, unique, 1–50 chars, letter or digit first; read-only when editing
Base URLOptional; overrides servers base in spec (absolute HTTP(S) URL)
CacheCache responses by HTTP method + path pattern — response cache
Use comma arraySerialize array query params as comma-separated single value (else duplicate keys)
Custom authenticationToggle shows KScript editor; inject header/query/cookie before request

Custom authentication script can use global request (read-only structure injected at runtime): body, querys, paths, headers, cookies. Example (default editor comment):

typescript
// request.headers.Authorization = 'bearer xxxx'
// request.querys.token = 'xxxx'

Types (selectable on create) ​

Type cannot change after create.

TypeDescription
URLOpenAPI JSON URL (e.g. https://petstore3.swagger.io/api/v3/openapi.json); downloads and normalizes JSON on save
CodePaste OpenAPI JSON body in Monaco (jsonData)
TemplatePick from Kooboo template library (openapi_template.kooboo.net); auto-fills baseUrl, authUrl, document, optional sample code
Type URL: spec addressType code: JSON body

Response cache ​

Each cache rule:

FieldDescription
MethodGET / POST / … / ALL
Path patternFragment matching spec paths (Contains match)
ExpiryMinutes

On cache hit, returns last response from memory until expiry.

Response cache rules

Authorization config ​

Path: /_Admin/development/openapi/authorizes?SiteId=...&id={OpenApiId}

From list Authorize (lock icon). Breadcrumb: OpenApis → Authorizes.

Maintain multiple authorization names per Open API definition (e.g. production, sandbox), each storing credentials required by spec securitySchemes. Scripts must configure here (or via k.openApi.{name}.authorize) before calling remote APIs, else Api not authorize.

Toolbar ​

ButtonDescription
CreateNew authorization record

List ​

ColumnDescription
NameauthorizeName; which credential set the script uses
Last modifiedSave time
ActionsChallenge (OAuth one-click redirect), Edit
Authorization list

New/edit authorization dialog ​

FieldDescription
NameAuthorization config name (required on create, unique)
Security schemeDynamic form from OpenAPI components.securitySchemes

Common credential fields (by scheme type):

SchemeFields
HTTP Basicusername, password
Bearer / API KeyaccessToken, name (e.g. Bearer prefix)
OAuth2clientId, clientSecret, accessToken, refreshToken, expiresIn, etc.

Challenge: for definitions with authUrl or OAuth2 authorizationCode flow, opens browser for authorization; callback handled by Kooboo /_api/openapioauth2callback/... or /_api/OpenApi/SaveToken and writes tokens back.

Edit authorization dialog

Use in the site ​

  1. Create Open API here and save (ensure valid jsonData).
  2. Add at least one credential set in authorization config.
  3. Call from server scripts in Layout / Page / Code, for example:
javascript
// Name matches admin Name column; operation names in k.openApi API docs
const result = k.openApi.myService.somePath_get({ query: { page: 1 } })

Operation names and parameter shapes match IDE OpenApi types for the site — see k.openApi.

DocDescription
k.openApiKScript: call operations, authorize credentials
k.net.httpClientGeneric HTTP client
k.security.jwtJWT (with Bearer in spec)
CodeThis site's API / CodeBlock
AuthenticationInbound request auth (not external API calls)
Development overviewDevelopment group index