gpt4 book ai didi

servicestack - 带有 ServiceStack 的 Swagger 不会在 POST 上将元素发送到服务器

转载 作者:行者123 更新时间:2023-12-02 22:09:40 24 4
gpt4 key购买 nike

我有一个简单的 session 对象,看起来像这样

[Route("/Session", Summary = "Creates a security session", Notes = "Some session related notes here")]
public class Session : IReturn<SessionResponse>
{
[ApiMember(Name = "DomainName", Description = "The Security Domain", ParameterType = "path", DataType = "string", IsRequired = true)]
public string DomainName { get; set; }

[ApiMember(Name = "UserName", Description = "The User Name", ParameterType = "path", DataType = "string", IsRequired = true)]
public string UserName { get; set; }

[ApiMember(Name = "Password", Description = "The password", ParameterType = "path", DataType = "string", IsRequired = true)]
public string Password { get; set; }
}

当我进入 swagger UI 时,我可以看到元素

但是,当我输入元素并按立即尝试时,我看到请求内容没有发送到服务器。

我是否使用 parameterType="path"正确配置了我的 poco,或者我应该在这里做其他事情吗?请指教。

最佳答案

是否有关于在不在正文参数定义中看到您的路径参数的情况下让它工作的任何更新?

[Route("/users/{UserId}/races", "POST", Summary = "Associates a race with a user")]
public class AddUserRace : IReturnVoid
{
[ApiMember(Description = "User Id to associate a race with to", ParameterType = "path", Verb="POST", DataType = "int", IsRequired = true)]
public int UserId { get; set; }
[Description("Race Id of race to associate with user")]
public int RaceId { get; set; }
}

Swagger UI Result

理想情况下,由于 UserId 是路径参数,我希望它对 DTO 主体隐藏。

关于servicestack - 带有 ServiceStack 的 Swagger 不会在 POST 上将元素发送到服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15533787/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com