Skip to content

About

Schema definition to validate configuration files and offer autocomplete on IDEs

Resources

Code of conduct

Contributing

Security policy

Stars

6 stars

Watchers

6 watching

Forks

Repository files navigation

KrakenD Configuration Schema

The official JSON Schema for KrakenD configuration files. Use it to get validation and autocompletion in your editor, to lint configurations in CI, and to build tools that generate or check KrakenD configurations.

If you are looking to validate the JSON payloads of your endpoints instead, see JSON Schema validation.

Quick start

Add $schema at the top of your krakend.json:

{
  "$schema": "https://www.krakend.io/schema/v3.0/krakend.json",
  "version": 4,
  "endpoints": []
}

Editors with built-in JSON Schema support (Visual Studio Code, JetBrains IDEs such as GoLand, IntelliJ IDEA or PyCharm, Eclipse, and others) pick it up with nothing to install. You get:

  • Validation as you type, with explanations of each error
  • Documentation of every attribute on hover
  • Autocompletion of properties and namespaces
  • Warnings for wrong types and unknown keys

IDE Integration

Note

version is the syntax version, not the KrakenD version. KrakenD 3.x uses "version": 4; KrakenD 2.x uses "version": 3. The schema enforces the right one for each release.

Which URL to use

URL Use it when
https://www.krakend.io/schema/v3.0/krakend.json Recommended. Pinned to the KrakenD version you run (replace v3.0 with yours).
https://www.krakend.io/schema/krakend.json You always want the latest release. It changes when a new version ships.
https://www.krakend.io/schema/v3.0/flexible_config.json Validating the flexible_config.json settings file of Extended Flexible Configuration (Enterprise).
https://www.krakend.io/schema/v3.0/e2e.json Validating the test case files of integration tests (Enterprise).

Schemas are published for KrakenD 2.1 and later, one folder per minor version (v2.1 … v2.13, v3.0). Use the one that matches the version you run. The schemas use JSON Schema draft 2019-09, so any validator you plug them into must support it.

The bundle: one file with everything

Each version's krakend.json (for example v3.0/krakend.json) is a bundle: every subschema is inlined under $defs, and there are no external references. That makes it a single self-contained file you can:

  • download once and use offline, or vendor into your own repository
  • pass to any JSON Schema validator without configuring reference resolution
  • use as the source of truth when generating code, forms or documentation for KrakenD configurations

For example, to lint against a local copy of the bundle:

curl -o krakend-schema.json https://www.krakend.io/schema/v3.0/krakend.json
krakend check -s krakend-schema.json -c krakend.json

Subschemas: validate one piece

The bundle is built from smaller subschemas, one per component, that you can also use on their own, for instance to validate a single extra_config block your tool generates. Their paths mostly mirror the configuration namespace they describe:

Namespace in your config Subschema
auth/validator v3.0/auth/validator.json
qos/ratelimit/router v3.0/qos/ratelimit/router.json
qos/circuit-breaker v3.0/qos/circuit-breaker.json
An endpoint / a backend v3.0/endpoint.json / v3.0/backend.json

Each one is published at the same path under https://www.krakend.io/schema/, for example https://www.krakend.io/schema/v3.0/auth/validator.json. Browse the v3.0 folder for the full list (ai, auth, backend, governance, messaging, modifier, qos, security, server, telemetry, validation and more). v3.0/_root.json is the top of the tree.

Subschemas reference shared definitions in other files (time units, TLS settings…). Validators that fetch $ref URLs resolve them automatically, because every $id is a real URL. Offline, point your validator at the version folder of a clone of this repository. With the jsonschema CLI that this repository uses:

jsonschema validate v3.0/auth/validator.json my-jwt-block.json --resolve v3.0

Linting in CI

krakend check validates your configuration against this schema. Always run it in your pipeline: krakend run ignores unknown keys, so a typo in an attribute silently does nothing.

Flag What it does
-l, --lint Lints against the online schema of your KrakenD version.
-n, --lint-no-network Lints against the schema embedded in the binary. No network needed, and faster.
-s, --lint-schema Lints against a schema path or URL you choose, such as a local copy of the bundle.

See krakend check for the full reference.

Contributing

Found an attribute that is missing, wrong or badly described? Please open an issue or a pull request.

  • Edit the source files inside the version folder (for example v3.0/auth/validator.json). Don't edit vX.Y/krakend.json by hand: it is generated, and CI fails if it doesn't match the sources.
  • Run make build to regenerate the bundle, and make test to run the test suite in test/. Both use the jsonschema CLI through Docker.

About

Schema definition to validate configuration files and offer autocomplete on IDEs

Resources

Code of conduct

Contributing

Security policy

Stars

6 stars

Watchers

6 watching

Forks

Releases

Packages

Used by

Contributors

Languages