public ClientCSharpApiGenerator(ClientCSharpApiProjectOptions projectOptions)
 {
     this.projectOptions    = projectOptions ?? throw new ArgumentNullException(nameof(projectOptions));
     this.apiProjectOptions = new ApiProjectOptions(
         projectOptions.PathForSrcGenerate,
         projectTestGeneratePath: null,
         projectOptions.Document,
         projectOptions.DocumentFile,
         projectOptions.ProjectName,
         projectSuffixName: null,
         projectOptions.ApiOptions,
         projectOptions.ForClient,
         projectOptions.ClientFolderName);
 }
Exemple #2
0
    public ClientCSharpApiGenerator(
        ILogger logger,
        ClientCSharpApiProjectOptions projectOptions)
    {
        this.logger         = logger ?? throw new ArgumentNullException(nameof(logger));
        this.projectOptions = projectOptions ?? throw new ArgumentNullException(nameof(projectOptions));

        this.apiProjectOptions = new ApiProjectOptions(
            projectOptions.PathForSrcGenerate,
            projectTestGeneratePath: null,
            projectOptions.Document,
            projectOptions.DocumentFile,
            projectOptions.ProjectName,
            projectSuffixName: null,
            projectOptions.ApiOptions,
            projectOptions.UsingCodingRules,
            projectOptions.ForClient,
            projectOptions.ClientFolderName);

        this.ExcludeEndpointGeneration = projectOptions.ExcludeEndpointGeneration;
    }
        public static List <LogKeyValueItem> GenerateServerCSharpClient(
            string projectPrefixName,
            string?clientFolder,
            DirectoryInfo outputPath,
            Tuple <OpenApiDocument, OpenApiDiagnostic, FileInfo> apiDocument,
            ApiOptions apiOptions)
        {
            if (projectPrefixName == null)
            {
                throw new ArgumentNullException(nameof(projectPrefixName));
            }

            if (outputPath == null)
            {
                throw new ArgumentNullException(nameof(outputPath));
            }

            if (apiDocument == null)
            {
                throw new ArgumentNullException(nameof(apiDocument));
            }

            if (apiOptions == null)
            {
                throw new ArgumentNullException(nameof(apiOptions));
            }

            var clientCSharpApiProjectOptions = new ClientCSharpApiProjectOptions(
                outputPath,
                clientFolder,
                apiDocument.Item1,
                apiDocument.Item3,
                projectPrefixName,
                "ApiClient.Generated",
                apiOptions);
            var clientCSharpApiGenerator = new ClientCSharpApiGenerator(clientCSharpApiProjectOptions);

            return(clientCSharpApiGenerator.Generate());
        }