riffer 0.16.0 → 0.16.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6fff2cbd2ae809651bb2a3b54cc79e591d9ba295fe8d096769e74ee75159e32b
4
- data.tar.gz: 18ea73a692e864fbb2bd1c4c880ec293348cd4012a5218364b9207d51686b9bf
3
+ metadata.gz: dd7f9f22c84f8d3680662d9cac4b242f0425395f510b36654c910b91448dc34f
4
+ data.tar.gz: 1718dd3b5ca59e62f3287e7ecdfdff201de124bcd2230687a7e3d5ed554fdc95
5
5
  SHA512:
6
- metadata.gz: 01eeb93e3253a1061d884e19470f880eebfdd354e3ae1a32673364533411e67f9e0ccfb48a1a90d7be88e12d0bf0d5b3027ea399e517b2d18783ec8599b0ee4b
7
- data.tar.gz: fd8ca068330ab1858055dc3e5a0fc75a69db606189cfe7af5feac049e8b634919fb78e3501a8bb513bc542d1883babfe627d8b6a355927eb1df4707dc05943a6
6
+ metadata.gz: bda15f6aef23966f078cbae8be85dce02f177d9d51cc8fb9c08368dc113dbac8efe6ecbe356ae22a5eba043a98278622f1ddc10126eaada061b98eec849ea75c
7
+ data.tar.gz: 02f951011443b6ce726292be3f19ceb870b1177c03a3eb78b876170aef4d667b583def11e0242acee130c6e87654c262a0f91df366daf537060be2f88aa33283
@@ -1,3 +1,3 @@
1
1
  {
2
- ".": "0.16.0"
2
+ ".": "0.16.1"
3
3
  }
data/CHANGELOG.md CHANGED
@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.16.1](https://github.com/janeapp/riffer/compare/riffer/v0.16.0...riffer/v0.16.1) (2026-03-03)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * use anyOf for optional enum params in strict JSON Schema ([#152](https://github.com/janeapp/riffer/issues/152)) ([2c7fc4d](https://github.com/janeapp/riffer/commit/2c7fc4db4eda33f6fbcbe4b3799b602050af058d))
14
+
8
15
  ## [0.16.0](https://github.com/janeapp/riffer/compare/riffer/v0.15.1...riffer/v0.16.0) (2026-02-27)
9
16
 
10
17
 
data/lib/riffer/param.rb CHANGED
@@ -67,10 +67,22 @@ class Riffer::Param
67
67
  # (+["type", "null"]+) so that strict mode providers can distinguish
68
68
  # "absent" from "present" without rejecting the schema.
69
69
  #
70
+ # Optional parameters with an +enum+ use +anyOf+ to separate the enum
71
+ # constraint from the null type, since providers like Anthropic reject
72
+ # +{"type": ["string", "null"], "enum": [...]}+.
73
+ #
70
74
  #: (?strict: bool) -> Hash[Symbol, untyped]
71
75
  def to_json_schema(strict: false)
76
+ nullable = strict && !required
77
+
78
+ if nullable && enum
79
+ schema = {anyOf: [{type: type_name, enum: enum}, {type: "null"}]}
80
+ schema[:description] = description if description
81
+ return schema
82
+ end
83
+
72
84
  type = type_name
73
- type = [type, "null"] if strict && !required
85
+ type = [type, "null"] if nullable
74
86
 
75
87
  schema = {type: type}
76
88
  schema[:description] = description if description
@@ -2,5 +2,5 @@
2
2
  # rbs_inline: enabled
3
3
 
4
4
  module Riffer
5
- VERSION = "0.16.0" #: String
5
+ VERSION = "0.16.1" #: String
6
6
  end
@@ -45,6 +45,10 @@ class Riffer::Param
45
45
  # (+["type", "null"]+) so that strict mode providers can distinguish
46
46
  # "absent" from "present" without rejecting the schema.
47
47
  #
48
+ # Optional parameters with an +enum+ use +anyOf+ to separate the enum
49
+ # constraint from the null type, since providers like Anthropic reject
50
+ # +{"type": ["string", "null"], "enum": [...]}+.
51
+ #
48
52
  # : (?strict: bool) -> Hash[Symbol, untyped]
49
53
  def to_json_schema: (?strict: bool) -> Hash[Symbol, untyped]
50
54
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: riffer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.0
4
+ version: 0.16.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jake Bottrall