To generate the Swagger documentation on the Controller actions, you can run the command below.
❯ nomirun generate swagger --module-csproj "CSPROJ_FILE_PATH"
It will scan all the Nomirun controllers and add the Swagger attribute if not already present.
Make sure you run the init process as it downloads the local LLM model.
If your computer has CUDA 12 installed, the process will use the Nvidia graphic card to run the AI model, which runs much faster than on the CPU.
What the generate swagger
command does it generates the missing swagger documentation for every HTTP endpoint.
This is how it looks before:
using Nomirun.Sdk.Abstractions.Interfaces;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
namespace CustomerModule.Infrastructure.HttpApi.v1;
[Route("api")]
public class CustomerModuleController : NomirunApiController
{
private readonly ILogger<CustomerModuleController> _logger;
public CustomerModuleController(ILogger<CustomerModuleController> logger): base(logger)
{
_logger = logger;
}
[HttpGet("demo")]
public async Task<IActionResult> DemoAction()
{
var output = "My awesome CustomerModuleController action log.";
_logger.LogInformation(output);
return Ok(output);
}
}
And this is how it looks afterwards:
using Swashbuckle.AspNetCore.Annotations;
using Nomirun.Sdk.Abstractions.Interfaces;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
namespace CustomerModule.Infrastructure.HttpApi.v1;
[Route("api")]
public class CustomerModuleController : NomirunApiController
{
private readonly ILogger<CustomerModuleController> _logger;
public CustomerModuleController(ILogger<CustomerModuleController> logger): base(logger)
{
_logger = logger;
}
[SwaggerOperation(
Summary = "Returns a demo action result",
Description = "Returns a demo action result. The action logs a message using the ILogger interface and returns the message as a response.",
OperationId = nameof(DemoAction),
Tags = new[] { "CustomerModule" }
)]
[HttpGet("demo")]
public async Task<IActionResult> DemoAction()
{
var output = "My awesome CustomerModuleController action log.";
_logger.LogInformation(output);
return Ok(output);
}
}
In reality, controllers will contain more business logic and code, and the LLM will be many more details in describing controller endpoint.