Skip to content

chore(config): externalize entity schema#56

Merged
bzp2010 merged 2 commits into
mainfrom
bzp/chore-externalize-entity-schema
Apr 24, 2026
Merged

chore(config): externalize entity schema#56
bzp2010 merged 2 commits into
mainfrom
bzp/chore-externalize-entity-schema

Conversation

@bzp2010
Copy link
Copy Markdown
Collaborator

@bzp2010 bzp2010 commented Apr 24, 2026

Summary by CodeRabbit

  • Refactor
    • Extracted JSON schema definitions for API key and model configurations into external schema files, decoupling them from application source.
    • Schema loading now uses embedded schema documents at build time; runtime validation and behavior remain unchanged.

Co-authored-by: Copilot <copilot@github.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 24, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3496bcca-a1cc-4da6-ac48-51788a2f05ff

📥 Commits

Reviewing files that changed from the base of the PR and between 78a3c59 and 0c5be35.

📒 Files selected for processing (2)
  • src/config/entities/apikeys.rs
  • src/config/entities/models.rs
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/config/entities/apikeys.rs
  • src/config/entities/models.rs

📝 Walkthrough

Walkthrough

Two JSON Schema files were added for API key and model configurations, and two Rust modules were updated to parse those schemas at compile time via include_str! instead of embedding JSON literals.

Changes

Cohort / File(s) Summary
Schema files
src/config/entities/apikeys-schema.json, src/config/entities/models-schema.json
Added JSON Schema documents: apikeys-schema.json defines required key, allowed_models, optional rate_limit; models-schema.json (draft 2020-12) enforces name, model, provider_config, provider-specific allOf rules for OpenAI-compatible vs Bedrock configs and disallows additional properties.
Rust schema loading
src/config/entities/apikeys.rs, src/config/entities/models.rs
Replaced inline json!({ ... }) schema literals with compile-time embedded JSON parsed from the new schema files using include_str! and serde_json::from_str. Removed unused serde_json::json imports; validator initialization remains based on parsed schema.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 6
✅ Passed checks (6 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'chore(config): externalize entity schema' accurately describes the main change: moving JSON schemas from inline Rust code to external JSON files, affecting both apikeys and models schemas across the config/entities directory.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
E2e Test Quality Review ✅ Passed PR includes robust test coverage across multiple layers: Rust unit tests comprehensively verify schema loading from external JSON files with boundary cases; TypeScript E2E tests exercise full business flow implicitly validating externalized schemas function identically to original implementations.
Security Check ✅ Passed Pure refactoring externalizing JSON schema definitions to separate files with compile-time embedding via include_str!(). Validation behavior, error handling, and security posture remain identical.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch bzp/chore-externalize-entity-schema

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/config/entities/models.rs`:
- Around line 20-21: The SCHEMA static currently wraps the file text as a JSON
string via json!(include_str!("models-schema.json")), which yields a
Value::String and breaks jsonschema::validator_for(); change SCHEMA's
initializer to parse the file text with
serde_json::from_str(include_str!("models-schema.json")) and unwrap/expect on
parse errors so SCHEMA is a proper serde_json::Value (object/boolean) usable by
the validator (refer to SCHEMA and LazyLock in models.rs and the
models-schema.json asset).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 0d5de95f-bf11-42ad-b8a2-aa3cefa6255b

📥 Commits

Reviewing files that changed from the base of the PR and between bcef7e1 and 78a3c59.

📒 Files selected for processing (4)
  • src/config/entities/apikeys-schema.json
  • src/config/entities/apikeys.rs
  • src/config/entities/models-schema.json
  • src/config/entities/models.rs

Comment thread src/config/entities/models.rs Outdated
Co-authored-by: Copilot <copilot@github.com>
@bzp2010 bzp2010 merged commit 82ec5df into main Apr 24, 2026
10 checks passed
@bzp2010 bzp2010 deleted the bzp/chore-externalize-entity-schema branch April 24, 2026 06:15
@api7 api7 deleted a comment from jarvis9443 Apr 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant