The OpenAPI generators are command-line utilities embedded in the KrakenD binary, offering OpenAPI import and export capabilities. The OpenAPI generator allows you to:
The OpenAPI-supported version is
Swagger v2 (not OAS3) in both functionalities.
The command needed to generate the OpenAPI specification is
krakend generate openapi:
When you don’t add any specific details in the configuration, KrakenD will generate a basic version of the OpenAPI specification, containing the declared endpoints in the gateway.
To enrich the OpenAPI output, see how to add OpenAPI information to your endpoints.
The swagger output can be saved statically and served to end-users once it is generated. An excellent place to develop the specs is in your CI/CD pipeline.
If what you want to do is to generate the KrakenD configuration when you have an existing OpenAPI file, then the command you need to use is
krakend generate from openapi:
For instance, you could generate a
krakend.json from an existing
openapi.yaml like this:
The generated configuration contains any
json-schema definitions that KrakenD can extract from the OpenAPI spec and forces users of the newly generated KrakenD API to use the declared types properly.
If your backend services do not exist yet or are not ready, you can import the OpenAPI configuration to KrakenD and let KrakenD respond with mock data so that you can reply to HTTP calls right away.
To create the mock data, simply pass the
The documentation is only a piece of the help you can get! Whether you are looking for Open Source or Enterprise support, see more support channels that can help you.