2017-09-15 10 views
0

ナンシーv 1.4.1とNancy.Swagger v 2.1.1(ナンシーv1をサポートする最後のもの)を使用すると、上記のエラーが/ api-docsパス。何か案は?私が見たセットアップのステップでは、「パス」フィールドについて何も言わない。Swagger.ObjectModel.Builders.RequiredFieldException: 'Paths'が必要です

マイモジュール:

public class General : NancyModule 
{ 
    public General() 
    { 


     Get["/","Home"] = parameters => 
     { 
      try 
      { 
       return "home";// View["view/index.html"]; 
      } 
      catch (Exception ex) 
      { 
       return ExceptionHelper.ExceptionResponse(Negotiate, ex); 
      } 
     }; 

     Get["/test/", "Test"] = parameters => { 
      return "testie"; 
     }; 
    } 
} 

私のモジュールのメタデータ:

public class GeneralMetadataModule : MetadataModule<PathItem> 
{ 
    public GeneralMetadataModule(ISwaggerModelCatalog modelCatalog) 
    { 
     Describe["Test"] = description => description.AsSwagger(
      with => with.Operation(
       op => op.OperationId("Test") 
         .Tag("Users") 
         .Summary("The list of users") 
         .Description("This returns a list of users from our awesome app"))); 
    } 
} 

スタックトレース:

Nancy.RequestExecutionException:ああNOEが! ---> Swagger.ObjectModel.Builders.RequiredFieldException: 'パス'が必要です。 でSwagger.ObjectModel.Builders.SwaggerRootBuilder.Build()C:\ projects \ nancy-swagger \ src \ Swagger.ObjectModel \ Builders \ SwaggerRootBuilder.cs:line 123 Nancy.Swagger.Services.SwaggerMetadataProvider.GetSwaggerJson() C:¥projects¥nancy-swagger¥src¥Nancy.Swagger¥Services¥SwaggerMetadataProvider.cs:行91 (Nancy.Swagger.Modules.SwaggerModule)にあります。 <> c__DisplayClass0_0。 (Closure、CallSite、Func`2、Object)の .ctor> b__0(Object _)C:¥projects¥nancy-swagger¥src¥Nancy.Swagger¥Modules¥SwaggerModule.cs:11行目 Nancy.Routing.Routeで。 <> c__DisplayClass4.b__3(オブジェクトのパラメータ、CancellationTokenコンテキスト) ---内部例外スタックトレースの終わり--- Nancy.NancyEngine.InvokeOnErrorHookで (NancyContextコンテキスト、ErrorPipelineパイプライン、例外EX)

答えて

1

あなたは間違った順序でそれを持っている - 名前は、その後、パス

Get["Home", "/"] = parameters => //this is right 
{ 
    try 
    { 
     return "home";// View["view/index.html"]; 
    } 
    catch (Exception ex) 
    { 
     return ExceptionHelper.ExceptionResponse(Negotiate, ex); 
    } 
}; 

Get["Test", "/test/"] = parameters => { //and this is right 
    return "testie"; 
}; 
+0

おかげで最初にする必要があります。あなたがここ1ヶ月前にLOLにいたことを祈って –

0

まあ、そう、とにかくそれはあなたがこれを行うために必要なことが判明:

public class General : NancyModule 
{ 
    public General() : base("/v1/general/")//this part 
    { 
     ... 
    { 
} 

サンプルnancy.swaggerプロジェクトは、実際にそれを行うと、まだいくつかの理由で機能しませんが。とにかく、継承ベース(パス)は私のためにそれを並べ替えました。

関連する問題