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

Method ParseMetadata

operation.go:211–230  ·  view source on GitHub ↗

ParseMetadata parse metadata.

(attribute, lowerAttribute, lineRemainder string)

Source from the content-addressed store, hash-verified

209
210// ParseMetadata parse metadata.
211func (operation *Operation) ParseMetadata(attribute, lowerAttribute, lineRemainder string) error {
212 // parsing specific meta data extensions
213 if strings.HasPrefix(lowerAttribute, "@x-") {
214 if len(lineRemainder) == 0 {
215 return fmt.Errorf("annotation %s need a value", attribute)
216 }
217
218 var valueJSON interface{}
219
220 err := json.Unmarshal([]byte(lineRemainder), &valueJSON)
221 if err != nil {
222 return fmt.Errorf("annotation %s need a valid json value", attribute)
223 }
224
225 // don't use the method provided by spec lib, because it will call toLower() on attribute names, which is wrongly
226 operation.Extensions[attribute[1:]] = valueJSON
227 }
228
229 return nil
230}
231
232var paramPattern = regexp.MustCompile(`(\S+)\s+(\w+)\s+([\S. ]+?)\s+(\w+)\s+"([^"]+)"`)
233

Callers 2

ParseCommentMethod · 0.95
ParseCodeSampleMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected