SH.Framework.OpenApi.Implementation 1.0.1

dotnet add package SH.Framework.OpenApi.Implementation --version 1.0.1
                    
NuGet\Install-Package SH.Framework.OpenApi.Implementation -Version 1.0.1
                    
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="SH.Framework.OpenApi.Implementation" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SH.Framework.OpenApi.Implementation" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="SH.Framework.OpenApi.Implementation" />
                    
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 SH.Framework.OpenApi.Implementation --version 1.0.1
                    
#r "nuget: SH.Framework.OpenApi.Implementation, 1.0.1"
                    
#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 SH.Framework.OpenApi.Implementation@1.0.1
                    
#: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=SH.Framework.OpenApi.Implementation&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=SH.Framework.OpenApi.Implementation&version=1.0.1
                    
Install as a Cake Tool

SH.Framework.OpenApi.Implementation

NuGet Version NuGet Downloads License: MIT

A comprehensive implementation layer for OpenAPI integration in ASP.NET Core projects. This package provides extension methods and helpers for customizing OpenAPI schema generation, including friendly schema reference IDs and configuration registration. It extends the default OpenAPI experience with practical utilities for schema naming and configuration.

๐Ÿš€ Features

  • ๐Ÿ”— Extension Methods: Easily register OpenAPI configuration in your DI container
  • ๐Ÿ†” Friendly Schema Reference IDs: Custom logic for readable and unique schema IDs
  • ๐Ÿ”ง Flexible Configuration: Customize OpenAPI options for your project
  • ๐Ÿ“ฆ .NET 10 Support: Modern .NET compatibility
  • ๐Ÿ›ก๏ธ Type Safety: Strongly-typed extension points
  • ๐ŸŽฏ Clean Architecture: Promotes maintainable and scalable API documentation

๐Ÿ“ฆ Installation

dotnet add package SH.Framework.OpenApi.Implementation

Note: This package automatically includes required dependencies for OpenAPI integration.

๐Ÿ› ๏ธ Quick Start

1. Register OpenAPI Configuration

using SH.Framework.Library.OpenApi.Implementation;

var builder = WebApplication.CreateBuilder(args);

// Register OpenAPI configuration
builder.Services.AddOpenApiConfiguration();

var app = builder.Build();

2. Customize Schema Reference IDs

The package provides a helper for generating friendly schema reference IDs:

using SH.Framework.Library.OpenApi.Implementation;

string schemaId = OpenApiExtensions.CreateFriendlyId(typeof(List<string>));
// Output: ListOfString

3. Use in ASP.NET Core Projects

Integrate with your API project for improved OpenAPI documentation:

public static class RegisterOpenApiConfiguration
{
    public static IServiceCollection AddOpenApiConfiguration(this IServiceCollection services) {
        services.AddOpenApi(options =>
        {
            options.CreateSchemaReferenceId = context =>
            {
                return OpenApiExtensions.CreateFriendlyId(context.Type);
            };
        });
        return services;
    }
}

๐Ÿ—๏ธ Architecture Components

Friendly Schema Reference ID

Generates readable and unique schema IDs for OpenAPI documents:

public static string CreateFriendlyId(Type type)
{
    if (type.IsArray)
        return $"{CreateFriendlyId(type.GetElementType()!)}Array";
    if (type.IsGenericType)
    {
        var nameBuilder = new StringBuilder();
        var cleanName = type.Name.Split('`')[0];
        nameBuilder.Append(cleanName);
        nameBuilder.Append("Of");
        var args = type.GetGenericArguments();
        for (int i = 0; i < args.Length; i++)
            nameBuilder.Append(CreateFriendlyId(args[i]));
        return nameBuilder.ToString();
    }
    if (type.IsNested && type.DeclaringType != null)
        return $"{CreateFriendlyId(type.DeclaringType)}{type.Name}";
    var id = type.Name;
    return id.Replace("[]", "Array").Replace("[", "").Replace("]", "").Replace(",", "").Replace("+", "");
}

Extension Registration

public static IServiceCollection AddOpenApiConfiguration(this IServiceCollection services)
{
    services.AddOpenApi(options =>
    {
        options.CreateSchemaReferenceId = context =>
        {
            return OpenApiExtensions.CreateFriendlyId(context.Type);
        };
    });
    return services;
}

๐Ÿ”ง Advanced Usage

Custom Schema Naming

You can extend or override the schema ID generation logic for your own types:

options.CreateSchemaReferenceId = context =>
{
    // Custom logic
    return MyCustomSchemaIdGenerator(context.Type);
};

Integration with Other OpenAPI Tools

This package is compatible with other OpenAPI/Swagger tools and can be used to enhance schema documentation and naming conventions.

๐Ÿ“Š Response Patterns

OpenAPI schema IDs generated by this package will be readable and unique, improving the clarity of your API documentation.

๐ŸŽฏ Best Practices

  1. Use friendly schema IDs for better documentation
  2. Register OpenAPI configuration early in your DI setup
  3. Customize options as needed for your API
  4. Leverage extension methods to keep your startup code clean
  5. Follow clean architecture principles for scalable API projects

๐Ÿ”— Dependencies

  • Microsoft.AspNetCore.OpenApi: OpenAPI integration for ASP.NET Core
  • Microsoft.Extensions.DependencyInjection: DI support
  • .NET 10.0: Target framework

๐Ÿค Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿข Company

Strawhats Company
Created by Muharrem Kaรงkฤฑn


โญ If you find this library helpful, please consider giving it a star on GitHub!

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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.1 84 3/29/2026
1.0.0 185 11/27/2025

v1.0.0:
     - Initial release with custom schema reference ID and OpenAPI configuration extensions.