OpenAPI-Specification icon indicating copy to clipboard operation
OpenAPI-Specification copied to clipboard

how to define the array with serial data

Open beaquant opened this issue 5 years ago • 7 comments
trafficstars

I'm try to define a oai spec for a rest api. but I don't know how to define the array with serial data response as followed

{
  "status": 0,
  "data": {
    "type": "ticker.btcusdt",
    "seq": 123,
    "ticker": [
      7140.890000000000000000,//latest
      1.000000000000000000,//volumn
      7131.330000000,//best bid
      233.524600000,//best bid amount
      7140.890000000,//best ask
      225.495049866//best ask amount
    ]
  }
}
{
  "status":0,
  "data":{
    "type": "depth.ethbtc",
    "ts": 1523611111000,
    "seq": 456,
    "bids": [0.000100000/*price*/, 1.000000000/*amount*/, 0.000010000/*price*/, 1.000000000/*amount*/],
    "asks": [1.000000000/*price*/, 1.000000000/*amount*/]
  }
}

how to define the ticker and bids/asks, thanks a lot

beaquant avatar Dec 07 '19 01:12 beaquant

That's not a valid JSON, as JSON does not allow comments. Assuming the comments are not really part of the JSON, what have you tried so far?

webron avatar Dec 08 '19 17:12 webron

That's not a valid JSON, as JSON does not allow comments. Assuming the comments are not really part of the JSON, what have you tried so far?

thanks @webron yes, the comments just describe the data meaning.

I tried to use these as followed

        "OrderBook": {
            "properties": {
                "status": {
                    "format": "int64",
                    "type": "number"
                },
                "data": {
                    "default": {},
                    "$ref": "#/definitions/OrderBookL2"
                }
            }
        },
        "OrderBookL2": {
            "properties": {
                "type": {
                    "type": "string"
                },
                "ts": {
                    "format": "int64",
                    "type": "integer"
                },
                "seq": {
                    "format": "int64",
                    "type": "integer"
                },
                "bids": {
                    "type": "array",
                    "items": {
	                    "format": "double",
	                    "type": "number"
                    }
                },
                "asks": {
                    "type": "array",
                    "items": {
	                    "format": "double",
	                    "type": "number"
                    }
                }
            },
            "required": ["symbol", "ts", "seq", "bids", "asks"],
            "type": "object"
        }

I don't know how to define asks and bids

beaquant avatar Dec 09 '19 01:12 beaquant

It looks like you defined asks and bids fine, what makes you think that's not working?

webron avatar Dec 09 '19 01:12 webron

It looks like you defined asks and bids fine, what makes you think that's not working?

yes, it work, but I want it have members which are price and amount in asks and bids

beaquant avatar Dec 09 '19 06:12 beaquant

@webron could you help me, please

beaquant avatar Dec 10 '19 09:12 beaquant

These look like floating point numbers, what is unusual about them that needs special handling?

handrews avatar Jan 27 '24 02:01 handrews

This issue has been labeled with No recent activity because there has been no recent activity. It will be closed if no further activity occurs within 28 days. Please re-open this issue or open a new one after this delay if you need to.

github-actions[bot] avatar Feb 04 '24 20:02 github-actions[bot]