首页 > 解决方案 > 如何删除此工件

问题描述

我正在使用 swashbuckle 来记录我的 API。当我打开招摇页面时,我会在图像中突出显示该项目。我如何摆脱它或更换它?使用 v5 的 swashbuckle 工具

我的路线的 Strangley 格式版本。

标签: swashbuckle

解决方案


这里是部分。

Startup.cs - 服务

// Register the Swagger generator, defining 1 or more Swagger documents
        services.AddSwaggerGen(c =>
        {
            c.SwaggerDoc("v0", new OpenApiInfo
            {
                Version = "v0",
                Title = "LTK Manager",
                Description = "Sample Description",
                TermsOfService = new Uri("https://example.com/terms"),
            });

            // Set the comments path for the Swagger JSON and UI.
            var xmlFile = $"{System.Reflection.Assembly.GetExecutingAssembly().GetName().Name}.xml";
            var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
            c.IncludeXmlComments(xmlPath);
            c.IgnoreObsoleteActions();
            c.IgnoreObsoleteProperties();

        });

Startup.cs - 配置

// Enable middleware to serve generated Swagger as a JSON endpoint.
        app.UseSwagger();

        // Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.),
        // specifying the Swagger JSON endpoint.
        app.UseSwaggerUI(c =>
        {
            c.SwaggerEndpoint("../swagger/v0/swagger.json", "LTK Manager V0 (alpha)");
            c.DisplayOperationId();

        });

路线装饰

      /// <summary>
    /// Retrieves a parameter store value from an account/region
    /// </summary>
    /// <remarks>Awesomeness!</remarks>
    /// <response code="200">Returns an Object Containing the response from the API.</response>
    [HttpPost]
    [Route("getParamStoreValue")]
    [ProducesResponseType(200)]
    public IActionResult getKey([FromBody] ParamStoreRequest req)

推荐阅读