简体   繁体   中英

web api with swagger versioning, ResolveVersionSupportByRouteConstraint not found

I have the api portion working but in my swaggerconfig it cannot find ResolveVersionSupportByRouteConstraint in

c.MultipleApiVersions(
(apiDesc, targetApiVersion) => ResolveVersionSupportByRouteConstraint(apiDesc, targetApiVersion),
(vc) =>
{
    vc.Version("v2", "Swashbuckle Dummy API V2");
    vc.Version("v1", "Swashbuckle Dummy API V1");
});

This causes my api import into azure api management to fail because the swagger docs returns an error :(

You have to create the method yourself. You may have to tweak the logic for your versioning scheme. Also, this method doesn't seem to get called for me when I choose a different version in the swashbuckle ui. This does get called on load, or if you request the doc via /swashbuckle/docs/.

    public static bool ResolveVersionSupportByRouteConstraint(ApiDescription apiDesc, string targetApiVersion)
    {
        return apiDesc.ID.Contains($"/{targetApiVersion}/");        
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM