MCPcopy
hub / github.com/swaggo/swag / NewOperation

Function NewOperation

operation.go:58–101  ·  view source on GitHub ↗

|| for compatibility with old version, && for clarity NewOperation creates a new Operation with default properties. map[int]Response.

(parser *Parser, options ...func(*Operation))

Source from the content-addressed store, hash-verified

56// NewOperation creates a new Operation with default properties.
57// map[int]Response.
58func NewOperation(parser *Parser, options ...func(*Operation)) *Operation {
59 if parser == nil {
60 parser = New()
61 }
62
63 result := &Operation{
64 parser: parser,
65 RouterProperties: []RouteProperties{},
66 Operation: spec.Operation{
67 OperationProps: spec.OperationProps{
68 ID: "",
69 Description: "",
70 Summary: "",
71 Security: nil,
72 ExternalDocs: nil,
73 Deprecated: false,
74 Tags: []string{},
75 Consumes: []string{},
76 Produces: []string{},
77 Schemes: []string{},
78 Parameters: []spec.Parameter{},
79 Responses: &spec.Responses{
80 VendorExtensible: spec.VendorExtensible{
81 Extensions: spec.Extensions{},
82 },
83 ResponsesProps: spec.ResponsesProps{
84 Default: nil,
85 StatusCodeResponses: make(map[int]spec.Response),
86 },
87 },
88 },
89 VendorExtensible: spec.VendorExtensible{
90 Extensions: spec.Extensions{},
91 },
92 },
93 codeExampleFilesDir: "",
94 }
95
96 for _, option := range options {
97 option(result)
98 }
99
100 return result
101}
102
103// SetCodeExampleFilesDirectory sets the directory to search for codeExamples.
104func SetCodeExampleFilesDirectory(directoryPath string) func(*Operation) {

Calls 1

NewFunction · 0.70

Used in the wild real call sites across dependent graphs

searching dependent graphs…