forked from TykTechnologies/tyk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
importer.go
34 lines (28 loc) · 805 Bytes
/
importer.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package importer
import (
"errors"
"io"
"github.com/TykTechnologies/tyk/apidef"
logger "github.com/TykTechnologies/tyk/log"
)
var log = logger.Get()
type APIImporter interface {
LoadFrom(io.Reader) error
ConvertIntoApiVersion(bool) (apidef.VersionInfo, error)
InsertIntoAPIDefinitionAsVersion(apidef.VersionInfo, *apidef.APIDefinition, string) error
ToAPIDefinition(string, string, bool) (*apidef.APIDefinition, error)
}
type APIImporterSource string
func GetImporterForSource(source APIImporterSource) (APIImporter, error) {
// Extend to add new importers
switch source {
case ApiaryBluePrint:
return &BluePrintAST{}, nil
case SwaggerSource:
return &SwaggerAST{}, nil
case WSDLSource:
return &WSDLDef{}, nil
default:
return nil, errors.New("source not matched, failing")
}
}