Skip to content

Commit 56c47cb

Browse files
committed
Remove JsonSchemaType.Any type
1 parent 924ff0d commit 56c47cb

File tree

5 files changed

+7
-13
lines changed

5 files changed

+7
-13
lines changed

src/Microsoft.OpenApi/Extensions/OpenApiTypeMapper.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) Microsoft Corporation. All rights reserved.
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT license.
33

44
using System;
@@ -44,12 +44,12 @@ public static JsonSchemaType IdentifierToEnumType(string identifier)
4444
"null" => JsonSchemaType.Null,
4545
"boolean" => JsonSchemaType.Boolean,
4646
"integer" or "int" => JsonSchemaType.Integer,
47-
"number" or "double" => JsonSchemaType.Number,
47+
"number" or "double" or "float" or "decimal"=> JsonSchemaType.Number,
4848
"string" => JsonSchemaType.String,
4949
"array" => JsonSchemaType.Array,
5050
"object" => JsonSchemaType.Object,
5151
"file" => JsonSchemaType.String, // File is treated as string
52-
_ => JsonSchemaType.Any,
52+
_ => throw new ArgumentException("Invalid schema type identifier", nameof(identifier))
5353
};
5454
}
5555

src/Microsoft.OpenApi/Models/JsonSchemaType.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@ namespace Microsoft.OpenApi.Models
1111
[Flags]
1212
public enum JsonSchemaType
1313
{
14-
/// <summary>
15-
/// Represents any type.
16-
/// </summary>
17-
Any = 0,
18-
1914
/// <summary>
2015
/// Represents a null type.
2116
/// </summary>

src/Microsoft.OpenApi/Models/OpenApiSchema.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -831,7 +831,7 @@ private static int CountEnumSetFlags(JsonSchemaType? schemaType)
831831
foreach (JsonSchemaType value in System.Enum.GetValues(typeof(JsonSchemaType)))
832832
{
833833
// Ignore the None flag and check if the flag is set
834-
if (value != JsonSchemaType.Any && (schemaType & value) == value)
834+
if ((schemaType & value) == value)
835835
{
836836
count++;
837837
}
@@ -849,7 +849,7 @@ private void UpCastSchemaTypeToV31(JsonSchemaType? type, IOpenApiWriter writer)
849849
foreach (JsonSchemaType flag in System.Enum.GetValues(typeof(JsonSchemaType)))
850850
{
851851
// Check if the flag is set in 'type' using a bitwise AND operation
852-
if ((Type & flag) == flag && flag != JsonSchemaType.Any)
852+
if ((Type & flag) == flag)
853853
{
854854
list.Add(OpenApiTypeMapper.ToIdentifier(flag));
855855
}
@@ -886,7 +886,7 @@ private void DowncastTypeArrayToV2OrV3(JsonSchemaType? schemaType, IOpenApiWrite
886886
foreach (JsonSchemaType flag in System.Enum.GetValues(typeof(JsonSchemaType)))
887887
{
888888
// Skip if the flag is not set or if it's the Null flag
889-
if ((schemaType & flag) == flag && flag != JsonSchemaType.Null && flag != JsonSchemaType.Any)
889+
if ((schemaType & flag) == flag && flag != JsonSchemaType.Null)
890890
{
891891
// Write the non-null flag value to the writer
892892
writer.WriteProperty(OpenApiConstants.Type, OpenApiTypeMapper.ToIdentifier(flag));

src/Microsoft.OpenApi/Reader/V31/OpenApiSchemaDeserializer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ internal static partial class OpenApiV31Deserializer
121121
else
122122
{
123123
var list = n.CreateSimpleList((n2, p) => n2.GetScalarValue());
124-
JsonSchemaType combinedType = JsonSchemaType.Any;
124+
JsonSchemaType combinedType = 0;
125125
foreach(var type in list)
126126
{
127127
var schemaType = OpenApiTypeMapper.IdentifierToEnumType(type);

test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,6 @@ namespace Microsoft.OpenApi.Models
334334
[System.Flags]
335335
public enum JsonSchemaType
336336
{
337-
Any = 0,
338337
Null = 1,
339338
Boolean = 2,
340339
Integer = 4,

0 commit comments

Comments
 (0)