protected BaseProjectOptions( DirectoryInfo projectSrcGeneratePath, DirectoryInfo?projectTestGeneratePath, OpenApiDocument openApiDocument, FileInfo openApiDocumentFile, string projectPrefixName, string projectSuffixName, ApiOptions.ApiOptions apiOptions) { if (projectSrcGeneratePath == null) { throw new ArgumentNullException(nameof(projectSrcGeneratePath)); } ProjectName = projectPrefixName ?? throw new ArgumentNullException(nameof(projectPrefixName)); PathForSrcGenerate = projectSrcGeneratePath.Name.StartsWith(ProjectName, StringComparison.OrdinalIgnoreCase) ? projectSrcGeneratePath.Parent ! : projectSrcGeneratePath; if (projectTestGeneratePath != null) { PathForTestGenerate = projectTestGeneratePath.Name.StartsWith(ProjectName, StringComparison.OrdinalIgnoreCase) ? projectTestGeneratePath.Parent ! : projectTestGeneratePath; } Document = openApiDocument ?? throw new ArgumentNullException(nameof(openApiDocument)); DocumentFile = openApiDocumentFile ?? throw new ArgumentNullException(nameof(openApiDocumentFile)); ToolName = "ApiGenerator"; ToolVersion = GenerateHelper.GetAtcToolVersion(); ApiOptions = apiOptions; ApiVersion = GetApiVersion(openApiDocument); ProjectName = projectPrefixName .Replace(" ", ".", StringComparison.Ordinal) .Replace("-", ".", StringComparison.Ordinal) .Trim() + $".{projectSuffixName}"; PathForSrcGenerate = new DirectoryInfo(Path.Combine(PathForSrcGenerate.FullName, ProjectName)); ProjectSrcCsProj = new FileInfo(Path.Combine(PathForSrcGenerate.FullName, $"{ProjectName}.csproj")); if (PathForTestGenerate != null) { PathForTestGenerate = new DirectoryInfo(Path.Combine(PathForTestGenerate.FullName, $"{ProjectName}.Tests")); ProjectTestCsProj = new FileInfo(Path.Combine(PathForTestGenerate.FullName, $"{ProjectName}.Tests.csproj")); } BasePathSegmentNames = OpenApiDocumentHelper.GetBasePathSegmentNames(openApiDocument); }
public ClientCSharpApiProjectOptions( DirectoryInfo projectSrcGeneratePath, string?clientFolderName, OpenApiDocument openApiDocument, FileInfo openApiDocumentFile, string projectPrefixName, string projectSuffixName, bool excludeEndpointGeneration, ApiOptions apiOptions, bool usingCodingRules) { ArgumentNullException.ThrowIfNull(projectSrcGeneratePath); ProjectName = projectPrefixName ?? throw new ArgumentNullException(nameof(projectPrefixName)); PathForSrcGenerate = projectSrcGeneratePath.Name.StartsWith(ProjectName, StringComparison.OrdinalIgnoreCase) ? projectSrcGeneratePath.Parent ! : projectSrcGeneratePath; ForClient = true; ClientFolderName = clientFolderName; Document = openApiDocument ?? throw new ArgumentNullException(nameof(openApiDocument)); DocumentFile = openApiDocumentFile ?? throw new ArgumentNullException(nameof(openApiDocumentFile)); ToolName = "ApiGenerator"; ToolVersion = GenerateHelper.GetAtcToolVersion(); ApiOptions = apiOptions; ProjectName = projectPrefixName .Replace(" ", ".", StringComparison.Ordinal) .Replace("-", ".", StringComparison.Ordinal) .Trim() + $".{projectSuffixName}"; PathForSrcGenerate = new DirectoryInfo(Path.Combine(PathForSrcGenerate.FullName, ProjectName)); ProjectSrcCsProj = new FileInfo(Path.Combine(PathForSrcGenerate.FullName, $"{ProjectName}.csproj")); BasePathSegmentNames = OpenApiDocumentHelper.GetBasePathSegmentNames(openApiDocument); UsingCodingRules = usingCodingRules; ExcludeEndpointGeneration = excludeEndpointGeneration; }
protected BaseProjectOptions( DirectoryInfo projectSrcGeneratePath, DirectoryInfo?projectTestGeneratePath, OpenApiDocument openApiDocument, FileInfo openApiDocumentFile, string projectPrefixName, string?projectSuffixName, ApiOptions apiOptions, bool usingCodingRules, bool forClient = false, string?clientFolderName = null) { ArgumentNullException.ThrowIfNull(projectSrcGeneratePath); ProjectName = projectPrefixName ?? throw new ArgumentNullException(nameof(projectPrefixName)); PathForSrcGenerate = projectSrcGeneratePath.Name.StartsWith(ProjectName, StringComparison.OrdinalIgnoreCase) ? projectSrcGeneratePath.Parent ! : projectSrcGeneratePath; if (projectTestGeneratePath is not null) { PathForTestGenerate = projectTestGeneratePath.Name.StartsWith(ProjectName, StringComparison.OrdinalIgnoreCase) ? projectTestGeneratePath.Parent ! : projectTestGeneratePath; } Document = openApiDocument ?? throw new ArgumentNullException(nameof(openApiDocument)); DocumentFile = openApiDocumentFile ?? throw new ArgumentNullException(nameof(openApiDocumentFile)); ToolName = "ApiGenerator"; ToolVersion = GenerateHelper.GetAtcToolVersion(); ApiOptions = apiOptions; RouteBase = OpenApiDocumentHelper.GetServerUrlBasePath(openApiDocument); ProjectName = string.IsNullOrEmpty(projectSuffixName) ? projectPrefixName .Replace(" ", ".", StringComparison.Ordinal) .Replace("-", ".", StringComparison.Ordinal) .Trim() : projectPrefixName .Replace(" ", ".", StringComparison.Ordinal) .Replace("-", ".", StringComparison.Ordinal) .Trim() + $".{projectSuffixName}"; ProjectPrefixName = ProjectName.Contains('.', StringComparison.Ordinal) ? ProjectName.Substring(0, ProjectName.IndexOf('.', StringComparison.Ordinal)) : ProjectName; PathForSrcGenerate = new DirectoryInfo(Path.Combine(PathForSrcGenerate.FullName, ProjectName)); ProjectSrcCsProj = new FileInfo(Path.Combine(PathForSrcGenerate.FullName, $"{ProjectName}.csproj")); if (PathForTestGenerate is not null) { PathForTestGenerate = new DirectoryInfo(Path.Combine(PathForTestGenerate.FullName, $"{ProjectName}.Tests")); ProjectTestCsProj = new FileInfo(Path.Combine(PathForTestGenerate.FullName, $"{ProjectName}.Tests.csproj")); } this.UsingCodingRules = usingCodingRules; this.IsForClient = forClient; this.ClientFolderName = clientFolderName; BasePathSegmentNames = OpenApiDocumentHelper.GetBasePathSegmentNames(openApiDocument); }