goai_link.go 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  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/gogf/gf.
  6. package goai
  7. import (
  8. "github.com/gogf/gf/v2/internal/json"
  9. )
  10. // Link is specified by OpenAPI/Swagger standard version 3.0.
  11. type Link struct {
  12. OperationID string `json:"operationId,omitempty"`
  13. OperationRef string `json:"operationRef,omitempty"`
  14. Description string `json:"description,omitempty"`
  15. Parameters map[string]interface{} `json:"parameters,omitempty"`
  16. Server *Server `json:"server,omitempty"`
  17. RequestBody interface{} `json:"requestBody,omitempty"`
  18. }
  19. type Links map[string]LinkRef
  20. type LinkRef struct {
  21. Ref string
  22. Value *Link
  23. }
  24. func (r LinkRef) MarshalJSON() ([]byte, error) {
  25. if r.Ref != "" {
  26. return formatRefToBytes(r.Ref), nil
  27. }
  28. return json.Marshal(r.Value)
  29. }