Documentation

AI Capabilities of Nomirun CLI

1. Generate Swagger and module summary documentation

To generate the Swagger documentation on the Controller actions, you can run the command below.

 nomirun generate swagger --module-name <MODULE_NAME> --ai-service LocalModel
        

It will scan all the Nomirun controllers and add the Swagger attribute to all controller actions if not already present.

Make sure you run the init process where you can configure which AI services you want to use to generate the swagger documentation. You can use OpenAI, AzureOpenAI and LocalModel services.

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 generate the missing swagger documentation for every HTTP endpoint.

This is how it looks before the generation of Swagger attributes:

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.