From 9fa1f743237699adfc533b3a4d8f2797c60dc76b Mon Sep 17 00:00:00 2001 From: Maxwell Weru Date: Thu, 16 May 2024 07:12:40 +0300 Subject: [PATCH] Add primitive types to SwaggerJsonSerializerContext that may be used with ReDocConfig.AdditionalItems --- .../SwaggerJsonSerializerContext.cs | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/Tingle.AspNetCore.Swagger/SwaggerJsonSerializerContext.cs b/src/Tingle.AspNetCore.Swagger/SwaggerJsonSerializerContext.cs index ef9a321..00aacef 100644 --- a/src/Tingle.AspNetCore.Swagger/SwaggerJsonSerializerContext.cs +++ b/src/Tingle.AspNetCore.Swagger/SwaggerJsonSerializerContext.cs @@ -1,7 +1,35 @@ -using System.Text.Json.Serialization; +using System.Text.Json.Nodes; +using System.Text.Json; +using System.Text.Json.Serialization; using Tingle.AspNetCore.Swagger.ReDoc; namespace Tingle.AspNetCore.Swagger; [JsonSerializable(typeof(ReDocConfig))] +// These primitive types are declared for common types that may be used with ReDocConfig.AdditionalItems. +[JsonSerializable(typeof(bool))] +[JsonSerializable(typeof(byte))] +[JsonSerializable(typeof(sbyte))] +[JsonSerializable(typeof(short))] +[JsonSerializable(typeof(ushort))] +[JsonSerializable(typeof(int))] +[JsonSerializable(typeof(uint))] +[JsonSerializable(typeof(long))] +[JsonSerializable(typeof(ulong))] +[JsonSerializable(typeof(float))] +[JsonSerializable(typeof(double))] +[JsonSerializable(typeof(decimal))] +[JsonSerializable(typeof(char))] +[JsonSerializable(typeof(string))] +[JsonSerializable(typeof(DateTime))] +[JsonSerializable(typeof(DateTimeOffset))] +[JsonSerializable(typeof(TimeSpan))] +[JsonSerializable(typeof(JsonArray))] +[JsonSerializable(typeof(JsonObject))] +[JsonSerializable(typeof(JsonDocument))] +[JsonSerializable(typeof(DateOnly))] +[JsonSerializable(typeof(TimeOnly))] +[JsonSerializable(typeof(Half))] +[JsonSerializable(typeof(Int128))] +[JsonSerializable(typeof(UInt128))] internal partial class SwaggerJsonSerializerContext : JsonSerializerContext { }