Change the oneOf to anyOf for Double/Single/Int64

This commit is contained in:
Sam Xu 2018-08-29 10:30:21 -07:00
parent f38b9d3ec0
commit 5a2a2af9ae
5 changed files with 17 additions and 13 deletions

View file

@ -182,7 +182,7 @@ namespace Microsoft.OpenApi.OData.Generator
schema.Format = "decimal";
break;
case EdmPrimitiveTypeKind.Double: // double
schema.OneOf = new List<OpenApiSchema>
schema.AnyOf = new List<OpenApiSchema>
{
new OpenApiSchema { Type = "number" },
new OpenApiSchema { Type = "string" },
@ -199,7 +199,7 @@ namespace Microsoft.OpenApi.OData.Generator
schema.Format = "double";
break;
case EdmPrimitiveTypeKind.Single: // single
schema.OneOf = new List<OpenApiSchema>
schema.AnyOf = new List<OpenApiSchema>
{
new OpenApiSchema { Type = "number" },
new OpenApiSchema { Type = "string" },

View file

@ -448,8 +448,10 @@ namespace Microsoft.OpenApi.OData.Tests
Assert.Equal("double", schema.Format);
Assert.Equal(isNullable, schema.Nullable);
Assert.NotNull(schema.OneOf);
Assert.Equal(3, schema.OneOf.Count);
Assert.Null(schema.OneOf);
Assert.NotNull(schema.AnyOf);
Assert.Equal(3, schema.AnyOf.Count);
}
[Theory]
@ -472,8 +474,10 @@ namespace Microsoft.OpenApi.OData.Tests
Assert.Equal("float", schema.Format);
Assert.Equal(isNullable, schema.Nullable);
Assert.NotNull(schema.OneOf);
Assert.Equal(3, schema.OneOf.Count);
Assert.Null(schema.OneOf);
Assert.NotNull(schema.AnyOf);
Assert.Equal(3, schema.AnyOf.Count);
}
#endregion
}

View file

@ -536,7 +536,7 @@ namespace Microsoft.OpenApi.OData.Tests
string json = schema.SerializeAsJson(OpenApiSpecVersion.OpenApi3_0);
Assert.Equal(@"{
""oneOf"": [
""anyOf"": [
{
""type"": ""number""
},

View file

@ -1941,7 +1941,7 @@
"in": "path",
"required": true,
"schema": {
"oneOf": [
"anyOf": [
{
"type": "number"
},
@ -1964,7 +1964,7 @@
"in": "path",
"required": true,
"schema": {
"oneOf": [
"anyOf": [
{
"type": "number"
},
@ -2335,7 +2335,7 @@
"nullable": true
},
"Budget": {
"oneOf": [
"anyOf": [
{
"type": "number"
},

View file

@ -1294,7 +1294,7 @@ paths:
in: path
required: true
schema:
oneOf:
anyOf:
- type: number
- type: string
- enum:
@ -1306,7 +1306,7 @@ paths:
in: path
required: true
schema:
oneOf:
anyOf:
- type: number
- type: string
- enum:
@ -1532,7 +1532,7 @@ components:
type: string
nullable: true
Budget:
oneOf:
anyOf:
- type: number
- type: string
- enum: