Comments (11)
And your problem isn't really a middleware problem, but a metadata problem—"how do I add this custom metadata (roles/permissions) automatically?" Still the same solution: use a custom metadata strategy and customise the views.
Hopefully v3 brings in a structure that would make it more straightforward than that, but right now, that's it.
from scribe.
What i've done for my project is looking like this:
In the tags are the names of the middlewares. I think it's pretty useful if you are using something like https://github.com/spatie/laravel-permission to manage your users premissions. With these output we can directly see our nessesary roles or permissions for an endpoint
from scribe.
On the contrary, I'm not convinced. I still think that, while there are some use cases, in most cases this will be leaking unnecessary implementation details to the end user. I don't think I'll be adding it to Scribe anytime soon.
However, it's fairly straightforward to customise your local installation of Scribe to include it yourself: Write your own metadata strategy (just extend the default one) that captures the middleware, then extend the vendor views to show the middleware.
Perhaps for v3, we'll look into providing easier ways to add your own metadata or labels, but no promises!
from scribe.
Did you read my response? I didn't say to manually write it. I've put a lot of work into making Scribe as extensible as it is. Take some time and look up the documentation on writing a custom strategy. I even created a template and collated some examples. All you need to do is grab the route middleware and add it to the returned array. The rest of the work is customising one Blade file, which is also quite easy, considering I've already provided the badge
components.
I've got a lot of things on my plate right now, so I really can't spend time debating this. But the tools are in place for you to get it done for yourself.
from scribe.
What's an example of what such documentation would look like?
from scribe.
I agree that it's useful in the scenario you describe, but generally, I think it would be a minus. Middleware are typically an internal, implementation detail. For instance, if we were printing out the names of included Laravel middleware, you'd probably see things like bindings
, and throttle:60,1
. Not very friendly for the user.
from scribe.
That depends on, who the user is. If we are talking about developers, it can be helpful.
from scribe.
No, it's not about skillset, but about perspective. As an end-user, I would only be confused if I saw things like ConvertEmptyStringsToNull
, and TrustProxies
listed there.
That said, I'm all for extracting as much information as possible from the framework, so, if we're going to do this, how can we:
- avoid showing the user unnecessary information?
- present it in a friendly format?
from scribe.
We could make the feature optional over a setting in the config so it's only generated if you want it. As for the presentation i would be open for your suggestions. In our case it's enough to know the middleware names since we have only developers as users
from scribe.
I agree, this is very much needed. please add in new version 2.0
from scribe.
My reason: say suppose we have 100+ routes out of which only 20 are for RoleA and 5 are for RoleB so on so forth. Now other developers need to know which route is given access to which role. Manually write this in all routes is too much work.
Maybe we can do the same approach like include and exclude, eg include Middleware starting with "role" only (referring to Spatie lib)
from scribe.
Related Issues (20)
- getting 401 Unauthorized in each routes where i set the middleware HOT 1
- Plugin List?
- How to override post-response script content for the postman? HOT 1
- Using @apiResource as a @bodyParam? HOT 1
- scalar theme doesnt properly generate example and child attributes HOT 1
- array request not render and not examplae
- Example is not using factory HOT 1
- Missing 'Accept' => 'application/json' HOT 5
- How to send NULL values? HOT 2
- Support wider range of types
- How use recursive schema ? HOT 1
- 404 Not Found on Production HOT 6
- Multiple responses do not generate oneOf correctly
- The package is ending with a Check Failed Error HOT 1
- Badges don't work with element theme HOT 3
- Response fields overflows to dark box on default theme
- Theme Dark Mode Support HOT 1
- HTML Generated by scribe uses a version of lodash that has had a 9.1 CVE vulnerability since 2019 amongst 5 others HOT 3
- Support auto generete with laravel-data HOT 1
- @urlParam not overriding ID parameters HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from scribe.