diff --git a/amf-api-contract/shared/src/main/scala/amf/apicontract/internal/spec/async/parser/domain/AsyncOperationParser.scala b/amf-api-contract/shared/src/main/scala/amf/apicontract/internal/spec/async/parser/domain/AsyncOperationParser.scala index 0767c9a34b..4cfeb5c6a6 100644 --- a/amf-api-contract/shared/src/main/scala/amf/apicontract/internal/spec/async/parser/domain/AsyncOperationParser.scala +++ b/amf-api-contract/shared/src/main/scala/amf/apicontract/internal/spec/async/parser/domain/AsyncOperationParser.scala @@ -83,7 +83,7 @@ class Async20ConcreteOperationParser(entry: YMapEntry, adopt: Operation => Opera override protected def parseMessages(map: YMap, operation: Operation): Unit = map.key( "message", messageEntry => - AsyncHelper.messageType(entry.key.value.toString) foreach { msgType => + AsyncHelper.messageType(entry.key.as[YScalar].text) foreach { msgType => val messages = AsyncMultipleMessageParser(messageEntry.value.as[YMap], operation.id, msgType).parse() operation.fields .setWithoutId(msgType.field, AmfArray(messages, Annotations(messageEntry.value)), Annotations(messageEntry)) diff --git a/amf-cli/shared/src/test/resources/upanddown/cycle/async20/message-json.json b/amf-cli/shared/src/test/resources/upanddown/cycle/async20/message-json.json new file mode 100644 index 0000000000..115717fb85 --- /dev/null +++ b/amf-cli/shared/src/test/resources/upanddown/cycle/async20/message-json.json @@ -0,0 +1,29 @@ +{ + "asyncapi": "2.6.0", + "info": { + "title": "async-json", + "version": "1.0.0" + }, + "channels": { + "CANCELLATIONS": { + "subscribe": { + "message": { + "payload": { + "type": "object", + "required": [ + "orderid" + ], + "properties": { + "orderid": { + "description": "id of the order that was cancelled", + "type": "string", + "format": "uuid" + } + } + }, + "contentType": "application/json" + } + } + } + } +} \ No newline at end of file diff --git a/amf-cli/shared/src/test/resources/upanddown/cycle/async20/message-json.yaml b/amf-cli/shared/src/test/resources/upanddown/cycle/async20/message-json.yaml new file mode 100644 index 0000000000..d8e2bf0978 --- /dev/null +++ b/amf-cli/shared/src/test/resources/upanddown/cycle/async20/message-json.yaml @@ -0,0 +1,18 @@ +asyncapi: 2.6.0 +info: + title: async-json + version: 1.0.0 +channels: + CANCELLATIONS: + subscribe: + message: + payload: + type: object + required: + - orderid + properties: + orderid: + description: id of the order that was cancelled + type: string + format: uuid + contentType: application/json diff --git a/amf-cli/shared/src/test/scala/amf/emit/Async20CycleTest.scala b/amf-cli/shared/src/test/scala/amf/emit/Async20CycleTest.scala index de9cf130a9..850a099ef6 100644 --- a/amf-cli/shared/src/test/scala/amf/emit/Async20CycleTest.scala +++ b/amf-cli/shared/src/test/scala/amf/emit/Async20CycleTest.scala @@ -283,10 +283,15 @@ class Async20CycleTest extends FunSuiteCycleTests { "bindings/solace-operation-queue-binding.yaml", "bindings/solace-operation-queue-binding.yaml" ), - FixtureData( + FixtureData( "solace binding 0.4.0 version", "bindings/solace-0.4.0-version.yaml", "bindings/solace-0.4.0-version.yaml" + ), + FixtureData( + "JSON AsyncAPI", + "message-json.json", + "message-json.yaml" ) // TODO: figure out why this test is commented out