Skip to content

[BAC-1043] Support arrays of enums in JSON schema - #22

Merged
yard merged 1 commit into
masterfrom
feature/BAC-1043
May 13, 2026
Merged

[BAC-1043] Support arrays of enums in JSON schema#22
yard merged 1 commit into
masterfrom
feature/BAC-1043

Conversation

@yard

@yard yard commented May 13, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Emit enum on items (not on the array itself) when an attribute :foo, :array, of: :primitive has an inclusion: { in: [...] } validator.
  • Built-in inclusion: { in: ... } already validates per-element on arrays in Rails 7.1 via Clusivity#include?, so no custom validator is needed.

Test plan

  • rspec spec/active_model/entity/schemas/json_spec.rb — added expected fieldEnumStringArray row in the main schema example, an inline-mode assertion, and a validation of arrays of enums context (valid / invalid / empty).
  • Full suite: 49 examples, 0 failures.
  • rubocop clean on the changed files.

BAC-1043

🤖 Generated with Claude Code

Built-in `inclusion: { in: ... }` already validates per-element on
array attributes via Clusivity in Rails 7.1, so only the schema
output needs adjusting: emit `enum` on `items` for array attributes
rather than on the array itself.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@yard
yard requested a review from HolyWalley May 13, 2026 13:38
@yard
yard merged commit 507b5d7 into master May 13, 2026
1 check 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.

2 participants