XML comments file could not be found - Swagger

前端 未结 8 852
慢半拍i
慢半拍i 2021-01-04 03:10

This is certainly one of those that drives you nuts. As the title indicates all I\'m simply trying to do is display comments pulled from an xml file using swagger.

I

8条回答
  •  遥遥无期
    2021-01-04 04:03

    As indicated by the exception, the application looks for the XML in the base directory of the project, not in the "bin" folder.

    Why does the app search in the base directory? Look at these lines:

    var baseDirectory = AppDomain.CurrentDomain.BaseDirectory;
    var commentsFileName = Assembly.GetExecutingAssembly().GetName().Name + ".XML";//"G2F.Collective.Api.XML"
    var commentsFile = Path.Combine(baseDirectory, commentsFileName);
    

    The name of the comment file is configured with the combination of the base directory and the xml with the name of the project

    c.IncludeXmlComments(commentsFile);
    

    Finally, this instruction tells Swagger which file to use to take the comments, it is the real reason why it looks for that file in that directory.

    So what is indicated in this last instruction must be according to what is configured in the Build tab of the project configuration.

提交回复
热议问题