knuckleswtf / scribe

Generate API documentation for humans from your Laravel codebase.✍
https://scribe.knuckles.wtf/laravel/
MIT License
1.59k stars 280 forks source link

Content-type: application/json missing #734

Closed DPlachkov1991 closed 9 months ago

DPlachkov1991 commented 9 months ago

Scribe version

3.3.1

Your question

I'm trying to generate documentation for my API having transitioned from laravel-apidoc-generator to scribe, but I'm experiencing issues in a few cases.

Most importantly the "content-type: application/json" header and Authorization: Bearer {token} are being set correctly.

The "content-type: application/json" is not being set in the generated static documentation and in the postman collection. The "Authorization Bearer {token}" - is not being set in the postman collection. I'm using the scribe config file to include 'Content-Type' => 'application/json' and 'Authorization' => "Bearer {token}"

The content-type application/json missing makes using the "try it out" functionality unable to work since the generated static page is not sending the header and the API does not recognize the call as application/json. Postman collection is also not working as intended since its missing. Postman collection is also not correct because the Authorization is missing even tho all my methods have the "@authenticated" 'apply' => [ 'headers' => [ 'Authorization' => 'Bearer {token}', 'Content-Type' => 'application/json', 'Accept' => 'application/json', ], 'response_calls' => [ ...

And ... 'auth' => [ 'enabled' => true, 'default' => false, 'in' => 'bearer', 'name' => 'Authorization', 'use_value' => env('SCRIBE_AUTH_KEY'), 'placeholder' => '{YOUR_AUTH_KEY}', ], ps. adding headers with custom names work correctly in the generated static doc and in postman ps2. openapi spec has the correct headers, but postman collection does not

Docs

shalvah commented 9 months ago

Hmm, dunno what to say here. If it's set correctly in your config, it should be showing up. As of the latest Scribe versions, this works fine. Unfortunately, I can't give further support on that, as v3 is an older version. Please upgrade to v4 and try again (the upgrade guide is clear, and most of the process is simple and automated). You can then reopen after that if there's still a problem.