简体   繁体   English

带有醒目的版本控制的Web API,未找到ResolveVersionSupportByRouteConstraint

[英]web api with swagger versioning, ResolveVersionSupportByRouteConstraint not found

I have the api portion working but in my swaggerconfig it cannot find ResolveVersionSupportByRouteConstraint in 我的api部分正常工作,但是在我的swaggerconfig中找不到它的ResolveVersionSupportByRouteConstraint

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 :( 这会导致我的api导入azure api管理失败,因为挥舞文档返回错误:(

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. 另外,当我在swashbuckle ui中选择其他版本时,似乎没有为我调用此方法。 This does get called on load, or if you request the doc via /swashbuckle/docs/. 确实会在加载时调用,或者如果您通过/ swashbuckle / docs /请求文档。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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