func createDefFromSwagger(s *SwaggerAST, orgId, upstreamURL string, as_mock bool) (*tykcommon.APIDefinition, error) { thisAD := tykcommon.APIDefinition{} thisAD.Name = s.Info.Title thisAD.Active = true thisAD.UseKeylessAccess = true thisAD.APIID = uuid.NewUUID().String() thisAD.OrgID = orgId thisAD.VersionDefinition.Key = "version" thisAD.VersionDefinition.Location = "header" thisAD.VersionData.Versions = make(map[string]tykcommon.VersionInfo) thisAD.VersionData.NotVersioned = false thisAD.Proxy.ListenPath = "/" + thisAD.APIID + "/" thisAD.Proxy.StripListenPath = true thisAD.Proxy.TargetURL = upstreamURL if as_mock { log.Warning("Mocks not supported for Swagger definitions, ignoring option") } versionData, err := s.ConvertIntoApiVersion(false) if err != nil { log.Error("Conversion into API Def failed: ", err) } s.InsertIntoAPIDefinitionAsVersion(versionData, &thisAD, strings.Trim(s.Info.Version, " ")) return &thisAD, nil }
func createDefFromBluePrint(bp *BluePrintAST, orgId, upstreamURL string, as_mock bool) (*tykcommon.APIDefinition, error) { thisAD := tykcommon.APIDefinition{} thisAD.Name = bp.Name thisAD.Active = true thisAD.UseKeylessAccess = true thisAD.APIID = uuid.NewUUID().String() thisAD.OrgID = orgId thisAD.VersionDefinition.Key = "version" thisAD.VersionDefinition.Location = "header" thisAD.VersionData.Versions = make(map[string]tykcommon.VersionInfo) thisAD.VersionData.NotVersioned = false thisAD.Proxy.ListenPath = "/" + thisAD.APIID + "/" thisAD.Proxy.StripListenPath = true thisAD.Proxy.TargetURL = upstreamURL versionData, err := bp.ConvertIntoApiVersion(as_mock) if err != nil { log.Error("onversion into API Def failed: ", err) } bp.InsertIntoAPIDefinitionAsVersion(versionData, &thisAD, strings.Trim(bp.Name, " ")) return &thisAD, nil }