Adding a custom Swagger document
Adding a custom Swagger document for a custom Management API
By default, all controllers based on ManagementApiControllerBase will be included in the default Management API Swagger document.
When building custom Management API controllers, sometimes it's preferable to have a dedicated Swagger document for them. Doing so is a three-step process:
Register the Swagger document with Swagger UI.
Instruct Swagger UI to utilize Umbraco authentication for the Swagger document.
Move the controllers to the Swagger document.
The following code exemplifies how to achieve the first two steps;
With this in place, the last step is to annotate the relevant API controllers with the MapToApi attribute:
Now when we visit the Swagger UI, "My item API" has its own Swagger document:
Last updated