| All Verbs | /hello | ||
|---|---|---|---|
| All Verbs | /hello/{Name} |
import Foundation
import ServiceStack
public class Hello : IHasVersion, Codable
{
public var name:String
public var version:Int
required public init(){}
}
public class HelloResponse : BaseResponse
{
public var data:HelloResponseData
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case data
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
data = try container.decodeIfPresent(HelloResponseData.self, forKey: .data)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if data != nil { try container.encode(data, forKey: .data) }
}
}
// @DataContract
public class BaseResponse : Codable
{
// @DataMember(Name="responseStatus")
public var responseStatus:ResponseStatus
required public init(){}
}
public class HelloResponseData : Codable
{
public var greeting:String
required public init(){}
}
To override the Content-type in your clients, use the HTTP Accept Header, append the .other suffix or ?format=other
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
POST /hello HTTP/1.1
Host: geniuslink-markable-api.qa.platform.georiot.com
Accept: text/jsonl
Content-Type: text/jsonl
Content-Length: length
{"name":"String","version":0}
HTTP/1.1 200 OK
Content-Type: text/jsonl
Content-Length: length
{"data":{"greeting":"String"},"responseStatus":{"errorCode":"String","message":"String","stackTrace":"String","errors":[{"errorCode":"String","fieldName":"String","message":"String","meta":{"String":"String"}}],"meta":{"String":"String"}}}