我有(超过)两个 Api POST 端点。每个都需要一个 json 作为参数。但是当我在两个端点参数类中使用相同的类名 Payload时,Swagger 不起作用。当我更改其中之一时,例如从Payload更改为Payload1 时,它会起作用。当然,我将正确的命名空间设置到包装类中,以便它找到 Payload。但我希望每次都使用相同的名称“Payload”。如何使用相同的类名Payload? 我可以在两种情况下都保留 json 名称“Payload”,只需为属性设置不同的名称(“Payload1”、“Payload2”)。有用。但是也有相同的属性名称会很好。,
端点 A
[HttpPost()]
公共异步任务 PostPerson([FromBody]JsonWrapperA jsonWrapperA)
namespace myProject.A
{
public class JsonWrapperA
{
[JsonProperty("name", Required = Required.AllowNull)]
public string Name { get; set; }
[JsonProperty("payload", Required = Required.AllowNull)]
public Payload Payload { get; set; }
}
public class Payload
{
[JsonProperty("value", Required = Required.AllowNull)]
public double Value { get; set; }
}
}
Run Code Online (Sandbox Code Playgroud)
端点 …
我有一个用C#和Elasticsearch编写的 .NET Web API 。在 Elasticsearch 上,我有一个索引“ logging ”,我想将我的日志从 API 推送到其中。
我不知道如何将我的日志从 C# API 获取到弹性“日志记录”中。我阅读了诸如Logging with ElasticSearch... 之类的文档,但我的 Elasticsearch 中没有可用的 logstash。所以我正在寻找一个包,它可以帮助我以简单的方式登录。我认为需要交出索引“记录”的,所以它知道在哪里登录。
有人可以为此推荐文档和/或包吗?
还是我需要自己编程?
在我的 DevOps Wiki 中,我有一个页面,想要创建一个包含文章链接的索引。主要是我找到了这个手册来做到这一点:learn.microsoft.com... 但我没有让它工作。
如何在 Wiki 页面内建立链接?你能举个例子吗?
我想我必须为标题设置一个锚点并链接到锚点的索引项?!
这里有一个例子:
Index
1.First article
2.Second article
#1.First article
bla bla bla ...
#2.Second article
bla bla bla ...
and a image
Run Code Online (Sandbox Code Playgroud) GET 请求的响应正文在 Swagger 中显示为短窗口中的文本。由于响应可能很长,而且它是 json,如果它可以折叠,那就太好了。这样我就可以更快地找到一些信息。
如何在 Swagger 中将响应正文显示为可折叠 json?
我有一个C# .NET Core Web API ( REST )。我想实现一个用于上传文件的端点和一个用于下载文件的端点(任何文件类型,如二进制)。设计和代码的最佳实践是什么?到目前为止,我通过搜索引擎找到的内容还算一周。 你有推荐给我吗? 我想我必须将标题(类型,..?)之类的元数据保存在其他地方。可以使搜索文件变得更容易。
在来自微软的链接中,我遇到了问题,它似乎仅适用于我不使用的 MVC API。
后
[HttpPost("UploadFiles")]
public async Task<IActionResult> Post(List<IFormFile> files)
Run Code Online (Sandbox Code Playgroud)
files
是空的。
而这个来自c-sharpcorner 的效果并没有更整洁。我的 Type 目标文件IFormFile
不知道该方法。GetFilename()
。
我有一个服务:
import { EventEmitter, Injectable } from '@angular/core';
@Injectable()
export class PingOnActionListenerService {
removingListener = new EventEmitter();
removeListener(): void {
this.removingListener.emit();
}
Run Code Online (Sandbox Code Playgroud)
在组件 AI 处调用服务:
this._pingOnActionListenerService.removeListener();
Run Code Online (Sandbox Code Playgroud)
在组件BI想要监听服务:
ngOnInit() {
this._pingOnActionListenerService.removingListener.subscribe(this.deactivatelistener());
}
deactivatelistener() {
window.removeEventListener('click', this.pingIfLastPingIsOld);
}
Run Code Online (Sandbox Code Playgroud)
当我运行此代码时,我在控制台上收到错误消息:
core.js:1671 错误 TypeError:generatorOrNext 不是 SafeSubscriber.schedulerFn [as _next] (core.js:3565) 的函数,位于 SafeSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.SafeSubscriber.__tryOrUnsub (Subscriber.js:195) 在 SafeSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.SafeSubscriber.next (Subscriber.js:133) 在 Subscriber.push../node_modules/rxjs/_esm5/internal /Subscriber.js.Subscriber._next (Subscriber.js:77) 在 Subscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next (Subscriber.js:54) 在 EventEmitter.push.. /node_modules/rxjs/_esm5/internal/Subject.js.Subject.next (Subject.js:47) 在 EventEmitter.push../node_modules/@angular/core/fesm5/core.js.EventEmitter.emit (core.js :3537) 在PingOnActionListenerService.push../src/app/core/services/ping-on-action/ping-on-action-listener.service.ts.PingOnActionListenerService.removeListener (ping-on-action-listener.service. ts:19) 在 CatchSubscriber.selector (logging-interceptor.ts:45) 在 CatchSubscriber.push../node_modules/rxjs/_esm5/internal/operators/catchError.js.CatchSubscriber.error (catchError.js:33)
我安装了新的 kubectl,收到消息后:
警告: - kubernetes-cli - kubernetes-cli v1.13.3 已安装。使用 --force 重新安装、指定要安装的版本或尝试升级。
但是当我询问kubectl 版本时 我得到以下信息:
C:\Users\myname> kubectl 版本
客户端版本:version.Info{主要:“1”,次要:“10”,GitVersion:“v1.10.11”,GitCommit:“637c7e288581ee40ab4ca210618a89a555b6e7e9”,GitTreeState:“clean”,BuildDate:“2018-11-26T14:38: 32Z", GoVersion:"go1.9.3", 编译器:"gc", 平台:"windows/amd64"} 服务器版本: version.Info{Major:"1", Minor:"11", GitVersion:"v1.11.5 ", GitCommit:"753b2dbc622f5cc417845f0ff8a77f539a4213ea", GitTreeState:"clean", BuildDate:"2018-11-26T14:31:35Z", GoVersion:"go1.10.3", 编译器:"gc", 平台:"linux/amd64"}
为什么我在版本信息中找不到版本号1.13?
我使用 Angular 5,弹出窗口的标题依赖于布尔值。当属性 isEditing 为 true 时,标题应为“编辑用户”。否则标题应该是“添加用户”。
它的语法是怎样的?
<dxo-popup title="edit user" .../>
Run Code Online (Sandbox Code Playgroud)
我搜索类似的东西:
感谢帮助!坦率
我正在应用Kubernetes CronJob。到目前为止它有效。现在我想添加环境变量。(env:-name ...见下文)尝试应用时出现错误
io.k8s.api.core.v1.EnvVarSource 中的未知字段“configMapRef”
我不喜欢在这里设置所有单打变量。我更喜欢将 configmap 链接到不使变量加倍。如何在 CronJob 文件中设置指向 configmap.yaml 变量的链接,如何编码?
坦率
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: ad-sync
creationTimestamp: 2019-02-15T09:10:20Z
namespace: default
selfLink: /apis/batch/v1beta1/namespaces/default/cronjobs/ad-sync
spec:
concurrencyPolicy: Allow
failedJobsHistoryLimit: 1
successfulJobsHistoryLimit: 3
suspend: false
schedule: "0 */1 * * *"
jobTemplate:
metadata:
labels:
job: ad-sync
spec:
template:
spec:
containers:
- name: ad-sync
image: foo.azurecr.io/foobar/ad-sync
command: ["dotnet", "AdSyncService.dll"]
args: []
env:
- name: AdSyncService
valueFrom:
configMapRef:
name: ad-sync-service-configmap
restartPolicy: OnFailure
Run Code Online (Sandbox Code Playgroud)
我有一个控制台应用程序,它的工作原理像网络api一样退出。我在Program.cs上注册
var collection = new ServiceCollection();
collection.AddScoped<IInfoBusinessComponent, InfoBusinessComponent>();
Run Code Online (Sandbox Code Playgroud)
在添加InfoBusinessComponent之前,InfoBusinessComponent还需要进行依赖项注入。我也注册我的ILogger。
在我的InfoController上,我像这样使用di:
public InfoController(IInfoBusinessComponent businessComponent, ILogger<InfoController> logger)
Run Code Online (Sandbox Code Playgroud)
当我现在呼叫该端点时,我立即收到500响应。当我从控制器中删除参数时,该过程将进入构造函数和控制器。但这不是我想要的。
public InfoController()
Run Code Online (Sandbox Code Playgroud)
为什么构造函数没有得到依赖注入或为什么没有调用构造函数?
public class Program
{
#region fields and propetries
public IConfiguration Configuration { get; }
//# if DEBUG
//#endif
public static IConnection Connection { get; set; }
public static ITimeSeriesBusinessComponent TimeSeriesBusinessComponent { get; set; }
public static IInfoBusinessComponent InfoBusinessComponent { get; set; }
private static int counter;
#endregion fields and propetries
public static void Main(string[] args)
{
IConfiguration config = GetConfigurations();
ILogger …
Run Code Online (Sandbox Code Playgroud) 我用于记录Microsoft.Extensions.Logging 和 NLog。日志写入Elasticsearch。当我使用Kibana查找日志时,所有日志都是在 UT 写入的,这意味着与我的本地时间(时区)MET 相差两个小时。我想查看我的日志以及 Kibana 当地时间。如何调整日志记录的时区?
我添加 NLog.config:
<nlog autoReload="true" throwExceptions="false"
internalLogLevel="Info" internalLogFile="NLogError.log"
xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<targets>
<target name="Logfile" xsi:type="File"
fileName="${basedir}dap.log"
layout="${longdate} ${level} ${callsite} -> ${message} ${exception:format=Message,StackTrace}"
archiveFileName="${basedir}/archives/log.{#}.log"
archiveEvery="Day"
archiveNumbering="Rolling"
maxArchiveFiles="14"
keepFileOpen="false"
/>
<target xsi:type="Network"
name="CentralLog"
newLine ="false"
maxMessageSize="65000"
connectionCacheSize="5"
encoding="utf-8"
keepConnection="false"
maxQueueSize="100"
address="tcp://myurl.org:5544"
onOverflow="Split">
<layout type="JsonLayout">
<attribute name="machinename" layout="${machinename}" />
<attribute name="level" layout="${level:upperCase=true}" />
<attribute name="processname" layout="${processname}" />
<attribute name="processid" layout="${processid}" />
<attribute name="sendertimestamp" layout="${date:universalTime=true:format=yyyy-MM-ddTHH\:mm\:ss.fff}" />
<attribute name="module" layout="dhp DataPickerApi ${logger}" …
Run Code Online (Sandbox Code Playgroud) 我在 Kibana for Elasticsearch 中创建了一个新索引。
开发工具/控制台:
PUT test42
{
"settings" : {
"number_of_shards" : 1
},
"mappings" : {
"_doc" : {
"properties" : {
"field1" : { "type" : "text" }
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
然后我检查所有索引:
GET /_cat/indices?v
Run Code Online (Sandbox Code Playgroud)
并得到一个这样的列表:
健康状态指数...
黄色打开测试黄色打开test42
绿色打开.kibana_1
黄色打开test_index2
黄色打开logging-190409
黄色打开time_series_double_values
当我查看 Kibana / Discover 时,我看不到 test42:
为什么新索引不可用?
我的目标是创建一个用于日志记录的索引模式,如下所述:Logging with ElasticSearch, Kibana, ASP.NET Core and Docker
c# ×3
angular ×2
kubernetes ×2
logging ×2
.net-core ×1
angular6 ×1
asp.net ×1
asp.net-core ×1
azure-devops ×1
json ×1
kibana ×1
nlog ×1
rest ×1
swagger ×1
swagger-ui ×1
timezone ×1