Skip to content

Commit

Permalink
Merge pull request #3493 from microsoft/feature/vs-code-config
Browse files Browse the repository at this point in the history
feature/vs code config
  • Loading branch information
baywet authored Oct 19, 2023
2 parents 1fc52ea + 368802f commit bcb1492
Show file tree
Hide file tree
Showing 23 changed files with 538 additions and 77 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added

- Added support for enum query parameter types. [#2490](https://github.com/microsoft/kiota/issues/2490)
- Added settings in the vscode extension for: backingStore, additionalData, excludeBackwardCompatible, cleanOutput, clearCache, serializers, deserializers, disabledValidationRules, structuredMimeTypes. [#3355](https://github.com/microsoft/kiota/issues/3355)
- Support for primary error message in PHP [#3276](https://github.com/microsoft/kiota/issues/3276)
- Support for primary error message in Python [#3277](https://github.com/microsoft/kiota/issues/3277)

Expand Down
12 changes: 6 additions & 6 deletions src/kiota/Rpc/IServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ internal interface IServer
{
LanguagesInformation Info();
string GetVersion();
Task<List<LogEntry>> UpdateAsync(string output, CancellationToken cancellationToken);
Task<SearchOperationResult> SearchAsync(string searchTerm, CancellationToken cancellationToken);
Task<ShowResult> ShowAsync(string descriptionPath, string[] includeFilters, string[] excludeFilters, CancellationToken cancellationToken);
Task<ManifestResult> GetManifestDetailsAsync(string manifestPath, string apiIdentifier, CancellationToken cancellationToken);
Task<List<LogEntry>> GenerateAsync(string descriptionPath, string output, GenerationLanguage language, string[] includeFilters, string[] excludeFilters, string clientClassName, string clientNamespaceName, CancellationToken cancellationToken);
Task<LanguagesInformation> InfoForDescriptionAsync(string descriptionPath, CancellationToken cancellationToken);
Task<List<LogEntry>> UpdateAsync(string output, bool cleanOutput, bool clearCache, CancellationToken cancellationToken);
Task<SearchOperationResult> SearchAsync(string searchTerm, bool clearCache, CancellationToken cancellationToken);
Task<ShowResult> ShowAsync(string descriptionPath, string[] includeFilters, string[] excludeFilters, bool clearCache, CancellationToken cancellationToken);
Task<ManifestResult> GetManifestDetailsAsync(string manifestPath, string apiIdentifier, bool clearCache, CancellationToken cancellationToken);
Task<List<LogEntry>> GenerateAsync(string openAPIFilePath, string outputPath, GenerationLanguage language, string[] includePatterns, string[] excludePatterns, string clientClassName, string clientNamespaceName, bool usesBackingStore, bool cleanOutput, bool clearCache, bool excludeBackwardCompatible, string[] disabledValidationRules, string[] serializers, string[] deserializers, string[] structuredMimeTypes, bool includeAdditionalData, CancellationToken cancellationToken);
Task<LanguagesInformation> InfoForDescriptionAsync(string descriptionPath, bool clearCache, CancellationToken cancellationToken);
}
45 changes: 32 additions & 13 deletions src/kiota/Rpc/Server.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public string GetVersion()
return KiotaVersion.Current();
}

public async Task<List<LogEntry>> UpdateAsync(string output, CancellationToken cancellationToken)
public async Task<List<LogEntry>> UpdateAsync(string output, bool cleanOutput, bool clearCache, CancellationToken cancellationToken)
{
var logger = new ForwardedLogger<KiotaBuilder>();
var searchPath = GetAbsolutePath(output);
Expand All @@ -63,9 +63,11 @@ public async Task<List<LogEntry>> UpdateAsync(string output, CancellationToken c
TaskScheduler.Default)));
var configurations = locks.Select(x =>
{
var config = Configuration.Generation;
var config = (GenerationConfiguration)Configuration.Generation.Clone();
x.lockInfo?.UpdateGenerationConfigurationFromLock(config);
config.OutputPath = x.lockDirectoryPath;
config.ClearCache = clearCache;
config.CleanOutput = cleanOutput;
return config;
}).ToArray();
_ = await Task.WhenAll(configurations
Expand All @@ -86,29 +88,32 @@ private static async Task<bool> GenerateClientAsync(GenerationConfiguration conf
var logger = new AggregateLogger<KiotaBuilder>(globalLogger, fileLogger);
return await new KiotaBuilder(logger, config, httpClient).GenerateClientAsync(cancellationToken);
}
public async Task<SearchOperationResult> SearchAsync(string searchTerm, CancellationToken cancellationToken)
public async Task<SearchOperationResult> SearchAsync(string searchTerm, bool clearCache, CancellationToken cancellationToken)
{
var logger = new ForwardedLogger<KiotaSearcher>();
var configuration = Configuration.Search;
configuration.ClearCache = clearCache;
var searchService = new KiotaSearcher(logger, configuration, httpClient, null, (_) => Task.FromResult(false));
var results = await searchService.SearchAsync(searchTerm, string.Empty, cancellationToken);
return new(logger.LogEntries, results);
}
public async Task<ManifestResult> GetManifestDetailsAsync(string manifestPath, string apiIdentifier, CancellationToken cancellationToken)
public async Task<ManifestResult> GetManifestDetailsAsync(string manifestPath, string apiIdentifier, bool clearCache, CancellationToken cancellationToken)
{
var logger = new ForwardedLogger<KiotaBuilder>();
var configuration = Configuration.Generation;
configuration.ClearCache = clearCache;
configuration.ApiManifestPath = $"{manifestPath}#{apiIdentifier}";
var builder = new KiotaBuilder(logger, configuration, httpClient);
var manifestResult = await builder.GetApiManifestDetailsAsync(cancellationToken: cancellationToken);
return new ManifestResult(logger.LogEntries,
manifestResult?.Item1,
manifestResult?.Item2.ToArray());
}
public async Task<ShowResult> ShowAsync(string descriptionPath, string[] includeFilters, string[] excludeFilters, CancellationToken cancellationToken)
public async Task<ShowResult> ShowAsync(string descriptionPath, string[] includeFilters, string[] excludeFilters, bool clearCache, CancellationToken cancellationToken)
{
var logger = new ForwardedLogger<KiotaBuilder>();
var configuration = Configuration.Generation;
configuration.ClearCache = clearCache;
configuration.OpenAPIFilePath = GetAbsolutePath(descriptionPath);
var builder = new KiotaBuilder(logger, configuration, httpClient);
var fullUrlTreeNode = await builder.GetUrlTreeNodeAsync(cancellationToken);
Expand Down Expand Up @@ -136,15 +141,28 @@ private static string NormalizeOperationNodePath(OpenApiUrlTreeNode node, Operat
return indexingNormalizationRegex.Replace(name, "{}");
return name;
}
public async Task<List<LogEntry>> GenerateAsync(string descriptionPath, string output, GenerationLanguage language, string[] includeFilters, string[] excludeFilters, string clientClassName, string clientNamespaceName, CancellationToken cancellationToken)
public async Task<List<LogEntry>> GenerateAsync(string openAPIFilePath, string outputPath, GenerationLanguage language, string[] includePatterns, string[] excludePatterns, string clientClassName, string clientNamespaceName, bool usesBackingStore, bool cleanOutput, bool clearCache, bool excludeBackwardCompatible, string[] disabledValidationRules, string[] serializers, string[] deserializers, string[] structuredMimeTypes, bool includeAdditionalData, CancellationToken cancellationToken)
{
var logger = new ForwardedLogger<KiotaBuilder>();
var configuration = Configuration.Generation;
configuration.IncludePatterns = includeFilters.ToHashSet();
configuration.ExcludePatterns = excludeFilters.ToHashSet();
configuration.OpenAPIFilePath = GetAbsolutePath(descriptionPath);
configuration.OutputPath = GetAbsolutePath(output);
configuration.IncludePatterns = includePatterns.ToHashSet(StringComparer.OrdinalIgnoreCase);
configuration.ExcludePatterns = excludePatterns.ToHashSet(StringComparer.OrdinalIgnoreCase);
configuration.OpenAPIFilePath = GetAbsolutePath(openAPIFilePath);
configuration.OutputPath = GetAbsolutePath(outputPath);
configuration.Language = language;
configuration.UsesBackingStore = usesBackingStore;
configuration.CleanOutput = cleanOutput;
configuration.ClearCache = clearCache;
configuration.ExcludeBackwardCompatible = excludeBackwardCompatible;
configuration.IncludeAdditionalData = includeAdditionalData;
if (disabledValidationRules is not null && disabledValidationRules.Any())
configuration.DisabledValidationRules = disabledValidationRules.ToHashSet(StringComparer.OrdinalIgnoreCase);
if (serializers is not null && serializers.Any())
configuration.Serializers = serializers.ToHashSet(StringComparer.OrdinalIgnoreCase);
if (deserializers is not null && deserializers.Any())
configuration.Deserializers = deserializers.ToHashSet(StringComparer.OrdinalIgnoreCase);
if (structuredMimeTypes is not null && structuredMimeTypes.Any())
configuration.StructuredMimeTypes = structuredMimeTypes.ToHashSet(StringComparer.OrdinalIgnoreCase);
if (!string.IsNullOrEmpty(clientClassName))
configuration.ClientClassName = clientClassName;
if (!string.IsNullOrEmpty(clientNamespaceName))
Expand All @@ -167,15 +185,16 @@ public LanguagesInformation Info()
{
return Configuration.Languages;
}
public Task<LanguagesInformation> InfoForDescriptionAsync(string descriptionPath, CancellationToken cancellationToken)
public Task<LanguagesInformation> InfoForDescriptionAsync(string descriptionPath, bool clearCache, CancellationToken cancellationToken)
{
ArgumentException.ThrowIfNullOrEmpty(descriptionPath);
return InfoInternalAsync(descriptionPath, cancellationToken);
return InfoInternalAsync(descriptionPath, clearCache, cancellationToken);
}
private async Task<LanguagesInformation> InfoInternalAsync(string descriptionPath, CancellationToken cancellationToken)
private async Task<LanguagesInformation> InfoInternalAsync(string descriptionPath, bool clearCache, CancellationToken cancellationToken)
{
var logger = new ForwardedLogger<KiotaBuilder>();
var configuration = Configuration.Generation;
configuration.ClearCache = clearCache;
configuration.OpenAPIFilePath = GetAbsolutePath(descriptionPath);
var builder = new KiotaBuilder(logger, configuration, httpClient);
var result = await builder.GetLanguagesInformationAsync(cancellationToken);
Expand Down
42 changes: 42 additions & 0 deletions vscode/microsoft-kiota/l10n/bundle.l10n.it.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"Client will be upgraded from version {0} to {1}, upgrade your dependencies": "Il client verrà aggiornato dalla versione {0} a {1}, aggiornate le vostre dipendenze",
"No description found, select a description first": "Nessuna descrizione trovata, selezionare una descrizione prima",
"No endpoints selected, select endpoints first": "Nessun endpoint selezionato, selezionare prima un'API",
"No workspace folder found, open a folder first": "Nessuna cartella di lavoro trovata, aprire prima una cartella",
"Yes": "Si",
"No": "No",
"not found": "non trovato",
"error updating the clients {error}": "errore durante l'aggiornamento dei client: {error}",
"updating client with path {path}": "aggiornamento del client {path}",
"Kiota Dependencies Information": "Informazioni sulle dipendenze di Kiota",
"Installation commands": "Comandi di installazione",
"Dependencies": "Dipendenze",
"No language selected, select a language first": "Nessun linguaggio selezionato, selezionare un linguaggio prima",
"Open an API description": "Apri una descrizione API",
"A path or url to an OpenAPI description": "Un path od una url ad una descrizione OpenAPI",
"Search for an API description": "Cerca una descrizione API",
"Enter a search query": "Inserisci una query di ricerca",
"Pick a search result": "Seleziona un risultato di ricerca",
"Generate an API client": "Genera un client API",
"Choose a name for the client class": "Scegli un nome per la classe client",
"Choose a name for the client class namespace": "Scegli un nome per namespace della classe client",
"Enter an output path relative to the root of the project": "Inserisci un path di output relativo alla root del progetto",
"Pick a language": "Seleziona un linguaggio",
"Downloading kiota requires an internet connection. Please check your connection and try again.": "Il download di kiota richiede una connessione internet. Controlla la tua connessione e riprova.",
"Kiota download failed. Check the extension host logs for more information.": "Il download di kiota è fallito. Controlla i log dell'host per maggiori informazioni.",
"Downloading kiota...": "Download di kiota in corso...",
"Generating client...": "Generazione del client in corso...",
"Updating clients...": "Aggiornamento dei client in corso...",
"Loading...": "Caricamento...",
"Pick a lock file": "Seleziona un file di lock",
"Open a lock file": "Apri un file di lock",
"Filter the API description": "Filtra la descrizione API",
"Enter a filter": "Inserisci un filtro",
"Searching...": "Ricerca in corso...",
"A path or URL to an API manifest": "Un path o un URL ad un manifest API",
"Open an API manifest": "Apri un manifest API",
"Invalid URL, please check the documentation for the supported URLs": "URL non valido, controlla la documentazione per gli URL supportati",
"No content found in the clipboard": "Nessun contenuto trovato negli appunti",
"Invalid content found in the clipboard": "Contenuto non valido trovato negli appunti",
"Select an API manifest key": "Seleziona una chiave del manifest API"
}
10 changes: 9 additions & 1 deletion vscode/microsoft-kiota/l10n/bundle.l10n.tr.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"Client will be upgraded from version {0} to {1}, upgrade your dependencies": "İstemci {0} sürümünden {1}'e yükseltilecek, bağımlılıklarınızı yükseltecek",
"No description found, select a description first": "Açıklama bulunamadı, önce bir açıklama seçin",
"No endpoints selected, select endpoints first": "Seçilen endpoint yok, önce endpointleri seçin",
"No workspace folder found, open a folder first": "Çalışma alanı klasörü bulunamadı, önce bir klasör açın",
Expand Down Expand Up @@ -30,5 +31,12 @@
"Pick a lock file": "Bir kilit dosyası seçin",
"Open a lock file": "Bir kilit dosyası açın",
"Filter the API description": "API açıklamasını filtreleyin",
"Enter a filter": "Filtre girin"
"Enter a filter": "Filtre girin",
"Searching...": "Araştırıcı...",
"A path or URL to an API manifest": "API manifestinin yolu veya URLsi",
"Open an API manifest": "API manifestini açın",
"Invalid URL, please check the documentation for the supported URLs": "Geçersiz URL, lütfen desteklenen URL'ler için dokümanları kontrol edin",
"No content found in the clipboard": "Panoda içerik bulunamadı",
"Invalid content found in the clipboard": "Panoda geçersiz içerik bulundu",
"Select an API manifest key": "Bir API manifest anahtarı seçin"
}
4 changes: 2 additions & 2 deletions vscode/microsoft-kiota/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit bcb1492

Please sign in to comment.