7.3.292-stable Switch to dev

SDK OpenAPI

Introduction

GreyCat exposes its API using the OpenAPI v3 specification.
This allows developers and tools to automatically discover and interact with the available endpoints.

The OpenAPI descriptor can be retrieved directly from the server at:

curl http://localhost:8080/runtime::OpenApi::v3

This endpoint returns a JSON specification describing all the HTTP endpoints exposed by the running GreyCat instance.
You can use this specification in tools such as Swagger UI, Postman, or code generators to explore and integrate with the API.

Offline generation

To produce a server specification without running the server, use the following script:

// in openapi.gcl
fn generate() {
  JsonWriter { path: "openapi.json" }.write(OpenApi::v3());
}

And execute it with the following command:

greycat run openapi::generate 

This creates an openapi.json file in the project root, which you can then use with any OpenAPI code generators to generate client code.

Swagger UI

Below is an embedded Swagger UI viewer that automatically loads the descriptor from this documentation server that also runs on GreyCat.


const el = document.createElement('div');
el.className = 'gui-theme-light';
SwaggerUIBundle({ url: `${page.branch === 'dev' ? '/dev/' : '/'}runtime::OpenApi::v3`, domNode: el });