Skip to content

Kitto.Web.Rest.OpenAPI

OpenAPI 3.0 description of the REST API (see Kitto.Web.Rest), generated at runtime from the application's metadata catalog (Models/Views) — NOT from Delphi DTO types, so no delphi-neon or typed-DTO layer is needed: the spec is built with the RTL System.JSON by walking the TKViewField metadata, the same source the serializer uses. Served (anonymously) at GET /api/v4/openapi.json; point any OpenAPI tool (Swagger UI, Postman, openapi-generator) at it. Part of the opt-in REST umbrella.

TKXOpenAPIBuilder class

Builds the OpenAPI 3.0 document for the current application's REST API.

pascal
class function Build(const ARestBaseUrl: string): TJSONObject;

Returns the OpenAPI document (caller owns and frees it). ARestBaseUrl is the server base the paths hang off (e.g. '/myapp/api/v4').

TKXApiDocHandler class

Serves the OpenAPI document at GET /api/v4/openapi.json (anonymous).

pascal
procedure GetOpenAPI;

Emits the OpenAPI 3.0 JSON describing every REST-exposed data view.

TKXApiSwaggerHandler class

Serves an interactive Swagger UI page at GET /api/v4/docs (anonymous). The page loads the vendored swagger-ui assets from /res and points them at /api/v4/openapi.json. Try-it-out calls need a token: click "Authorize" and paste the JWT obtained from POST /api/v4/token.

pascal
procedure GetSwaggerUI;

Emits the Swagger UI HTML page for the API.

Released under Apache License, Version 2.0.