2017-09-15 5 views
0

Nancy v 1.4.1 및 Nancy.Swagger v 2.1.1 (Nancy 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 : 오 noes! ---> Swagger.ObjectModel.Builders.RequiredFieldException : '경로'가 필요합니다. Swagger.ObjectModel.Builders.SwaggerRootBuilder.Build() C시 : \ 프로젝트 \ 낭시 자신감 \ SRC \ Swagger.ObjectModel \ 빌더 \ SwaggerRootBuilder.cs : Nancy.Swagger.Services.SwaggerMetadataProvider.GetSwaggerJson에서 선 123 () C : \ projects \ nancy-swagger \ src \ Nancy.Swagger \ Services \ SwaggerMetadataProvider.cs : 줄 91 (Nancy.Swagger.Modules.SwaggerModule)에 있습니다. <> c__DisplayClass0_0. C# \ projects \ nancy-swagger \ src \ Nancy.Swagger \ Modules \ SwaggerModule.cs : .ctor> b__0 (Object _) 낸시에서. 떠난다. 라우트. <> Nancy.NancyEngine.InvokeOnErrorHook에서 c__DisplayClass4.b__3 (개체 매개 변수, CancellationToken 컨텍스트) --- 내부 예외 스택 추적의 끝 --- (NancyContext 컨텍스트, ErrorPipeline 파이프 라인, 예외 예)

답변

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

감사를 먼저해야합니다. 너 한달 전에 여기 있었으면 좋겠다 LOL –

0

음, 그래서 어쨌든 당신이이 작업을 수행 할 필요가 있음을 밝혀 : 샘플 nancy.swagger 프로젝트가 어떤 이유로 기능을 아직 실제로하지 않습니다 그것을하고

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

에도 불구하고. 어쨌든, 상속 기지 (경로)는 나를 위해 그것을 정렬.