khrt / Raisin

Raisin - a REST API micro framework for Perl 🐫 🐪
61 stars 29 forks source link

Check type exists for params #107

Closed m-dango closed 3 years ago

m-dango commented 3 years ago

The documentation suggests that type in params is optional, but the code currently assumes it will always be there.

Commented out uses of Raisin::log to be addressed as the sub appears to no longer exist.

khrt commented 3 years ago

type argument is a mandatory one and cannot be skipped, if the documentation says otherwise that must be fixed.

Could you please show me where the documentation says that type argument is optional?

Also, Raisin::log is the function imported from plugins and exists in the runtime.

I'm closing the merge request, but feel free to re-open if you feel like I'm wrong.

m-dango commented 3 years ago

Ah I see. I think there was a bit of a misunderstanding with this part of the doc:

route_param

Defines a route parameter as a resource id which can be anything if type isn't specified for it.

This led me to believe that this was the intent:

params(
  requires('id'),
);
route_param id => sub {
  get sub {};
};

But I see now it actually means excluding params completely, not just the type.