Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using Microsoft.OpenApi.Any;
using Microsoft.OpenApi.Extensions;
using Microsoft.OpenApi.Models;
Expand Down Expand Up @@ -171,6 +172,8 @@ private static OpenApiRequestBody CreateFormBody(ParsingContext context, List<Op
k => k,
_ => mediaType)
};
foreach(var value in formBody.Content.Values.Where(static x => x.Schema is not null && x.Schema.Properties.Any() && string.IsNullOrEmpty(x.Schema.Type)))
value.Schema.Type = "object";

return formBody;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.OpenApi/Models/OpenApiParameter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ public void SerializeAsV2WithoutReference(IOpenApiWriter writer)
// In V2 parameter's type can't be a reference to a custom object schema or can't be of type object
// So in that case map the type as string.
else
if (Schema?.UnresolvedReference == true || Schema?.Type == "object")
if (Schema?.UnresolvedReference == true || "object".Equals(Schema?.Type, StringComparison.OrdinalIgnoreCase))
{
writer.WriteProperty(OpenApiConstants.Type, "string");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.

using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
Expand Down Expand Up @@ -80,6 +81,7 @@ public class OpenApiOperationTests
{
Schema = new()
{
Type = "object",
Properties =
{
["name"] = new()
Expand All @@ -103,6 +105,7 @@ public class OpenApiOperationTests
{
Schema = new()
{
Type = "object",
Properties =
{
["name"] = new()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
Expand Down Expand Up @@ -67,6 +68,7 @@ public class OpenApiPathItemTests
{
Schema = new()
{
Type = "object",
Properties =
{
["name"] = new()
Expand All @@ -90,6 +92,7 @@ public class OpenApiPathItemTests
{
Schema = new()
{
Type = "object",
Properties =
{
["name"] = new()
Expand Down Expand Up @@ -171,6 +174,7 @@ public class OpenApiPathItemTests
{
Schema = new()
{
Type = "object",
Properties =
{
["name"] = new()
Expand Down Expand Up @@ -199,6 +203,7 @@ public class OpenApiPathItemTests
{
Schema = new()
{
Type = "object",
Properties =
{
["name"] = new()
Expand Down