-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
How do I ignore APIs with swagger-springmvc? #80
Comments
@agentgonzo which version of the library are you using? In 0.5.0 its much simpler to do stuff Just create a subclass of the ExtensibilityModel and pull it in your spring configuration. Depending on how you've got your server configured you might need to use context:annotation configuration. See an example over at the example project. The spring configuration needs to look like so and your extensibility bean might look something like this. You might need to override the customizeExcludedResources method to do what you need. just add "/" as an entry to that list. |
I'm using 0.4.2, the latest version. 0.5.0 isn't in the maven repos. On 14 May 2013, at 18:04, Dilip Krishnan notifications@github.com wrote:
|
@agentgonzo I just download 0.5.0 yesterday, so it is out there |
@agentgonzo it should be there http://search.maven.org/#search%7Cga%7C1%7Cswagger-springmvc |
Oh, thanks. I was looking on Is mvnrepository.org a mirror then that's out of date - that's what I've 'gonz On 14/05/2013 18:20, Dilip Krishnan wrote:
|
I've created myself another annotation @ApiIncludeController once that annotation is present in at least one controller my ExtensibilityModule filter controllers without that annotation excluding all of them, maybe that would be a good idea for you.. |
@lucassagarana There is already support for @ApiInclude and @ApiIgnore. So you shouldnt need to do that. |
@dilipkrish but the target to that is Method, so i cannot use it on the scope of my class to include everything.. |
One could really get lost in the extensibility module's methods, especially since they have no documentation. What does |
In fact, I didn't find a way to use an include-only strategy. DocumentationEndPoint filters cannot remove endpoints from the Documentation, and a Documentation Filter is invoked before the endpoints are added, so you can't remove them there either. |
@Glamdring There are a lot of extensibility points.. The challenge is to choose the right one for the job :). Agreed, that the documentation is fairly sparse, but hopefully the examples in the example project serve as a replacement for that. Also some of the issues marked as questions are meant to build up faqs over time. Going from simple to complex here are the tools at your disposal.
I suppose the name of the type Filter is throwing you off. Its Filter used in the sense of Pipes-and-filters pattern, and not to filter the documentation endpoints from whats rendered! So a filter is just an part of the pipeline that can augment the type the filter is acting on. So an implementation of You shouldn't need to use reflection at all. I'd be curious what your use case is. Aside from the library documentation, if the apis are not leading you to the pit of success :) thats something I'd love to know about, so that it can be addressed from a api usability standpoint. It would be useful if you can share what you're trying to do and how you're solving the problem. That way if theres a simpler solution I might be able to suggest alternatives. |
Thanks. The I'll check the Transformation option. What I want to do is simply expose one or several controllers as an API, and have all other controllers as internal. I don't want to split it in two projects (which might be generally a good idea), because the project is small and that would be an overhead. So, a single projects, with 1-2 controllers with a public API and the rest used internally bu the web app. Pretty standard, I think. The @ApiIgnore is good, but as mentioned above it works on a method level, rather than on controller level. As far as I saw, customizeExcluded requires an explicit list, you can't use a pattern e.g /api/**. And having to manually ignore/exclude each individual method (and each future method) is tedious. Ideally, I would like to have a configuration switch that excludes everything by default and includes only @ApiInclude methods, or even better - @ApiIncludeClass* classes. |
We had a similar requirement and excluded everything without a swagger protected void customizeExcludedResources(List excludedResources) {
this.requestMappingHandlerMapping.getHandlerMethods();
handlerMethods.entrySet()) {
|
@dilipkrish btw, the transformer I registered isn't picked up for some reason, I don't have time to investigate further |
I've got three controllers in my project:
The / controller is just for providing a health-check endpoint and version info, and so I don't want this to be listed in the Swagger docs (but don't want to keep it as an HTTP get on the main tomcat context is the handiest way to find version info). Is there an easy way to get swagger to ignore this Controller? I've found some stuff about endpoint filters but can't figure out how to get it to work.
Any help gladly appreciated.
The text was updated successfully, but these errors were encountered: