github.com/wangyougui/gf/v2@v2.6.5/net/goai/goai_link.go (about)

     1  // Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
     2  //
     3  // This Source Code Form is subject to the terms of the MIT License.
     4  // If a copy of the MIT was not distributed with this file,
     5  // You can obtain one at https://github.com/wangyougui/gf.
     6  
     7  package goai
     8  
     9  import (
    10  	"github.com/wangyougui/gf/v2/internal/json"
    11  )
    12  
    13  // Link is specified by OpenAPI/Swagger standard version 3.0.
    14  type Link struct {
    15  	OperationID  string                 `json:"operationId,omitempty"`
    16  	OperationRef string                 `json:"operationRef,omitempty"`
    17  	Description  string                 `json:"description,omitempty"`
    18  	Parameters   map[string]interface{} `json:"parameters,omitempty"`
    19  	Server       *Server                `json:"server,omitempty"`
    20  	RequestBody  interface{}            `json:"requestBody,omitempty"`
    21  }
    22  
    23  type Links map[string]LinkRef
    24  
    25  type LinkRef struct {
    26  	Ref   string
    27  	Value *Link
    28  }
    29  
    30  func (r LinkRef) MarshalJSON() ([]byte, error) {
    31  	if r.Ref != "" {
    32  		return formatRefToBytes(r.Ref), nil
    33  	}
    34  	return json.Marshal(r.Value)
    35  }