summary refs log tree commit diff
path: root/scripts/schema.js
diff options
context:
space:
mode:
authorMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2023-03-24 04:16:58 +1100
committerMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2023-03-24 04:16:58 +1100
commit0f928e479cbd81b17710da5dad14a092f23cdf0d (patch)
treed885d84ba47d601c4ba064e1cf47d1369198c617 /scripts/schema.js
parentMerge branch 'master' of github.com:fosscord/fosscord-server (diff)
downloadserver-0f928e479cbd81b17710da5dad14a092f23cdf0d.tar.xz
Work towards fixing openapi spec
Diffstat (limited to 'scripts/schema.js')
-rw-r--r--scripts/schema.js34
1 files changed, 28 insertions, 6 deletions
diff --git a/scripts/schema.js b/scripts/schema.js

index be1a7a3f..bd0f73d3 100644 --- a/scripts/schema.js +++ b/scripts/schema.js
@@ -91,9 +91,9 @@ function main() { if (!part) continue; // this is a hack. want some want to check if its a @column, instead - if (part.properties) - Object.keys(part.properties) - .filter((key) => + if (part.properties) { + for (let key in part.properties) { + if ( [ // BaseClass methods "toJSON", @@ -104,9 +104,31 @@ function main() { "recover", "reload", "assign", - ].includes(key), - ) - .forEach((key) => delete part.properties[key]); + ].includes(key) + ) { + delete part.properties[key]; + continue; + } + + if (part.properties[key].anyOf) { + const nullIndex = part.properties[key].anyOf.findIndex( + (x) => x.type == "null", + ); + if (nullIndex != -1) { + part.properties[key].nullable = true; + part.properties[key].anyOf.splice(nullIndex, 1); + + if (part.properties[key].anyOf.length == 1) { + Object.assign( + part.properties[key], + part.properties[key].anyOf[0], + ); + delete part.properties[key].anyOf; + } + } + } + } + } definitions = { ...definitions, [name]: { ...part } }; }