Skip to content

Conversation

CharlieTLe
Copy link
Member

@CharlieTLe CharlieTLe commented Aug 10, 2025

What this PR does:
Adds a JSON schema for our cortex configuration so that we could get validation and auto completion in editors that support the yaml-language-server. This will make it easier to understand our configuration since the description of what each field is about will also appear as a popover in the ide when the field is hovered over by the cursor.

Changes to the schema are automated just like how the docs are generated, making it easy to maintain.

Which issue(s) this PR fixes:
Fixes #

Checklist

  • Tests updated
  • Documentation added
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds JSON schema generation functionality to the existing documentation generator tool, allowing the Cortex configuration to be exported as a JSON schema in addition to the existing markdown documentation.

  • Adds a new JSONSchemaWriter that converts parsed configuration blocks into JSON schema format
  • Extends the main doc-generator with command-line flags for JSON schema generation (-json-schema and -output)
  • Integrates JSON schema generation into the build process via Makefile

Reviewed Changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 4 comments.

File Description
tools/doc-generator/main.go Adds JSON schema generation mode with CLI flags and routing logic
tools/doc-generator/json_schema_writer.go Implements complete JSON schema generation functionality with type mapping and structure handling
Makefile Adds JSON schema generation to the documentation build target

@SungJin1212
Copy link
Member

Do we need a CI to verify the consistency of the JSON file when new fields are added or removed?

Copy link
Contributor

@yeya24 yeya24 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. This looks promising!

@CharlieTLe
Copy link
Member Author

CI should be covered since the Makefile was updated to generate the schema.

Signed-off-by: Charlie Le <[email protected]>
Signed-off-by: Charlie Le <[email protected]>
@CharlieTLe CharlieTLe force-pushed the cortex-config-json-schema branch from 647fe9f to 011d192 Compare September 27, 2025 19:46
Signed-off-by: Charlie Le <[email protected]>
@CharlieTLe CharlieTLe merged commit 1bc480f into cortexproject:master Sep 28, 2025
32 of 34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants