Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--filter not working #16

Closed
captainmio opened this issue Dec 5, 2019 · 2 comments
Closed

--filter not working #16

captainmio opened this issue Dec 5, 2019 · 2 comments

Comments

@captainmio
Copy link

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
Copy link
Author

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
Copy link
Owner

mtrajano commented Dec 6, 2019

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.

@mtrajano mtrajano closed this as completed Dec 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants