buildTools converts an OpenAPI spec into a list of tools.
(spec *v3.Document)
| 165 | |
| 166 | // buildTools converts an OpenAPI spec into a list of tools. |
| 167 | func (t *ToolSet) buildTools(spec *v3.Document) ([]tools.Tool, error) { |
| 168 | baseURL, err := t.resolveBaseURL(spec) |
| 169 | if err != nil { |
| 170 | return nil, err |
| 171 | } |
| 172 | |
| 173 | var result []tools.Tool |
| 174 | if spec.Paths != nil && spec.Paths.PathItems != nil { |
| 175 | for path, pathItem := range spec.Paths.PathItems.FromOldest() { |
| 176 | for method, op := range pathOperations(pathItem) { |
| 177 | result = append(result, t.operationToTool(baseURL, path, method, op)) |
| 178 | } |
| 179 | } |
| 180 | } |
| 181 | |
| 182 | return result, nil |
| 183 | } |
| 184 | |
| 185 | // pathOperations returns all non-nil operations for a path item. |
| 186 | func pathOperations(item *v3.PathItem) map[string]*v3.Operation { |
no test coverage detected