Skip to content

Commit 71cf48f

Browse files
chore(internal): codegen related update
1 parent 7d8ee4f commit 71cf48f

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

lib/openai/internal/util.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ def writable_enum(&blk)
470470
# @type [Regexp]
471471
JSON_CONTENT = %r{^application/(?:vnd(?:\.[^.]+)*\+)?json(?!l)}
472472
# @type [Regexp]
473-
JSONL_CONTENT = %r{^application/(?:x-)?jsonl}
473+
JSONL_CONTENT = %r{^application/(:?x-(?:n|l)djson)|(:?(?:x-)?jsonl)}
474474

475475
class << self
476476
# @api private

rbi/openai/internal/util.rbi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ module OpenAI
187187
end
188188

189189
JSON_CONTENT = T.let(%r{^application/(?:vnd(?:\.[^.]+)*\+)?json(?!l)}, Regexp)
190-
JSONL_CONTENT = T.let(%r{^application/(?:x-)?jsonl}, Regexp)
190+
JSONL_CONTENT = T.let(%r{^application/(:?x-(?:n|l)djson)|(:?(?:x-)?jsonl)}, Regexp)
191191

192192
class << self
193193
# @api private

test/openai/internal/util_test.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,22 @@ def test_json_content
172172
end
173173
end
174174
end
175+
176+
def test_jsonl_content
177+
cases = {
178+
"application/x-ndjson" => true,
179+
"application/x-ldjson" => true,
180+
"application/jsonl" => true,
181+
"application/x-jsonl" => true,
182+
"application/json" => false,
183+
"application/vnd.api+json" => false
184+
}
185+
cases.each do |header, verdict|
186+
assert_pattern do
187+
OpenAI::Internal::Util::JSONL_CONTENT.match?(header) => ^verdict
188+
end
189+
end
190+
end
175191
end
176192

177193
class OpenAI::Test::UtilFormDataEncodingTest < Minitest::Test

0 commit comments

Comments
 (0)