github.com/dbernstein1/tyk@v2.9.0-beta9-dl-apic+incompatible/apidef/importer/importer.go (about) 1 package importer 2 3 import ( 4 "errors" 5 "io" 6 7 "github.com/TykTechnologies/tyk/apidef" 8 logger "github.com/TykTechnologies/tyk/log" 9 ) 10 11 var log = logger.Get() 12 13 type APIImporter interface { 14 LoadFrom(io.Reader) error 15 ConvertIntoApiVersion(bool) (apidef.VersionInfo, error) 16 InsertIntoAPIDefinitionAsVersion(apidef.VersionInfo, *apidef.APIDefinition, string) error 17 ToAPIDefinition(string, string, bool) (*apidef.APIDefinition, error) 18 } 19 20 type APIImporterSource string 21 22 func GetImporterForSource(source APIImporterSource) (APIImporter, error) { 23 // Extend to add new importers 24 switch source { 25 case ApiaryBluePrint: 26 return &BluePrintAST{}, nil 27 case SwaggerSource: 28 return &SwaggerAST{}, nil 29 case WSDLSource: 30 return &WSDLDef{}, nil 31 default: 32 return nil, errors.New("source not matched, failing") 33 } 34 }