From 76b551f8185652ffd94b0a264f585e2c1e72d9d6 Mon Sep 17 00:00:00 2001 From: Jim Kalafut Date: Wed, 19 Jun 2019 16:48:58 -0700 Subject: [PATCH] Add new structures for OpenAPI/UI enhancements (#6931) --- sdk/framework/backend.go | 4 ++++ sdk/framework/path.go | 30 ++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/sdk/framework/backend.go b/sdk/framework/backend.go index 0cc0aac78b..e56c91a7bd 100644 --- a/sdk/framework/backend.go +++ b/sdk/framework/backend.go @@ -543,6 +543,10 @@ type FieldSchema struct { // DisplaySensitive indicates that the value should be masked by default in the UI. DisplaySensitive bool + + // DisplayAttrs provides hints for UI and documentation generators. They + // will be included in OpenAPI output if set. + DisplayAttrs *DisplayAttributes } // DefaultOrZero returns the default value if it is set, or otherwise diff --git a/sdk/framework/path.go b/sdk/framework/path.go index 419ce34f6c..744a696603 100644 --- a/sdk/framework/path.go +++ b/sdk/framework/path.go @@ -112,6 +112,10 @@ type Path struct { // be automatically line-wrapped at 80 characters. HelpSynopsis string HelpDescription string + + // DisplayAttrs provides hints for UI and documentation generators. They + // will be included in OpenAPI output if set. + DisplayAttrs *DisplayAttributes } // OperationHandler defines and describes a specific operation handler. @@ -148,6 +152,32 @@ type OperationProperties struct { // Deprecated indicates that this operation should be avoided. Deprecated bool + + // DisplayAttrs provides hints for UI and documentation generators. They + // will be included in OpenAPI output if set. + DisplayAttrs *DisplayAttributes +} + +type DisplayAttributes struct { + // Name is the name of the field suitable as a label or documentation heading. + Name string `json:"name,omitempty"` + + // Value is a sample value to display for this field. This may be used + // to indicate a default value, but it is for display only and completely separate + // from any Default member handling. + Value interface{} `json:"value,omitempty"` + + // Sensitive indicates that the value should be masked by default in the UI. + Sensitive bool `json:"sensitive,omitempty"` + + // Navigation indicates that the path should be available as a navigation tab + Navigation bool `json:"navigation,omitempty"` + + // Group is the suggested UI group to place this field in. + Group string `json:"group,omitempty"` + + // Action is the verb to use for the operation. + Action string `json:"action,omitempty"` } // RequestExample is example of request data.