-
Notifications
You must be signed in to change notification settings - Fork 371
Make the router work with controllers named only by operationId #218
Conversation
If x-swagger-router-controller is not set the router will try to match the handler only by operationId. This makes it easier to use swagger-tools without having to add the non standard field x-swagger-router-controller to the swagger specification file.
What's the purpose of this? The idea is that |
The routes just match based on the operationid. According to the spec
The operationid itself should be sufficient to match the function to be called. Maybe I'm doing somthing wrong? |
I stumbled upon this too, This is definitely a bug, please merge this pull request. |
Well, the purpose of using I'm not against accepting the pull request because simpler naming is never a bad thing. Do you mind adding a unit test for this? Not only is that a requirement anyways but it would also showcase how you intend people to use this. It would also be nice to update the docs in |
What I don't understand is why it should be better to force people to add a non standard In my opinion it makes more sense to require the users to set I will try to add a unit test and update the documentation. |
I do not disagree, nor have I been attempting to push back. I just was trying to explain the reasons behind this originally. One thing that has happened with swagger-tools is that most of the features were written for Swagger 1.2 and were then later ported to work with Swagger 2.0 when that spec was finalized/released. We are currently in the process of breaking swagger-tools into smaller, feature specific modules and during this process we are rewriting based on our knowledge now and not what was when we wrote it originally. In the end, the only thing holding this up is a unit test. |
👍 I've been wondering the same thing, glad to see it's not far off. |
I'd love to see any pre-alpha stuff of breaking swagger-tools into smaller, feature specific modules as its current structure is keeping us from using it. |
@gaberoffman Do you mind sharing your opinion on what its current state is causing you grief? File and issue and give me the details. |
Make the router work with controllers named only by operationId
@whitlockjc Yes I imagine that, but as an intermediate solution it's goood, as this should not break any existing code while it is still usable with operationId only. |
Agreed. I like what is there now, just saying we might change it so that you don't have to manually build the |
If x-swagger-router-controller is not set the router will try to match
the handler only by operationId. This makes it easier to use swagger-tools
without having to add the non standard field x-swagger-router-controller
to the swagger specification file.