1 // Copyright 2015 go-swagger maintainers
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
7 // http://www.apache.org/licenses/LICENSE-2.0
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.
20 "github.com/go-openapi/jsonpointer"
21 "github.com/go-openapi/swag"
24 // PathItemProps the path item specific properties
25 type PathItemProps struct {
26 Get *Operation `json:"get,omitempty"`
27 Put *Operation `json:"put,omitempty"`
28 Post *Operation `json:"post,omitempty"`
29 Delete *Operation `json:"delete,omitempty"`
30 Options *Operation `json:"options,omitempty"`
31 Head *Operation `json:"head,omitempty"`
32 Patch *Operation `json:"patch,omitempty"`
33 Parameters []Parameter `json:"parameters,omitempty"`
36 // PathItem describes the operations available on a single path.
37 // A Path Item may be empty, due to [ACL constraints](http://goo.gl/8us55a#securityFiltering).
38 // The path itself is still exposed to the documentation viewer but they will
39 // not know which operations and parameters are available.
41 // For more information: http://goo.gl/8us55a#pathItemObject
42 type PathItem struct {
48 // JSONLookup look up a value by the json property name
49 func (p PathItem) JSONLookup(token string) (interface{}, error) {
50 if ex, ok := p.Extensions[token]; ok {
56 r, _, err := jsonpointer.GetForToken(p.PathItemProps, token)
60 // UnmarshalJSON hydrates this items instance with the data from JSON
61 func (p *PathItem) UnmarshalJSON(data []byte) error {
62 if err := json.Unmarshal(data, &p.Refable); err != nil {
65 if err := json.Unmarshal(data, &p.VendorExtensible); err != nil {
68 return json.Unmarshal(data, &p.PathItemProps)
71 // MarshalJSON converts this items object to JSON
72 func (p PathItem) MarshalJSON() ([]byte, error) {
73 b3, err := json.Marshal(p.Refable)
77 b4, err := json.Marshal(p.VendorExtensible)
81 b5, err := json.Marshal(p.PathItemProps)
85 concated := swag.ConcatJSON(b3, b4, b5)