goai_callback.go 664 B

12345678910111213141516171819202122232425262728
  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. // Callback is specified by OpenAPI/Swagger standard version 3.0.
  11. type Callback map[string]*Path
  12. type Callbacks map[string]*CallbackRef
  13. type CallbackRef struct {
  14. Ref string
  15. Value *Callback
  16. }
  17. func (r CallbackRef) MarshalJSON() ([]byte, error) {
  18. if r.Ref != "" {
  19. return formatRefToBytes(r.Ref), nil
  20. }
  21. return json.Marshal(r.Value)
  22. }