I installed Swashbuckle in my Episerver site that of course also uses Find.

Firstly I got a crash that I got around by activating this line in my SwaggerConfig.cs (would be nice if Epi changed their methods to not conflict).

c.ResolveConflictingActions(apiDescriptions => apiDescriptions.First());

When I then browsed /swagger/ I got a bunch of Find methods listed. These operations are built using ASP.NET Web API and therefore gets listed by default. I only wanted my own API was in scope for this so I had to activate a custom filter in SwaggerConfig.


After trying out some different stuff this was the one crude way I found to exclude them.

private class FindFilter : IDocumentFilter
	public void Apply(SwaggerDocument swaggerDoc, SchemaRegistry schemaRegistry, IApiExplorer apiExplorer)
		foreach (var path in swaggerDoc.paths)
			string k = path.Key.ToLower();

			if (k.StartsWith("/episerver/find/api")
				|| k.Contains("/api/bestbets")
				|| k.Contains("/find_v2")
				|| k.Contains("/api/click")
				|| k.Contains("/api/editorialboosting"))
				// Exclude from docs by nulling them
				var p = path.Value;
				p.delete = null;
				p.get = null;
				p.head = null;
				p.options = null;
				p.patch = null;
				p.post = null;
				p.put = null;

Added Monday 21 December 2015 13:37 — Tags for this page: Episerver, ASP.NET


Add Your Comment