mtrajano / laravel-swagger

Auto generates the swagger documentation of a laravel project based on best practices and simple assumptions
167 stars 71 forks source link

--filter not working #16

Closed captainmio closed 4 years ago

captainmio commented 4 years ago

Hello, I'm currently laravel-swagger to auto-generate my api endpoints. I want to filter only "API" endpoints will be create in the .json file. the code I've tried to run:

php artisan laravel-swagger:generate > public/swagger.json --filter="/api"

Its not working and returns NULL

{ "swagger": "2.0", "info": { "title": null, "description": "", "version": "1.0.0" }, "host": null, "basePath": "\/", "paths": [] }

image below is my api routes file

image

captainmio commented 4 years ago

my colleague tried to replicate this library and make it function with filter. he was able to make it work. I'm not sure why in my local machine --filter is not working.

and also in addition with my question. how to add POST, DELETE and UPDATE/PATCH parameters?

mtrajano commented 4 years ago

Not sure if this is the issue but it looks like you're passing the filter after the output redirect, you should pass the filter to the command php artisan laravel-swagger:generate --filter="/api" > public/swagger.json, also use the latest possible version of the library. As for the parameters: the command automatically generates it depending how your application is structured. For body parameters, it will parse injected FormRequested classes in your controllers and generate them based on it's best guess as to how your rules look. It can't generate these if you're using the validator in the method body since php's reflection doesn't have access to these. For path parameters it will scan your routes and look for any variables in the route and generate them based on the name. Feel free to reopen if you're still facing issues.