IDE Support (JSON Schemas)
Add support for creating connector configuration in your IDE.
The Connect JSON Schema toot is a tool that generates JSON Schema from Kafka Connect connector, Single Message Transforms and Secret Provider configurations. It helps validate and document connector configurations by providing a standardized schema format that can be used for validation and documentation purposes.
Many IDE's support JSON schemas allowing for intellisense and auto completion. For VS code you can find out more information here.
Generates JSON Schema from any Kafka Connect Connector, SMT or Secret Provider JAR
Includes all connector configuration fields with types and descriptions
Includes default Kafka Connect fields.
Beta - The Schemas are still beta and can change and are currently for the latest version of the Stream Reactor connector.
The Generator Tool
will generate JSON schemas from jars containing classes implementing:
Sink Connector
Source Connector
Single Message Transforms
Secret Providers
In addition it can also merge the individual connectors schemas into a Union schema.
Optionally it can then include overrides for Connect converters (header, key & value) and consumer and producers.
Usage
To triggered the default snippets at the root level start typing:
Connectors: for connector examples
Overrides: for converters, consumer & producer
You can type further to get default snippets for different connector types, e.g. AWS S3.
VS Code Setup
Once you have JSON schema you can enable JSON Schema validation and auto completion in VS Code for both JSON and YAML files:
Install the required VS Code extensions
"YAML" by Red Hat
"JSON Language Features" (built-in)
Configure VS Code settings:
Open VS Code settings (Ctrl+,)
Add the following configuration to your
settings.json
:
{
"yaml.schemas": {
"file:///path/to/your/schema.json": ["*.yaml", "*.yml"]
},
"json.schemas": [
{
"fileMatch": ["*.json"],
"url": "file:///path/to/your/schema.json"
}
],
"yaml.format.enable": true,
"yaml.validate": true,
"yaml.hover": true,
"yaml.completion": true,
"yaml.format.singleQuote": false,
"yaml.format.bracketSpacing": true,
"yaml.format.proseWrap": "preserve"
}
Replace /path/to/your/schema.json
with the actual path to your schema file.
For project-specific settings, create a .vscode/settings.json
file in your project root:
{
"yaml.schemas": {
"file://${workspaceFolder}/schema.json": ["*.yaml", "*.yml"]
},
"json.schemas": [
{
"fileMatch": ["*.json"],
"url": "file://${workspaceFolder}/schema.json"
}
]
}
This setup will provide:
Schema validation for both JSON and YAML files
Auto completion for connector configurations
Hover documentation for fields
Formatting support for YAML files
Project-specific schema configuration
Last updated
Was this helpful?