Router middleware to dispatch based on operationId
See original GitHub issueIt would be nice to have a router middleware that would simplify the creation of handlers for methods based on the operationId.
The idea would be as follows.
Based on the following snippet
/pets:
get:
summary: List all pets
operationId: listPets
one would create an object and use something like the following snippet to create the router.
var petrouter = {
listPets: function(req, res, next) {
// Do something
}
};
app.use(middleware.router(petrouter));
Instead of having to the the following for ever method defined in the specification file
app.patch('/pets', function(req, res, next) {
// Do something
});
The advantage I see would be that the redundancy between what method to use (GET
, PUT
, …) and the exact path specification could be avoided. The only thing that maps between the swagger spec and the implementation is the operationId.
What do you think? Would this be a sensible enhancement?
Issue Analytics
- State:
- Created 8 years ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
Adding route specific middleware? · Issue #291 - GitHub
In standard express speak, I'd have had a route middleware on the user ... operationId: post parameters: - in: body name: body description: ......
Read more >Path Operation Advanced Configuration - FastAPI
You can set the OpenAPI operationId to be used in your path operation with the parameter operation_id . You would have to make...
Read more >How to dispatch an action when clicking on Link when using ...
So I'm thinking of a way to render based on the state whether its on edit-mode or delete-mode etc. javascript · reactjs ·...
Read more >Express Tutorial Part 4: Routes and controllers - MDN Web Docs
Router middleware as it allows us to group the route handlers for a particular part of a site together and access them using...
Read more >Chapter 5. Middleware - Redux in Action - liveBook · Manning
Redux middleware is code that sits between an action being dispatched and the store passing the action to the reducer and broadcasting the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I too would like to know if this is a part of the
swagger-express-middleware
. The documentation is unclear as to how you bind operationId names to functions. The sample projects don’t see to even have js functions mapping the operationId in the YAML, so I’m not entirely sure how to wire any any of this up.Is this a part of
swagger-express-middleware
or not?