Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Output OpenAPI json file during build #348

Closed
LoaderB0T opened this issue Nov 24, 2022 · 5 comments
Closed

Output OpenAPI json file during build #348

LoaderB0T opened this issue Nov 24, 2022 · 5 comments
Assignees
Labels
enhancement New feature or request implemented requested feature has been implemented

Comments

@LoaderB0T
Copy link

Hi,

I just started looking into a project that uses FastEndpoints and I am trying to find a way to generate the OpenAPI file(s) during the build.

I imagine it would work similarly to the GenerateClientsAndExitAsync method. The difference is that I don't want a whole Client to be generated, just the OpenAPI description file (json or yaml) that is otherwise available during runtime in the browser.

Is this somehow possible or planned? 😃. Otherwise FastEndpoints seems like a really nice choice for creating... well... fast endpoints! 😁

Thanks

@dj-nitehawk
Copy link
Member

can add that in a few days. but if you're in a hurry, it's pretty easy to do it yourself inside an if block in the startup yourself. see this test code for an example:
https://github.com/FastEndpoints/FastEndpoints/blob/main/Tests/IntegrationTests/FastEndpoints.Swagger.IntegrationTests/SwaggerDocTests.cs

@dj-nitehawk dj-nitehawk added the enhancement New feature or request label Nov 25, 2022
@dj-nitehawk dj-nitehawk self-assigned this Nov 25, 2022
@LoaderB0T
Copy link
Author

Thanks for the hint, I got it working in no time,
A built-in method would be the cherry on the top 👍

dj-nitehawk added a commit that referenced this issue Nov 25, 2022
@dj-nitehawk dj-nitehawk added the implemented requested feature has been implemented label Nov 25, 2022
@dj-nitehawk
Copy link
Member

implemented in v5.4.1.5-beta

/// <summary>
/// exports swagger.json files to disk if the application is run with the commandline argument <c>--exportswaggerjson true</c>
/// and exits the program with a zero exit code.
/// <para>HINT: make sure to place the call straight after <c>app.UseFastEndpoints()</c></para>
/// </summary>
/// <param name="documentName">the name of the swagger document to generate the clients for</param>
/// <param name="destinationPath">the folder path (without file name) where the client files will be save to</param>
public static async Task ExportSwaggerJsonAndExitAsync(this WebApplication app, string documentName, string destinationPath)

@LoaderB0T
Copy link
Author

Wow, thanks a lot for the quick solution!

@frasermclean
Copy link

This is awesome! Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request implemented requested feature has been implemented
Development

No branches or pull requests

3 participants