From f84a459d24e7b8d11000bb6e16babdd2bfedfad1 Mon Sep 17 00:00:00 2001 From: Michael Drury Date: Thu, 24 Feb 2022 23:25:03 +0000 Subject: [PATCH] Fixing some errors in the generated spec. --- packages/server/specs/openapi.json | 9 +++------ packages/server/specs/openapi.yaml | 3 --- packages/server/specs/resources/utils/index.js | 7 +++++-- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/packages/server/specs/openapi.json b/packages/server/specs/openapi.json index cb72857fc0..b89bd0617b 100644 --- a/packages/server/specs/openapi.json +++ b/packages/server/specs/openapi.json @@ -941,21 +941,18 @@ }, "query": { "type": "object", - "properties": {}, - "required": [] + "properties": {} }, "user": { "type": "object", - "properties": {}, - "required": [] + "properties": {} }, "userOutput": { "type": "object", "properties": { "user": { "type": "object", - "properties": {}, - "required": [] + "properties": {} } }, "required": [ diff --git a/packages/server/specs/openapi.yaml b/packages/server/specs/openapi.yaml index c8d611950d..a8b2ed4a45 100644 --- a/packages/server/specs/openapi.yaml +++ b/packages/server/specs/openapi.yaml @@ -690,18 +690,15 @@ components: query: type: object properties: {} - required: [] user: type: object properties: {} - required: [] userOutput: type: object properties: user: type: object properties: {} - required: [] required: - user nameSearch: diff --git a/packages/server/specs/resources/utils/index.js b/packages/server/specs/resources/utils/index.js index 606e82051b..9bd0ecc6cf 100644 --- a/packages/server/specs/resources/utils/index.js +++ b/packages/server/specs/resources/utils/index.js @@ -1,8 +1,11 @@ exports.object = (props, opts) => { - return { + const base = { type: "object", properties: props, - required: Object.keys(props), ...opts, } + if (Object.keys(props).length > 0 && (!opts || !opts.required)) { + base.required = Object.keys(props) + } + return base }