extensions.go 723 B

123456789101112131415161718192021
  1. package restful
  2. // Copyright 2021 Ernest Micklei. All rights reserved.
  3. // Use of this source code is governed by a license
  4. // that can be found in the LICENSE file.
  5. // ExtensionProperties provides storage of vendor extensions for entities
  6. type ExtensionProperties struct {
  7. // Extensions vendor extensions used to describe extra functionality
  8. // (https://swagger.io/docs/specification/2-0/swagger-extensions/)
  9. Extensions map[string]interface{}
  10. }
  11. // AddExtension adds or updates a key=value pair to the extension map.
  12. func (ep *ExtensionProperties) AddExtension(key string, value interface{}) {
  13. if ep.Extensions == nil {
  14. ep.Extensions = map[string]interface{}{key: value}
  15. } else {
  16. ep.Extensions[key] = value
  17. }
  18. }