@@ -1131,6 +1131,108 @@ public void SerializeV2_WithFullSpec_Serializes()
11311131 . BePlatformAgnosticEquivalentTo ( expected ) ;
11321132 }
11331133
1134+ [ Test ]
1135+ public void Read_WithAvroSchemaPayload_NoErrors ( )
1136+ {
1137+ // Arrange
1138+ var yaml =
1139+ """
1140+ asyncapi: '2.6.0'
1141+ info:
1142+ title: schema-validation-test
1143+ version: '1.0.0'
1144+ description: Async API for schema validation tests
1145+ contact:
1146+ name: Test
1147+ url: https://test.test/
1148+
1149+ channels:
1150+ schema-validation-topic:
1151+ description: A topic to publish messages for testing Pulsar schema validation
1152+ publish:
1153+ message:
1154+ $ref: '#/components/messages/schema-validation-message'
1155+
1156+ components:
1157+ messages:
1158+ schema-validation-message:
1159+ name: schema-validation-message
1160+ title: Message for schema validation testing that is a json object
1161+ summary: A test message is used for testing Pulsar schema validation
1162+ payload:
1163+ type: record
1164+ name: UserSignedUp
1165+ namespace: esp
1166+ doc: ESP Schema validation test
1167+ fields:
1168+ - name: userId
1169+ type: int
1170+ - name: userEmail
1171+ type: string
1172+ schemaFormat: 'application/vnd.apache.avro;version=1.9.0'
1173+ """ ;
1174+
1175+ // Act
1176+ var result = new AsyncApiStringReader ( ) . Read ( yaml , out var diagnostics ) ;
1177+
1178+ // Assert
1179+ diagnostics . Errors . Should ( ) . HaveCount ( 0 ) ;
1180+ result . Channels . First ( ) . Value . Publish . Message . First ( ) . Payload . As < AsyncApiAvroSchemaPayload > ( ) . TryGetAs < AvroRecord > ( out var record ) . Should ( ) . BeTrue ( ) ;
1181+ record . Name . Should ( ) . Be ( "UserSignedUp" ) ;
1182+ }
1183+
1184+ [ Test ]
1185+ public void Read_WithJsonSchemaReference_NoErrors ( )
1186+ {
1187+ // Arrange
1188+ var yaml =
1189+ """
1190+ asyncapi: '2.6.0'
1191+ info:
1192+ title: schema-validation-test
1193+ version: '1.0.0'
1194+ description: Async API for schema validation tests
1195+ contact:
1196+ name: Test
1197+ url: https://test.test/
1198+
1199+ channels:
1200+ schema-validation-topic:
1201+ description: A topic to publish messages for testing Pulsar schema validation
1202+ publish:
1203+ message:
1204+ $ref: '#/components/messages/schema-validation-message'
1205+ subscribe:
1206+ message:
1207+ $ref: '#/components/messages/schema-validation-message'
1208+
1209+ components:
1210+ schemas:
1211+ schema-validation-message-payload:
1212+ type: object
1213+ properties:
1214+ content:
1215+ type: string
1216+ description: Content of the message
1217+ messages:
1218+ schema-validation-message:
1219+ name: schema-validation-message
1220+ title: Message for schema validation testing that is a json object
1221+ summary: A test message is used for testing Pulsar schema validation
1222+ payload:
1223+ $ref: '#/components/schemas/schema-validation-message-payload'
1224+ contentType: application/json
1225+ """ ;
1226+
1227+ // Act
1228+ var result = new AsyncApiStringReader ( ) . Read ( yaml , out var diagnostics ) ;
1229+
1230+ // Assert
1231+ diagnostics . Errors . Should ( ) . HaveCount ( 0 ) ;
1232+ result . Channels . First ( ) . Value . Publish . Message . First ( ) . Title . Should ( ) . Be ( "Message for schema validation testing that is a json object" ) ;
1233+ result . Channels . First ( ) . Value . Publish . Message . First ( ) . Payload . As < AsyncApiJsonSchemaPayload > ( ) . Properties . Should ( ) . HaveCount ( 1 ) ;
1234+ }
1235+
11341236 [ Test ]
11351237 public void Serialize_WithBindingReferences_SerializesDeserializes ( )
11361238 {
0 commit comments