0

I want to have generated typescript files. In Startup.cs there is following code.

Configure:
    services.AddSwaggerDocument();
ConfigureServices: 
    app.UseOpenApi();
    app.UseSwaggerUi3();

So I need something like this:

var document = OpenApiDocument.FromUrlAsync("http://localhost:5005/swagger/v1/swagger.json").Result;
var clientSettings = new TypeScriptClientGeneratorSettings
{
   ClassName = "MyClass",
   TypeScriptGeneratorSettings = { Namespace = "MyNamespace" }
};
var clientGenerator = new TypeScriptClientGenerator(document, clientSettings);
var code = clientGenerator.GenerateFile();
File.WriteAllText(Path.Join(Directory.GetCurrentDirectory(), "generated"), code);

What place should i choose for this code?

FoxPro
  • 2,054
  • 4
  • 11
  • 34

1 Answers1

0

I have done it with this:

// Configure(...)
            app.UseOpenApi();
            app.UseSwaggerUi3();
            new Thread(() =>
            {
                Thread.Sleep(800);
                GenerateClientCode();
            }).Start();
FoxPro
  • 2,054
  • 4
  • 11
  • 34