Skip to content

Commit

Permalink
Use method_name instead of method when generating required warnings
Browse files Browse the repository at this point in the history
Unlike the previous commit, this isn't strictly required as we're not calling the un-delegated `method`, but instead the warning will contain a standard `to_s` of the `@controller_method` that isn't very easy to read, like this:

    WARNING (105): [#<Apipie::MethodDescription:0x0000000126316f60>] -- The parameter :param is optional but default value is not specified (use :default_value => ...)

By using `method_name` instead we get symmetry with the hash warning from the previous commit.
  • Loading branch information
h-lame committed Jun 24, 2024
1 parent a7485f2 commit 831c7d8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/apipie/generator/swagger/param_description/builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def warn_optional_without_default_value(definition)
if !required? && !definition.key?(:default)
method_id =
if @param_description.is_a?(Apipie::ResponseDescriptionAdapter::PropDesc)
@controller_method
@controller_method.method_name
else
Apipie::Generator::Swagger::MethodDescription::Decorator.new(@controller_method).ruby_name
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,24 @@
/is optional but default value is not specified/
).to_stderr
end

context 'and param is a prop desc with a delegated controller method' do
let(:param_description) do
Apipie.prop(:param, 'object', param_description_options, [])
end

let(:method_desc) do
Apipie::Generator::Swagger::MethodDescription::Decorator.new(
Apipie::MethodDescription.new(:show, resource_desc, dsl_data)
)
end

it 'warns' do
expect { subject }.to output(
/is optional but default value is not specified/
).to_stderr
end
end
end
end
end
Expand Down

0 comments on commit 831c7d8

Please sign in to comment.