L5-Swagger
L5-Swagger copied to clipboard
Different routes depends on env
- L5-Swagger Version: 8
Description:
Is it possible to show/hide some route depending on environment?
E.g. I have couple of private routes for my developers, I want its been shown only in dev
env, but I want to hide it on prod
env.
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
Are you talking about API endpoints in spec which you want to hide?
If yes the first through which comes into my mind would be to move these endpoints annotations into a separate file and include path to it only in local environment 💭 🤔
I thought about this way... But how to "ignore" that file only in prod?
Have some kind of provider/helper which returns array of paths and call it in config?
This is assuming you generate json file always or specifically for/on production 🤓
Has the swagger any variable like "env" which we can put in doc block? e.g.
/**
* @OA\Get(
* env="local,development",
* path="/news",
* tags={"getNews"},
* summary="Get News",
* description="Returns News data",
* security={{"api":{}}},
* @OA\Parameter(
* name="limit",
* in="query",
* required=false,
* @OA\Schema(type="integer"),
* ),
that sounds like "show this doc only in env local or development" and show everywhere if this var is not defined in the block
If there is not, so we can put "extra" files in config. Even not extra but hidden - we should hide these files by default, and "uncomment" locally?