http urls monitor.

path_item.go 2.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. import (
  16. "encoding/json"
  17. "github.com/go-openapi/jsonpointer"
  18. "github.com/go-openapi/swag"
  19. )
  20. // PathItemProps the path item specific properties
  21. type PathItemProps struct {
  22. Get *Operation `json:"get,omitempty"`
  23. Put *Operation `json:"put,omitempty"`
  24. Post *Operation `json:"post,omitempty"`
  25. Delete *Operation `json:"delete,omitempty"`
  26. Options *Operation `json:"options,omitempty"`
  27. Head *Operation `json:"head,omitempty"`
  28. Patch *Operation `json:"patch,omitempty"`
  29. Parameters []Parameter `json:"parameters,omitempty"`
  30. }
  31. // PathItem describes the operations available on a single path.
  32. // A Path Item may be empty, due to [ACL constraints](http://goo.gl/8us55a#securityFiltering).
  33. // The path itself is still exposed to the documentation viewer but they will
  34. // not know which operations and parameters are available.
  35. //
  36. // For more information: http://goo.gl/8us55a#pathItemObject
  37. type PathItem struct {
  38. Refable
  39. VendorExtensible
  40. PathItemProps
  41. }
  42. // JSONLookup look up a value by the json property name
  43. func (p PathItem) JSONLookup(token string) (interface{}, error) {
  44. if ex, ok := p.Extensions[token]; ok {
  45. return &ex, nil
  46. }
  47. if token == "$ref" {
  48. return &p.Ref, nil
  49. }
  50. r, _, err := jsonpointer.GetForToken(p.PathItemProps, token)
  51. return r, err
  52. }
  53. // UnmarshalJSON hydrates this items instance with the data from JSON
  54. func (p *PathItem) UnmarshalJSON(data []byte) error {
  55. if err := json.Unmarshal(data, &p.Refable); err != nil {
  56. return err
  57. }
  58. if err := json.Unmarshal(data, &p.VendorExtensible); err != nil {
  59. return err
  60. }
  61. if err := json.Unmarshal(data, &p.PathItemProps); err != nil {
  62. return err
  63. }
  64. return nil
  65. }
  66. // MarshalJSON converts this items object to JSON
  67. func (p PathItem) MarshalJSON() ([]byte, error) {
  68. b3, err := json.Marshal(p.Refable)
  69. if err != nil {
  70. return nil, err
  71. }
  72. b4, err := json.Marshal(p.VendorExtensible)
  73. if err != nil {
  74. return nil, err
  75. }
  76. b5, err := json.Marshal(p.PathItemProps)
  77. if err != nil {
  78. return nil, err
  79. }
  80. concated := swag.ConcatJSON(b3, b4, b5)
  81. return concated, nil
  82. }