Skip to content

Add enum parameter to number and integer schema methods#29

Merged
crmne merged 3 commits into
crmne:mainfrom
jondavidschober:main
Jun 6, 2026
Merged

Add enum parameter to number and integer schema methods#29
crmne merged 3 commits into
crmne:mainfrom
jondavidschober:main

Conversation

@jondavidschober

@jondavidschober jondavidschober commented Dec 23, 2025

Copy link
Copy Markdown
Contributor

Adds enum support for numeric schema builders, including integer and number examples/spec coverage.\n\nCloses #30

@jondavidschober

Copy link
Copy Markdown
Contributor Author

I'm not sure about this PR now. I cant find where enum is defined in the spec, but the bedrock API didnt seem to like having enum on number

@jondavidschober jondavidschober marked this pull request as draft December 23, 2025 23:05
@diegocostares

Copy link
Copy Markdown

Hi! Is there any update on this? I started a thread about the same thing on the #30

@crmne crmne linked an issue May 19, 2026 that may be closed by this pull request
@crmne

crmne commented May 19, 2026

Copy link
Copy Markdown
Owner

enum is defined by JSON Schema as a validation keyword for any instance type, not only strings:

https://json-schema.org/draft/2020-12/json-schema-validation#section-6.1.2

The spec says the value must be an array, and an instance is valid if it equals one of the array elements. Those elements can be any JSON type, so integer and number enums are valid JSON Schema.

This PR looks complete for the runtime DSL behavior. number and integer already forward **options into number_schema / integer_schema, so adding enum: there is enough to make the API work.

What I’d still like before merge:

  • Add specs in spec/ruby_llm/schema/properties/numbers_spec.rb for integer :level, enum: [0, 1, 2]
  • Add a spec for number :score, enum: [0.5, 1.5]
  • Optionally update the README Numbers section to mention enum
  • Add Closes #30 to the PR description

No further implementation changes look necessary.

@crmne crmne added this to the 1.0.0 milestone May 19, 2026
@crmne crmne marked this pull request as ready for review May 20, 2026 12:47

@crmne crmne left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

As mentioned in the previous comment

@crmne crmne left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

All requested changes are addressed.

@codecov

codecov Bot commented Jun 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.79%. Comparing base (8861130) to head (861f300).

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #29   +/-   ##
=======================================
  Coverage   94.79%   94.79%           
=======================================
  Files          12       12           
  Lines         365      365           
  Branches       73       73           
=======================================
  Hits          346      346           
  Misses         19       19           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@crmne crmne merged commit ce25986 into crmne:main Jun 6, 2026
10 checks passed
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.

Feature request: Add enum support for integer type

3 participants