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?
I have done it with this:
// Configure(...)
app.UseOpenApi();
app.UseSwaggerUi3();
new Thread(() =>
{
Thread.Sleep(800);
GenerateClientCode();
}).Start();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.