Laravel-apidoc-generator: @bodyParam not sending data to sample requests

Created on 22 Nov 2019  路  2Comments  路  Source: mpociot/laravel-apidoc-generator

I am using the doc generator with 'methods' => ['*'] because I want to dump sample requests for the POST requests. But, it appears that the values in @bodyParam are not getting attached to the request.

Here is a quick reproduction of the issue. My function looks like this:

    /**
     * Sample Request
     *
     * Generates a sample request
     *
     * @queryParam query_id int required The variable being sent to the query id Example: 123
     * @bodyParam body_id int required The variable being sent to the body id Example: 456
     */
    public function index()
    {
        return request()->all();
    }

And, the response I'm getting in the docs is:

{
    "query_id": "123"
}

But, if I perform the sample curl request from the command line, I get my expected response:

{"body_id":456,"query_id":"123"}

Most helpful comment

Fixed in 4.0.2 (https://github.com/mpociot/laravel-apidoc-generator/commit/5d9371c14391485630941c718d7f168afd540126)

All 2 comments

I've looked in ResponseCalls and can get it to work correctly if I modify addBodyParameters to:

    private function addBodyParameters(Request $request, array $body)
    {
        $request->request->add($body);
        $request->query->add($body);

        return $request;
    }

but I'm not familiar enough with the Request object to know if that's an acceptable solution.

Fixed in 4.0.2 (https://github.com/mpociot/laravel-apidoc-generator/commit/5d9371c14391485630941c718d7f168afd540126)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

herpaderpaldent picture herpaderpaldent  路  7Comments

yakabay picture yakabay  路  3Comments

arikardnoir picture arikardnoir  路  8Comments

bvaledev picture bvaledev  路  3Comments

wyq2214368 picture wyq2214368  路  3Comments