Forum Discussion

cbet's avatar
cbet
New Member
6 years ago

Does response type must match `type` parameter of property in swagger.json?

Let's assume we have specified an object like this:

"Topic" : {
            "type" : "object",
            "required" : [ "id" ],
            "properties" : {
                "id" : {
                    "type" : "string"
                },
                "title" : {
                    "type" : "string"
                },
                "text" : {
                    "type" : "string"
                },
"timestamp" : {
"type" : "integer",
"format" : "int64"
} } }

with server response like this:

{
    "id": "348750893475",
    "title": "Title",
    "text": "Info text",
    "timestamp": "15628369075436"
}

Is it swagger contract violation that `timestamp` resonse type is `string`?
Should client try by himself recognize that `timestamp` is string and convert such string to number?
Is following `type` property of swagger.json in server resonse is required and a must?

 

  • It is a violation, yes. How it should be handled is entirely up to the client. I'd recommend trying to fix the documentation.