我对 RESTful 服务还很陌生,我刚刚实现了测试代码以使 ServiceStack RESTful 服务与 Swagger 插件一起工作,这让我想到了我的问题......
在 swagger-ui/index.html 中有一个“api_key”字段。我知道变量名是 umm... 变量,我也可以随意设置它,但我有点困惑它的用途以及我是否应该使用它。
另外,如果我确实使用它,servicestack 如何在服务器端向我呈现该值?
这是我从文档中启动并运行的测试服务...
[Api("Hello Web Services")]
[Route("/Hello", Summary = @"Noel's ServiceStackSwagger thingy", Notes = "Some more info in here cause these are notes")]
[Route("/Hello/{name}", Summary = @"N031'5 ServiceStackSwagger thingy", Notes = "Some more info in here cause these are notes", Verbs="GET,POST" )]
public class Hello
{
[ApiMember(Name = "Name", Description = "This is a description", ParameterType = "path", DataType = "string", Verb="GET,POST")]
public string Name { get; set; }
}
public class HelloResponse
{
public string Result { get; set; }
}
public class HelloService : Service
{
public object Any(Hello request)
{
return new HelloResponse { Result = "Hello, " + request.Name };
}
}