-
Hello community, I'd like to describe a service running over Socket.IO protocol (uses Websocket for transport) using AsyncAPI v3.0.0. The payloads of the Socket.IO messages are tuples — arrays having fixed length and the elements of different types. JSON Schema Draft 2020 offers the What would be your advice on describing a payload like this?: type ChatMessage = [ string, { from: string } ] So far I invented a hacky approach of describing those tuples as objects having numeric props, because arrays are objects in JavaScript. payload:
type: object
format: tuple
properties:
"0":
type: string
description: message
examples:
- Hello there!
"1":
type: object
properties:
from:
type: string
description: the ID of author
required:
- from
description: extra info
examples:
- from: 123abc
required:
- "0"
- "1"
additionalProperties: false What would be a community advice on that topic? Is there a better way? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
The JSON Schema Draft-07, which is per my understanding Async API is based on, also say that |
Beta Was this translation helpful? Give feedback.
I figured out what was the issue with
items
approach — it does work, but for non-empty tuples only.If
items
is an empty array, validator of Studio shows a huge pile of errors pointing to wrong lines.But once I restricted
items
to describe only non-empty tuples, it began working as expected:Here is my implementation for those might having similar issue: