knuckleswtf / scribe

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

Manipulate tags by Plugins #835

Closed Evoolo closed 5 months ago

Evoolo commented 5 months ago

Scribe version

4.34.0

Your question

Hello,

I recently requested the addition of x-tagGroups to Scalar to enable multi-level navigation, similar to what is possible in the Elements theme (https://github.com/scalar/scalar/pull/1174).

Now, I'm looking to manipulate the tags in the OpenAPI documentation by adding subgroups to the tags and also adding the x-tagGroup into the OpenAPI document, as demonstrated in the example provided https://github.com/scalar/scalar/discussions/1016.

Could someone please guide me on how to manipulate the tags of an endpoint with a plugin?

Thank you!

Docs

shalvah commented 5 months ago

Seems like what you need is a custom writer. Basically, inherit the OpenAPISpecWriter and change what you need, then bind it in a service provider so Scribe loads yours.

Evoolo commented 5 months ago

Hi @shalvah , I was successful with this approach. Thank you for your help