goai_header.go 739 B

12345678910111213141516171819202122232425262728293031
  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. // Header is specified by OpenAPI/Swagger 3.0 standard.
  11. // See https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.0.md#headerObject
  12. type Header struct {
  13. Parameter
  14. }
  15. type Headers map[string]HeaderRef
  16. type HeaderRef struct {
  17. Ref string
  18. Value *Header
  19. }
  20. func (r HeaderRef) MarshalJSON() ([]byte, error) {
  21. if r.Ref != "" {
  22. return formatRefToBytes(r.Ref), nil
  23. }
  24. return json.Marshal(r.Value)
  25. }