From 3b9c7a633021656c383af8b12fe47ddd8266a860 Mon Sep 17 00:00:00 2001 From: Sander ten Brinke Date: Wed, 12 Feb 2025 12:07:40 +0100 Subject: [PATCH 01/21] Add basic set up for the new flag with translations by Copilot --- .../WebApiAot-CSharp.csproj.in | 5 +++++ .../.template.config/dotnetcli.host.json | 6 +++++- .../.template.config/ide.host.json | 17 ++++++++++++++++- .../localize/templatestrings.cs.json | 5 +++-- .../localize/templatestrings.de.json | 5 +++-- .../localize/templatestrings.en.json | 5 +++-- .../localize/templatestrings.es.json | 5 +++-- .../localize/templatestrings.fr.json | 5 +++-- .../localize/templatestrings.it.json | 5 +++-- .../localize/templatestrings.ja.json | 5 +++-- .../localize/templatestrings.ko.json | 5 +++-- .../localize/templatestrings.pl.json | 5 +++-- .../localize/templatestrings.pt-BR.json | 5 +++-- .../localize/templatestrings.ru.json | 5 +++-- .../localize/templatestrings.tr.json | 5 +++-- .../localize/templatestrings.zh-Hans.json | 5 +++-- .../localize/templatestrings.zh-Hant.json | 5 +++-- .../.template.config/template.json | 14 ++++++++++++-- 18 files changed, 80 insertions(+), 32 deletions(-) diff --git a/src/ProjectTemplates/Web.ProjectTemplates/WebApiAot-CSharp.csproj.in b/src/ProjectTemplates/Web.ProjectTemplates/WebApiAot-CSharp.csproj.in index 135250791270..10ae259ed9e3 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/WebApiAot-CSharp.csproj.in +++ b/src/ProjectTemplates/Web.ProjectTemplates/WebApiAot-CSharp.csproj.in @@ -10,4 +10,9 @@ true + + + + + diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/dotnetcli.host.json b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/dotnetcli.host.json index 2569634c24f9..d24ccc689f1c 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/dotnetcli.host.json +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/dotnetcli.host.json @@ -21,9 +21,13 @@ "UseProgramMain": { "longName": "use-program-main", "shortName": "" + }, + "DisableOpenAPI": { + "longName": "no-openapi", + "shortName": "" } }, "usageExamples": [ "" ] -} +} \ No newline at end of file diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/ide.host.json b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/ide.host.json index 00b1829bfeb4..de0bfb10ae91 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/ide.host.json +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/ide.host.json @@ -9,6 +9,21 @@ "isVisible": true, "persistenceScope": "shared", "persistenceScopeName": "Microsoft" + }, + { + "id": "DisableOpenAPI", + "name": { + "text": "Enable _OpenAPI support", + "overrideDefaultText": true + }, + "description": { + "text": "Enables OpenAPI (Swagger) support", + "overrideDefaultText": true + }, + "invertBoolean": true, + "isVisible": true, + "defaultValue": "true", + "persistenceScope": "templateGroup" } ] -} +} \ No newline at end of file diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.cs.json b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.cs.json index d9f5aba08d8d..8488ef8a45d3 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.cs.json +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.cs.json @@ -1,7 +1,7 @@ { "author": "Microsoft", "name": "ASP.NET Core Web API (native AOT)", - "description": "Šablona projektu pro vytvoření webového rozhraní RESTful API s využitím minimálních rozhraní API ASP.NET Core publikovaných jako native AOT.", + "description": "Šablona projektu pro vytvoření webového rozhraní RESTful API s využitím minimálních rozhraní API ASP.NET Core publikovaných jako native AOT, s volitelnou podporou OpenAPI.", "symbols/ExcludeLaunchSettings/description": "Určuje, jestli se má z vygenerované šablony vyloučit soubor launchSettings.json.", "symbols/kestrelHttpPort/description": "Číslo portu, který se má použít pro koncový bod HTTP v souboru launchSettings.json.", "symbols/iisHttpPort/description": "Číslo portu, který se má použít pro koncový bod IIS Express HTTP v souboru launchSettings.json.", @@ -10,6 +10,7 @@ "symbols/skipRestore/description": "Pokud se tato možnost zadá, přeskočí automatické obnovení projektu při vytvoření.", "symbols/UseProgramMain/displayName": "Nepoužívat _příkazy nejvyšší úrovně", "symbols/UseProgramMain/description": "Určuje, jestli se má místo příkazů nejvyšší úrovně generovat explicitní třída Program a metoda Main.", + "symbols/DisableOpenAPI/description": "Zakázání podpory OpenAPI (Swagger)", "postActions/restore/description": "Obnoví balíčky NuGet vyžadované tímto projektem.", "postActions/restore/manualInstructions/default/text": "Spustit dotnet restore" -} \ No newline at end of file +} diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.de.json b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.de.json index 82c0bf5121ef..510590d4bffc 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.de.json +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.de.json @@ -1,7 +1,7 @@ { "author": "Microsoft", "name": "ASP.NET Core Web-API (native AOT)", - "description": "Eine Projektvorlage zum Erstellen einer RESTful-Web-API mit ASP.NET Core minimalen APIs, die als native AOT veröffentlicht wurden.", + "description": "Eine Projektvorlage zum Erstellen einer RESTful-Web-API mit ASP.NET Core minimalen APIs, die als native AOT veröffentlicht wurden, mit optionaler Unterstützung für OpenAPI.", "symbols/ExcludeLaunchSettings/description": "Ob launchSettings.json aus der generierten Vorlage ausgeschlossen werden soll.", "symbols/kestrelHttpPort/description": "Portnummer, die für den HTTP Endpunkt in launchSettings.json verwendet werden soll.", "symbols/iisHttpPort/description": "Portnummer, die für den IIS Express HTTP Endpunkt in launchSettings.json verwendet werden soll.", @@ -10,6 +10,7 @@ "symbols/skipRestore/description": "Wenn angegeben, wird die automatische Wiederherstellung des Projekts beim Erstellen übersprungen.", "symbols/UseProgramMain/displayName": "Keine Anweisungen_der obersten Ebene verwenden", "symbols/UseProgramMain/description": "Gibt an, ob anstelle von Anweisungen der obersten Ebene eine explizite Programmklasse und eine Main-Methode generiert werden soll.", + "symbols/DisableOpenAPI/description": "Deaktivieren Sie die OpenAPI (Swagger) Unterstützung", "postActions/restore/description": "„NuGet-Pakete“ wiederherstellen, die für dieses Projekt erforderlich sind.", "postActions/restore/manualInstructions/default/text": "„dotnet restore“ ausführen" -} \ No newline at end of file +} diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.en.json b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.en.json index 0805132c3eb8..2f30a6ccb97b 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.en.json +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.en.json @@ -1,7 +1,7 @@ { "author": "Microsoft", "name": "ASP.NET Core Web API (native AOT)", - "description": "A project template for creating a RESTful Web API using ASP.NET Core minimal APIs published as native AOT.", + "description": "A project template for creating a RESTful Web API using ASP.NET Core minimal APIs published as native AOT, with optional support for OpenAPI.", "symbols/ExcludeLaunchSettings/description": "Whether to exclude launchSettings.json from the generated template.", "symbols/kestrelHttpPort/description": "Port number to use for the HTTP endpoint in launchSettings.json.", "symbols/iisHttpPort/description": "Port number to use for the IIS Express HTTP endpoint in launchSettings.json.", @@ -10,6 +10,7 @@ "symbols/skipRestore/description": "If specified, skips the automatic restore of the project on create.", "symbols/UseProgramMain/displayName": "Do not use _top-level statements", "symbols/UseProgramMain/description": "Whether to generate an explicit Program class and Main method instead of top-level statements.", + "symbols/DisableOpenAPI/description": "Disable OpenAPI (Swagger) support", "postActions/restore/description": "Restore NuGet packages required by this project.", "postActions/restore/manualInstructions/default/text": "Run 'dotnet restore'" -} \ No newline at end of file +} diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.es.json b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.es.json index 538c473b54a8..3161af488147 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.es.json +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.es.json @@ -1,7 +1,7 @@ { "author": "Microsoft", "name": "API web ASP.NET Core (native AOT)", - "description": "Una plantilla de proyecto para crear una API web RESTful utilizando las API mínimas de ASP.NET Core publicadas como native AOT.", + "description": "Una plantilla de proyecto para crear una API web RESTful utilizando las API mínimas de ASP.NET Core publicadas como native AOT, con soporte opcional para OpenAPI.", "symbols/ExcludeLaunchSettings/description": "Indica si se va a excluir launchSettings.json de la plantilla generada.", "symbols/kestrelHttpPort/description": "Número de puerto que se va a usar para el punto de conexión HTTP en launchSettings.json.", "symbols/iisHttpPort/description": "Número de puerto que se va a usar para el punto de conexión HTTP de IIS Express en launchSettings.json.", @@ -10,6 +10,7 @@ "symbols/skipRestore/description": "Si se especifica, se omite la restauración automática del proyecto durante la creación.", "symbols/UseProgramMain/displayName": "No usar instrucciones de _nivel superior", "symbols/UseProgramMain/description": "Indica si se debe generar una clase Program explícita y un método Main en lugar de instrucciones de nivel superior.", + "symbols/DisableOpenAPI/description": "Deshabilitar la compatibilidad con OpenAPI (Swagger)", "postActions/restore/description": "Restaure los paquetes NuGet necesarios para este proyecto.", "postActions/restore/manualInstructions/default/text": "Ejecutar \"dotnet restore\"" -} \ No newline at end of file +} diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.fr.json b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.fr.json index 463429e219a1..73a745235302 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.fr.json +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.fr.json @@ -1,7 +1,7 @@ { "author": "Microsoft", "name": "API web ASP.NET Core (AOT natif)", - "description": "Modèle de projet pour la création d’une API web RESTful à l’aide de ASP.NET Core api minimales publiées en tant qu’AOT natif.", + "description": "Modèle de projet pour la création d’une API web RESTful à l’aide de ASP.NET Core api minimales publiées en tant qu’AOT natif, avec prise en charge optionnelle d’OpenAPI.", "symbols/ExcludeLaunchSettings/description": "Indique s’il faut exclure launchSettings.json du modèle généré.", "symbols/kestrelHttpPort/description": "Numéro de port à utiliser pour le point de terminaison HTTP dans launchSettings.json.", "symbols/iisHttpPort/description": "Numéro de port à utiliser pour le point de terminaison HTTP IIS Express dans launchSettings.json.", @@ -10,6 +10,7 @@ "symbols/skipRestore/description": "S’il est spécifié, ignore la restauration automatique du projet lors de la création.", "symbols/UseProgramMain/displayName": "N’utilisez pas _d’instructions de niveau supérieur.", "symbols/UseProgramMain/description": "Indique s’il faut générer une classe Programme explicite et une méthode Main au lieu d’instructions de niveau supérieur.", + "symbols/DisableOpenAPI/description": "Désactiver la prise en charge d’OpenAPI (Swagger)", "postActions/restore/description": "Restaurez les packages NuGet requis par ce projet.", "postActions/restore/manualInstructions/default/text": "Exécuter « dotnet restore »" -} \ No newline at end of file +} diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.it.json b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.it.json index 15792378214e..f5b529a8aeb4 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.it.json +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.it.json @@ -1,7 +1,7 @@ { "author": "Microsoft", "name": "API Web di ASP.NET Core (native AOT)", - "description": "Modello di progetto per la creazione di un'API Web RESTful tramite API minime di ASP.NET Core pubblicate come native AOT.", + "description": "Modello di progetto per la creazione di un'API Web RESTful tramite API minime di ASP.NET Core pubblicate come native AOT, con supporto opzionale per OpenAPI.", "symbols/ExcludeLaunchSettings/description": "Indica se escludere launchSettings.json dal modello generato.", "symbols/kestrelHttpPort/description": "Numero di porta da usare per l'endpoint HTTP in launchSettings.json.", "symbols/iisHttpPort/description": "Numero di porta da usare per l'endpoint HTTP in launchSettings.json.", @@ -10,6 +10,7 @@ "symbols/skipRestore/description": "Se specificato, ignora il ripristino automatico del progetto durante la creazione.", "symbols/UseProgramMain/displayName": "Non usare_istruzioni di primo livello", "symbols/UseProgramMain/description": "Indica se generare una classe Program esplicita e un metodo Main anziché istruzioni di primo livello.", + "symbols/DisableOpenAPI/description": "Disabilita il supporto di OpenAPI (Swagger)", "postActions/restore/description": "Ripristina i pacchetti NuGet richiesti da questo progetto.", "postActions/restore/manualInstructions/default/text": "Esegui 'dotnet restore'" -} \ No newline at end of file +} diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.ja.json b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.ja.json index 16fad5c66aa0..0348ea54507a 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.ja.json +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.ja.json @@ -1,7 +1,7 @@ { "author": "Microsoft", "name": "ASP.NET Core Web API (native AOT)", - "description": "最小限の API.NET Core API を使用して RESTful Web API を作成するプロジェクト テンプレート。native AOT として公開されます。", + "description": "最小限の API.NET Core API を使用して RESTful Web API を作成するプロジェクト テンプレート。native AOT として公開されます。OpenAPI のサポートもオプションで利用できます。", "symbols/ExcludeLaunchSettings/description": "生成されたテンプレートから launchSettings.json を除外するかどうか。", "symbols/kestrelHttpPort/description": "launchSettings.json の HTTP エンドポイントに使用するポート番号。", "symbols/iisHttpPort/description": "launchSettings.json の IIS Express HTTP エンドポイントに使用するポート番号。", @@ -10,6 +10,7 @@ "symbols/skipRestore/description": "指定した場合、作成時にプロジェクトの自動復元がスキップされます。", "symbols/UseProgramMain/displayName": "最上位レベルのステートメントを使用しない(_T)", "symbols/UseProgramMain/description": "最上位レベルのステートメントではなく、明示的な Program クラスと Main メソッドを生成するかどうか。", + "symbols/DisableOpenAPI/description": "OpenAPI (Swagger) サポートを無効にする", "postActions/restore/description": "このプロジェクトに必要な NuGet パッケージを復元します。", "postActions/restore/manualInstructions/default/text": "'dotnet restore' を実行する" -} \ No newline at end of file +} diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.ko.json b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.ko.json index 763695fd5a3e..101bf3078978 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.ko.json +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.ko.json @@ -1,7 +1,7 @@ { "author": "Microsoft", "name": "ASP.NET Core 웹 API(native AOT)", - "description": "native AOT로 게시된 ASP.NET Core 최소 API를 사용하여 RESTful 웹 API를 만들기 위한 프로젝트 템플릿입니다.", + "description": "native AOT로 게시된 ASP.NET Core 최소 API를 사용하여 RESTful 웹 API를 만들기 위한 프로젝트 템플릿입니다. OpenAPI 지원도 선택적으로 사용할 수 있습니다.", "symbols/ExcludeLaunchSettings/description": "생성된 템플릿에서 launchSettings.json을 제외할지 여부입니다.", "symbols/kestrelHttpPort/description": "launchSettings.json의 HTTP 엔드포인트에 사용할 포트 번호입니다.", "symbols/iisHttpPort/description": "launchSettings.json의 IIS Express HTTP 엔드포인트에 사용할 포트 번호입니다.", @@ -10,6 +10,7 @@ "symbols/skipRestore/description": "지정된 경우, 프로젝트 생성 시 자동 복원을 건너뜁니다.", "symbols/UseProgramMain/displayName": "최상위 문 사용 안 함(_T)", "symbols/UseProgramMain/description": "최상위 문 대신 명시적 Program 클래스 및 Main 메서드를 생성할지 여부입니다.", + "symbols/DisableOpenAPI/description": "OpenAPI(Swagger) 지원 비활성화", "postActions/restore/description": "이 프로젝트에 필요한 NuGet 패키지를 복원합니다.", "postActions/restore/manualInstructions/default/text": "'dotnet restore' 실행" -} \ No newline at end of file +} diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.pl.json b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.pl.json index f85ea12cb58c..b5fbda402a02 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.pl.json +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.pl.json @@ -1,7 +1,7 @@ { "author": "Microsoft", "name": "Internetowy interfejs API platformy ASP.NET Core (native AOT)", - "description": "Szablon projektu służący do tworzenia internetowego interfejsu API RESTful przy użyciu minimalnych interfejsów API platformy ASP.NET Core publikowanego jako native AOT.", + "description": "Szablon projektu służący do tworzenia internetowego interfejsu API RESTful przy użyciu minimalnych interfejsów API platformy ASP.NET Core publikowanego jako native AOT, z opcjonalnym wsparciem dla OpenAPI.", "symbols/ExcludeLaunchSettings/description": "Określa, czy wykluczyć plik launchSettings.json z wygenerowanego szablonu.", "symbols/kestrelHttpPort/description": "Numer portu do użycia dla punktu końcowego HTTP w pliku launchSettings.json.", "symbols/iisHttpPort/description": "Numer portu do użycia dla punktu końcowego HTTP usług IIS Express w pliku launchSettings.json.", @@ -10,6 +10,7 @@ "symbols/skipRestore/description": "Jeśli ta opcja jest określona, pomija automatyczne przywracanie projektu podczas tworzenia.", "symbols/UseProgramMain/displayName": "Nie używaj ins_trukcji najwyższego poziomu", "symbols/UseProgramMain/description": "Określa, czy wygenerować jawną klasę Program i metodę Main zamiast instrukcji najwyższego poziomu.", + "symbols/DisableOpenAPI/description": "Włącz obsługę interfejsu OpenAPI (Swagger)", "postActions/restore/description": "Przywróć pakiety NuGet wymagane przez ten projekt.", "postActions/restore/manualInstructions/default/text": "Uruchom polecenie \"dotnet restore\"" -} \ No newline at end of file +} diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.pt-BR.json b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.pt-BR.json index d56c2f98339b..19149890e8d8 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.pt-BR.json +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.pt-BR.json @@ -1,7 +1,7 @@ { "author": "Microsoft", "name": "ASP.NET Core API Web (native AOT)", - "description": "Um modelo de projeto para criar uma API Web RESTful usando ASP.NET Core APIs mínimas publicadas como native AOT.", + "description": "Um modelo de projeto para criar uma API Web RESTful usando ASP.NET Core APIs mínimas publicadas como native AOT, com suporte opcional para OpenAPI.", "symbols/ExcludeLaunchSettings/description": "Se deve excluir launchSettings.json do modelo gerado.", "symbols/kestrelHttpPort/description": "Número da porta a ser usada para o ponto de extremidade HTTP em launchSettings.json.", "symbols/iisHttpPort/description": "Número da porta a ser usada para o ponto de extremidade HTTP do IIS Express em launchSettings.json.", @@ -10,6 +10,7 @@ "symbols/skipRestore/description": "Se especificado, ignora a restauração automática do projeto sendo criado.", "symbols/UseProgramMain/displayName": "Não use ins_truções de nível superior", "symbols/UseProgramMain/description": "Se deve gerar uma classe de Programa explícita e um método principal em vez de instruções de nível superior.", + "symbols/DisableOpenAPI/description": "Desabilitar suporte a OpenAPI (Swagger)", "postActions/restore/description": "Restaure os pacotes NuGet exigidos por este projeto.", "postActions/restore/manualInstructions/default/text": "Executa 'dotnet restore'" -} \ No newline at end of file +} diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.ru.json b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.ru.json index b1303ffe207e..c8acbd89ac34 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.ru.json +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.ru.json @@ -1,7 +1,7 @@ { "author": "Microsoft", "name": "Веб-API ASP.NET Core (native AOT)", - "description": "Шаблон проекта для создания веб-API на основе REST с использованием минимальных API ASP.NET Core, опубликованных как «native AOT».", + "description": "Шаблон проекта для создания веб-API на основе REST с использованием минимальных API ASP.NET Core, опубликованных как «native AOT», с поддержкой OpenAPI по желанию.", "symbols/ExcludeLaunchSettings/description": "Следует ли исключить launchSettings.json из созданного шаблона.", "symbols/kestrelHttpPort/description": "Номер порта, используемый для конечной точки HTTP в launchSettings.json.", "symbols/iisHttpPort/description": "Номер порта, используемый для конечной точки HTTP IIS Express в launchSettings.json.", @@ -10,6 +10,7 @@ "symbols/skipRestore/description": "Если установлено, автоматическое восстановление проекта при создании пропускается.", "symbols/UseProgramMain/displayName": "Не использовать _операторы верхнего уровня", "symbols/UseProgramMain/description": "Следует ли создавать явный класс Program и метод Main вместо операторов верхнего уровня.", + "symbols/DisableOpenAPI/description": "Отключение поддержки OpenAPI (Swagger)", "postActions/restore/description": "Восстановление пакетов NuGet, необходимых для этого проекта.", "postActions/restore/manualInstructions/default/text": "Выполнить команду \"dotnet restore\"" -} \ No newline at end of file +} diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.tr.json b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.tr.json index 008a53a65f0f..06d3c47b1e71 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.tr.json +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.tr.json @@ -1,7 +1,7 @@ { "author": "Microsoft", "name": "ASP.NET Core Web API'si (yerel AOT)", - "description": "Yerel AOT olarak yayımlanan ASP.NET Core minimal API’ları kullanarak RESTful Web API oluşturmaya yönelik proje şablonu.", + "description": "Yerel AOT olarak yayımlanan ASP.NET Core minimal API’ları kullanarak RESTful Web API oluşturmaya yönelik proje şablonu, isteğe bağlı OpenAPI desteği ile.", "symbols/ExcludeLaunchSettings/description": "launchSettings.json öğesinin oluşturulan şablondan dışlanıp dışlanmayacağı.", "symbols/kestrelHttpPort/description": "launchSettings.json içinde HTTP uç noktası için kullanılacak bağlantı noktası numarası.", "symbols/iisHttpPort/description": "launchSettings.json içinde IIS Express HTTP uç noktası için kullanılacak bağlantı noktası numarası.", @@ -10,6 +10,7 @@ "symbols/skipRestore/description": "Belirtilirse, oluşturma sırasında projenin otomatik geri yüklenmesini atlar.", "symbols/UseProgramMain/displayName": "_Üst düzey deyimler kullanmayın", "symbols/UseProgramMain/description": "Üst düzey deyimler yerine açık bir Program sınıfı ve Ana yöntem oluşturup oluşturulmayacağını belirtir.", + "symbols/DisableOpenAPI/description": "OpenAPI (Swagger) desteğini devre dışı bırak", "postActions/restore/description": "Bu projenin gerektirdiği NuGet paketlerini geri yükleyin.", "postActions/restore/manualInstructions/default/text": "'dotnet restore' çalıştır" -} \ No newline at end of file +} diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.zh-Hans.json b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.zh-Hans.json index 2247dc6d4b36..67fb5e454dec 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.zh-Hans.json +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.zh-Hans.json @@ -1,7 +1,7 @@ { "author": "Microsoft", "name": "ASP.NET Core Web API (native AOT)", - "description": "用于使用发布为 native AOT 的 ASP.NET Core 最小 API 的 RESTful Web API 的项目模板。", + "description": "用于使用发布为 native AOT 的 ASP.NET Core 最小 API 的 RESTful Web API 的项目模板,支持可选的 OpenAPI。", "symbols/ExcludeLaunchSettings/description": "是否从生成的模板中排除 launchSettings.json。", "symbols/kestrelHttpPort/description": "要用于 launchSettings.json 中 HTTP 终结点的端口号。", "symbols/iisHttpPort/description": "要用于 launchSettings.json 中 IIS Express HTTP 终结点的端口号。", @@ -10,6 +10,7 @@ "symbols/skipRestore/description": "如果指定,则在创建时跳过项目的自动还原。", "symbols/UseProgramMain/displayName": "不使用顶级语句(_T)", "symbols/UseProgramMain/description": "是否生成显式程序类和主方法,而不是顶级语句。", + "symbols/DisableOpenAPI/description": "禁用 OpenAI (Swagger)支持", "postActions/restore/description": "还原此项目所需的 NuGet 包。", "postActions/restore/manualInstructions/default/text": "运行 \"dotnet restore\"" -} \ No newline at end of file +} diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.zh-Hant.json b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.zh-Hant.json index 7691752108c9..89da0798ddbf 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.zh-Hant.json +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.zh-Hant.json @@ -1,7 +1,7 @@ { "author": "Microsoft", "name": "ASP.NET 核心 Web API (Native AOT)", - "description": "此專案範本可用於使用發佈為 Native AOT 的 ASP.NET Core 最小 API 來建立 RESTful Web API。", + "description": "此專案範本可用於使用發佈為 Native AOT 的 ASP.NET Core 最小 API 來建立 RESTful Web API,並可選擇支援 OpenAPI。", "symbols/ExcludeLaunchSettings/description": "是否要從產生的範本排除 launchSettings.json。", "symbols/kestrelHttpPort/description": "launchSettings.json 中 HTTP 端點要使用的連接埠號碼。", "symbols/iisHttpPort/description": "launchSettings.json 中 IIS Express HTTP 端點要使用的連接埠號碼。", @@ -10,6 +10,7 @@ "symbols/skipRestore/description": "若指定,會在建立時跳過專案的自動還原。", "symbols/UseProgramMain/displayName": "不要使用最上層陳述式(_T)", "symbols/UseProgramMain/description": "是否要產生明確的 Program 類別和 Main 方法,而非最上層語句。", + "symbols/DisableOpenAPI/description": "停用 OpenAPI (Swagger) 支援", "postActions/restore/description": "還原此專案所需的 NuGet 套件。", "postActions/restore/manualInstructions/default/text": "執行 'dotnet restore'" -} \ No newline at end of file +} diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/template.json b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/template.json index bbc12adc0cc1..26f2ea88e496 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/template.json +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/template.json @@ -9,7 +9,7 @@ ], "name": "ASP.NET Core Web API (native AOT)", "generatorVersions": "[1.0.0.0-*)", - "description": "A project template for creating a RESTful Web API using ASP.NET Core minimal APIs published as native AOT.", + "description": "A project template for creating a RESTful Web API using ASP.NET Core minimal APIs published as native AOT, with optional support for OpenAPI.", "groupIdentity": "Microsoft.Web.WebApiAot", "precedence": "10000", "identity": "Microsoft.Web.WebApiAot.CSharp.10.0", @@ -130,6 +130,16 @@ "defaultValue": "false", "displayName": "Do not use _top-level statements", "description": "Whether to generate an explicit Program class and Main method instead of top-level statements." + }, + "DisableOpenAPI": { + "type": "parameter", + "dataType": "bool", + "defaultValue": "false", + "description": "Disable OpenAPI (Swagger) support" + }, + "EnableOpenAPI": { + "type": "computed", + "value": "(!DisableOpenAPI)" } }, "primaryOutputs": [ @@ -152,4 +162,4 @@ "continueOnError": true } ] -} +} \ No newline at end of file From 734817a12efdf2da4b52e66be0baf31f0c1c104e Mon Sep 17 00:00:00 2001 From: Sander ten Brinke Date: Wed, 12 Feb 2025 12:16:47 +0100 Subject: [PATCH 02/21] Add conditional logic to use OpenAPI --- .../content/WebApiAot-CSharp/Program.Main.cs | 15 +++++++++-- .../content/WebApiAot-CSharp/Program.cs | 27 +++++++++++++++++-- 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/Program.Main.cs b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/Program.Main.cs index ea2807072a37..907ecea580d8 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/Program.Main.cs +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/Program.Main.cs @@ -24,11 +24,22 @@ public static void Main(string[] args) }; var todosApi = app.MapGroup("/todos"); - todosApi.MapGet("/", () => sampleTodos); + todosApi.MapGet("/", () => sampleTodos) + #if (EnableOpenAPI) + .WithName("GetTodos"); + #elif + ; + #endif + todosApi.MapGet("/{id}", (int id) => sampleTodos.FirstOrDefault(a => a.Id == id) is { } todo ? Results.Ok(todo) - : Results.NotFound()); + : Results.NotFound()) + #if (EnableOpenAPI) + .WithName("GetTodoById"); + #elif + ; + #endif app.Run(); } diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/Program.cs b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/Program.cs index d3b48c954001..e54005211bbf 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/Program.cs +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/Program.cs @@ -7,8 +7,20 @@ options.SerializerOptions.TypeInfoResolverChain.Insert(0, AppJsonSerializerContext.Default); }); +#if (EnableOpenAPI) +// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi +builder.Services.AddOpenApi(); +#endif + var app = builder.Build(); +#if (EnableOpenAPI) +if (app.Environment.IsDevelopment()) +{ + app.MapOpenApi(); +} +#endif + var sampleTodos = new Todo[] { new(1, "Walk the dog"), new(2, "Do the dishes", DateOnly.FromDateTime(DateTime.Now)), @@ -18,11 +30,22 @@ }; var todosApi = app.MapGroup("/todos"); -todosApi.MapGet("/", () => sampleTodos); +todosApi.MapGet("/", () => sampleTodos) + #if (EnableOpenAPI) + .WithName("GetTodos"); + #elif + ; + #endif + todosApi.MapGet("/{id}", (int id) => sampleTodos.FirstOrDefault(a => a.Id == id) is { } todo ? Results.Ok(todo) - : Results.NotFound()); + : Results.NotFound()) + #if (EnableOpenAPI) + .WithName("GetTodoById"); + #elif + ; + #endif app.Run(); From 5be274c5a69c177a0229a3dcb10bba7c2846ccab Mon Sep 17 00:00:00 2001 From: Sander ten Brinke Date: Wed, 12 Feb 2025 12:30:02 +0100 Subject: [PATCH 03/21] Add OpenAPI test to WebAPIAOT template tests --- .../WebApiNativeAotTemplateTest.cs | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/ProjectTemplates/test/Templates.Tests/WebApiNativeAotTemplateTest.cs b/src/ProjectTemplates/test/Templates.Tests/WebApiNativeAotTemplateTest.cs index 71c113aa7105..113da3c18df7 100644 --- a/src/ProjectTemplates/test/Templates.Tests/WebApiNativeAotTemplateTest.cs +++ b/src/ProjectTemplates/test/Templates.Tests/WebApiNativeAotTemplateTest.cs @@ -44,6 +44,30 @@ public async Task WebApiNativeAotTemplateProgramMainCSharp() await WebApiNativeAotTemplateCore(languageOverride: null, args: new[] { ArgConstants.UseProgramMain }); } + [ConditionalTheory] + [InlineData(false)] + [InlineData(true)] + [SkipOnHelix("https://github.com/dotnet/aspnetcore/issues/47478", Queues = HelixConstants.NativeAotNotSupportedHelixQueues)] + public async Task WebApiTemplateCSharp_WithoutOpenAPI(bool useProgramMain) + { + var project = await FactoryFixture.CreateProject(Output); + + var args = useProgramMain + ? new[] { ArgConstants.UseProgramMain, ArgConstants.NoOpenApi } + : new[] { ArgConstants.NoOpenApi }; + + await project.RunDotNetNewAsync("webapi", args: args); + + await project.RunDotNetBuildAsync(); + + using var aspNetProcess = project.StartBuiltProjectAsync(); + Assert.False( + aspNetProcess.Process.HasExited, + ErrorMessages.GetFailedProcessMessageOrEmpty("Run built project", project, aspNetProcess.Process)); + + await aspNetProcess.AssertNotFound("openapi/v1.json"); + } + private async Task WebApiNativeAotTemplateCore(string languageOverride, string[] args = null) { var project = await ProjectFactory.CreateProject(Output); From d8693b2d299b969a38d631d96aa0daf01edd98f5 Mon Sep 17 00:00:00 2001 From: Sander ten Brinke Date: Wed, 12 Feb 2025 12:50:02 +0100 Subject: [PATCH 04/21] Fix tests --- .../WebApiNativeAotTemplateTest.cs | 41 +++++++++++-------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/src/ProjectTemplates/test/Templates.Tests/WebApiNativeAotTemplateTest.cs b/src/ProjectTemplates/test/Templates.Tests/WebApiNativeAotTemplateTest.cs index 113da3c18df7..45e0d930874b 100644 --- a/src/ProjectTemplates/test/Templates.Tests/WebApiNativeAotTemplateTest.cs +++ b/src/ProjectTemplates/test/Templates.Tests/WebApiNativeAotTemplateTest.cs @@ -34,14 +34,14 @@ public ITestOutputHelper Output [SkipOnHelix("https://github.com/dotnet/aspnetcore/issues/47478", Queues = HelixConstants.NativeAotNotSupportedHelixQueues)] public async Task WebApiNativeAotTemplateCSharp() { - await WebApiNativeAotTemplateCore(languageOverride: null); + await WebApiNativeAotTemplateCore(languageOverride: null, additionalEndpointsThatShould200Ok: new[] { "/openapi/v1.json" }); } [ConditionalFact] [SkipOnHelix("https://github.com/dotnet/aspnetcore/issues/47478", Queues = HelixConstants.NativeAotNotSupportedHelixQueues)] public async Task WebApiNativeAotTemplateProgramMainCSharp() { - await WebApiNativeAotTemplateCore(languageOverride: null, args: new[] { ArgConstants.UseProgramMain }); + await WebApiNativeAotTemplateCore(languageOverride: null, args: new[] { ArgConstants.UseProgramMain }, additionalEndpointsThatShould200Ok: new[] { "/openapi/v1.json" }); } [ConditionalTheory] @@ -50,25 +50,14 @@ public async Task WebApiNativeAotTemplateProgramMainCSharp() [SkipOnHelix("https://github.com/dotnet/aspnetcore/issues/47478", Queues = HelixConstants.NativeAotNotSupportedHelixQueues)] public async Task WebApiTemplateCSharp_WithoutOpenAPI(bool useProgramMain) { - var project = await FactoryFixture.CreateProject(Output); - var args = useProgramMain ? new[] { ArgConstants.UseProgramMain, ArgConstants.NoOpenApi } : new[] { ArgConstants.NoOpenApi }; - await project.RunDotNetNewAsync("webapi", args: args); - - await project.RunDotNetBuildAsync(); - - using var aspNetProcess = project.StartBuiltProjectAsync(); - Assert.False( - aspNetProcess.Process.HasExited, - ErrorMessages.GetFailedProcessMessageOrEmpty("Run built project", project, aspNetProcess.Process)); - - await aspNetProcess.AssertNotFound("openapi/v1.json"); + await WebApiNativeAotTemplateCore(languageOverride: null, args: args, additionalEndpointsThatShould404NotFound: new[] { "/openapi/v1.json" }); } - private async Task WebApiNativeAotTemplateCore(string languageOverride, string[] args = null) + private async Task WebApiNativeAotTemplateCore(string languageOverride, string[] args = null, string[] additionalEndpointsThatShould200Ok = null, string[] additionalEndpointsThatShould404NotFound = null) { var project = await ProjectFactory.CreateProject(Output); project.SetCurrentRuntimeIdentifier(); @@ -101,7 +90,7 @@ private async Task WebApiNativeAotTemplateCore(string languageOverride, string[] Assert.False( aspNetProcess.Process.HasExited, ErrorMessages.GetFailedProcessMessageOrEmpty("Run built project", project, aspNetProcess.Process)); - await AssertEndpoints(aspNetProcess); + await AssertEndpoints(aspNetProcess, additionalEndpointsThatShould200Ok, additionalEndpointsThatShould404NotFound); } using (var aspNetProcess = project.StartPublishedProjectAsync(noHttps: true, usePublishedAppHost: true)) @@ -110,15 +99,31 @@ private async Task WebApiNativeAotTemplateCore(string languageOverride, string[] aspNetProcess.Process.HasExited, ErrorMessages.GetFailedProcessMessageOrEmpty("Run published project", project, aspNetProcess.Process)); - await AssertEndpoints(aspNetProcess); + await AssertEndpoints(aspNetProcess, additionalEndpointsThatShould200Ok, additionalEndpointsThatShould404NotFound); } } - private async Task AssertEndpoints(AspNetProcess aspNetProcess) + private async Task AssertEndpoints(AspNetProcess aspNetProcess, string[] additionalEndpointsThatShould200Ok = null, string[] additionalEndpointsThatShould404NotFound = null) { await aspNetProcess.AssertOk("/todos"); await aspNetProcess.AssertOk("/todos/1"); await aspNetProcess.AssertNotFound("/todos/100"); await aspNetProcess.AssertNotFound("/"); + + if (additionalEndpointsThatShould200Ok is not null) + { + foreach (var endpoint in additionalEndpointsThatShould200Ok) + { + await aspNetProcess.AssertOk(endpoint); + } + } + + if (additionalEndpointsThatShould404NotFound is not null) + { + foreach (var endpoint in additionalEndpointsThatShould404NotFound) + { + await aspNetProcess.AssertNotFound(endpoint); + } + } } } From d0b3ce9e78964de0d6fc58d4c2ff4bb17060df84 Mon Sep 17 00:00:00 2001 From: Sander ten Brinke Date: Wed, 12 Feb 2025 12:59:09 +0100 Subject: [PATCH 05/21] Add missing endif in the csproj --- .../Web.ProjectTemplates/WebApiAot-CSharp.csproj.in | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ProjectTemplates/Web.ProjectTemplates/WebApiAot-CSharp.csproj.in b/src/ProjectTemplates/Web.ProjectTemplates/WebApiAot-CSharp.csproj.in index 10ae259ed9e3..9445c03a87bd 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/WebApiAot-CSharp.csproj.in +++ b/src/ProjectTemplates/Web.ProjectTemplates/WebApiAot-CSharp.csproj.in @@ -14,5 +14,6 @@ + From ffee0b219057f3113ec8a334bfb14864d0db6135 Mon Sep 17 00:00:00 2001 From: Sander ten Brinke Date: Wed, 12 Feb 2025 15:06:23 +0100 Subject: [PATCH 06/21] Add more metadata to get 404 not found in the openapi doc correctly --- .../content/WebApiAot-CSharp/Program.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/Program.cs b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/Program.cs index e54005211bbf..6de1fd0e4309 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/Program.cs +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/Program.cs @@ -31,18 +31,20 @@ var todosApi = app.MapGroup("/todos"); todosApi.MapGet("/", () => sampleTodos) - #if (EnableOpenAPI) + #if (EnableOpenAPI) .WithName("GetTodos"); - #elif - ; - #endif + #elif + ; + #endif todosApi.MapGet("/{id}", (int id) => sampleTodos.FirstOrDefault(a => a.Id == id) is { } todo ? Results.Ok(todo) : Results.NotFound()) #if (EnableOpenAPI) - .WithName("GetTodoById"); + .WithName("GetTodoById") + .Produces(StatusCodes.Status200OK) + .Produces(StatusCodes.Status404NotFound); #elif ; #endif From 94e40fd7e4f7f4000954be3eccf3283f739c7ddf Mon Sep 17 00:00:00 2001 From: Sander ten Brinke Date: Wed, 12 Feb 2025 15:09:29 +0100 Subject: [PATCH 07/21] Also add the 404 metadata to the other file --- .../content/WebApiAot-CSharp/Program.Main.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/Program.Main.cs b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/Program.Main.cs index 907ecea580d8..55d1b8e69fd5 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/Program.Main.cs +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/Program.Main.cs @@ -36,7 +36,9 @@ public static void Main(string[] args) ? Results.Ok(todo) : Results.NotFound()) #if (EnableOpenAPI) - .WithName("GetTodoById"); + .WithName("GetTodoById") + .Produces(StatusCodes.Status200OK) + .Produces(StatusCodes.Status404NotFound); #elif ; #endif From d918e321d9ec0d067a161550358b512826cdc75b Mon Sep 17 00:00:00 2001 From: Sander ten Brinke Date: Fri, 14 Feb 2025 13:35:27 +0100 Subject: [PATCH 08/21] Change elif to else --- .../content/WebApiAot-CSharp/Program.Main.cs | 4 ++-- .../Web.ProjectTemplates/content/WebApiAot-CSharp/Program.cs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/Program.Main.cs b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/Program.Main.cs index 55d1b8e69fd5..222e14d834b8 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/Program.Main.cs +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/Program.Main.cs @@ -27,7 +27,7 @@ public static void Main(string[] args) todosApi.MapGet("/", () => sampleTodos) #if (EnableOpenAPI) .WithName("GetTodos"); - #elif + #else ; #endif @@ -39,7 +39,7 @@ public static void Main(string[] args) .WithName("GetTodoById") .Produces(StatusCodes.Status200OK) .Produces(StatusCodes.Status404NotFound); - #elif + #else ; #endif diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/Program.cs b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/Program.cs index 6de1fd0e4309..51a991174349 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/Program.cs +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/Program.cs @@ -33,7 +33,7 @@ todosApi.MapGet("/", () => sampleTodos) #if (EnableOpenAPI) .WithName("GetTodos"); - #elif + #else ; #endif @@ -45,7 +45,7 @@ .WithName("GetTodoById") .Produces(StatusCodes.Status200OK) .Produces(StatusCodes.Status404NotFound); - #elif + #else ; #endif From 664bec653fc9e64f6fd3b0a3e52bcff98c791ca1 Mon Sep 17 00:00:00 2001 From: Sander ten Brinke Date: Fri, 14 Feb 2025 13:37:49 +0100 Subject: [PATCH 09/21] Remove unnecessary 118n changes --- .../.template.config/localize/templatestrings.cs.json | 5 ++--- .../.template.config/localize/templatestrings.de.json | 5 ++--- .../.template.config/localize/templatestrings.en.json | 5 ++--- .../.template.config/localize/templatestrings.es.json | 5 ++--- .../.template.config/localize/templatestrings.fr.json | 5 ++--- .../.template.config/localize/templatestrings.it.json | 5 ++--- .../.template.config/localize/templatestrings.ja.json | 5 ++--- .../.template.config/localize/templatestrings.ko.json | 5 ++--- .../.template.config/localize/templatestrings.pl.json | 5 ++--- .../.template.config/localize/templatestrings.pt-BR.json | 5 ++--- .../.template.config/localize/templatestrings.ru.json | 5 ++--- .../.template.config/localize/templatestrings.tr.json | 5 ++--- .../.template.config/localize/templatestrings.zh-Hans.json | 5 ++--- .../.template.config/localize/templatestrings.zh-Hant.json | 5 ++--- 14 files changed, 28 insertions(+), 42 deletions(-) diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.cs.json b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.cs.json index 8488ef8a45d3..d9f5aba08d8d 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.cs.json +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.cs.json @@ -1,7 +1,7 @@ { "author": "Microsoft", "name": "ASP.NET Core Web API (native AOT)", - "description": "Šablona projektu pro vytvoření webového rozhraní RESTful API s využitím minimálních rozhraní API ASP.NET Core publikovaných jako native AOT, s volitelnou podporou OpenAPI.", + "description": "Šablona projektu pro vytvoření webového rozhraní RESTful API s využitím minimálních rozhraní API ASP.NET Core publikovaných jako native AOT.", "symbols/ExcludeLaunchSettings/description": "Určuje, jestli se má z vygenerované šablony vyloučit soubor launchSettings.json.", "symbols/kestrelHttpPort/description": "Číslo portu, který se má použít pro koncový bod HTTP v souboru launchSettings.json.", "symbols/iisHttpPort/description": "Číslo portu, který se má použít pro koncový bod IIS Express HTTP v souboru launchSettings.json.", @@ -10,7 +10,6 @@ "symbols/skipRestore/description": "Pokud se tato možnost zadá, přeskočí automatické obnovení projektu při vytvoření.", "symbols/UseProgramMain/displayName": "Nepoužívat _příkazy nejvyšší úrovně", "symbols/UseProgramMain/description": "Určuje, jestli se má místo příkazů nejvyšší úrovně generovat explicitní třída Program a metoda Main.", - "symbols/DisableOpenAPI/description": "Zakázání podpory OpenAPI (Swagger)", "postActions/restore/description": "Obnoví balíčky NuGet vyžadované tímto projektem.", "postActions/restore/manualInstructions/default/text": "Spustit dotnet restore" -} +} \ No newline at end of file diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.de.json b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.de.json index 510590d4bffc..82c0bf5121ef 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.de.json +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.de.json @@ -1,7 +1,7 @@ { "author": "Microsoft", "name": "ASP.NET Core Web-API (native AOT)", - "description": "Eine Projektvorlage zum Erstellen einer RESTful-Web-API mit ASP.NET Core minimalen APIs, die als native AOT veröffentlicht wurden, mit optionaler Unterstützung für OpenAPI.", + "description": "Eine Projektvorlage zum Erstellen einer RESTful-Web-API mit ASP.NET Core minimalen APIs, die als native AOT veröffentlicht wurden.", "symbols/ExcludeLaunchSettings/description": "Ob launchSettings.json aus der generierten Vorlage ausgeschlossen werden soll.", "symbols/kestrelHttpPort/description": "Portnummer, die für den HTTP Endpunkt in launchSettings.json verwendet werden soll.", "symbols/iisHttpPort/description": "Portnummer, die für den IIS Express HTTP Endpunkt in launchSettings.json verwendet werden soll.", @@ -10,7 +10,6 @@ "symbols/skipRestore/description": "Wenn angegeben, wird die automatische Wiederherstellung des Projekts beim Erstellen übersprungen.", "symbols/UseProgramMain/displayName": "Keine Anweisungen_der obersten Ebene verwenden", "symbols/UseProgramMain/description": "Gibt an, ob anstelle von Anweisungen der obersten Ebene eine explizite Programmklasse und eine Main-Methode generiert werden soll.", - "symbols/DisableOpenAPI/description": "Deaktivieren Sie die OpenAPI (Swagger) Unterstützung", "postActions/restore/description": "„NuGet-Pakete“ wiederherstellen, die für dieses Projekt erforderlich sind.", "postActions/restore/manualInstructions/default/text": "„dotnet restore“ ausführen" -} +} \ No newline at end of file diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.en.json b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.en.json index 2f30a6ccb97b..0805132c3eb8 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.en.json +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.en.json @@ -1,7 +1,7 @@ { "author": "Microsoft", "name": "ASP.NET Core Web API (native AOT)", - "description": "A project template for creating a RESTful Web API using ASP.NET Core minimal APIs published as native AOT, with optional support for OpenAPI.", + "description": "A project template for creating a RESTful Web API using ASP.NET Core minimal APIs published as native AOT.", "symbols/ExcludeLaunchSettings/description": "Whether to exclude launchSettings.json from the generated template.", "symbols/kestrelHttpPort/description": "Port number to use for the HTTP endpoint in launchSettings.json.", "symbols/iisHttpPort/description": "Port number to use for the IIS Express HTTP endpoint in launchSettings.json.", @@ -10,7 +10,6 @@ "symbols/skipRestore/description": "If specified, skips the automatic restore of the project on create.", "symbols/UseProgramMain/displayName": "Do not use _top-level statements", "symbols/UseProgramMain/description": "Whether to generate an explicit Program class and Main method instead of top-level statements.", - "symbols/DisableOpenAPI/description": "Disable OpenAPI (Swagger) support", "postActions/restore/description": "Restore NuGet packages required by this project.", "postActions/restore/manualInstructions/default/text": "Run 'dotnet restore'" -} +} \ No newline at end of file diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.es.json b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.es.json index 3161af488147..538c473b54a8 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.es.json +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.es.json @@ -1,7 +1,7 @@ { "author": "Microsoft", "name": "API web ASP.NET Core (native AOT)", - "description": "Una plantilla de proyecto para crear una API web RESTful utilizando las API mínimas de ASP.NET Core publicadas como native AOT, con soporte opcional para OpenAPI.", + "description": "Una plantilla de proyecto para crear una API web RESTful utilizando las API mínimas de ASP.NET Core publicadas como native AOT.", "symbols/ExcludeLaunchSettings/description": "Indica si se va a excluir launchSettings.json de la plantilla generada.", "symbols/kestrelHttpPort/description": "Número de puerto que se va a usar para el punto de conexión HTTP en launchSettings.json.", "symbols/iisHttpPort/description": "Número de puerto que se va a usar para el punto de conexión HTTP de IIS Express en launchSettings.json.", @@ -10,7 +10,6 @@ "symbols/skipRestore/description": "Si se especifica, se omite la restauración automática del proyecto durante la creación.", "symbols/UseProgramMain/displayName": "No usar instrucciones de _nivel superior", "symbols/UseProgramMain/description": "Indica si se debe generar una clase Program explícita y un método Main en lugar de instrucciones de nivel superior.", - "symbols/DisableOpenAPI/description": "Deshabilitar la compatibilidad con OpenAPI (Swagger)", "postActions/restore/description": "Restaure los paquetes NuGet necesarios para este proyecto.", "postActions/restore/manualInstructions/default/text": "Ejecutar \"dotnet restore\"" -} +} \ No newline at end of file diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.fr.json b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.fr.json index 73a745235302..463429e219a1 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.fr.json +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.fr.json @@ -1,7 +1,7 @@ { "author": "Microsoft", "name": "API web ASP.NET Core (AOT natif)", - "description": "Modèle de projet pour la création d’une API web RESTful à l’aide de ASP.NET Core api minimales publiées en tant qu’AOT natif, avec prise en charge optionnelle d’OpenAPI.", + "description": "Modèle de projet pour la création d’une API web RESTful à l’aide de ASP.NET Core api minimales publiées en tant qu’AOT natif.", "symbols/ExcludeLaunchSettings/description": "Indique s’il faut exclure launchSettings.json du modèle généré.", "symbols/kestrelHttpPort/description": "Numéro de port à utiliser pour le point de terminaison HTTP dans launchSettings.json.", "symbols/iisHttpPort/description": "Numéro de port à utiliser pour le point de terminaison HTTP IIS Express dans launchSettings.json.", @@ -10,7 +10,6 @@ "symbols/skipRestore/description": "S’il est spécifié, ignore la restauration automatique du projet lors de la création.", "symbols/UseProgramMain/displayName": "N’utilisez pas _d’instructions de niveau supérieur.", "symbols/UseProgramMain/description": "Indique s’il faut générer une classe Programme explicite et une méthode Main au lieu d’instructions de niveau supérieur.", - "symbols/DisableOpenAPI/description": "Désactiver la prise en charge d’OpenAPI (Swagger)", "postActions/restore/description": "Restaurez les packages NuGet requis par ce projet.", "postActions/restore/manualInstructions/default/text": "Exécuter « dotnet restore »" -} +} \ No newline at end of file diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.it.json b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.it.json index f5b529a8aeb4..15792378214e 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.it.json +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.it.json @@ -1,7 +1,7 @@ { "author": "Microsoft", "name": "API Web di ASP.NET Core (native AOT)", - "description": "Modello di progetto per la creazione di un'API Web RESTful tramite API minime di ASP.NET Core pubblicate come native AOT, con supporto opzionale per OpenAPI.", + "description": "Modello di progetto per la creazione di un'API Web RESTful tramite API minime di ASP.NET Core pubblicate come native AOT.", "symbols/ExcludeLaunchSettings/description": "Indica se escludere launchSettings.json dal modello generato.", "symbols/kestrelHttpPort/description": "Numero di porta da usare per l'endpoint HTTP in launchSettings.json.", "symbols/iisHttpPort/description": "Numero di porta da usare per l'endpoint HTTP in launchSettings.json.", @@ -10,7 +10,6 @@ "symbols/skipRestore/description": "Se specificato, ignora il ripristino automatico del progetto durante la creazione.", "symbols/UseProgramMain/displayName": "Non usare_istruzioni di primo livello", "symbols/UseProgramMain/description": "Indica se generare una classe Program esplicita e un metodo Main anziché istruzioni di primo livello.", - "symbols/DisableOpenAPI/description": "Disabilita il supporto di OpenAPI (Swagger)", "postActions/restore/description": "Ripristina i pacchetti NuGet richiesti da questo progetto.", "postActions/restore/manualInstructions/default/text": "Esegui 'dotnet restore'" -} +} \ No newline at end of file diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.ja.json b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.ja.json index 0348ea54507a..16fad5c66aa0 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.ja.json +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.ja.json @@ -1,7 +1,7 @@ { "author": "Microsoft", "name": "ASP.NET Core Web API (native AOT)", - "description": "最小限の API.NET Core API を使用して RESTful Web API を作成するプロジェクト テンプレート。native AOT として公開されます。OpenAPI のサポートもオプションで利用できます。", + "description": "最小限の API.NET Core API を使用して RESTful Web API を作成するプロジェクト テンプレート。native AOT として公開されます。", "symbols/ExcludeLaunchSettings/description": "生成されたテンプレートから launchSettings.json を除外するかどうか。", "symbols/kestrelHttpPort/description": "launchSettings.json の HTTP エンドポイントに使用するポート番号。", "symbols/iisHttpPort/description": "launchSettings.json の IIS Express HTTP エンドポイントに使用するポート番号。", @@ -10,7 +10,6 @@ "symbols/skipRestore/description": "指定した場合、作成時にプロジェクトの自動復元がスキップされます。", "symbols/UseProgramMain/displayName": "最上位レベルのステートメントを使用しない(_T)", "symbols/UseProgramMain/description": "最上位レベルのステートメントではなく、明示的な Program クラスと Main メソッドを生成するかどうか。", - "symbols/DisableOpenAPI/description": "OpenAPI (Swagger) サポートを無効にする", "postActions/restore/description": "このプロジェクトに必要な NuGet パッケージを復元します。", "postActions/restore/manualInstructions/default/text": "'dotnet restore' を実行する" -} +} \ No newline at end of file diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.ko.json b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.ko.json index 101bf3078978..763695fd5a3e 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.ko.json +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.ko.json @@ -1,7 +1,7 @@ { "author": "Microsoft", "name": "ASP.NET Core 웹 API(native AOT)", - "description": "native AOT로 게시된 ASP.NET Core 최소 API를 사용하여 RESTful 웹 API를 만들기 위한 프로젝트 템플릿입니다. OpenAPI 지원도 선택적으로 사용할 수 있습니다.", + "description": "native AOT로 게시된 ASP.NET Core 최소 API를 사용하여 RESTful 웹 API를 만들기 위한 프로젝트 템플릿입니다.", "symbols/ExcludeLaunchSettings/description": "생성된 템플릿에서 launchSettings.json을 제외할지 여부입니다.", "symbols/kestrelHttpPort/description": "launchSettings.json의 HTTP 엔드포인트에 사용할 포트 번호입니다.", "symbols/iisHttpPort/description": "launchSettings.json의 IIS Express HTTP 엔드포인트에 사용할 포트 번호입니다.", @@ -10,7 +10,6 @@ "symbols/skipRestore/description": "지정된 경우, 프로젝트 생성 시 자동 복원을 건너뜁니다.", "symbols/UseProgramMain/displayName": "최상위 문 사용 안 함(_T)", "symbols/UseProgramMain/description": "최상위 문 대신 명시적 Program 클래스 및 Main 메서드를 생성할지 여부입니다.", - "symbols/DisableOpenAPI/description": "OpenAPI(Swagger) 지원 비활성화", "postActions/restore/description": "이 프로젝트에 필요한 NuGet 패키지를 복원합니다.", "postActions/restore/manualInstructions/default/text": "'dotnet restore' 실행" -} +} \ No newline at end of file diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.pl.json b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.pl.json index b5fbda402a02..f85ea12cb58c 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.pl.json +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.pl.json @@ -1,7 +1,7 @@ { "author": "Microsoft", "name": "Internetowy interfejs API platformy ASP.NET Core (native AOT)", - "description": "Szablon projektu służący do tworzenia internetowego interfejsu API RESTful przy użyciu minimalnych interfejsów API platformy ASP.NET Core publikowanego jako native AOT, z opcjonalnym wsparciem dla OpenAPI.", + "description": "Szablon projektu służący do tworzenia internetowego interfejsu API RESTful przy użyciu minimalnych interfejsów API platformy ASP.NET Core publikowanego jako native AOT.", "symbols/ExcludeLaunchSettings/description": "Określa, czy wykluczyć plik launchSettings.json z wygenerowanego szablonu.", "symbols/kestrelHttpPort/description": "Numer portu do użycia dla punktu końcowego HTTP w pliku launchSettings.json.", "symbols/iisHttpPort/description": "Numer portu do użycia dla punktu końcowego HTTP usług IIS Express w pliku launchSettings.json.", @@ -10,7 +10,6 @@ "symbols/skipRestore/description": "Jeśli ta opcja jest określona, pomija automatyczne przywracanie projektu podczas tworzenia.", "symbols/UseProgramMain/displayName": "Nie używaj ins_trukcji najwyższego poziomu", "symbols/UseProgramMain/description": "Określa, czy wygenerować jawną klasę Program i metodę Main zamiast instrukcji najwyższego poziomu.", - "symbols/DisableOpenAPI/description": "Włącz obsługę interfejsu OpenAPI (Swagger)", "postActions/restore/description": "Przywróć pakiety NuGet wymagane przez ten projekt.", "postActions/restore/manualInstructions/default/text": "Uruchom polecenie \"dotnet restore\"" -} +} \ No newline at end of file diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.pt-BR.json b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.pt-BR.json index 19149890e8d8..d56c2f98339b 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.pt-BR.json +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.pt-BR.json @@ -1,7 +1,7 @@ { "author": "Microsoft", "name": "ASP.NET Core API Web (native AOT)", - "description": "Um modelo de projeto para criar uma API Web RESTful usando ASP.NET Core APIs mínimas publicadas como native AOT, com suporte opcional para OpenAPI.", + "description": "Um modelo de projeto para criar uma API Web RESTful usando ASP.NET Core APIs mínimas publicadas como native AOT.", "symbols/ExcludeLaunchSettings/description": "Se deve excluir launchSettings.json do modelo gerado.", "symbols/kestrelHttpPort/description": "Número da porta a ser usada para o ponto de extremidade HTTP em launchSettings.json.", "symbols/iisHttpPort/description": "Número da porta a ser usada para o ponto de extremidade HTTP do IIS Express em launchSettings.json.", @@ -10,7 +10,6 @@ "symbols/skipRestore/description": "Se especificado, ignora a restauração automática do projeto sendo criado.", "symbols/UseProgramMain/displayName": "Não use ins_truções de nível superior", "symbols/UseProgramMain/description": "Se deve gerar uma classe de Programa explícita e um método principal em vez de instruções de nível superior.", - "symbols/DisableOpenAPI/description": "Desabilitar suporte a OpenAPI (Swagger)", "postActions/restore/description": "Restaure os pacotes NuGet exigidos por este projeto.", "postActions/restore/manualInstructions/default/text": "Executa 'dotnet restore'" -} +} \ No newline at end of file diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.ru.json b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.ru.json index c8acbd89ac34..b1303ffe207e 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.ru.json +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.ru.json @@ -1,7 +1,7 @@ { "author": "Microsoft", "name": "Веб-API ASP.NET Core (native AOT)", - "description": "Шаблон проекта для создания веб-API на основе REST с использованием минимальных API ASP.NET Core, опубликованных как «native AOT», с поддержкой OpenAPI по желанию.", + "description": "Шаблон проекта для создания веб-API на основе REST с использованием минимальных API ASP.NET Core, опубликованных как «native AOT».", "symbols/ExcludeLaunchSettings/description": "Следует ли исключить launchSettings.json из созданного шаблона.", "symbols/kestrelHttpPort/description": "Номер порта, используемый для конечной точки HTTP в launchSettings.json.", "symbols/iisHttpPort/description": "Номер порта, используемый для конечной точки HTTP IIS Express в launchSettings.json.", @@ -10,7 +10,6 @@ "symbols/skipRestore/description": "Если установлено, автоматическое восстановление проекта при создании пропускается.", "symbols/UseProgramMain/displayName": "Не использовать _операторы верхнего уровня", "symbols/UseProgramMain/description": "Следует ли создавать явный класс Program и метод Main вместо операторов верхнего уровня.", - "symbols/DisableOpenAPI/description": "Отключение поддержки OpenAPI (Swagger)", "postActions/restore/description": "Восстановление пакетов NuGet, необходимых для этого проекта.", "postActions/restore/manualInstructions/default/text": "Выполнить команду \"dotnet restore\"" -} +} \ No newline at end of file diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.tr.json b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.tr.json index 06d3c47b1e71..008a53a65f0f 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.tr.json +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.tr.json @@ -1,7 +1,7 @@ { "author": "Microsoft", "name": "ASP.NET Core Web API'si (yerel AOT)", - "description": "Yerel AOT olarak yayımlanan ASP.NET Core minimal API’ları kullanarak RESTful Web API oluşturmaya yönelik proje şablonu, isteğe bağlı OpenAPI desteği ile.", + "description": "Yerel AOT olarak yayımlanan ASP.NET Core minimal API’ları kullanarak RESTful Web API oluşturmaya yönelik proje şablonu.", "symbols/ExcludeLaunchSettings/description": "launchSettings.json öğesinin oluşturulan şablondan dışlanıp dışlanmayacağı.", "symbols/kestrelHttpPort/description": "launchSettings.json içinde HTTP uç noktası için kullanılacak bağlantı noktası numarası.", "symbols/iisHttpPort/description": "launchSettings.json içinde IIS Express HTTP uç noktası için kullanılacak bağlantı noktası numarası.", @@ -10,7 +10,6 @@ "symbols/skipRestore/description": "Belirtilirse, oluşturma sırasında projenin otomatik geri yüklenmesini atlar.", "symbols/UseProgramMain/displayName": "_Üst düzey deyimler kullanmayın", "symbols/UseProgramMain/description": "Üst düzey deyimler yerine açık bir Program sınıfı ve Ana yöntem oluşturup oluşturulmayacağını belirtir.", - "symbols/DisableOpenAPI/description": "OpenAPI (Swagger) desteğini devre dışı bırak", "postActions/restore/description": "Bu projenin gerektirdiği NuGet paketlerini geri yükleyin.", "postActions/restore/manualInstructions/default/text": "'dotnet restore' çalıştır" -} +} \ No newline at end of file diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.zh-Hans.json b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.zh-Hans.json index 67fb5e454dec..2247dc6d4b36 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.zh-Hans.json +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.zh-Hans.json @@ -1,7 +1,7 @@ { "author": "Microsoft", "name": "ASP.NET Core Web API (native AOT)", - "description": "用于使用发布为 native AOT 的 ASP.NET Core 最小 API 的 RESTful Web API 的项目模板,支持可选的 OpenAPI。", + "description": "用于使用发布为 native AOT 的 ASP.NET Core 最小 API 的 RESTful Web API 的项目模板。", "symbols/ExcludeLaunchSettings/description": "是否从生成的模板中排除 launchSettings.json。", "symbols/kestrelHttpPort/description": "要用于 launchSettings.json 中 HTTP 终结点的端口号。", "symbols/iisHttpPort/description": "要用于 launchSettings.json 中 IIS Express HTTP 终结点的端口号。", @@ -10,7 +10,6 @@ "symbols/skipRestore/description": "如果指定,则在创建时跳过项目的自动还原。", "symbols/UseProgramMain/displayName": "不使用顶级语句(_T)", "symbols/UseProgramMain/description": "是否生成显式程序类和主方法,而不是顶级语句。", - "symbols/DisableOpenAPI/description": "禁用 OpenAI (Swagger)支持", "postActions/restore/description": "还原此项目所需的 NuGet 包。", "postActions/restore/manualInstructions/default/text": "运行 \"dotnet restore\"" -} +} \ No newline at end of file diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.zh-Hant.json b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.zh-Hant.json index 89da0798ddbf..7691752108c9 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.zh-Hant.json +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.zh-Hant.json @@ -1,7 +1,7 @@ { "author": "Microsoft", "name": "ASP.NET 核心 Web API (Native AOT)", - "description": "此專案範本可用於使用發佈為 Native AOT 的 ASP.NET Core 最小 API 來建立 RESTful Web API,並可選擇支援 OpenAPI。", + "description": "此專案範本可用於使用發佈為 Native AOT 的 ASP.NET Core 最小 API 來建立 RESTful Web API。", "symbols/ExcludeLaunchSettings/description": "是否要從產生的範本排除 launchSettings.json。", "symbols/kestrelHttpPort/description": "launchSettings.json 中 HTTP 端點要使用的連接埠號碼。", "symbols/iisHttpPort/description": "launchSettings.json 中 IIS Express HTTP 端點要使用的連接埠號碼。", @@ -10,7 +10,6 @@ "symbols/skipRestore/description": "若指定,會在建立時跳過專案的自動還原。", "symbols/UseProgramMain/displayName": "不要使用最上層陳述式(_T)", "symbols/UseProgramMain/description": "是否要產生明確的 Program 類別和 Main 方法,而非最上層語句。", - "symbols/DisableOpenAPI/description": "停用 OpenAPI (Swagger) 支援", "postActions/restore/description": "還原此專案所需的 NuGet 套件。", "postActions/restore/manualInstructions/default/text": "執行 'dotnet restore'" -} +} \ No newline at end of file From e225cc2facb4fac0d1bd6e83cd698ffe60e834a1 Mon Sep 17 00:00:00 2001 From: Sander ten Brinke Date: Fri, 14 Feb 2025 13:40:05 +0100 Subject: [PATCH 10/21] Add english translation back --- .../.template.config/localize/templatestrings.en.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.en.json b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.en.json index 0805132c3eb8..1507b1e8498f 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.en.json +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.en.json @@ -1,7 +1,7 @@ { "author": "Microsoft", "name": "ASP.NET Core Web API (native AOT)", - "description": "A project template for creating a RESTful Web API using ASP.NET Core minimal APIs published as native AOT.", + "description": "A project template for creating a RESTful Web API using ASP.NET Core minimal APIs published as native AOT, with optional support for OpenAPI.", "symbols/ExcludeLaunchSettings/description": "Whether to exclude launchSettings.json from the generated template.", "symbols/kestrelHttpPort/description": "Port number to use for the HTTP endpoint in launchSettings.json.", "symbols/iisHttpPort/description": "Port number to use for the IIS Express HTTP endpoint in launchSettings.json.", @@ -10,6 +10,7 @@ "symbols/skipRestore/description": "If specified, skips the automatic restore of the project on create.", "symbols/UseProgramMain/displayName": "Do not use _top-level statements", "symbols/UseProgramMain/description": "Whether to generate an explicit Program class and Main method instead of top-level statements.", + "symbols/DisableOpenAPI/description": "Disable OpenAPI (Swagger) support", "postActions/restore/description": "Restore NuGet packages required by this project.", "postActions/restore/manualInstructions/default/text": "Run 'dotnet restore'" } \ No newline at end of file From 539ba41e599c75d39d654f8a39dc2c1f3a15d65c Mon Sep 17 00:00:00 2001 From: Sander ten Brinke Date: Fri, 14 Feb 2025 14:02:51 +0100 Subject: [PATCH 11/21] Keep the semicolon on the same line as requested by PR review --- .../content/WebApiAot-CSharp/Program.Main.cs | 19 +++++++++++-------- .../content/WebApiAot-CSharp/Program.cs | 19 +++++++++++-------- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/Program.Main.cs b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/Program.Main.cs index 222e14d834b8..dda1e082a679 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/Program.Main.cs +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/Program.Main.cs @@ -24,24 +24,27 @@ public static void Main(string[] args) }; var todosApi = app.MapGroup("/todos"); + #if (EnableOpenAPI) todosApi.MapGet("/", () => sampleTodos) - #if (EnableOpenAPI) .WithName("GetTodos"); - #else - ; - #endif + #else + todosApi.MapGet("/", () => sampleTodos); + #endif + #if (EnableOpenAPI) todosApi.MapGet("/{id}", (int id) => sampleTodos.FirstOrDefault(a => a.Id == id) is { } todo ? Results.Ok(todo) : Results.NotFound()) - #if (EnableOpenAPI) .WithName("GetTodoById") .Produces(StatusCodes.Status200OK) .Produces(StatusCodes.Status404NotFound); - #else - ; - #endif + #else + todosApi.MapGet("/{id}", (int id) => + sampleTodos.FirstOrDefault(a => a.Id == id) is { } todo + ? Results.Ok(todo) + : Results.NotFound()); + #endif app.Run(); } diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/Program.cs b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/Program.cs index 51a991174349..c7d11e2a05c3 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/Program.cs +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/Program.cs @@ -30,24 +30,27 @@ }; var todosApi = app.MapGroup("/todos"); +#if (EnableOpenAPI) todosApi.MapGet("/", () => sampleTodos) - #if (EnableOpenAPI) .WithName("GetTodos"); - #else - ; - #endif +#else +todosApi.MapGet("/", () => sampleTodos); +#endif +#if (EnableOpenAPI) todosApi.MapGet("/{id}", (int id) => sampleTodos.FirstOrDefault(a => a.Id == id) is { } todo ? Results.Ok(todo) : Results.NotFound()) - #if (EnableOpenAPI) .WithName("GetTodoById") .Produces(StatusCodes.Status200OK) .Produces(StatusCodes.Status404NotFound); - #else - ; - #endif +#else +todosApi.MapGet("/{id}", (int id) => + sampleTodos.FirstOrDefault(a => a.Id == id) is { } todo + ? Results.Ok(todo) + : Results.NotFound()); +#endif app.Run(); From 06112f253fd28b6436e7b66a0e8828a876652add Mon Sep 17 00:00:00 2001 From: Sander ten Brinke Date: Fri, 14 Feb 2025 14:11:07 +0100 Subject: [PATCH 12/21] Use TypedResults instead of extension methods and reduce the if else statements --- .../content/WebApiAot-CSharp/Program.Main.cs | 22 ++++++++----------- .../content/WebApiAot-CSharp/Program.cs | 22 ++++++++----------- 2 files changed, 18 insertions(+), 26 deletions(-) diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/Program.Main.cs b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/Program.Main.cs index dda1e082a679..6bfc32df93c6 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/Program.Main.cs +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/Program.Main.cs @@ -27,23 +27,19 @@ public static void Main(string[] args) #if (EnableOpenAPI) todosApi.MapGet("/", () => sampleTodos) .WithName("GetTodos"); - #else - todosApi.MapGet("/", () => sampleTodos); - #endif - #if (EnableOpenAPI) - todosApi.MapGet("/{id}", (int id) => + todosApi.MapGet("/{id}", Results, NotFound> (int id) => sampleTodos.FirstOrDefault(a => a.Id == id) is { } todo - ? Results.Ok(todo) - : Results.NotFound()) - .WithName("GetTodoById") - .Produces(StatusCodes.Status200OK) - .Produces(StatusCodes.Status404NotFound); + ? TypedResults.Ok(todo) + : TypedResults.NotFound()) + .WithName("GetTodoById"); #else - todosApi.MapGet("/{id}", (int id) => + todosApi.MapGet("/", () => sampleTodos); + + todosApi.MapGet("/{id}", Results, NotFound> (int id) => sampleTodos.FirstOrDefault(a => a.Id == id) is { } todo - ? Results.Ok(todo) - : Results.NotFound()); + ? TypedResults.Ok(todo) + : TypedResults.NotFound()); #endif app.Run(); diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/Program.cs b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/Program.cs index c7d11e2a05c3..870024e24f6c 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/Program.cs +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/Program.cs @@ -33,23 +33,19 @@ #if (EnableOpenAPI) todosApi.MapGet("/", () => sampleTodos) .WithName("GetTodos"); -#else -todosApi.MapGet("/", () => sampleTodos); -#endif -#if (EnableOpenAPI) -todosApi.MapGet("/{id}", (int id) => +todosApi.MapGet("/{id}", Results, NotFound> (int id) => sampleTodos.FirstOrDefault(a => a.Id == id) is { } todo - ? Results.Ok(todo) - : Results.NotFound()) - .WithName("GetTodoById") - .Produces(StatusCodes.Status200OK) - .Produces(StatusCodes.Status404NotFound); + ? TypedResults.Ok(todo) + : TypedResults.NotFound()) + .WithName("GetTodoById"); #else -todosApi.MapGet("/{id}", (int id) => +todosApi.MapGet("/", () => sampleTodos); + +todosApi.MapGet("/{id}", Results, NotFound> (int id) => sampleTodos.FirstOrDefault(a => a.Id == id) is { } todo - ? Results.Ok(todo) - : Results.NotFound()); + ? TypedResults.Ok(todo) + : TypedResults.NotFound()); #endif app.Run(); From 8dc2ceb3c9210384718c741983d7ba63f735d3ab Mon Sep 17 00:00:00 2001 From: Sander ten Brinke Date: Fri, 14 Feb 2025 16:00:50 +0100 Subject: [PATCH 13/21] Add template strings back after running `bash build.sh -test -configuration Release`. I assume this is part of the natural process of creating a PR and thus should be committed. --- .../.template.config/localize/templatestrings.cs.json | 1 + .../.template.config/localize/templatestrings.de.json | 1 + .../.template.config/localize/templatestrings.es.json | 1 + .../.template.config/localize/templatestrings.fr.json | 1 + .../.template.config/localize/templatestrings.it.json | 1 + .../.template.config/localize/templatestrings.ja.json | 1 + .../.template.config/localize/templatestrings.ko.json | 1 + .../.template.config/localize/templatestrings.pl.json | 1 + .../.template.config/localize/templatestrings.pt-BR.json | 1 + .../.template.config/localize/templatestrings.ru.json | 1 + .../.template.config/localize/templatestrings.tr.json | 1 + .../.template.config/localize/templatestrings.zh-Hans.json | 1 + .../.template.config/localize/templatestrings.zh-Hant.json | 1 + 13 files changed, 13 insertions(+) diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.cs.json b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.cs.json index d9f5aba08d8d..1fa10bab25ad 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.cs.json +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.cs.json @@ -10,6 +10,7 @@ "symbols/skipRestore/description": "Pokud se tato možnost zadá, přeskočí automatické obnovení projektu při vytvoření.", "symbols/UseProgramMain/displayName": "Nepoužívat _příkazy nejvyšší úrovně", "symbols/UseProgramMain/description": "Určuje, jestli se má místo příkazů nejvyšší úrovně generovat explicitní třída Program a metoda Main.", + "symbols/DisableOpenAPI/description": "Disable OpenAPI (Swagger) support", "postActions/restore/description": "Obnoví balíčky NuGet vyžadované tímto projektem.", "postActions/restore/manualInstructions/default/text": "Spustit dotnet restore" } \ No newline at end of file diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.de.json b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.de.json index 82c0bf5121ef..72c37fdff835 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.de.json +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.de.json @@ -10,6 +10,7 @@ "symbols/skipRestore/description": "Wenn angegeben, wird die automatische Wiederherstellung des Projekts beim Erstellen übersprungen.", "symbols/UseProgramMain/displayName": "Keine Anweisungen_der obersten Ebene verwenden", "symbols/UseProgramMain/description": "Gibt an, ob anstelle von Anweisungen der obersten Ebene eine explizite Programmklasse und eine Main-Methode generiert werden soll.", + "symbols/DisableOpenAPI/description": "Disable OpenAPI (Swagger) support", "postActions/restore/description": "„NuGet-Pakete“ wiederherstellen, die für dieses Projekt erforderlich sind.", "postActions/restore/manualInstructions/default/text": "„dotnet restore“ ausführen" } \ No newline at end of file diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.es.json b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.es.json index 538c473b54a8..d6902478a520 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.es.json +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.es.json @@ -10,6 +10,7 @@ "symbols/skipRestore/description": "Si se especifica, se omite la restauración automática del proyecto durante la creación.", "symbols/UseProgramMain/displayName": "No usar instrucciones de _nivel superior", "symbols/UseProgramMain/description": "Indica si se debe generar una clase Program explícita y un método Main en lugar de instrucciones de nivel superior.", + "symbols/DisableOpenAPI/description": "Disable OpenAPI (Swagger) support", "postActions/restore/description": "Restaure los paquetes NuGet necesarios para este proyecto.", "postActions/restore/manualInstructions/default/text": "Ejecutar \"dotnet restore\"" } \ No newline at end of file diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.fr.json b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.fr.json index 463429e219a1..5a6146402f37 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.fr.json +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.fr.json @@ -10,6 +10,7 @@ "symbols/skipRestore/description": "S’il est spécifié, ignore la restauration automatique du projet lors de la création.", "symbols/UseProgramMain/displayName": "N’utilisez pas _d’instructions de niveau supérieur.", "symbols/UseProgramMain/description": "Indique s’il faut générer une classe Programme explicite et une méthode Main au lieu d’instructions de niveau supérieur.", + "symbols/DisableOpenAPI/description": "Disable OpenAPI (Swagger) support", "postActions/restore/description": "Restaurez les packages NuGet requis par ce projet.", "postActions/restore/manualInstructions/default/text": "Exécuter « dotnet restore »" } \ No newline at end of file diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.it.json b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.it.json index 15792378214e..18be8dbf2fa2 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.it.json +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.it.json @@ -10,6 +10,7 @@ "symbols/skipRestore/description": "Se specificato, ignora il ripristino automatico del progetto durante la creazione.", "symbols/UseProgramMain/displayName": "Non usare_istruzioni di primo livello", "symbols/UseProgramMain/description": "Indica se generare una classe Program esplicita e un metodo Main anziché istruzioni di primo livello.", + "symbols/DisableOpenAPI/description": "Disable OpenAPI (Swagger) support", "postActions/restore/description": "Ripristina i pacchetti NuGet richiesti da questo progetto.", "postActions/restore/manualInstructions/default/text": "Esegui 'dotnet restore'" } \ No newline at end of file diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.ja.json b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.ja.json index 16fad5c66aa0..04549054ce8f 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.ja.json +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.ja.json @@ -10,6 +10,7 @@ "symbols/skipRestore/description": "指定した場合、作成時にプロジェクトの自動復元がスキップされます。", "symbols/UseProgramMain/displayName": "最上位レベルのステートメントを使用しない(_T)", "symbols/UseProgramMain/description": "最上位レベルのステートメントではなく、明示的な Program クラスと Main メソッドを生成するかどうか。", + "symbols/DisableOpenAPI/description": "Disable OpenAPI (Swagger) support", "postActions/restore/description": "このプロジェクトに必要な NuGet パッケージを復元します。", "postActions/restore/manualInstructions/default/text": "'dotnet restore' を実行する" } \ No newline at end of file diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.ko.json b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.ko.json index 763695fd5a3e..795971474519 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.ko.json +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.ko.json @@ -10,6 +10,7 @@ "symbols/skipRestore/description": "지정된 경우, 프로젝트 생성 시 자동 복원을 건너뜁니다.", "symbols/UseProgramMain/displayName": "최상위 문 사용 안 함(_T)", "symbols/UseProgramMain/description": "최상위 문 대신 명시적 Program 클래스 및 Main 메서드를 생성할지 여부입니다.", + "symbols/DisableOpenAPI/description": "Disable OpenAPI (Swagger) support", "postActions/restore/description": "이 프로젝트에 필요한 NuGet 패키지를 복원합니다.", "postActions/restore/manualInstructions/default/text": "'dotnet restore' 실행" } \ No newline at end of file diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.pl.json b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.pl.json index f85ea12cb58c..9d140822a380 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.pl.json +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.pl.json @@ -10,6 +10,7 @@ "symbols/skipRestore/description": "Jeśli ta opcja jest określona, pomija automatyczne przywracanie projektu podczas tworzenia.", "symbols/UseProgramMain/displayName": "Nie używaj ins_trukcji najwyższego poziomu", "symbols/UseProgramMain/description": "Określa, czy wygenerować jawną klasę Program i metodę Main zamiast instrukcji najwyższego poziomu.", + "symbols/DisableOpenAPI/description": "Disable OpenAPI (Swagger) support", "postActions/restore/description": "Przywróć pakiety NuGet wymagane przez ten projekt.", "postActions/restore/manualInstructions/default/text": "Uruchom polecenie \"dotnet restore\"" } \ No newline at end of file diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.pt-BR.json b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.pt-BR.json index d56c2f98339b..387de16a6714 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.pt-BR.json +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.pt-BR.json @@ -10,6 +10,7 @@ "symbols/skipRestore/description": "Se especificado, ignora a restauração automática do projeto sendo criado.", "symbols/UseProgramMain/displayName": "Não use ins_truções de nível superior", "symbols/UseProgramMain/description": "Se deve gerar uma classe de Programa explícita e um método principal em vez de instruções de nível superior.", + "symbols/DisableOpenAPI/description": "Disable OpenAPI (Swagger) support", "postActions/restore/description": "Restaure os pacotes NuGet exigidos por este projeto.", "postActions/restore/manualInstructions/default/text": "Executa 'dotnet restore'" } \ No newline at end of file diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.ru.json b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.ru.json index b1303ffe207e..34073d1f5999 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.ru.json +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.ru.json @@ -10,6 +10,7 @@ "symbols/skipRestore/description": "Если установлено, автоматическое восстановление проекта при создании пропускается.", "symbols/UseProgramMain/displayName": "Не использовать _операторы верхнего уровня", "symbols/UseProgramMain/description": "Следует ли создавать явный класс Program и метод Main вместо операторов верхнего уровня.", + "symbols/DisableOpenAPI/description": "Disable OpenAPI (Swagger) support", "postActions/restore/description": "Восстановление пакетов NuGet, необходимых для этого проекта.", "postActions/restore/manualInstructions/default/text": "Выполнить команду \"dotnet restore\"" } \ No newline at end of file diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.tr.json b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.tr.json index 008a53a65f0f..c2b211a3eac5 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.tr.json +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.tr.json @@ -10,6 +10,7 @@ "symbols/skipRestore/description": "Belirtilirse, oluşturma sırasında projenin otomatik geri yüklenmesini atlar.", "symbols/UseProgramMain/displayName": "_Üst düzey deyimler kullanmayın", "symbols/UseProgramMain/description": "Üst düzey deyimler yerine açık bir Program sınıfı ve Ana yöntem oluşturup oluşturulmayacağını belirtir.", + "symbols/DisableOpenAPI/description": "Disable OpenAPI (Swagger) support", "postActions/restore/description": "Bu projenin gerektirdiği NuGet paketlerini geri yükleyin.", "postActions/restore/manualInstructions/default/text": "'dotnet restore' çalıştır" } \ No newline at end of file diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.zh-Hans.json b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.zh-Hans.json index 2247dc6d4b36..cedb5e3c71aa 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.zh-Hans.json +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.zh-Hans.json @@ -10,6 +10,7 @@ "symbols/skipRestore/description": "如果指定,则在创建时跳过项目的自动还原。", "symbols/UseProgramMain/displayName": "不使用顶级语句(_T)", "symbols/UseProgramMain/description": "是否生成显式程序类和主方法,而不是顶级语句。", + "symbols/DisableOpenAPI/description": "Disable OpenAPI (Swagger) support", "postActions/restore/description": "还原此项目所需的 NuGet 包。", "postActions/restore/manualInstructions/default/text": "运行 \"dotnet restore\"" } \ No newline at end of file diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.zh-Hant.json b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.zh-Hant.json index 7691752108c9..19940e8d352a 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.zh-Hant.json +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/.template.config/localize/templatestrings.zh-Hant.json @@ -10,6 +10,7 @@ "symbols/skipRestore/description": "若指定,會在建立時跳過專案的自動還原。", "symbols/UseProgramMain/displayName": "不要使用最上層陳述式(_T)", "symbols/UseProgramMain/description": "是否要產生明確的 Program 類別和 Main 方法,而非最上層語句。", + "symbols/DisableOpenAPI/description": "Disable OpenAPI (Swagger) support", "postActions/restore/description": "還原此專案所需的 NuGet 套件。", "postActions/restore/manualInstructions/default/text": "執行 'dotnet restore'" } \ No newline at end of file From a442d805ef74654cd841496ae72bf4a0977e0d03 Mon Sep 17 00:00:00 2001 From: Sander ten Brinke Date: Mon, 3 Mar 2025 21:43:55 +0100 Subject: [PATCH 14/21] Add usings for TypedResults and Results/NotFound/Ok etc.. --- .../content/WebApiAot-CSharp/Program.Main.cs | 8 +++++--- .../content/WebApiAot-CSharp/Program.cs | 2 ++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/Program.Main.cs b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/Program.Main.cs index 6bfc32df93c6..d15ec793c671 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/Program.Main.cs +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/Program.Main.cs @@ -1,4 +1,6 @@ using System.Text.Json.Serialization; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.HttpResults; namespace Company.WebApplication1; @@ -24,7 +26,7 @@ public static void Main(string[] args) }; var todosApi = app.MapGroup("/todos"); - #if (EnableOpenAPI) +#if (EnableOpenAPI) todosApi.MapGet("/", () => sampleTodos) .WithName("GetTodos"); @@ -33,14 +35,14 @@ public static void Main(string[] args) ? TypedResults.Ok(todo) : TypedResults.NotFound()) .WithName("GetTodoById"); - #else +#else todosApi.MapGet("/", () => sampleTodos); todosApi.MapGet("/{id}", Results, NotFound> (int id) => sampleTodos.FirstOrDefault(a => a.Id == id) is { } todo ? TypedResults.Ok(todo) : TypedResults.NotFound()); - #endif +#endif app.Run(); } diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/Program.cs b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/Program.cs index 870024e24f6c..4a5b3fbb19fc 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/Program.cs +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/Program.cs @@ -1,4 +1,6 @@ using System.Text.Json.Serialization; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.HttpResults; var builder = WebApplication.CreateSlimBuilder(args); From 0891a991a9dfd6e509dabd89c0dbfe786531c375 Mon Sep 17 00:00:00 2001 From: Sander ten Brinke Date: Mon, 3 Mar 2025 21:54:00 +0100 Subject: [PATCH 15/21] Add OpenAPI services to Program.Main.cs --- .../content/WebApiAot-CSharp/Program.Main.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/Program.Main.cs b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/Program.Main.cs index d15ec793c671..6519b07a3333 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/Program.Main.cs +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/Program.Main.cs @@ -15,8 +15,20 @@ public static void Main(string[] args) options.SerializerOptions.TypeInfoResolverChain.Insert(0, AppJsonSerializerContext.Default); }); +#if (EnableOpenAPI) + // Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi + builder.Services.AddOpenApi(); +#endif + var app = builder.Build(); +#if (EnableOpenAPI) + if (app.Environment.IsDevelopment()) + { + app.MapOpenApi(); + } +#endif + var sampleTodos = new Todo[] { new(1, "Walk the dog"), new(2, "Do the dishes", DateOnly.FromDateTime(DateTime.Now)), From 3c4d85467750463f58efc892327573b90cf59283 Mon Sep 17 00:00:00 2001 From: Sander ten Brinke Date: Mon, 3 Mar 2025 22:38:50 +0100 Subject: [PATCH 16/21] Remove http using because thats already part of the implicit usings --- .../content/WebApiAot-CSharp/Program.Main.cs | 1 - .../Web.ProjectTemplates/content/WebApiAot-CSharp/Program.cs | 1 - 2 files changed, 2 deletions(-) diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/Program.Main.cs b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/Program.Main.cs index 6519b07a3333..5cbfe789b9ed 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/Program.Main.cs +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/Program.Main.cs @@ -1,5 +1,4 @@ using System.Text.Json.Serialization; -using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.HttpResults; namespace Company.WebApplication1; diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/Program.cs b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/Program.cs index 4a5b3fbb19fc..819db8fb6a3a 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/Program.cs +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/Program.cs @@ -1,5 +1,4 @@ using System.Text.Json.Serialization; -using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.HttpResults; var builder = WebApplication.CreateSlimBuilder(args); From 63cf302e75f871ae01f0e77f84284a23ecdb28f4 Mon Sep 17 00:00:00 2001 From: Sander ten Brinke Date: Tue, 4 Mar 2025 11:04:44 +0100 Subject: [PATCH 17/21] TEMP COMMIT - Removing EnableOpenAPI flags to find out why tests fail --- .../content/WebApiAot-CSharp/Program.Main.cs | 14 +------------- .../content/WebApiAot-CSharp/Program.cs | 13 ------------- 2 files changed, 1 insertion(+), 26 deletions(-) diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/Program.Main.cs b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/Program.Main.cs index 5cbfe789b9ed..7828b35c40d1 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/Program.Main.cs +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/Program.Main.cs @@ -14,19 +14,15 @@ public static void Main(string[] args) options.SerializerOptions.TypeInfoResolverChain.Insert(0, AppJsonSerializerContext.Default); }); -#if (EnableOpenAPI) // Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi builder.Services.AddOpenApi(); -#endif var app = builder.Build(); -#if (EnableOpenAPI) if (app.Environment.IsDevelopment()) { app.MapOpenApi(); } -#endif var sampleTodos = new Todo[] { new(1, "Walk the dog"), @@ -37,7 +33,7 @@ public static void Main(string[] args) }; var todosApi = app.MapGroup("/todos"); -#if (EnableOpenAPI) + todosApi.MapGet("/", () => sampleTodos) .WithName("GetTodos"); @@ -46,14 +42,6 @@ public static void Main(string[] args) ? TypedResults.Ok(todo) : TypedResults.NotFound()) .WithName("GetTodoById"); -#else - todosApi.MapGet("/", () => sampleTodos); - - todosApi.MapGet("/{id}", Results, NotFound> (int id) => - sampleTodos.FirstOrDefault(a => a.Id == id) is { } todo - ? TypedResults.Ok(todo) - : TypedResults.NotFound()); -#endif app.Run(); } diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/Program.cs b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/Program.cs index 819db8fb6a3a..03fb8eddee52 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/Program.cs +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/Program.cs @@ -8,19 +8,15 @@ options.SerializerOptions.TypeInfoResolverChain.Insert(0, AppJsonSerializerContext.Default); }); -#if (EnableOpenAPI) // Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi builder.Services.AddOpenApi(); -#endif var app = builder.Build(); -#if (EnableOpenAPI) if (app.Environment.IsDevelopment()) { app.MapOpenApi(); } -#endif var sampleTodos = new Todo[] { new(1, "Walk the dog"), @@ -31,7 +27,6 @@ }; var todosApi = app.MapGroup("/todos"); -#if (EnableOpenAPI) todosApi.MapGet("/", () => sampleTodos) .WithName("GetTodos"); @@ -40,14 +35,6 @@ ? TypedResults.Ok(todo) : TypedResults.NotFound()) .WithName("GetTodoById"); -#else -todosApi.MapGet("/", () => sampleTodos); - -todosApi.MapGet("/{id}", Results, NotFound> (int id) => - sampleTodos.FirstOrDefault(a => a.Id == id) is { } todo - ? TypedResults.Ok(todo) - : TypedResults.NotFound()); -#endif app.Run(); From 9674e324841896cb7f549fdc82ee2e21c1a5e7b4 Mon Sep 17 00:00:00 2001 From: Sander ten Brinke Date: Tue, 4 Mar 2025 16:37:04 +0100 Subject: [PATCH 18/21] Revert "TEMP COMMIT - Removing EnableOpenAPI flags to find out why tests fail" This reverts commit 63cf302e75f871ae01f0e77f84284a23ecdb28f4. --- .../content/WebApiAot-CSharp/Program.Main.cs | 14 +++++++++++++- .../content/WebApiAot-CSharp/Program.cs | 13 +++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/Program.Main.cs b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/Program.Main.cs index 7828b35c40d1..5cbfe789b9ed 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/Program.Main.cs +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/Program.Main.cs @@ -14,15 +14,19 @@ public static void Main(string[] args) options.SerializerOptions.TypeInfoResolverChain.Insert(0, AppJsonSerializerContext.Default); }); +#if (EnableOpenAPI) // Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi builder.Services.AddOpenApi(); +#endif var app = builder.Build(); +#if (EnableOpenAPI) if (app.Environment.IsDevelopment()) { app.MapOpenApi(); } +#endif var sampleTodos = new Todo[] { new(1, "Walk the dog"), @@ -33,7 +37,7 @@ public static void Main(string[] args) }; var todosApi = app.MapGroup("/todos"); - +#if (EnableOpenAPI) todosApi.MapGet("/", () => sampleTodos) .WithName("GetTodos"); @@ -42,6 +46,14 @@ public static void Main(string[] args) ? TypedResults.Ok(todo) : TypedResults.NotFound()) .WithName("GetTodoById"); +#else + todosApi.MapGet("/", () => sampleTodos); + + todosApi.MapGet("/{id}", Results, NotFound> (int id) => + sampleTodos.FirstOrDefault(a => a.Id == id) is { } todo + ? TypedResults.Ok(todo) + : TypedResults.NotFound()); +#endif app.Run(); } diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/Program.cs b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/Program.cs index 03fb8eddee52..819db8fb6a3a 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/Program.cs +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/Program.cs @@ -8,15 +8,19 @@ options.SerializerOptions.TypeInfoResolverChain.Insert(0, AppJsonSerializerContext.Default); }); +#if (EnableOpenAPI) // Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi builder.Services.AddOpenApi(); +#endif var app = builder.Build(); +#if (EnableOpenAPI) if (app.Environment.IsDevelopment()) { app.MapOpenApi(); } +#endif var sampleTodos = new Todo[] { new(1, "Walk the dog"), @@ -27,6 +31,7 @@ }; var todosApi = app.MapGroup("/todos"); +#if (EnableOpenAPI) todosApi.MapGet("/", () => sampleTodos) .WithName("GetTodos"); @@ -35,6 +40,14 @@ ? TypedResults.Ok(todo) : TypedResults.NotFound()) .WithName("GetTodoById"); +#else +todosApi.MapGet("/", () => sampleTodos); + +todosApi.MapGet("/{id}", Results, NotFound> (int id) => + sampleTodos.FirstOrDefault(a => a.Id == id) is { } todo + ? TypedResults.Ok(todo) + : TypedResults.NotFound()); +#endif app.Run(); From 983ec24f060462f7a4b733793854b713e4bcaa38 Mon Sep 17 00:00:00 2001 From: Sander ten Brinke Date: Tue, 4 Mar 2025 16:52:58 +0100 Subject: [PATCH 19/21] Fix assertions where we expected OpenAPI to be enabled for published apps, which is not the case --- .../WebApiNativeAotTemplateTest.cs | 35 +++++++++++++++---- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/src/ProjectTemplates/test/Templates.Tests/WebApiNativeAotTemplateTest.cs b/src/ProjectTemplates/test/Templates.Tests/WebApiNativeAotTemplateTest.cs index 45e0d930874b..9eb6c5a04db4 100644 --- a/src/ProjectTemplates/test/Templates.Tests/WebApiNativeAotTemplateTest.cs +++ b/src/ProjectTemplates/test/Templates.Tests/WebApiNativeAotTemplateTest.cs @@ -34,30 +34,51 @@ public ITestOutputHelper Output [SkipOnHelix("https://github.com/dotnet/aspnetcore/issues/47478", Queues = HelixConstants.NativeAotNotSupportedHelixQueues)] public async Task WebApiNativeAotTemplateCSharp() { - await WebApiNativeAotTemplateCore(languageOverride: null, additionalEndpointsThatShould200Ok: new[] { "/openapi/v1.json" }); + await WebApiNativeAotTemplateCore(languageOverride: null, additionalEndpointsThatShould200OkForBuiltProjects: new[] { "/openapi/v1.json" }); } [ConditionalFact] [SkipOnHelix("https://github.com/dotnet/aspnetcore/issues/47478", Queues = HelixConstants.NativeAotNotSupportedHelixQueues)] public async Task WebApiNativeAotTemplateProgramMainCSharp() { - await WebApiNativeAotTemplateCore(languageOverride: null, args: new[] { ArgConstants.UseProgramMain }, additionalEndpointsThatShould200Ok: new[] { "/openapi/v1.json" }); + await WebApiNativeAotTemplateCore(languageOverride: null, args: new[] { ArgConstants.UseProgramMain }, additionalEndpointsThatShould200OkForBuiltProjects: new[] { "/openapi/v1.json" }); + } + + [ConditionalTheory] + [InlineData(false)] + [InlineData(true)] + public async Task WebApiNativeAotTemplateCSharp_OpenApiDisabledInProductionEnvironment() + { + var args = useProgramMain + ? new[] { ArgConstants.UseProgramMain } + : new[] { }; + + await WebApiNativeAotTemplateCore(languageOverride: null, args: args, additionalEndpointsThatShould404NotFoundForPublishedProjects: new[] { "/openapi/v1.json" }); } [ConditionalTheory] [InlineData(false)] [InlineData(true)] [SkipOnHelix("https://github.com/dotnet/aspnetcore/issues/47478", Queues = HelixConstants.NativeAotNotSupportedHelixQueues)] - public async Task WebApiTemplateCSharp_WithoutOpenAPI(bool useProgramMain) + public async Task WebApiNativeAotTemplateCSharp_WithoutOpenAPI(bool useProgramMain) { var args = useProgramMain ? new[] { ArgConstants.UseProgramMain, ArgConstants.NoOpenApi } : new[] { ArgConstants.NoOpenApi }; - await WebApiNativeAotTemplateCore(languageOverride: null, args: args, additionalEndpointsThatShould404NotFound: new[] { "/openapi/v1.json" }); + await WebApiNativeAotTemplateCore( + languageOverride: null, + args: args, + additionalEndpointsThatShould404NotFoundForBuiltProjects: new[] { "/openapi/v1.json" }; } - private async Task WebApiNativeAotTemplateCore(string languageOverride, string[] args = null, string[] additionalEndpointsThatShould200Ok = null, string[] additionalEndpointsThatShould404NotFound = null) + private async Task WebApiNativeAotTemplateCore( + string languageOverride, + string[] args = null, + string[] additionalEndpointsThatShould200OkForBuiltProjects = null, + string[] additionalEndpointsThatShould200OkForPublishedProjects = null, + string[] additionalEndpointsThatShould404NotFoundForBuiltProjects = null, + string[] additionalEndpointsThatShould404NotFoundForPublishedProjects = null) { var project = await ProjectFactory.CreateProject(Output); project.SetCurrentRuntimeIdentifier(); @@ -90,7 +111,7 @@ private async Task WebApiNativeAotTemplateCore(string languageOverride, string[] Assert.False( aspNetProcess.Process.HasExited, ErrorMessages.GetFailedProcessMessageOrEmpty("Run built project", project, aspNetProcess.Process)); - await AssertEndpoints(aspNetProcess, additionalEndpointsThatShould200Ok, additionalEndpointsThatShould404NotFound); + await AssertEndpoints(aspNetProcess, additionalEndpointsThatShould200OkForBuiltProjects, additionalEndpointsThatShould404NotFoundForBuiltProjects); } using (var aspNetProcess = project.StartPublishedProjectAsync(noHttps: true, usePublishedAppHost: true)) @@ -99,7 +120,7 @@ private async Task WebApiNativeAotTemplateCore(string languageOverride, string[] aspNetProcess.Process.HasExited, ErrorMessages.GetFailedProcessMessageOrEmpty("Run published project", project, aspNetProcess.Process)); - await AssertEndpoints(aspNetProcess, additionalEndpointsThatShould200Ok, additionalEndpointsThatShould404NotFound); + await AssertEndpoints(aspNetProcess, additionalEndpointsThatShould200OkForPublishedProjects, additionalEndpointsThatShould404NotFoundForPublishedProjects); } } From 102bbb4528fe686b9807b0f84a6f7fe4629bbd4d Mon Sep 17 00:00:00 2001 From: Sander ten Brinke Date: Tue, 4 Mar 2025 16:55:54 +0100 Subject: [PATCH 20/21] Added consistent indentation in test methods --- .../Templates.Tests/WebApiNativeAotTemplateTest.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/ProjectTemplates/test/Templates.Tests/WebApiNativeAotTemplateTest.cs b/src/ProjectTemplates/test/Templates.Tests/WebApiNativeAotTemplateTest.cs index 9eb6c5a04db4..6c4644622946 100644 --- a/src/ProjectTemplates/test/Templates.Tests/WebApiNativeAotTemplateTest.cs +++ b/src/ProjectTemplates/test/Templates.Tests/WebApiNativeAotTemplateTest.cs @@ -34,14 +34,19 @@ public ITestOutputHelper Output [SkipOnHelix("https://github.com/dotnet/aspnetcore/issues/47478", Queues = HelixConstants.NativeAotNotSupportedHelixQueues)] public async Task WebApiNativeAotTemplateCSharp() { - await WebApiNativeAotTemplateCore(languageOverride: null, additionalEndpointsThatShould200OkForBuiltProjects: new[] { "/openapi/v1.json" }); + await WebApiNativeAotTemplateCore( + languageOverride: null, + additionalEndpointsThatShould200OkForBuiltProjects: new[] { "/openapi/v1.json" }); } [ConditionalFact] [SkipOnHelix("https://github.com/dotnet/aspnetcore/issues/47478", Queues = HelixConstants.NativeAotNotSupportedHelixQueues)] public async Task WebApiNativeAotTemplateProgramMainCSharp() { - await WebApiNativeAotTemplateCore(languageOverride: null, args: new[] { ArgConstants.UseProgramMain }, additionalEndpointsThatShould200OkForBuiltProjects: new[] { "/openapi/v1.json" }); + await WebApiNativeAotTemplateCore( + languageOverride: null, + args: new[] { ArgConstants.UseProgramMain }, + additionalEndpointsThatShould200OkForBuiltProjects: new[] { "/openapi/v1.json" }); } [ConditionalTheory] @@ -53,7 +58,10 @@ public async Task WebApiNativeAotTemplateCSharp_OpenApiDisabledInProductionEnvir ? new[] { ArgConstants.UseProgramMain } : new[] { }; - await WebApiNativeAotTemplateCore(languageOverride: null, args: args, additionalEndpointsThatShould404NotFoundForPublishedProjects: new[] { "/openapi/v1.json" }); + await WebApiNativeAotTemplateCore( + languageOverride: null, + args: args, + additionalEndpointsThatShould404NotFoundForPublishedProjects: new[] { "/openapi/v1.json" }); } [ConditionalTheory] From 7cf3a0bbc03a5d9a2baf25531118eca2e09a6522 Mon Sep 17 00:00:00 2001 From: Sander ten Brinke Date: Tue, 4 Mar 2025 20:00:35 +0100 Subject: [PATCH 21/21] Fix build errors --- .../test/Templates.Tests/WebApiNativeAotTemplateTest.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/ProjectTemplates/test/Templates.Tests/WebApiNativeAotTemplateTest.cs b/src/ProjectTemplates/test/Templates.Tests/WebApiNativeAotTemplateTest.cs index 6c4644622946..d1d6547c8484 100644 --- a/src/ProjectTemplates/test/Templates.Tests/WebApiNativeAotTemplateTest.cs +++ b/src/ProjectTemplates/test/Templates.Tests/WebApiNativeAotTemplateTest.cs @@ -52,11 +52,12 @@ await WebApiNativeAotTemplateCore( [ConditionalTheory] [InlineData(false)] [InlineData(true)] - public async Task WebApiNativeAotTemplateCSharp_OpenApiDisabledInProductionEnvironment() + [SkipOnHelix("https://github.com/dotnet/aspnetcore/issues/47478", Queues = HelixConstants.NativeAotNotSupportedHelixQueues)] + public async Task WebApiNativeAotTemplateCSharp_OpenApiDisabledInProductionEnvironment(bool useProgramMain) { var args = useProgramMain ? new[] { ArgConstants.UseProgramMain } - : new[] { }; + : new string[] { }; await WebApiNativeAotTemplateCore( languageOverride: null, @@ -77,7 +78,7 @@ public async Task WebApiNativeAotTemplateCSharp_WithoutOpenAPI(bool useProgramMa await WebApiNativeAotTemplateCore( languageOverride: null, args: args, - additionalEndpointsThatShould404NotFoundForBuiltProjects: new[] { "/openapi/v1.json" }; + additionalEndpointsThatShould404NotFoundForBuiltProjects: new[] { "/openapi/v1.json" }); } private async Task WebApiNativeAotTemplateCore(