Headless API Swashbuckle

I’m trying to add Headless API to Accelerator 7.4.0, but I’m stuck with:

Method not found: Swashbuckle.Application.SwaggerEnabledConfiguration Swashbuckle.Application.HttpConfigurationExtensions.EnableSwagger(System.Web.Http.HttpConfiguration, System.Action`1<Swashbuckle.Application.SwaggerDocsConfig>).

Litium Version: 7.4

Do you have some warnings when compiling on different versions?
From the Docs:
“Note: Headless API Addon may use a different version of Litium and other package references than your solution. In which case fix any warnings in the build that shows incompatibility of Litium dlls you have in your project vs Litium version used by the headless api addon. You may add binding redirects (recomended) or choose to upgrade/downgrade headless API addon references)”
Maybe you need binding-redirect in web.config?

Yeah, and I have upgraded all the versions that it has been warnings about.

Check this:

Yes, I’ve read it before and tried it out…

Swagger is already installed by default in Litium 7.4 and you only need to add some extra decoration and classes.

On the classes, or the base class, for your API controllers, add the ApiCollection attribute.

    [ApiCollection("site")]
    public abstract class ApiControllerBase : ApiController
    {
    }

Add an extra configuration file like the following, the Collection property should return the same value as you enter in the ApiCollection-attribute.

    public class SiteOpenApiCollection : IApiCollection
    {
        internal const string _collectionName = "site";

        public string Name { get; } = "Accelerator Web API";
        public string Collection => _collectionName;

        public void Configure(OpenApiDocumentBuilder builder)
        {
        }

        public bool IsAuthorized() => true;
    }

Compile the solution and enter https://yourdomain/Litium/swagger and your defined collection will be visible in the dropdown to the right in top-bar.

I still have the same problem after the configurations

This AddOn is really not upgraded for L7.4 version yet so we need to upgrade it before we can guarantee it should be working.

I did get it working now, much work with different packages!

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.