diff --git a/CHANGELOG.md b/CHANGELOG.md index 1bc7568..33757c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.0.4 (2024-06-24) + +- Update `grape.rbi` + ## 0.0.3 (2024-06-05) - Better support for callbacks diff --git a/Gemfile.lock b/Gemfile.lock index a1834e9..0778329 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - grape_sorbet (0.0.3) + grape_sorbet (0.0.4) activesupport grape (~> 2.0) sorbet-runtime (~> 0.5.10741) diff --git a/lib/grape_sorbet/version.rb b/lib/grape_sorbet/version.rb index 280c5f4..8be7df1 100644 --- a/lib/grape_sorbet/version.rb +++ b/lib/grape_sorbet/version.rb @@ -2,5 +2,5 @@ # frozen_string_literal: true module GrapeSorbet - VERSION = "0.0.3" + VERSION = "0.0.4" end diff --git a/rbi/grape.rbi b/rbi/grape.rbi index 08ba5c6..99d2801 100644 --- a/rbi/grape.rbi +++ b/rbi/grape.rbi @@ -2,102 +2,122 @@ # frozen_string_literal: true module Grape - module DSL::Desc - # grape evaluates config_block in the context of a dynamically created module that implements the DSL it exposes - # at runtime. There's no good way to represent this statically, so block is just typed as T.untyped to prevent - # Sorbet from complaining that the DSL methods don't exist. - sig do - params( - description: String, - options: T.nilable(T::Hash[Symbol, T.untyped]), - config_block: T.nilable(T.proc.bind(T.untyped).void), - ).void + module DSL + module Desc + # grape evaluates config_block in the context of a dynamically created module that implements the DSL it exposes + # at runtime. There's no good way to represent this statically, so block is just typed as T.untyped to prevent + # Sorbet from complaining that the DSL methods don't exist. + sig do + params( + description: String, + options: T.nilable(T::Hash[Symbol, T.untyped]), + config_block: T.nilable(T.proc.bind(T.untyped).void), + ).void + end + def desc(description, options = T.unsafe(nil), &config_block); end end - def desc(description, options = T.unsafe(nil), &config_block); end - end - - module DSL::RequestResponse::ClassMethods - sig { params(args: T.untyped, block: T.proc.bind(Grape::Endpoint).void).void } - def rescue_from(*args, &block); end - end - module DSL::Routing::ClassMethods - # @shim: https://github.com/ruby-grape/grape/blob/v2.0.0/lib/grape/dsl/routing.rb#L148-L154 - sig do - params( - args: T.untyped, - block: T.nilable(T.proc.bind(Grape::Endpoint).void), - ).void + module Helpers + module BaseHelper + sig { params(name: Symbol, block: T.proc.bind(Grape::Validations::ParamsScope).void).void } + def params(name, &block); end + end end - def delete(*args, &block); end - # @shim: https://github.com/ruby-grape/grape/blob/v2.0.0/lib/grape/dsl/routing.rb#L148-L154 - sig do - params( - args: T.untyped, - block: T.nilable(T.proc.bind(Grape::Endpoint).void), - ).void + module RequestResponse + module ClassMethods + sig { params(args: T.untyped, block: T.proc.bind(Grape::Endpoint).void).void } + def rescue_from(*args, &block); end + end end - def get(*args, &block); end - # @shim: https://github.com/ruby-grape/grape/blob/v2.0.0/lib/grape/dsl/routing.rb#L148-L154 - sig do - params( - args: T.untyped, - block: T.nilable(T.proc.bind(Grape::Endpoint).void), - ).void - end - def options(*args, &block); end + module Routing + module ClassMethods + # @shim: https://github.com/ruby-grape/grape/blob/v2.0.0/lib/grape/dsl/routing.rb#L148-L154 + sig do + params( + args: T.untyped, + block: T.nilable(T.proc.bind(Grape::Endpoint).void), + ).void + end + def delete(*args, &block); end - # @shim: https://github.com/ruby-grape/grape/blob/v2.0.0/lib/grape/dsl/routing.rb#L148-L154 - sig do - params( - args: T.untyped, - block: T.nilable(T.proc.bind(Grape::Endpoint).void), - ).void - end - def patch(*args, &block); end + # @shim: https://github.com/ruby-grape/grape/blob/v2.0.0/lib/grape/dsl/routing.rb#L148-L154 + sig do + params( + args: T.untyped, + block: T.nilable(T.proc.bind(Grape::Endpoint).void), + ).void + end + def get(*args, &block); end - # @shim: https://github.com/ruby-grape/grape/blob/v2.0.0/lib/grape/dsl/routing.rb#L148-L154 - sig do - params( - args: T.untyped, - block: T.nilable(T.proc.bind(Grape::Endpoint).void), - ).void - end - def post(*args, &block); end + # @shim: https://github.com/ruby-grape/grape/blob/v2.0.0/lib/grape/dsl/routing.rb#L148-L154 + sig do + params( + args: T.untyped, + block: T.nilable(T.proc.bind(Grape::Endpoint).void), + ).void + end + def options(*args, &block); end - # @shim: https://github.com/ruby-grape/grape/blob/v2.0.0/lib/grape/dsl/routing.rb#L148-L154 - sig do - params( - args: T.untyped, - block: T.nilable(T.proc.bind(Grape::Endpoint).void), - ).void - end - def put(*args, &block); end + # @shim: https://github.com/ruby-grape/grape/blob/v2.0.0/lib/grape/dsl/routing.rb#L148-L154 + sig do + params( + args: T.untyped, + block: T.nilable(T.proc.bind(Grape::Endpoint).void), + ).void + end + def patch(*args, &block); end + + # @shim: https://github.com/ruby-grape/grape/blob/v2.0.0/lib/grape/dsl/routing.rb#L148-L154 + sig do + params( + args: T.untyped, + block: T.nilable(T.proc.bind(Grape::Endpoint).void), + ).void + end + def post(*args, &block); end + + # @shim: https://github.com/ruby-grape/grape/blob/v2.0.0/lib/grape/dsl/routing.rb#L148-L154 + sig do + params( + args: T.untyped, + block: T.nilable(T.proc.bind(Grape::Endpoint).void), + ).void + end + def put(*args, &block); end + + sig do + params( + methods: T.any(Symbol, String, T::Array[String]), + paths: T.nilable(T.any(String, T::Array[String])), + route_options: T.nilable(T::Hash[Symbol, T.untyped]), + block: T.nilable(T.proc.bind(Grape::Endpoint).void), + ).void + end + def route(methods, paths = T.unsafe(nil), route_options = T.unsafe(nil), &block); end - sig do - params( - methods: T.any(Symbol, String, T::Array[String]), - paths: T.nilable(T.any(String, T::Array[String])), - route_options: T.nilable(T::Hash[Symbol, T.untyped]), - block: T.nilable(T.proc.bind(Grape::Endpoint).void), - ).void + sig do + params( + param: Symbol, + options: T.nilable(T::Hash[Symbol, T.untyped]), + block: T.nilable(T.proc.bind(T.class_of(Grape::API::Instance)).void), + ).void + end + def route_param(param, options = T.unsafe(nil), &block); end + end end - def route(methods, paths = T.unsafe(nil), route_options = T.unsafe(nil), &block); end - sig do - params( - param: Symbol, - options: T.nilable(T::Hash[Symbol, T.untyped]), - block: T.nilable(T.proc.bind(T.class_of(Grape::API::Instance)).void), - ).void + module Validations + module ClassMethods + sig { params(block: T.proc.bind(Grape::Validations::ParamsScope).void).void } + def params(&block); end + end end - def route_param(param, options = T.unsafe(nil), &block); end end - module DSL::Validations::ClassMethods - sig { params(block: T.proc.bind(Grape::Validations::ParamsScope).void).void } - def params(&block); end + class Endpoint + sig { returns(Grape::Request) } + def request; end end end