Beispiel #1
0
        public override void Handle(Arguments args, DotvvmProjectMetadata dotvvmProjectMetadata)
        {
            var swaggerFile = args[0] ??
                              throw new InvalidCommandUsageException("You have to specify the swagger file.");

            if (!Uri.TryCreate(swaggerFile, UriKind.RelativeOrAbsolute, out var swaggerFileUri))
            {
                throw new InvalidCommandUsageException($"'{swaggerFile}' is not a valid uri.");
            }
            var @namespace = args[1] ??
                             throw new InvalidCommandUsageException("You have to specify the namespace.");
            var csharpFile = args[2] ??
                             throw new InvalidCommandUsageException("You have to specify the csharp output file.");
            var typescriptFile = args[3] ??
                                 throw new InvalidCommandUsageException("You have to specify the typescript output file.");

            ApiClientManager.AddApiClient(swaggerFileUri, @namespace, csharpFile, typescriptFile, dotvvmProjectMetadata);
        }
Beispiel #2
0
        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);
            }
        }
Beispiel #3
0
        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);
            }
        }