Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
ZOXEXIVO committed Feb 19, 2023
1 parent 3f029a7 commit 78bc1c8
Show file tree
Hide file tree
Showing 13 changed files with 5,049 additions and 14,983 deletions.
3 changes: 3 additions & 0 deletions src/Backend/Geen.Web/Geen.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,7 @@
<ProjectReference Include="..\Geen.Core\Geen.Core.csproj" />
<ProjectReference Include="..\Geen.Data\Geen.Data.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="wwwroot" />
</ItemGroup>
</Project>
11 changes: 11 additions & 0 deletions src/Backend/Geen.sln
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Geen.Jobs", "Geen.Jobs\Geen.Jobs.csproj", "{5FF04ABB-E63F-410E-8FD4-8F3F8F466D26}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Shared", "Shared", "{18E7F239-0C6D-4B63-99E5-C17FCB17F144}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Geen.ClientGenerator", "Shared\Geen.ClientGenerator\Geen.ClientGenerator.csproj", "{2399B714-C97A-4FBC-B3B3-95C3E157609D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -44,11 +48,18 @@ Global
{5FF04ABB-E63F-410E-8FD4-8F3F8F466D26}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5FF04ABB-E63F-410E-8FD4-8F3F8F466D26}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5FF04ABB-E63F-410E-8FD4-8F3F8F466D26}.Release|Any CPU.Build.0 = Release|Any CPU
{2399B714-C97A-4FBC-B3B3-95C3E157609D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2399B714-C97A-4FBC-B3B3-95C3E157609D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2399B714-C97A-4FBC-B3B3-95C3E157609D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2399B714-C97A-4FBC-B3B3-95C3E157609D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {DA22B06E-3BE5-4E2A-B952-67F0BDBA1274}
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{2399B714-C97A-4FBC-B3B3-95C3E157609D} = {18E7F239-0C6D-4B63-99E5-C17FCB17F144}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="NSwag.CodeGeneration.TypeScript" Version="13.18.2" />
<PackageReference Include="NSwag.Core" Version="13.18.2" />
</ItemGroup>

</Project>
43 changes: 43 additions & 0 deletions src/Backend/Shared/Geen.ClientGenerator/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using NJsonSchema.CodeGeneration.TypeScript;
using NSwag;
using NSwag.CodeGeneration.OperationNameGenerators;
using NSwag.CodeGeneration.TypeScript;

var geenSwaggerUrl = "http://localhost:7000/swagger/v1/swagger.json";

var settings = new TypeScriptClientGeneratorSettings();

settings.GenerateDtoTypes = true;
settings.GenerateClientClasses = true;
settings.GenerateClientInterfaces = false;
settings.GenerateOptionalParameters = false;
settings.ExceptionClass = "ApiException";
settings.OperationNameGenerator = new MultipleClientsFromFirstTagAndOperationIdGenerator();
settings.InjectionTokenType = InjectionTokenType.InjectionToken;
settings.RxJsVersion = 7.0m;
settings.TypeScriptGeneratorSettings.TypeStyle = TypeScriptTypeStyle.Class;
settings.TypeScriptGeneratorSettings.TypeScriptVersion = 3.5M;
settings.HttpClass = HttpClass.HttpClient;
settings.Template = TypeScriptTemplate.Angular;
settings.ClassName = "{controller}Client";
settings.UseSingletonProvider = true;

settings.TypeScriptGeneratorSettings.DateTimeType = TypeScriptDateTimeType.Date;

var generator = new TypeScriptClientGenerator(await OpenApiDocument.FromUrlAsync(geenSwaggerUrl), settings);
var code = generator.GenerateFile();

string outFile = "../../../../../../Frontend/src/client/apiClient.ts";

if (File.Exists(outFile))
{
File.Delete(outFile);
}

Directory.CreateDirectory(Path.GetDirectoryName(outFile));

await File.WriteAllTextAsync(outFile, code);

Console.WriteLine(Directory.GetCurrentDirectory());

Console.WriteLine($"Writed: {outFile}");
Loading

0 comments on commit 78bc1c8

Please sign in to comment.