L5-Swagger icon indicating copy to clipboard operation
L5-Swagger copied to clipboard

Different routes depends on env

Open psprokofiev opened this issue 3 years ago • 5 comments

  • 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.

psprokofiev avatar Apr 26 '21 09:04 psprokofiev

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 💭 🤔

DarkaOnLine avatar Apr 26 '21 13:04 DarkaOnLine

I thought about this way... But how to "ignore" that file only in prod?

psprokofiev avatar Apr 26 '21 13:04 psprokofiev

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 🤓

DarkaOnLine avatar Apr 26 '21 13:04 DarkaOnLine

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

psprokofiev avatar Apr 26 '21 13:04 psprokofiev

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?

psprokofiev avatar Apr 26 '21 13:04 psprokofiev