File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change 1+ package openapi3
2+
3+ import (
4+ "errors"
5+ "fmt"
6+ "reflect"
7+
8+ oas3 "github.com/getkin/kin-openapi/openapi3"
9+ "github.com/grokify/mogo/net/http/httputilmore"
10+ )
11+
12+ type PathItemMore struct {
13+ PathItem * oas3.PathItem
14+ }
15+
16+ func (pm * PathItemMore ) AddPathItemOperations (add * oas3.PathItem , overwriteOpration bool ) error {
17+ if add == nil {
18+ return nil
19+ } else if pm .PathItem == nil {
20+ return errors .New ("path item is not set" )
21+ }
22+ methods := httputilmore .Methods ()
23+ for _ , method := range methods {
24+ opAdd := add .GetOperation (method )
25+ if opAdd == nil {
26+ continue
27+ } else if overwriteOpration {
28+ pm .PathItem .SetOperation (method , opAdd )
29+ } else {
30+ opSrc := pm .PathItem .GetOperation (method )
31+ if opSrc == nil {
32+ pm .PathItem .SetOperation (method , opAdd )
33+ } else if ! reflect .DeepEqual (opAdd , opSrc ) {
34+ return fmt .Errorf ("operation collision on op id (%s)" , opSrc .OperationID )
35+ }
36+ }
37+ }
38+ return nil
39+ }
You can’t perform that action at this time.
0 commit comments