protected override bool ExecuteInner() { var specificationFiles = SpecificationFiles.Select(x => x.GetMetadata("Fullpath")).ToList(); var repository = ControlFlow.SuppressErrors(() => GitRepository.FromLocalDirectory(BaseDirectory)); string GetFilePath(Tool tool) => (AbsolutePath)BaseDirectory / (UseNestedNamespaces ? tool.Name : ".") / tool.DefaultOutputFileName; string GetNamespace(Tool tool) => !UseNestedNamespaces ? BaseNamespace : string.IsNullOrEmpty(BaseNamespace) ? tool.Name : $"{BaseNamespace}.{tool.Name}"; string GetSourceFile(Tool tool) => repository.IsGitHubRepository() ? repository?.GetGitHubDownloadUrl(tool.SpecificationFile) : null; specificationFiles .ForEachLazy(x => LogMessage(message: $"Handling {x} ...")) .ForEach(x => CodeGenerator.GenerateCode(x, GetFilePath, GetNamespace, GetSourceFile)); if (UpdateReferences) { ReferenceUpdater.UpdateReferences(specificationFiles); } return(true); }
public bool Execute() { var specificationFiles = SpecificationFiles.Select(x => x.GetMetadata("Fullpath")).ToList(); var repository = ControlFlow.SuppressErrors(() => GitRepository.FromLocalDirectory(BaseDirectory)); CodeGenerator.GenerateCode( specificationFiles, outputFileProvider: x => (AbsolutePath)BaseDirectory / (UseNestedNamespaces ? x.Name : ".") / x.DefaultOutputFileName, namespaceProvider: x => !UseNestedNamespaces ? BaseNamespace : string.IsNullOrEmpty(BaseNamespace) ? x.Name : $"{BaseNamespace}.{x.Name}", sourceFileProvider: x => repository.IsGitHubRepository() ? repository?.GetGitHubDownloadUrl(x.SpecificationFile) : null); if (UpdateReferences) { ReferenceUpdater.UpdateReferences(specificationFiles); } return(true); }
private RestSpecMapping CreateMapping(FileInfo file) { var typeName = Path.GetFileNameWithoutExtension(file.Name); if (SkipRequestImplementation(typeName)) { return(null); } var specFileName = typeName.Replace("Request", ""); if (!_badDescriptorFors.Contains(typeName)) { specFileName = FindDescriptorForRemapping(file, specFileName); } specFileName = specFileName.SnakeCase().Replace("_", ".").Replace("async.search", "async_search"); do { if (SpecificationFiles.TryGetValue(specFileName, out var f)) { return new RestSpecMapping { TypeName = $"I{typeName}", Json = f } } }; while (TryGetSpecTarget(specFileName, out specFileName)) { ; }