Swagger xml 注释没有显示在文档 UI 中,不确定我在这里遗漏了一些东西..至少有人告诉我这是一个错误
Step1:创建一个全新的 ASP.NET Web 应用程序 Web API 项目
Step2:创建Web API项目
步骤3:安装Swashbuckle 5.6.0 NuGet包
第四步:启用生成 XML 文档文件(项目属性 -> 构建)
步骤 5:更新 SwaggerConfig.cs 以包含 XmlComments
public static void Register()
{
var thisAssembly = typeof(SwaggerConfig).Assembly;
GlobalConfiguration.Configuration.EnableSwagger(c =>
{
var xmlFile = "bin\\" + $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
c.IncludeXmlComments(xmlPath);
});
}
Run Code Online (Sandbox Code Playgroud)
Step6:向控制器添加XML注释
///<Summary>
/// Get these comments1
///</Summary>
public class ValuesController : ApiController
{
///<Summary>
/// Get these comments2
///</Summary>
public IEnumerable<string> Get()
{
return new string[] { …Run Code Online (Sandbox Code Playgroud) 我有一个 flutter 电子商务应用程序,其中有一个 orderDetails 页面,我想使用 flutter pdf 包将整个页面转换为 pdf,因为数据是从 FirebaseFirestore 检索的,这样会更方便。有什么办法可以实现这一目标吗?
sub:我想使用这个库将整个颤动屏幕转换为pdf
我无法序列化元组。我创建一个模板 VS2019 .Net Core API 项目并将控制器替换为:
[ApiController]
[Route("[controller]")]
public class WeatherForecastController : ControllerBase
{
[HttpGet]
public List<(int number, string text)> Get()
{
var x = new List<(int number, string text)>
{
(1, "one"),
(2, "two"),
(3, "three")
};
return x;
}
/*[HttpGet]
public List<string> Get()
{
var x = new List<string>
{
"one",
"two",
"three"
};
return x;
}*/
}
Run Code Online (Sandbox Code Playgroud)
调用时,第一个方法将返回:[{},{},{}]
第二个方法(未注释时):["one","two","three"]
为什么元组没有序列化?这个例子很容易重现。
我的 ASP.NET Core 应用程序使用“开箱即用”的外部登录身份验证。我想要实现的 - 在 facebook 挑战中,我想包装重定向 url 并将其作为 json 返回以在 jquery 前端使用。但请求结束后,我在浏览器中看到 500 错误,在应用程序控制台中看到下一个错误:
失败:Microsoft.AspNetCore.Server.Kestrel[13] 连接 ID“0HLV651D6KVJC”,请求 ID“0HLV651D6KVJC:00000005”:应用程序抛出了一个未处理的异常。System.InvalidOperationException:响应内容长度不匹配:写入的字节太少(470 个中的 0 个)。
我的外部登录操作,没什么特别看的
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public IActionResult ExternalLogin(string provider, string returnUrl = null)
{
// Request a redirect to the external login provider.
var redirectUrl = Url.Action(nameof(ExternalLoginCallback), "Account", new { returnUrl });
var properties = _signInManager.ConfigureExternalAuthenticationProperties(provider, redirectUrl);
return Challenge(properties, provider);
}
Run Code Online (Sandbox Code Playgroud)
脸书认证配置:
services.AddAuthentication().AddFacebook(facebookOptions =>
{
facebookOptions.AppId = Configuration["Authentication:Facebook:AppId"];
facebookOptions.AppSecret = Configuration["Authentication:Facebook:AppSecret"];
facebookOptions.Events.OnRedirectToAuthorizationEndpoint =
async (x) =>
{
UTF8Encoding …Run Code Online (Sandbox Code Playgroud) 我有带有基于服务帐户的访问权限的节点应用程序,所以我使用了firebase-admin. 正如我之前所看到的,firebase-admin大部分是重复的firebase包(除了身份验证部分、签名和其他一些部分),但现在我想调用函数,但找不到firebase.apps[0].functions().httpsCallable('myFunction'). 我研究了 Typescript 类型,他们甚至没有提到函数。
admin.initializeApp({
credential: admin.credential.cert('./service-account-credentials.json'),
databaseURL: process.env.REACT_APP_FIREBASE_DATABASE_URL,
});
const config = {
storageBucket: process.env.REACT_APP_FIREBASE_STORAGE_BUCKET,
};
const storageBucket = admin.storage().bucket(config.storageBucket);
const firestore = admin.firestore();
// const functions = admin.apps[0].functions(); // not possible
const functions = firebase.apps[0].functions(); // possible, but Firestore.apps not initialized
Run Code Online (Sandbox Code Playgroud)
我有什么选择?
我正在尝试用 C# 创建一个 Discord 机器人,这里的代码会产生一个异常,并显示以下消息:“ServiceCollection”不包含采用 0 个参数的构造函数
_services = new ServiceCollection()
.AddSingleton(_client)
.AddSingleton(_commands)
.BuildServiceProvider();
Run Code Online (Sandbox Code Playgroud)
参考资料(如果有帮助的话)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Services.Description;
using Discord;
using Discord.Commands;
using Discord.WebSocket;
Run Code Online (Sandbox Code Playgroud)
我是编程的初学者,所以任何帮助将不胜感激!
我正在使用 Material Ui 自动完成组件。因此,如果您在该框中写了一些内容,然后单击该输入字段之外的任何位置,您的输入字段文本就会被清除。我该如何解决这个问题?
import React from 'react';
import TextField from '@material-ui/core/TextField';
import Autocomplete, { createFilterOptions } from '@material-ui/lab/Autocomplete';
export default function Filter() {
return (
<Autocomplete
id="filter-demo"
options={top100Films}
getOptionLabel={(option) => option.title}
filterOptions={x => x}
style={{ width: 300 }}
renderInput={(params) => <TextField {...params} label="Custom filter" variant="outlined" />}
/>
);
}
Run Code Online (Sandbox Code Playgroud)
class MyClass {
public MyClass() {}
public override string ToString() {
return String.Format(
"BaseType:\t{0}\nbase.toString:\t{1}",
this.GetType().BaseType.ToString(),
base.ToString());
}
}
static void Main(string[] args) {
MyClass obj = new MyClass();
Console.WriteLine(obj.ToString());
}
Run Code Online (Sandbox Code Playgroud)
结果是:
BaseType: System.Object
base.toString: TestesNET.Program+MyClass
Run Code Online (Sandbox Code Playgroud)
为什么不base.toString显示System.Object?
附加说明:Java 具有相同的行为。
我有一个输入字段,模型中的价格为小数。
<div class="form-group">
<label asp-for="Price" class="control-label">Price</label>
<input asp-for="Price" class="form-control"/>
</div>
Run Code Online (Sandbox Code Playgroud)
[DataType(DataType.Currency)]
[Column(TypeName = "money")]
public decimal Price { get; set; }
Run Code Online (Sandbox Code Playgroud)
当我用逗号发布输入字段时,页面返回验证错误,
当我用句点发布时,价格将作为整数接收。
例如,当我将价格设置为 7.00 时,我的控制器中会收到 700。
asp.net-core ×4
c# ×4
.net-core ×1
asp.net-mvc ×1
firebase ×1
flutter ×1
html ×1
inheritance ×1
material-ui ×1
node.js ×1
reactjs ×1
swagger ×1
swagger-2.0 ×1
tostring ×1