public override void Handle(Arguments args, DotvvmProjectMetadata dotvvmProjectMetadata) { var swaggerFile = args[0]; if (swaggerFile != null) { var apiClient = (Uri.TryCreate(swaggerFile, UriKind.Absolute, out var swaggerFileUri) ? dotvvmProjectMetadata.ApiClients.FirstOrDefault(a => a.SwaggerFile == swaggerFileUri) : null) ?? dotvvmProjectMetadata.ApiClients.FirstOrDefault(a => a.CSharpClient == swaggerFile || a.TypescriptClient == swaggerFile); if (apiClient == null) { throw new InvalidCommandUsageException($"No API client with the following URL or path was found: {swaggerFile}"); } ApiClientManager.RegenApiClient(apiClient, promptOnFileOverwrite: false).Wait(); } else { dotvvmProjectMetadata.ApiClients .Select(c => ApiClientManager.RegenApiClient(c, promptOnFileOverwrite: false)) .ToArray() .ApplyAction(Task.WaitAll); } }
public override void Handle(Arguments args, DotvvmProjectMetadata dotvvmProjectMetadata) { var swaggerFile = args[0]; if (swaggerFile != null) { var apiClient = (Uri.TryCreate(swaggerFile, UriKind.Absolute, out var swaggerFileUri) ? dotvvmProjectMetadata.ApiClients.FirstOrDefault(a => a.SwaggerFile == swaggerFileUri) : null) ?? dotvvmProjectMetadata.ApiClients.FirstOrDefault(a => a.CSharpClient == swaggerFile || a.TypescriptClient == swaggerFile); if (apiClient == null) { throw new InvalidCommandUsageException($"No api client is using {swaggerFile} url or file."); } ApiClientManager.RegenApiClient(apiClient).Wait(); } else { dotvvmProjectMetadata.ApiClients .Select(ApiClientManager.RegenApiClient) .ToArray() .ApplyAction(Task.WaitAll); } }