Skip to content

Fast.OpenApi ​

Public members, parameters, returns, and exceptions

The installation example uses NuGet package 3.5.47 for net8.0, net9.0 and net10.0.

Reference source version 3.5.47.

Contract and constraints ​

Generates JavaScript/TypeScript clients from Swagger JSON and application API descriptions. AddOpenApi() defaults to OpenApiSettings; it does not serve Swagger UI. OpenApiUtil generation requests swagger/{group}/swagger.json and writes beneath Fast.OpenApi in the application base directory. An existing output directory is recursively removed before generation. Call generation only from an explicitly approved maintenance operation after checking that directory. It has no output-directory or CancellationToken parameter. Blank/non-absolute addresses throw ArgumentException; a missing description provider throws ArgumentNullException. Generated Web/Mobile variants preserve download response types, expose upload progress and use unknown for unresolved schemas. Successful generation is not proof that the consumer project compiles.

Installation and examples ​

Install the package ​

bash
dotnet add package Fast.OpenApi --version 3.5.47

Register services in Program.cs ​

csharp
using Fast.OpenApi;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Builder;

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllers();
builder.Services.AddOpenApi(builder.Configuration, "OpenApiSettings");

var app = builder.Build();
app.MapControllers();
app.Run();

Generator signature ​

csharp
public static Task GenerateOpenApi(
    string address,
    IApiDescriptionGroupCollectionProvider apiDescriptionGroupCollectionProvider,
    List<string> groupList = null);

Invoke from a maintenance command ​

csharp
using Fast.OpenApi;
using Microsoft.AspNetCore.Mvc.ApiExplorer;

public sealed class ClientExporter(IApiDescriptionGroupCollectionProvider descriptions)
{
    public Task ExportAsync(Uri documentationHost, List<string> groups)
    {
        ArgumentNullException.ThrowIfNull(documentationHost);
        if (!documentationHost.IsAbsoluteUri)
            throw new ArgumentException("需要绝对地址", nameof(documentationHost));
        return OpenApiUtil.GenerateOpenApi(documentationHost.AbsoluteUri, descriptions, groups);
    }
}

Use a web project targeting a supported .NET version. Register services before builder.Build() and map endpoints before app.Run(). Invoke generation from a maintenance command after checking the output directory.

Pagination detection in 3.5.47 ​

Starting with 3.5.47, the default PagedSchemaProperties includes isOrderBy. A generated TypeScript DTO extends PagedInput when its schema contains every field in that set. The generator omits the configured fields by name, even for schemas that do not qualify for pagination. To retain inheritance for legacy schemas without isOrderBy, explicitly configure PagedSchemaProperties to match their fields.

The published fast-element-plus@2.0.27 package does not declare isOrderBy in PagedInput. If your schema includes this field and the frontend needs it to be typed, omit isOrderBy from your custom PagedSchemaProperties so the generator keeps it on the DTO. The remaining pagination fields must still match for the DTO to extend PagedInput.

Source reference ​

Dependency alignment on 2026-11-02 ​

2026-11-02 dependency alignment: this batch incremented the package from 3.5.45 to 3.5.46 and updated its dependency to Fast.Runtime 3.5.37. Runtime adds mobile H5 and shifts Android and subsequent flags; migrate numeric protocols/masks, rebuild consumers and regenerate client enums. See the Runtime H5 migration guide. Historical batches retain their original versions and validation scope.

2026-10-24 versions and dependencies ​

On 2026-10-24, this package increments from 3.5.42 to 3.5.43, with dependencies updated to Fast.Runtime 3.5.34. This module's own implementation and public declarations are unchanged.

Consumers using AppEnvironmentEnum must migrate numeric values and rebuild according to the Runtime HarmonyOS migration guide. This batch reviewed source and effective MSBuild package metadata only. Tests were skipped as requested; no restore, build, pack or consumer runtime validation was performed.