Add the requestBody for the post endpoints
Opened this issue · 12 comments
The post endpoints in the API doc doesn't have a requestBody example or specification. Would be nice to have it.
If added to the openapi.yaml should be enough
https://learn.openapis.org/specification/parameters.html
Great spot! I'm not at my laptop at the moment, but I'll get this fixed when I'm back.
I had a quick look at this earlier and it's caused by us switching to spatie/laravel-data. Scribe is no longer able to read a FormRequest so is unable to derive the request body.
We'll need to write a custom Scribe strategy to pull the data from Laravel Data, pretty gnarly.
Actually, pinging @joelbutcher (refactored Cachet into laravel-data and @olivernybroe (experience writing Scribe strategies).
@jbrooksuk I'm working on a Scribe strategy specifically for Laravel Data for work. I'm hoping to publish this soon. If you assign this to me, I'll make sure to create a PR once this is done. 👍
Hah, no way @joelbutcher! I'll make the PR in Cachet itself that installs, configures and generates the Scribe docs.
@joelbutcher I've tested this out (cachethq/cachet#4449) but it's not generating everything. A good example is the POST components endpoint. Only the name field is generated.
@jbrooksuk That's odd, by the looks of it, Laravel Data itself isn't returning any rules for the properties with default values. Might have to dig a bit deeper into laravel-data as to why this is occurring. An alternative is to scrap using PHP attributes and define a static rules method on each request (similar to Laravel Form requests):
public static function rules(ValidationContext $context): array
{
return [
//...
];
}@jbrooksuk I'll send in a PR today that uses the rules method to explicitly define the validation rules, rather than having Laravel Data infer from types and attributes
Amazing, thanks @joelbutcher!
@jbrooksuk at one point we had float as a validation rule for creating and updating a metric, but I'm now running into this error:
Method Illuminate\Validation\Validator::validateFloat does not exist.Is there an alternative rule we can use? I was thinking decimal?
Yeah, decimal should be fine.