我使用来自jsonapi.org的JSONAPI规范,然后我使用JsonApiSerializer来完成 JSONAPI 规范,所以我的响应和请求正文如下所示:
{
"data": {
"type": "articles",
"id": "stringId",
"attributes": {
"title": "JSON:API paints my bikeshed!"
}
}
Run Code Online (Sandbox Code Playgroud)
我有一个实体“文章”,它看起来像:
public class Article
{
public string Id { get; set; }
public string title { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
然后我尝试使用Swashbuckle Swagger来记录我的 API,但在Swagger UI 中,我的示例请求和响应正文如下所示:
{
"id": "string",
"title": "string"
}
Run Code Online (Sandbox Code Playgroud)
我认为 swagger 忽略了JsonApiSerializer,有没有办法更改 swagger 的默认序列化程序并使用我自己的序列化程序?
我的 Startup.cs 看起来像:
public class Startup
{
public Startup(IConfiguration configuration)
{
this.Configuration = …Run Code Online (Sandbox Code Playgroud)