Skip to content

release: 1.0.24 #579

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "1.0.23"
".": "1.0.24"
}
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## 1.0.24 (2025-08-10)

Full Changelog: [v1.0.23...v1.0.24](https://github.com/OneBusAway/ruby-sdk/compare/v1.0.23...v1.0.24)

### Chores

* collect metadata from type DSL ([8c6ebea](https://github.com/OneBusAway/ruby-sdk/commit/8c6ebea6b7370965b7809e6747599dda37628a93))
* **internal:** update comment in script ([008e80f](https://github.com/OneBusAway/ruby-sdk/commit/008e80fd1d7f13cfe7c09f8cca1da9b11072388d))
* update @stainless-api/prism-cli to v5.15.0 ([2849a58](https://github.com/OneBusAway/ruby-sdk/commit/2849a582e1b7446b830f9e882575b9d5ba9e629c))

## 1.0.23 (2025-08-01)

Full Changelog: [v1.0.22...v1.0.23](https://github.com/OneBusAway/ruby-sdk/compare/v1.0.22...v1.0.23)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ To use this gem, install via Bundler by adding the following to your application
<!-- x-release-please-start-version -->

```ruby
gem "onebusaway-sdk", "~> 1.0.23"
gem "onebusaway-sdk", "~> 1.0.24"
```

<!-- x-release-please-end -->
Expand Down
1 change: 1 addition & 0 deletions lib/onebusaway_sdk/internal/type/array_of.rb
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ def to_sorbet_type
# @option spec [Boolean] :"nil?"
def initialize(type_info, spec = {})
@item_type_fn = OnebusawaySDK::Internal::Type::Converter.type_info(type_info || spec)
@meta = OnebusawaySDK::Internal::Type::Converter.meta_info(type_info, spec)
@nilable = spec.fetch(:nil?, false)
end

Expand Down
4 changes: 3 additions & 1 deletion lib/onebusaway_sdk/internal/type/base_model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def fields
#
# @option spec [Boolean] :"nil?"
private def add_field(name_sym, required:, type_info:, spec:)
meta = OnebusawaySDK::Internal::Type::Converter.meta_info(type_info, spec)
type_fn, info =
case type_info
in Proc | OnebusawaySDK::Internal::Type::Converter | Class
Expand Down Expand Up @@ -81,7 +82,8 @@ def fields
required: required,
nilable: nilable,
const: const,
type_fn: type_fn
type_fn: type_fn,
meta: meta
}

define_method(setter) do |value|
Expand Down
27 changes: 27 additions & 0 deletions lib/onebusaway_sdk/internal/type/converter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,33 @@ def type_info(spec)
end
end

# @api private
#
# @param type_info [Hash{Symbol=>Object}, Proc, OnebusawaySDK::Internal::Type::Converter, Class] .
#
# @option type_info [NilClass, TrueClass, FalseClass, Integer, Float, Symbol] :const
#
# @option type_info [Proc] :enum
#
# @option type_info [Proc] :union
#
# @option type_info [Boolean] :"nil?"
#
# @param spec [Hash{Symbol=>Object}, Proc, OnebusawaySDK::Internal::Type::Converter, Class] .
#
# @option spec [NilClass, TrueClass, FalseClass, Integer, Float, Symbol] :const
#
# @option spec [Proc] :enum
#
# @option spec [Proc] :union
#
# @option spec [Boolean] :"nil?"
#
# @return [Hash{Symbol=>Object}]
def meta_info(type_info, spec)
[spec, type_info].grep(Hash).first.to_h.except(:const, :enum, :union, :nil?)
end

# @api private
#
# @param translate_names [Boolean]
Expand Down
1 change: 1 addition & 0 deletions lib/onebusaway_sdk/internal/type/hash_of.rb
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ def to_sorbet_type
# @option spec [Boolean] :"nil?"
def initialize(type_info, spec = {})
@item_type_fn = OnebusawaySDK::Internal::Type::Converter.type_info(type_info || spec)
@meta = OnebusawaySDK::Internal::Type::Converter.meta_info(type_info, spec)
@nilable = spec.fetch(:nil?, false)
end

Expand Down
16 changes: 9 additions & 7 deletions lib/onebusaway_sdk/internal/type/union.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@ module Union
#
# All of the specified variant info for this union.
#
# @return [Array<Array(Symbol, Proc)>]
# @return [Array<Array(Symbol, Proc, Hash{Symbol=>Object})>]
private def known_variants = (@known_variants ||= [])

# @api private
#
# @return [Array<Array(Symbol, Object)>]
# @return [Array<Array(Symbol, Object, Hash{Symbol=>Object})>]
protected def derefed_variants
known_variants.map { |key, variant_fn| [key, variant_fn.call] }
known_variants.map { |key, variant_fn, meta| [key, variant_fn.call, meta] }
end

# All of the specified variants for this union.
#
# @return [Array<Object>]
def variants = derefed_variants.map(&:last)
def variants = derefed_variants.map { _2 }

# @api private
#
Expand All @@ -51,12 +51,13 @@ def variants = derefed_variants.map(&:last)
#
# @option spec [Boolean] :"nil?"
private def variant(key, spec = nil)
meta = OnebusawaySDK::Internal::Type::Converter.meta_info(nil, spec)
variant_info =
case key
in Symbol
[key, OnebusawaySDK::Internal::Type::Converter.type_info(spec)]
[key, OnebusawaySDK::Internal::Type::Converter.type_info(spec), meta]
in Proc | OnebusawaySDK::Internal::Type::Converter | Class | Hash
[nil, OnebusawaySDK::Internal::Type::Converter.type_info(key)]
[nil, OnebusawaySDK::Internal::Type::Converter.type_info(key), meta]
end

known_variants << variant_info
Expand All @@ -79,7 +80,8 @@ def variants = derefed_variants.map(&:last)
return nil if key == OnebusawaySDK::Internal::OMIT

key = key.to_sym if key.is_a?(String)
known_variants.find { |k,| k == key }&.last&.call
_, found = known_variants.find { |k,| k == key }
found&.call
else
nil
end
Expand Down
2 changes: 1 addition & 1 deletion lib/onebusaway_sdk/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module OnebusawaySDK
VERSION = "1.0.23"
VERSION = "1.0.24"
end
58 changes: 58 additions & 0 deletions rbi/onebusaway_sdk/internal/type/converter.rbi
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,64 @@ module OnebusawaySDK
def self.type_info(spec)
end

# @api private
sig do
params(
type_info:
T.any(
{
const:
T.nilable(
T.any(NilClass, T::Boolean, Integer, Float, Symbol)
),
enum:
T.nilable(
T.proc.returns(
OnebusawaySDK::Internal::Type::Converter::Input
)
),
union:
T.nilable(
T.proc.returns(
OnebusawaySDK::Internal::Type::Converter::Input
)
)
},
T.proc.returns(
OnebusawaySDK::Internal::Type::Converter::Input
),
OnebusawaySDK::Internal::Type::Converter::Input
),
spec:
T.any(
{
const:
T.nilable(
T.any(NilClass, T::Boolean, Integer, Float, Symbol)
),
enum:
T.nilable(
T.proc.returns(
OnebusawaySDK::Internal::Type::Converter::Input
)
),
union:
T.nilable(
T.proc.returns(
OnebusawaySDK::Internal::Type::Converter::Input
)
)
},
T.proc.returns(
OnebusawaySDK::Internal::Type::Converter::Input
),
OnebusawaySDK::Internal::Type::Converter::Input
)
).returns(OnebusawaySDK::Internal::AnyHash)
end
def self.meta_info(type_info, spec)
end

# @api private
sig do
params(translate_names: T::Boolean).returns(
Expand Down
11 changes: 9 additions & 2 deletions rbi/onebusaway_sdk/internal/type/union.rbi
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ module OnebusawaySDK
T::Array[
[
T.nilable(Symbol),
T.proc.returns(OnebusawaySDK::Internal::Type::Converter::Input)
T.proc.returns(OnebusawaySDK::Internal::Type::Converter::Input),
OnebusawaySDK::Internal::AnyHash
]
]
)
Expand All @@ -25,7 +26,13 @@ module OnebusawaySDK
end

# @api private
sig { returns(T::Array[[T.nilable(Symbol), T.anything]]) }
sig do
returns(
T::Array[
[T.nilable(Symbol), T.anything, OnebusawaySDK::Internal::AnyHash]
]
)
end
protected def derefed_variants
end

Expand Down
4 changes: 2 additions & 2 deletions scripts/mock
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ echo "==> Starting mock server with URL ${URL}"

# Run prism mock on the given spec
if [ "$1" == "--daemon" ]; then
npm exec --package=@stainless-api/prism-cli@5.8.5 -- prism mock "$URL" &> .prism.log &
npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL" &> .prism.log &

# Wait for server to come online
echo -n "Waiting for server"
Expand All @@ -37,5 +37,5 @@ if [ "$1" == "--daemon" ]; then

echo
else
npm exec --package=@stainless-api/prism-cli@5.8.5 -- prism mock "$URL"
npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL"
fi
2 changes: 1 addition & 1 deletion scripts/test
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ elif ! prism_is_running ; then
echo -e "To run the server, pass in the path or url of your OpenAPI"
echo -e "spec to the prism command:"
echo
echo -e " \$ ${YELLOW}npm exec --package=@stoplight/prism-cli@~5.3.2 -- prism mock path/to/your.openapi.yml${NC}"
echo -e " \$ ${YELLOW}npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock path/to/your.openapi.yml${NC}"
echo

exit 1
Expand Down
17 changes: 17 additions & 0 deletions sig/onebusaway_sdk/internal/type/converter.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,23 @@ module OnebusawaySDK
| OnebusawaySDK::Internal::Type::Converter::input spec
) -> (^-> top)

def self.meta_info: (
{
const: (nil | bool | Integer | Float | Symbol)?,
enum: ^-> OnebusawaySDK::Internal::Type::Converter::input?,
union: ^-> OnebusawaySDK::Internal::Type::Converter::input?
}
| ^-> OnebusawaySDK::Internal::Type::Converter::input
| OnebusawaySDK::Internal::Type::Converter::input type_info,
{
const: (nil | bool | Integer | Float | Symbol)?,
enum: ^-> OnebusawaySDK::Internal::Type::Converter::input?,
union: ^-> OnebusawaySDK::Internal::Type::Converter::input?
}
| ^-> OnebusawaySDK::Internal::Type::Converter::input
| OnebusawaySDK::Internal::Type::Converter::input spec
) -> ::Hash[Symbol, top]

def self.new_coerce_state: (
?translate_names: bool
) -> OnebusawaySDK::Internal::Type::Converter::coerce_state
Expand Down
4 changes: 2 additions & 2 deletions sig/onebusaway_sdk/internal/type/union.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ module OnebusawaySDK
include OnebusawaySDK::Internal::Type::Converter
include OnebusawaySDK::Internal::Util::SorbetRuntimeSupport

private def self.known_variants: -> ::Array[[Symbol?, (^-> OnebusawaySDK::Internal::Type::Converter::input)]]
private def self.known_variants: -> ::Array[[Symbol?, (^-> OnebusawaySDK::Internal::Type::Converter::input), ::Hash[Symbol, top]]]

def self.derefed_variants: -> ::Array[[Symbol?, top]]
def self.derefed_variants: -> ::Array[[Symbol?, top, ::Hash[Symbol, top]]]

def self.variants: -> ::Array[top]

Expand Down
32 changes: 32 additions & 0 deletions test/onebusaway_sdk/internal/type/base_model_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -687,3 +687,35 @@ def test_equality
end
end
end

class OnebusawaySDK::Test::MetaInfoTest < Minitest::Test
A1 = OnebusawaySDK::Internal::Type::ArrayOf[Integer, nil?: true, doc: "dog"]
H1 = OnebusawaySDK::Internal::Type::HashOf[-> { String }, nil?: true, doc: "dawg"]

class M1 < OnebusawaySDK::Internal::Type::BaseModel
required :a, Integer, doc: "dog"
optional :b, -> { String }, nil?: true, doc: "dawg"
end

module U1
extend OnebusawaySDK::Internal::Type::Union

variant -> { Integer }, const: 2, doc: "dog"
variant -> { String }, doc: "dawg"
end

def test_meta_retrieval
m1 = A1.instance_variable_get(:@meta)
m2 = H1.instance_variable_get(:@meta)
assert_equal({doc: "dog"}, m1)
assert_equal({doc: "dawg"}, m2)

ma, mb = M1.fields.fetch_values(:a, :b)
assert_equal({doc: "dog"}, ma.fetch(:meta))
assert_equal({doc: "dawg"}, mb.fetch(:meta))

ua, ub = U1.send(:known_variants).map(&:last)
assert_equal({doc: "dog"}, ua)
assert_equal({doc: "dawg"}, ub)
end
end