mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-30 00:22:40 +01:00
Fix incorrect nullable schemas [APIDeploy]
This commit is contained in:
+1
-1
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user