NewOpenAPIIndex creates a new OpenAPI index from the embedded spec.
()
| 76 | |
| 77 | // NewOpenAPIIndex creates a new OpenAPI index from the embedded spec. |
| 78 | func NewOpenAPIIndex() (*OpenAPIIndex, error) { |
| 79 | document, err := libopenapi.NewDocument(openAPISpec) |
| 80 | if err != nil { |
| 81 | return nil, err |
| 82 | } |
| 83 | |
| 84 | model, err := document.BuildV3Model() |
| 85 | if err != nil { |
| 86 | return nil, err |
| 87 | } |
| 88 | |
| 89 | idx := &OpenAPIIndex{ |
| 90 | doc: model, |
| 91 | byOperation: make(map[string]*EndpointInfo), |
| 92 | byService: make(map[string][]*EndpointInfo), |
| 93 | keywords: make(map[string][]*EndpointInfo), |
| 94 | } |
| 95 | |
| 96 | idx.parseSpec() |
| 97 | return idx, nil |
| 98 | } |
| 99 | |
| 100 | var permissionRegex = regexp.MustCompile(`Permissions required:\s*([^\n]+)`) |
| 101 |