2017-12-30 56 views
0

私はAspNet 5 WebApiプロジェクトにSwashbuckle 5.6.0(現在は最新)をインストールしました。私は派手なUIを表示するが、私のAPIメソッドのどれも表示されません。Swaggerで私のowin apiコントローラを一覧表示するには

私は永遠に成功しなかったので、きれいなスタートを切った。動作中のAPIから、私はSwashbuckleをインストールしました。それを残しておくと、より簡単に関連付けることができます。

APIは、ExpressではなくIISでホストされています。それは試してみる。

これはどのようにデバッグできますか?それとも、誰かが私が間違っていることを見ることができますか?

以下のコード。 stackoverflowを満たすために読みやすさのために空行を削除しなければならなかった、申し訳ありません!

スタートアップ

public class Startup 
{ 
    public void Configuration(IAppBuilder app) 
    { 
     JwtSecurityTokenHandler.InboundClaimTypeMap = new Dictionary<string, string>(); 
     app.UseIdentityServerBearerTokenAuthentication(
      new IdentityServerBearerTokenAuthenticationOptions 
      { 
       Authority = ConfigurationManager.AppSettings["IdentityServerApplicationUrl"], 
       RequiredScopes = new[] {"gallerymanagement"} 
      }); 
     var config = WebApiConfig.Register(); 
     app.UseWebApi(config); 
    } 
} 

WebApiConfig

public static class WebApiConfig 
{ 
    public static HttpConfiguration Register() 
    { 
     var config = new HttpConfiguration(); 
     // Web API routes 
     config.MapHttpAttributeRoutes(); 
     config.Routes.MapHttpRoute(
      name: "DefaultRouting", 
      routeTemplate: "api/{controller}/{id}", 
      defaults: new { id = RouteParameter.Optional } 
     ); 
     config.EnableCors(); 
     // clear the supported mediatypes of the xml formatter 
     config.Formatters.XmlFormatter.SupportedMediaTypes.Clear(); 
     config.Formatters.JsonFormatter.SupportedMediaTypes.Add(
      new MediaTypeHeaderValue("application/json-patch+json")); 
     var json = config.Formatters.JsonFormatter; 
     json.SerializerSettings.Formatting = Newtonsoft.Json.Formatting.Indented; 
     json.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); 
     return config; 
    } 
} 

EventsController

[EnableCors("*", "*", "GET, POST, DELETE")] 
public class EventsController : ApiController 
{ 
    [Route("api/Events/{sub}")] 
    public async Task<IHttpActionResult> GetSingleEvent(string sub) 
    { 
    } 

    [Route("api/Events/")] 
    public async Task<IHttpActionResult> Get() 
    { 
    } 
} 
+0

あなたはスワッシュバクラのユニットが欠けています。 https://github.com/domaindrivendev/Swashbuckle ... addをご覧ください。 config。 .EnableSwagger(c => c.SingleApiVersion( "v1"、 "APIのタイトル")) .EnableSwaggerUi(); WebApiConfigに送信します。書式設定のために、私はタブレットでオンラインです – DotNetDev

答えて

0

あなたは、init swashbuckleに欠場。 https://github.com/domaindrivendev/Swashbuckleを参照してください、あなたはWebApiConfigに

config 
.EnableSwagger(c => c.SingleApiVersion("v1", "A title for your API")) 
.EnableSwaggerUi(); 

を追加する必要があります。

関連する問題