ParseCodeSample parse code sample.
(attribute, _, lineRemainder string)
| 168 | |
| 169 | // ParseCodeSample parse code sample. |
| 170 | func (operation *Operation) ParseCodeSample(attribute, _, lineRemainder string) error { |
| 171 | if lineRemainder == "file" { |
| 172 | data, err := getCodeExampleForSummary(operation.Summary, operation.codeExampleFilesDir) |
| 173 | if err != nil { |
| 174 | return err |
| 175 | } |
| 176 | |
| 177 | var valueJSON interface{} |
| 178 | |
| 179 | err = json.Unmarshal(data, &valueJSON) |
| 180 | if err != nil { |
| 181 | return fmt.Errorf("annotation %s need a valid json value", attribute) |
| 182 | } |
| 183 | |
| 184 | // don't use the method provided by spec lib, because it will call toLower() on attribute names, which is wrongly |
| 185 | operation.Extensions[attribute[1:]] = valueJSON |
| 186 | |
| 187 | return nil |
| 188 | } |
| 189 | |
| 190 | // Fallback into existing logic |
| 191 | return operation.ParseMetadata(attribute, strings.ToLower(attribute), lineRemainder) |
| 192 | } |
| 193 | |
| 194 | // ParseStateComment parse state comment. |
| 195 | func (operation *Operation) ParseStateComment(lineRemainder string) { |
no test coverage detected