OpenAPIPlus 1.0.0

dotnet add package OpenAPIPlus --version 1.0.0
                    
NuGet\Install-Package OpenAPIPlus -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="OpenAPIPlus" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="OpenAPIPlus" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="OpenAPIPlus" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add OpenAPIPlus --version 1.0.0
                    
#r "nuget: OpenAPIPlus, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package OpenAPIPlus@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=OpenAPIPlus&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=OpenAPIPlus&version=1.0.0
                    
Install as a Cake Tool

OpenAPI Plus

An enhanced OpenAPI/Swagger documentation generator for ASP.NET Core that automatically extracts and applies XML documentation comments to API parameters, including nested properties in complex objects.

Features

  • Automatic Parameter Descriptions: Extracts descriptions from XML comments and applies them to OpenAPI schema
  • GET Request Support: Adds descriptions to query parameters and route parameters
  • POST/PUT Request Support: Adds detailed descriptions to JSON body parameters, including nested properties
  • Form Parameter Support: Applies descriptions to form parameters
  • Nested Property Descriptions: Automatically includes descriptions for inner properties of complex objects
  • Type Information: Includes parameter types, validation rules, and constraints in documentation

Installation

  1. Add the OpenAPIGenerator project reference to your API project
  2. Configure Swagger in your Program.cs:
builder.Services.AddSwaggerGen(c =>
{
    c.SwaggerDoc("v1", new()
    {
        Title = "Sample API",
        Version = "v1",
        Description = "Sample API for testing OpenAPI DescriptionFilter extensions"
    });
    
    // Include XML comments
    var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
    var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
    if (File.Exists(xmlPath))
    {
        c.IncludeXmlComments(xmlPath);
    }
    
    // Add the DescriptionFilter
    c.OperationFilter<DescriptionFilter>();
});
  1. Enable XML documentation generation in your .csproj:
<PropertyGroup>
  <GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>

Usage

Documenting GET Endpoints

For GET requests, add XML comments to your controller methods and parameters:

/// <summary>
/// Retrieves a list of users with optional filtering and pagination parameters.
/// </summary>
/// <param name="pageNumber">The page number for pagination. Must be greater than 0. Default is 1.</param>
/// <param name="pageSize">The number of items per page. Must be between 1 and 100. Default is 10.</param>
/// <param name="isActive">Optional filter to return only active or inactive users.</param>
[HttpGet("users")]
public IActionResult GetUsers([FromQuery] int pageNumber = 1, [FromQuery] int pageSize = 10, [FromQuery] bool? isActive = null)
{
    // Implementation
}

Result in Swagger UI:

GET Parameters in Swagger

Documenting POST/PUT Endpoints with Complex Objects

For POST and PUT requests, document your complex object parameters and their nested properties:

/// <summary>
/// Creates a new user in the system.
/// </summary>
/// <param name="user">The user object containing all necessary information to create a new user.</param>
[HttpPost("users")]
public IActionResult CreateUser([FromBody] User user)
{
    // Implementation
}

Document your model classes with XML comments:

public class User
{
    /// <summary>
    /// Gets or sets the user's first name. This field is required and must be between 2 and 50 characters.
    /// </summary>
    public string FirstName { get; set; } = string.Empty;

    /// <summary>
    /// Gets or sets the metadata information associated with this user.
    /// </summary>
    public Metadata? Metadata { get; set; }
}

public class Metadata
{
    /// <summary>
    /// Gets or sets the version number of the metadata. This is used for tracking changes over time.
    /// </summary>
    public int Version { get; set; }

    /// <summary>
    /// Gets or sets the creation timestamp when this metadata was first created. Format: ISO 8601.
    /// </summary>
    public DateTime CreatedTimestamp { get; set; }
}

Result in Swagger UI:

![POST Parameters with JSON Schema Descriptions](Screenshots/Post-parameters-description of json schema-swagger.png)

Result in Postman:

The descriptions are automatically included in the OpenAPI schema, which Postman imports:

Postman PUT JSON Inner Properties Description

Postman PUT Documentation JSON Description

How It Works

The DescriptionFilter implements IOperationFilter and processes OpenAPI operations:

  • For GET/Other Requests: Extracts method and parameter descriptions from XML comments and applies them to query/route parameters
  • For POST/PUT Requests:
    • Builds a comprehensive description tree from XML comments
    • Applies descriptions to JSON schema properties, including nested objects
    • Handles form parameters with their descriptions

Project Structure

OpenAPIPlus/
├── OpenAPIGenerator/          # Core library
│   ├── DescriptionFilter.cs   # Main operation filter
│   ├── OpenApiOperationExtention.cs
│   ├── ControllerActionDescriptorExtention.cs
│   └── Models/                # Internal models
└── Test.SampleAPI/            # Sample API for testing
    ├── Controllers/
    ├── Models/
    └── Program.cs

Requirements

  • .NET 8.0 or later
  • ASP.NET Core
  • Swashbuckle.AspNetCore (Swagger/OpenAPI)

License

MIT License - see LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 166 12/13/2025