public void SerializeAdvancedSchemaNumberAsV3JsonWorks() { // Arrange var expected = @"{ ""title"": ""title1"", ""multipleOf"": 3, ""maximum"": 42, ""minimum"": 10, ""exclusiveMinimum"": true, ""type"": ""integer"", ""default"": 15, ""nullable"": true, ""externalDocs"": { ""url"": ""http://example.com/externalDocs"" } }"; // Act var actual = AdvancedSchemaNumber.SerializeAsJson(OpenApiSpecVersion.OpenApi3_0_0); // Assert actual = actual.MakeLineBreaksEnvironmentNeutral(); expected = expected.MakeLineBreaksEnvironmentNeutral(); actual.Should().Be(expected); }
public void SerializeBasicSchemaAsV3JsonWorks() { // Arrange var expected = @"{ }"; // Act var actual = BasicSchema.SerializeAsJson(OpenApiSpecVersion.OpenApi3_0_0); // Assert actual = actual.MakeLineBreaksEnvironmentNeutral(); expected = expected.MakeLineBreaksEnvironmentNeutral(); actual.Should().Be(expected); }
public void SerializeAdvancedSchemaWithAllOfAsV3JsonWorks() { // Arrange var expected = @"{ ""title"": ""title1"", ""allOf"": [ { ""title"": ""title2"", ""properties"": { ""property1"": { ""type"": ""integer"" }, ""property2"": { ""maxLength"": 15, ""type"": ""string"" } } }, { ""title"": ""title3"", ""properties"": { ""property3"": { ""properties"": { ""property4"": { ""type"": ""boolean"" } } }, ""property5"": { ""minLength"": 2, ""type"": ""string"" } }, ""nullable"": true } ], ""nullable"": true, ""externalDocs"": { ""url"": ""http://example.com/externalDocs"" } }"; // Act var actual = AdvancedSchemaWithAllOf.SerializeAsJson(OpenApiSpecVersion.OpenApi3_0_0); // Assert actual = actual.MakeLineBreaksEnvironmentNeutral(); expected = expected.MakeLineBreaksEnvironmentNeutral(); actual.Should().Be(expected); }
public void CreateStructuredTypePropertiesSchemaWithCustomAttributeReturnsCorrectSchema() { // Arrange IEdmModel model = EdmModelHelper.GraphBetaModel; ODataContext context = new(model); context.Settings.CustomXMLAttributesMapping.Add("IsHidden", "x-ms-isHidden"); IEdmEntityType entity = model.SchemaElements.OfType <IEdmEntityType>().First(t => t.Name == "userSettings"); Assert.NotNull(entity); // Guard // Act OpenApiSchema schema = context.CreateStructuredTypeSchema(entity); string json = schema.SerializeAsJson(OpenApiSpecVersion.OpenApi3_0); // Assert Assert.NotNull(json); Assert.Equal(@"{ ""allOf"": [ { ""$ref"": ""#/components/schemas/microsoft.graph.entity"" }, { ""title"": ""userSettings"", ""type"": ""object"", ""properties"": { ""contributionToContentDiscoveryAsOrganizationDisabled"": { ""type"": ""boolean"", ""x-ms-isHidden"": ""true"" }, ""contributionToContentDiscoveryDisabled"": { ""type"": ""boolean"", ""x-ms-isHidden"": ""true"" }, ""itemInsights"": { ""anyOf"": [ { ""$ref"": ""#/components/schemas/microsoft.graph.userInsightsSettings"" }, { ""type"": ""object"", ""nullable"": true } ], ""x-ms-isHidden"": ""true"" }, ""regionalAndLanguageSettings"": { ""anyOf"": [ { ""$ref"": ""#/components/schemas/microsoft.graph.regionalAndLanguageSettings"" }, { ""type"": ""object"", ""nullable"": true } ] }, ""shiftPreferences"": { ""anyOf"": [ { ""$ref"": ""#/components/schemas/microsoft.graph.shiftPreferences"" }, { ""type"": ""object"", ""nullable"": true } ] } } } ] }".ChangeLineBreaks(), json); }