public void CanWriteSimpleModelSchemaToJson() { // Arrange string expect = @" { ""type"": ""object"", ""required"": [ ""name"" ], ""properties"": { ""name"": { ""type"": ""string"" }, ""address"": { ""$ref"": ""#/components/schemas/Address"" }, ""age"": { ""type"": ""integer"", ""format"": ""int32"", ""minimum"": 0 } } } ".Replace(); // Act & Assert Assert.Equal(expect, _simpleModel.WriteToJson()); }
public void CanWritePrimitiveSchemaSampleToJson() { // Arrange string expect = @" { ""type"": ""string"", ""format"": ""email"" } ".Replace(); // Act & Assert Assert.Equal(expect, _primitiveSample.WriteToJson()); }
public void CanWriteSimpleStringToModelMappingSchemaToJson() { // Arrange string expect = @" { ""type"": ""object"", ""additionalProperties"": { ""$ref"": ""#/components/schemas/ComplexModel"" } }".Replace(); // Act & Assert Assert.Equal(expect, _simpleStringToModelMapping.WriteToJson()); }
public void CanWriteSimpleStringToStringMappingSchemaToJson() { // Arrange string expect = @" { ""type"": ""object"", ""additionalProperties"": { ""type"": ""string"" } }".Replace(); // Act & Assert Assert.Equal(expect, _simpleStringToStringMapping.WriteToJson()); }
public void CanWriteModelWithExampleSchemaToJson() { // Arrange string expect = @" { ""type"": ""object"", ""example"": { ""name"": ""Puma"", ""id"": 1 } }".Replace(); // Act & Assert Assert.Equal(expect, _modelWithExampleMapping.WriteToJson()); }
public void CanWriteModelWithCompositionSchemaToJson() { // Arrange string expect = @" { ""type"": ""object"", ""required"": [ ""message"", ""code"" ], ""allOf"": [ { ""$ref"": ""#/components/schemas/ErrorModel"" }, { ""type"": ""object"", ""required"": [ ""rootCause"" ], ""properties"": { ""rootCause"": { ""type"": ""string"" } } } ], ""properties"": { ""message"": { ""type"": ""string"" }, ""code"": { ""type"": ""integer"", ""maximum"": 600, ""minimum"": 100 } } }".Replace(); // Act & Assert Assert.Equal(expect, _modelWithCompositionMapping.WriteToJson()); }