ASP.NET Core Web API에서 사용자 정의 UI를 사용자 정의하려고합니다. 나는이 자습서 다음있어Cutomize Swagger UI ASP.NET 핵심 웹 API
:
- https://docs.microsoft.com/en-us/aspnet/core/tutorials/web-api-help-pages-using-swagger?tabs=visual-studio
- https://github.com/swagger-api/swagger-ui
이것은 Startup.cs입니다
나는이 같은 UI 원하는 구성 :
// Add the detail information for the API.
services.ConfigureSwaggerGen(options =>
{
// Determine base path for the application.
var basePath = _env.WebRootPath;
// Complete path
var xmlPath = Path.Combine(basePath, "myapi.xml");
// Set the comments path for the swagger json and ui.
options.IncludeXmlComments(xmlPath);
});
app.UseStaticFiles();
// Enable middleware to serve generated Swagger as a JSON endpoint
app.UseSwagger();
// Enable middleware to serve swagger-ui assets (HTML, JS, CSS etc.)
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "MyAPI");
});
이미이 같은 자식 저장소에서 자신감의 UI 파일을 다운로드하여 내 프로젝트에 넣어 :
나는이 옳은 일이라고 알고 있지만하지 않습니다 더러운 UI에 대한 변경 사항을 볼 수 없습니다.
'index.html' 파일에 CSS를 참조하고 있습니까? 또한 'http : // localhost :/swagger/ui/index.html'을 탐색하고 상단에있는 입력 상자에'http : // localhost : /swagger/v1/swagger.json'을 입력하십시오. 렌더링 된 페이지? –
그게 문제입니다. 해당 index.html 페이지는 호출되지 않습니다. – perozzo
'index.html 페이지가 호출되지 않습니다'라는 것을 어떻게 의미합니까? 그것이 올바르게 서비스되고 있는지 확인하기 위해 브라우징을 해봤습니까? –