openapi: Use at most one inline subschema in allOf.

This fixes some of the warnings from openapi-generator.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg
2020-09-30 18:52:34 -07:00
parent 07bba28889
commit cf5ededa35
2 changed files with 63 additions and 52 deletions

View File

@@ -10,6 +10,17 @@ const SwaggerParser = require("swagger-parser");
function checkRefSiblings(file, path, data) {
let ok = true;
if (typeof data === "object" && data !== null) {
if (
"allOf" in data &&
Object.values(data.allOf).filter((subschema) => !("$ref" in subschema)).length !== 1
) {
console.error(
`${file}: Too many inline allOf subschemas at ${JSON.stringify(
path,
)}: ${JSON.stringify(data, undefined, 2)}`,
);
ok = false;
}
if ("$ref" in data && Object.entries(data).length !== 1) {
console.error(
`${file}: Siblings of $ref have no effect at ${JSON.stringify(