feat: add JSON schema generator tool#655
Merged
jem-davies merged 5 commits intowarpstreamlabs:mainfrom Jan 19, 2026
Merged
Conversation
Add a new command-line tool `json_schema_gen` that generates JSON schemas from Bento configuration specifications. This tool converts `FieldSpec` definitions into proper JSON Schema format, handling various field types, nested objects, arrays, and special component configurations like processors, caches, and rate limits. The implementation includes: - Core JSON Schema structs (`JSONSchema`, `Property`) - Conversion logic from Bento field types to JSON Schema types - Special handling for component arrays (processors, caches, etc.) - Default value inclusion in property descriptions - Example values preservation - Proper type mapping for all supported Bento field types This enables auto completion and validation capabilities for Bento configurations.
The JSON schema generator now correctly identifies and handles array fields by checking the field's Kind property. Previously, array fields with string types were incorrectly mapped to "string" type in the JSON schema. This change ensures that array fields are properly mapped to "array" type in the generated JSON schema.
Contributor
|
oooo very very cool |
jem-davies
reviewed
Jan 19, 2026
| os.Exit(1) | ||
| } | ||
|
|
||
| fmt.Println(string(output)) |
Collaborator
There was a problem hiding this comment.
Wondering if it would be better to write to a file?
Collaborator
|
I have added the output of the binary to ./resources/schemastore and have opened the PR: SchemaStore/schemastore#5293 🙏 Thanks for this contribution ! I will open up an issue to see about adding this to the makefile & Release process. Issue #658 |
jem-davies
added a commit
to jem-davies/bento
that referenced
this pull request
Feb 2, 2026
* feat: add JSON schema generator tool Add a new command-line tool `json_schema_gen` that generates JSON schemas from Bento configuration specifications. This tool converts `FieldSpec` definitions into proper JSON Schema format, handling various field types, nested objects, arrays, and special component configurations like processors, caches, and rate limits. The implementation includes: - Core JSON Schema structs (`JSONSchema`, `Property`) - Conversion logic from Bento field types to JSON Schema types - Special handling for component arrays (processors, caches, etc.) - Default value inclusion in property descriptions - Example values preservation - Proper type mapping for all supported Bento field types This enables auto completion and validation capabilities for Bento configurations. * fix: handle array fields in JSON schema generation The JSON schema generator now correctly identifies and handles array fields by checking the field's Kind property. Previously, array fields with string types were incorrectly mapped to "string" type in the JSON schema. This change ensures that array fields are properly mapped to "array" type in the generated JSON schema. * fix lint Signed-off-by: Jem Davies <jemsot@gmail.com> * fix lints Signed-off-by: Jem Davies <jemsot@gmail.com> * add bento.json to ./resources/schemastore Signed-off-by: Jem Davies <jemsot@gmail.com> --------- Signed-off-by: Jem Davies <jemsot@gmail.com> Co-authored-by: Jem Davies <jemsot@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add a new command-line tool
json_schema_genthat generates JSON schemas from Bento configuration specifications. This tool convertsFieldSpecdefinitions into proper JSON Schema format, handling various field types, nested objects, arrays, and special component configurations like processors, caches, and rate limits.The implementation includes:
JSONSchema,Property)This enables auto completion and validation capabilities for Bento configurations in almost every IDE.
This resolves #647.
I decided not to include it in the main
bentoCLI, but create a separate tool as schema creation is usually not required locally. But if you like, we can include this in the CLI later. It's more important to serve the schema via the bento repo.If you accept this PR please run
go run cmd/tools/json_schema_gen/main.go > bento.jsonand put the resulting JSON Schema in a place of your choice in the bento repo. It is VERY IMPORTANT that this location and file name MUST NOT change!Once the schema file is in place I will register the Schema for
bento.yamlas it is used in the Dockerfile at schemastore.org, so the schema will automatically be imported by the IDEs, once a user creates abento.yamlfile.