I am trying to use SwashBuckle in my Umbraco MVC Project. MVC Version - 4.0 and Umbraco Version - 7.2.6. I am facing some issues like
1) The response in /swagger/ui/index.html is taking too much time to load and its listing all apis in umbraco such as "Media", "Content Tree" etc.. instead of listing my api controller actions alone. Have any one experienced this issue?
2) "Not supported by Swagger 2.0: Multiple operations with path 'api/ContentTree/CreateTreeNode/{id}' and method 'POST'. See the config setting - "ResolveConflictingActions" for a potential workaround. This is the message I am getting.
Can some one provide a solution for the same. Is there any version dependencies with Umbraco.
Thank you this helped me a lot. Out of curiosity do you know how to remove the option {id} that is appearing in all the methods for my api controller?
ie
POST /umbraco/Api/Stuff/MyRequests/{id}
Everyone of the actions has that id in the swagger docs which I assume is defined in some default route. The action MyRequests doesn't accept any parameters so I'd like to see about removing it.
In my case, that didn't solve this issue. The {id} still appears at the end of each method in my UmbracoApiController.
For you, the solution was only set the [Route("")] attribute with the same name as the method?
If you're just trying to get rid of the ID parameter, well couldn't you just ignore it? It's not exactly mandatory. It's easier to ignore than to remove I think.
So in Umbraco 7.5.3, I installed Swashbuckle. There is no Swagger.config file but there is a SwaggerConfig.cs but the signature is different.
I implemented the OptInApiExplorer code as per the example, and because there is no Register signature that is taking HttpConfiguration, I tried the following but it doesn't work.
HttpConfiguration config = new HttpConfiguration();
config.Services.Replace(typeof(IApiExplorer), new OptInApiExplorer(config));
I tried this in the SwaggerConfig.cs before and after the initialisation code bit:
var thisAssembly = typeof(SwaggerConfig).Assembly;
GlobalConfiguration.Configuration
.EnableSwagger(c => ...).EnableSwaggerUI(c => ...);
httpConfiguration
.EnableSwagger((c) =>
{
c.SingleApiVersion("v1", "A title for your API"));
c.ResolveConflictingActions(apiDescriptions => apiDescriptions.First());
});
Anyone found a solution to this, its confusing the hell out of our frontenders with the extra ID but overall it helps a ton having this functionality :) Plus its making errors when we try to autogenerate a client from this, is there anyway to overwrite the route config from umbraco and just use ones own? :)
Umbraco and SwaggerUI/SwashBuckle
Hi,
I am trying to use SwashBuckle in my Umbraco MVC Project. MVC Version - 4.0 and Umbraco Version - 7.2.6. I am facing some issues like
1) The response in /swagger/ui/index.html is taking too much time to load and its listing all apis in umbraco such as "Media", "Content Tree" etc.. instead of listing my api controller actions alone. Have any one experienced this issue?
2) "Not supported by Swagger 2.0: Multiple operations with path 'api/ContentTree/CreateTreeNode/{id}' and method 'POST'. See the config setting - "ResolveConflictingActions" for a potential workaround. This is the message I am getting.
Can some one provide a solution for the same. Is there any version dependencies with Umbraco.
Thanks, Vinod
Hi,
Found the solution for the same.
Step 1: Create WebAPI project and install Umbraco.
Step 2: Follow the procedure mentioned in http://www.strathweb.com/2014/04/opt-opt-asp-net-web-api-help-page/ and create the classes( create IncludeInApiExplorer, IncludeInApiExplorerAttribute, ApiController)
Step 3: Install SwashBuckle
Step 4: And add the "httpConfiguration.Services.Replace(typeof(IApiExplorer), new OptInApiExplorer(config));" in the Swagger.config file
Step 5: Navigate to localhost:port/swagger/ui/index
Thanks Vinod
Thank you this helped me a lot. Out of curiosity do you know how to remove the option {id} that is appearing in all the methods for my api controller?
ie
POST /umbraco/Api/Stuff/MyRequests/{id}
Everyone of the actions has that id in the swagger docs which I assume is defined in some default route. The action MyRequests doesn't accept any parameters so I'd like to see about removing it.
I ended up just decorating each method with the route attribute to remove it.
Hi,
In my case, that didn't solve this issue. The {id} still appears at the end of each method in my UmbracoApiController. For you, the solution was only set the [Route("")] attribute with the same name as the method?
Can you help me? Thanks in advance
If you're just trying to get rid of the ID parameter, well couldn't you just ignore it? It's not exactly mandatory. It's easier to ignore than to remove I think.
So in Umbraco 7.5.3, I installed Swashbuckle. There is no Swagger.config file but there is a SwaggerConfig.cs but the signature is different.
I implemented the OptInApiExplorer code as per the example, and because there is no Register signature that is taking HttpConfiguration, I tried the following but it doesn't work.
I tried this in the SwaggerConfig.cs before and after the initialisation code bit:
but nothing works. Any ideas?
Fixed it by entering
after the initialisation block.
How to remove the {id} wrong parameter?
Here is another info: https://stackoverflow.com/questions/40308111/c-sharp-attribute-appsettings
I wrote following and it worked for me
httpConfiguration .EnableSwagger((c) => { c.SingleApiVersion("v1", "A title for your API")); c.ResolveConflictingActions(apiDescriptions => apiDescriptions.First()); });
Anyone found a solution to this, its confusing the hell out of our frontenders with the extra ID but overall it helps a ton having this functionality :) Plus its making errors when we try to autogenerate a client from this, is there anyway to overwrite the route config from umbraco and just use ones own? :)
In case somebody is still wandering "how to remove Id".
1) Add Route ( namespace : System.Web.Http, NOT System.Web.Mvc )
2) Check that you have MapHttpAttributeRoutes() in App_Start
Works in my case.
is working on a reply...