本站源代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 lines
1.9KB

  1. // Copyright 2015 go-swagger maintainers
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. package spec
  15. // XMLObject a metadata object that allows for more fine-tuned XML model definitions.
  16. //
  17. // For more information: http://goo.gl/8us55a#xmlObject
  18. type XMLObject struct {
  19. Name string `json:"name,omitempty"`
  20. Namespace string `json:"namespace,omitempty"`
  21. Prefix string `json:"prefix,omitempty"`
  22. Attribute bool `json:"attribute,omitempty"`
  23. Wrapped bool `json:"wrapped,omitempty"`
  24. }
  25. // WithName sets the xml name for the object
  26. func (x *XMLObject) WithName(name string) *XMLObject {
  27. x.Name = name
  28. return x
  29. }
  30. // WithNamespace sets the xml namespace for the object
  31. func (x *XMLObject) WithNamespace(namespace string) *XMLObject {
  32. x.Namespace = namespace
  33. return x
  34. }
  35. // WithPrefix sets the xml prefix for the object
  36. func (x *XMLObject) WithPrefix(prefix string) *XMLObject {
  37. x.Prefix = prefix
  38. return x
  39. }
  40. // AsAttribute flags this object as xml attribute
  41. func (x *XMLObject) AsAttribute() *XMLObject {
  42. x.Attribute = true
  43. return x
  44. }
  45. // AsElement flags this object as an xml node
  46. func (x *XMLObject) AsElement() *XMLObject {
  47. x.Attribute = false
  48. return x
  49. }
  50. // AsWrapped flags this object as wrapped, this is mostly useful for array types
  51. func (x *XMLObject) AsWrapped() *XMLObject {
  52. x.Wrapped = true
  53. return x
  54. }
  55. // AsUnwrapped flags this object as an xml node
  56. func (x *XMLObject) AsUnwrapped() *XMLObject {
  57. x.Wrapped = false
  58. return x
  59. }
上海开阖软件有限公司 沪ICP备12045867号-1