discord-api-spec
discord-api-spec copied to clipboard
Improve create message route
Currently, the create message route is... kinda sucky:
https://github.com/discord/discord-api-spec/blob/bab7bf1988b7a49fb8f45fae936126122d0a25e4/specs/openapi.json#L4496-L4537
This could be better expressed as:
"patternProperties": {
"^files\\[[0-9]+\\]$": {
"type": "string",
"contentEncoding": "binary"
}
}
using patternProperties
.
🤔 pretty sure the ID can be any snowflake as well
Yeah this uses a regex to say the number is any sequence of digits. I would use \d
but that's not in the restricted subset of regex JSON schema recommends :(
This is a technical limitation needed to express that we don't accept unlimited uploads in a single request. (In general, for requests, I'd prefer that the spec expresses a subset rather than a superset of allowed inputs, if it can't be exactly precise).
How about using maxProperties
then? IIRC you can only send the payload_json
key for the form body (... maybe I'm misremembering?) so just set the max number of properties to the max amount of files + 1? (... or maybe without the +1?).
i think we currently accept body properties as form properties (but if payload_json is present, they all have to be in there instead)? i could be wrong as well
I checked, you're correct. Maybe there should be an oneOf
where one branch allows only these fixed names and no payload_json
, and the other branch allows any file numbers and only an extra payload_json
field?
(I imagine "the other branch" is the significantly more common case; that's how I've implemented things before :P)