From 3b59ff0bb9c90fc06608ae50d64ecb9fe6b1cf4c Mon Sep 17 00:00:00 2001 From: AnPucel Date: Fri, 11 Nov 2022 14:05:12 -0800 Subject: [PATCH] Make request objects required (#17909) --- changelog/17909.txt | 3 +++ sdk/framework/openapi.go | 2 ++ sdk/framework/testdata/legacy.json | 1 + sdk/framework/testdata/operations.json | 1 + 4 files changed, 7 insertions(+) create mode 100644 changelog/17909.txt diff --git a/changelog/17909.txt b/changelog/17909.txt new file mode 100644 index 0000000000..3f19f94398 --- /dev/null +++ b/changelog/17909.txt @@ -0,0 +1,3 @@ +```release-note:improvement +openapi: Mark request body objects as required +``` diff --git a/sdk/framework/openapi.go b/sdk/framework/openapi.go index 4659f7ae2f..9851948ebb 100644 --- a/sdk/framework/openapi.go +++ b/sdk/framework/openapi.go @@ -146,6 +146,7 @@ type OASParameter struct { type OASRequestBody struct { Description string `json:"description,omitempty"` + Required bool `json:"required,omitempty"` Content OASContent `json:"content,omitempty"` } @@ -391,6 +392,7 @@ func documentPath(p *Path, specialPaths *logical.Paths, requestResponsePrefix st requestName := constructRequestName(requestResponsePrefix, path) doc.Components.Schemas[requestName] = s op.RequestBody = &OASRequestBody{ + Required: true, Content: OASContent{ "application/json": &OASMediaTypeObject{ Schema: &OASSchema{Ref: fmt.Sprintf("#/components/schemas/%s", requestName)}, diff --git a/sdk/framework/testdata/legacy.json b/sdk/framework/testdata/legacy.json index cb1f7ebd3f..f526f1e2aa 100644 --- a/sdk/framework/testdata/legacy.json +++ b/sdk/framework/testdata/legacy.json @@ -38,6 +38,7 @@ "summary": "Synopsis", "tags": ["secrets"], "requestBody": { + "required": true, "content": { "application/json": { "schema": { diff --git a/sdk/framework/testdata/operations.json b/sdk/framework/testdata/operations.json index 097399c02e..e1db674401 100644 --- a/sdk/framework/testdata/operations.json +++ b/sdk/framework/testdata/operations.json @@ -63,6 +63,7 @@ "summary": "Update Summary", "description": "Update Description", "requestBody": { + "required": true, "content": { "application/json": { "schema": {