cancel
Showing results for 
Search instead for 
Did you mean: 

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

New Member

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?

 

Tags (3)
1 REPLY 1
Moderator

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

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


Did my reply answer your question? Give Kudos or Accept it as a Solution to help others.↓↓↓↓↓