我对restful服务比较新,刚刚实现了测试代码来运行一个带有Swagger插件的ServiceStack restful服务,这就引出了我的问题......
在swagger-ui/index.html中,有一个名为'api_key'的字段。我知道变量名是什么...变量,并且我可以将其设置为任何我喜欢的值,但是我有点困惑它用于什么以及我是否应该使用它。
另外,如果我使用它,ServiceStack如何在服务器端向我呈现该值?
以下是我从文档中得到并成功运行的测试服务:...
在swagger-ui/index.html中,有一个名为'api_key'的字段。我知道变量名是什么...变量,并且我可以将其设置为任何我喜欢的值,但是我有点困惑它用于什么以及我是否应该使用它。
另外,如果我使用它,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 };
}
}
class Hello : IReturn<HelloResponse> ...
- Mike Mertsock