小编Yoa*_*eva的帖子

不支持没有无参数构造函数的引用类型的反序列化

我有这个 API

 public ActionResult AddDocument([FromBody]AddDocumentRequestModel documentRequestModel)
        {
            AddDocumentStatus documentState = _documentService.AddDocument(documentRequestModel, DocumentType.OutgoingPosShipment);
            if (documentState.IsSuccess)
                return Ok();

            return BadRequest();
        }
Run Code Online (Sandbox Code Playgroud)

这是我的请求模型

    public class AddDocumentRequestModel
    {
        public AddDocumentRequestModel(int partnerId, List<ProductRequestModel> products)
        {
            PartnerId = partnerId;
            Products = products;
        }

        [Range(1, int.MaxValue, ErrorMessage = "Value for {0} must be between {1} and {2}.")]
        public int PartnerId { get; private set; }

        [Required, MustHaveOneElement(ErrorMessage = "At least one product is required")]
        public List<ProductRequestModel> Products { get; private set; }
    }
Run Code Online (Sandbox Code Playgroud)

所以当我试图用这个身体点击 API 时

{ …
Run Code Online (Sandbox Code Playgroud)

serialization json-deserialization .net-core-3.0

21
推荐指数
3
解决办法
2万
查看次数

是否有 &lt;NonBodyParameter&gt; 等效项

我更新了 Swashbuckle v5 并且 operation.Parameters() 不再有效。是否有替代品?

        {
            var apiDescription = context.ApiDescription;

            operation.Deprecated |= apiDescription.IsDeprecated();

            if (operation.Parameters == null)
            {
                return;
            }

            // REF: https://github.com/domaindrivendev/Swashbuckle.AspNetCore/issues/412
            // REF: https://github.com/domaindrivendev/Swashbuckle.AspNetCore/pull/413
            foreach (var parameter in operation.Parameters<NonBodyParameter>())
            {

                var description = apiDescription.ParameterDescriptions.First(p => p.Name == parameter.Name);

                if (parameter.Description == null)
                {
                    parameter.Description = description.ModelMetadata?.Description;
                }

                if (parameter.Default == null)
                {
                    parameter.Default = description.DefaultValue;
                }

                parameter.Required |= description.IsRequired;
            }
        }
Run Code Online (Sandbox Code Playgroud)

错误 CS0307 属性“OpenApiOperation.Parameters”不能与类型参数一起使用

swagger swashbuckle .net-core-3.0

7
推荐指数
1
解决办法
2857
查看次数

Lucene Term 和 Fields 的区别

我读了很多关于 Lucene 索引和搜索的内容,但仍然不明白 Term 是什么?term 和 fields 之间有什么区别?

lucene lucene.net search-engine

5
推荐指数
1
解决办法
924
查看次数