You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to use the SwaggerGenerator to export the swagger.json file. I follow how the cli does.
public static void ExportSwaggerJsonFile(this WebApplication app, string outputFilePath)
{
var swaggerProvider = app.Services.GetRequiredService<ISwaggerProvider>();
var swagger = swaggerProvider.GetSwagger(app.Environment.ApplicationName);
var s = swagger.Paths;
var outputPath = Path.Combine(Directory.GetCurrentDirectory(), outputFilePath);
FileInfo fi = new(outputPath);
fi.Directory?.Create();
using var streamWriter = File.CreateText(outputPath);
IOpenApiWriter writer = new OpenApiJsonWriter(streamWriter);
swagger.SerializeAsV3(writer);
Console.WriteLine($"Swagger JSON/YAML successfully written to {outputPath}");
}
However, if I dont run the app.Run or app.Start or execute the function before the app.Run or app.Start, the output file wont contain the paths and schemas etc.
Is there a particular reason that we have to start server? We cant generate the json file based on the metadata? Or am i missing something? Any help is much appreciated.
BTW, i am on .net 6 and using swashbuckle 6.4.
The text was updated successfully, but these errors were encountered:
I am trying to use the SwaggerGenerator to export the swagger.json file. I follow how the cli does.
However, if I dont run the app.Run or app.Start or execute the function before the app.Run or app.Start, the output file wont contain the paths and schemas etc.
Is there a particular reason that we have to start server? We cant generate the json file based on the metadata? Or am i missing something? Any help is much appreciated.
BTW, i am on .net 6 and using swashbuckle 6.4.
The text was updated successfully, but these errors were encountered: