[PR #3168] [CLOSED] Add JsonNonStringKeyDictionaryConverter and Factory #9366

Closed
opened 2026-02-07 06:00:55 +03:00 by OVERLORD · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/jellyfin/jellyfin/pull/3168
Author: @crobibero
Created: 5/24/2020
Status: Closed

Base: api-migrationHead: api-json-dictionary


📄 Description

part of #2872

Currently, System.Text.Json does not support Dictionaries that don't use string keys.
This converter and factory allow the JSON middleware to serialize and deserialize these dictionaries.

The roadmap for System.Text.Json has this feature slated for .NET 5.0

These dictionaries also cause errors with the docs generation, so the following will have to be added for each dictionary we intend on returning: src

services.AddSwaggerGen(c =>
{
    ...

    c.MapType<Dictionary<MyEnum, int>>(() =>
        new OpenApiSchema
        {
            Type = "object",
            Properties = typeof(MyEnum).GetEnumNames().ToDictionary(
                name => name,
                name => new OpenApiSchema { Type = "integer", Format = "int32" })
        });
});

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/jellyfin/jellyfin/pull/3168 **Author:** [@crobibero](https://github.com/crobibero) **Created:** 5/24/2020 **Status:** ❌ Closed **Base:** `api-migration` ← **Head:** `api-json-dictionary` --- ### 📄 Description part of #2872 Currently, System.Text.Json does not support Dictionaries that don't use `string` keys. This converter and factory allow the JSON middleware to serialize and deserialize these dictionaries. The roadmap for System.Text.Json has this feature slated for .NET 5.0 These dictionaries also cause errors with the docs generation, so the following will have to be added for each dictionary we intend on returning: [src](https://github.com/domaindrivendev/Swashbuckle.AspNetCore/issues/1667#issuecomment-628913717) ```c# services.AddSwaggerGen(c => { ... c.MapType<Dictionary<MyEnum, int>>(() => new OpenApiSchema { Type = "object", Properties = typeof(MyEnum).GetEnumNames().ToDictionary( name => name, name => new OpenApiSchema { Type = "integer", Format = "int32" }) }); }); ``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
OVERLORD added the pull-request label 2026-02-07 06:00:55 +03:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/jellyfin#9366