Skip to content

Comments

[pydantic codegen] add (beta) codegen lib#47

Draft
ostrowr wants to merge 35 commits intomainfrom
dev/robbie/codegen
Draft

[pydantic codegen] add (beta) codegen lib#47
ostrowr wants to merge 35 commits intomainfrom
dev/robbie/codegen

Conversation

@ostrowr
Copy link
Owner

@ostrowr ostrowr commented Dec 31, 2025

Start thinking about what it might look like to generate code from the ast we have. Not yet ready for prime time

@ostrowr
Copy link
Owner Author

ostrowr commented Dec 31, 2025

@codex review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

src/subset.rs Outdated
Comment on lines 369 to 377
fn integer_multiple_subset(parent: Option<f64>, source: Option<f64>) -> bool {
let Some(pm) = parent else {
return true;
};
if let Some(sm) = source {
let ratio = sm / pm;
return (ratio.fract()).abs() < f64::EPSILON;
}
(pm - 1.0).abs() < f64::EPSILON

Choose a reason for hiding this comment

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

P1 Badge Treat integer schema as subset of fractional multipleOf

The integer→number path relies on integer_multiple_subset, but when the integer schema has no multipleOf, this function only returns true if the parent multipleOf is exactly 1.0. Under JSON Schema semantics, any integer is a multiple of 0.5, 0.25, 0.1, etc. (division yields an integer), so {type: integer} should be a subschema of {type: number, multipleOf: 0.5}. As written, is_subschema_of will return false for those cases, causing compatibility checks to flag valid changes as breaking; this is especially visible with fractional multipleOf in the parent.

Useful? React with 👍 / 👎.

Comment on lines +1735 to +1739
// Handle anchors and fragment identifiers by searching the entire
// document tree for matching `$id`/`$anchor` pairs.
if let Some((base, frag)) = path.split_once('#') {
let anchor = if frag.is_empty() { None } else { Some(frag) };
let base_opt = if base.is_empty() { None } else { Some(base) };

Choose a reason for hiding this comment

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

P1 Badge Resolve base-only $ref IDs in document scope

resolve_refs_internal only calls find_ref_target when the $ref contains a # fragment, so absolute IDs without fragments (e.g. URN $ref values used in the JSON Schema test suite) skip this lookup and fall through to the BoolSchema(true) fallback below. That means $ref: "urn:uuid:…" is treated as “accept anything” instead of resolving to the schema with that $id, which can silently make breaking changes look compatible. Consider adding a base-only $id lookup across the document tree before falling back.

Useful? React with 👍 / 👎.

@ostrowr ostrowr changed the title add codegen lib [pydantic codegen] add (beta) codegen lib Jan 2, 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