Fix incorrect nullable schemas [APIDeploy]

This commit is contained in:
Jordan Brown
2020-08-15 13:21:11 -04:00
parent 3c7e9296db
commit 57050f4196
2 changed files with 9 additions and 2 deletions
+1 -1
View File
@@ -4,7 +4,7 @@
<!-- Integration tests will ensure they match across the board -->
<TgsCoreVersion>4.4.5</TgsCoreVersion>
<TgsConfigVersion>2.0.0</TgsConfigVersion>
<TgsApiVersion>7.2.3</TgsApiVersion>
<TgsApiVersion>7.2.4</TgsApiVersion>
<TgsClientVersion>8.2.0</TgsClientVersion>
<TgsDmapiVersion>5.2.3</TgsDmapiVersion>
<TgsControlPanelVersion>0.4.0</TgsControlPanelVersion>
@@ -4,6 +4,7 @@ using Microsoft.OpenApi.Any;
using Microsoft.OpenApi.Models;
using Swashbuckle.AspNetCore.SwaggerGen;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Net;
@@ -190,6 +191,11 @@ namespace Tgstation.Server.Host.Core
operation.OperationId = $"{context.MethodInfo.DeclaringType.Name}.{context.MethodInfo.Name}";
// request bodies are never nullable
var bodySchemas = operation.RequestBody?.Content.Select(x => x.Value.Schema) ?? Enumerable.Empty<OpenApiSchema>();
foreach (var bodySchema in bodySchemas)
bodySchema.Nullable = false;
var authAttributes = context
.MethodInfo
.DeclaringType
@@ -356,7 +362,8 @@ namespace Tgstation.Server.Host.Core
? context.Type.GenericTypeArguments.First()
: context.Type;
if (nonNullableType != context.Type)
if (nonNullableType != context.Type
&& !context.Type.GetInterfaces().Any(x => x == typeof(IEnumerable)))
schema.Nullable = true;
if (!schema.Enum?.Any() ?? false)