From 7cddb54cb074233853f9c810d4511cf904171c61 Mon Sep 17 00:00:00 2001 From: Leandro Libarona Date: Thu, 23 May 2024 11:25:34 -0300 Subject: [PATCH 01/16] bump versions --- dependencies.properties | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dependencies.properties b/dependencies.properties index d0cc83309..28ee73140 100644 --- a/dependencies.properties +++ b/dependencies.properties @@ -1,5 +1,5 @@ -version=6.2.0-SNAPSHOT -amf=5.5.1-RC.2 +version=6.3.0-SNAPSHOT +amf=5.5.1 amf.custom-validator.js=1.7.2 -amf.custom-validator-scalajs=0.5.10 +amf.custom-validator-scalajs=0.5.11 amf-antlr-parsers=0.7.25 From 6a5843bc666515a320eaafc443a291a8d2af254c Mon Sep 17 00:00:00 2001 From: Leandro Libarona Date: Thu, 23 May 2024 16:09:32 -0300 Subject: [PATCH 02/16] W-15758639: add test for asserting that serialization manager uses correct URIs (encoded) --- .../scala/org/mulesoft/als/common/Spy.scala | 13 ++ .../CleanSerializationTest.scala | 115 ++++++++++++++++++ 2 files changed, 128 insertions(+) create mode 100644 als-server/shared/src/test/scala/org/mulesoft/als/common/Spy.scala create mode 100644 als-server/shared/src/test/scala/org/mulesoft/als/server/modules/serialization/CleanSerializationTest.scala diff --git a/als-server/shared/src/test/scala/org/mulesoft/als/common/Spy.scala b/als-server/shared/src/test/scala/org/mulesoft/als/common/Spy.scala new file mode 100644 index 000000000..9ca9c008d --- /dev/null +++ b/als-server/shared/src/test/scala/org/mulesoft/als/common/Spy.scala @@ -0,0 +1,13 @@ +package org.mulesoft.als.common + +abstract class Spy[T] { + private var flag = false + def passed(): Unit = flag = true + def hasPassed: Boolean = flag + + def innerEvaluate(param: T): Boolean + def evaluate(param: T): T = { + if (innerEvaluate(param)) passed() + param + } +} diff --git a/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/serialization/CleanSerializationTest.scala b/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/serialization/CleanSerializationTest.scala new file mode 100644 index 000000000..483d61909 --- /dev/null +++ b/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/serialization/CleanSerializationTest.scala @@ -0,0 +1,115 @@ +package org.mulesoft.als.server.modules.serialization + +import amf.core.client.common.remote.Content +import amf.core.client.scala.resource.ResourceLoader +import org.mulesoft.als.common.Spy +import org.mulesoft.als.common.URIImplicits.StringUriImplicits +import org.mulesoft.als.common.diff.FileAssertionTest +import org.mulesoft.als.server._ +import org.mulesoft.als.server.client.platform.ClientNotifier +import org.mulesoft.als.server.client.scala.LanguageServerBuilder +import org.mulesoft.als.server.feature.serialization.SerializationClientCapabilities +import org.mulesoft.als.server.modules.configuration.WorkspaceConfigurationManager +import org.mulesoft.als.server.modules.{WorkspaceManagerFactory, WorkspaceManagerFactoryBuilder} +import org.mulesoft.als.server.protocol.LanguageServer +import org.mulesoft.als.server.protocol.configuration.{AlsClientCapabilities, AlsInitializeParams} +import org.mulesoft.als.server.workspace.ChangesWorkspaceConfiguration +import org.mulesoft.amfintegration.amfconfiguration.{ALSConfigurationState, EditorConfiguration} +import org.mulesoft.lsp.configuration.TraceKind +import org.mulesoft.lsp.feature.diagnostic.PublishDiagnosticsParams +import org.mulesoft.lsp.feature.telemetry.TelemetryMessage +import org.yaml.builder.{DocBuilder, JsonOutputBuilder} + +import java.io.StringWriter +import scala.concurrent.{ExecutionContext, Future} + +class CleanSerializationTest extends LanguageServerBaseTest with ChangesWorkspaceConfiguration with FileAssertionTest { + + override implicit val executionContext: ExecutionContext = + ExecutionContext.Implicits.global + + override val initializeParams: AlsInitializeParams = AlsInitializeParams( + Some(AlsClientCapabilities(serialization = Some(SerializationClientCapabilities(true)))), + Some(TraceKind.Off) + ) + + test("Request serialized - check that URIs are fetched correctly to the configuration manager (normal encoded URI)") { + val alsClient: MockAlsClientNotifier = new MockAlsClientNotifier + val spyResourceLoader: Spy[String] = (param: String) => param.isValidUri + val serializationProps: SerializationProps[StringWriter] = + new SerializationProps[StringWriter](alsClient) { + override def newDocBuilder(prettyPrint: Boolean): DocBuilder[StringWriter] = + JsonOutputBuilder(prettyPrint) + } + + val apiUrl = "file://api%20.raml" + val resourceLoader = new ResourceLoader { + + private val fs: Map[String, String] = Map { + apiUrl -> """#%RAML 1.0 + |title: test + |description: missing title + |""".stripMargin + } + + override def fetch(resource: String): Future[Content] = + Future.successful(new Content(fs(resource), resource)) + + override def accepts(resource: String): Boolean = { + fs.contains(spyResourceLoader.evaluate(resource)) + } + } + val spyConfiguration: Spy[String] = (param: String) => param.isValidUri + withServer(buildServer(serializationProps, resourceLoader, spyConfiguration)) { server => + for { + s <- serialize(server, apiUrl, serializationProps, clean = true, sourcemaps = true) + } yield { + assert(s.contains("sourcemaps")) + assert(spyConfiguration.hasPassed) + assert(spyResourceLoader.hasPassed) + } + } + } + + def buildServer( + serializationProps: SerializationProps[StringWriter], + resourceLoader: ResourceLoader, + spy: Spy[String] + ): LanguageServer = { + val factoryBuilder: WorkspaceManagerFactoryBuilder = + new WorkspaceManagerFactoryBuilder( + new ClientNotifier { + override def notifyDiagnostic(params: PublishDiagnosticsParams): Unit = {} + override def notifyTelemetry(params: TelemetryMessage): Unit = {} + }, + EditorConfiguration(Seq(resourceLoader), Seq.empty, Seq.empty) + ) + val serializationManager: SerializationManager[StringWriter] = + factoryBuilder.serializationManager(serializationProps) + val factory: WorkspaceManagerFactory = factoryBuilder.buildWorkspaceManagerFactory() + + val builder = + new LanguageServerBuilder( + factory.documentManager, + factory.workspaceManager, + factory.configurationManager, + factory.resolutionTaskManager + ) + + builder.addInitializableModule(serializationManager) + val spiedManager: WorkspaceConfigurationManager = + new TestWorkspaceConfigurationManager(factory.workspaceConfigurationManager, spy) + serializationManager.withWorkspaceConfigurationManager(spiedManager) + builder.addRequestModule(serializationManager) + builder.build() + } + + override def rootPath: String = "" + + sealed class TestWorkspaceConfigurationManager(delegate: WorkspaceConfigurationManager, spy: Spy[String]) + extends WorkspaceConfigurationManager(delegate.workspaceManager) { + override def getConfigurationState(uri: String): Future[ALSConfigurationState] = + super.getConfigurationState(spy.evaluate(uri)) + } + +} From 0e6623d44830ae87d2c78372ce39cf24aca0fa5f Mon Sep 17 00:00:00 2001 From: Leandro Libarona Date: Wed, 29 May 2024 15:13:08 -0300 Subject: [PATCH 03/16] W-15832126: fix async2 references for publish messages --- ...JsonSchemaStyleDeclarationReferences.scala | 11 +- .../expected/message-ref-publish.yaml.json | 146 ++++++++++++++++++ .../expected/message-ref-subscribe.yaml.json | 146 ++++++++++++++++++ .../messages/message-ref-publish.yaml | 14 ++ .../messages/message-ref-subscribe.yaml | 14 ++ 5 files changed, 329 insertions(+), 2 deletions(-) create mode 100644 als-suggestions/shared/src/test/resources/test/async26/by-directory/messages/expected/message-ref-publish.yaml.json create mode 100644 als-suggestions/shared/src/test/resources/test/async26/by-directory/messages/expected/message-ref-subscribe.yaml.json create mode 100644 als-suggestions/shared/src/test/resources/test/async26/by-directory/messages/message-ref-publish.yaml create mode 100644 als-suggestions/shared/src/test/resources/test/async26/by-directory/messages/message-ref-subscribe.yaml diff --git a/als-suggestions/shared/src/main/scala/org/mulesoft/als/suggestions/plugins/aml/AMLJsonSchemaStyleDeclarationReferences.scala b/als-suggestions/shared/src/main/scala/org/mulesoft/als/suggestions/plugins/aml/AMLJsonSchemaStyleDeclarationReferences.scala index 9368713c5..8018ec9fd 100644 --- a/als-suggestions/shared/src/main/scala/org/mulesoft/als/suggestions/plugins/aml/AMLJsonSchemaStyleDeclarationReferences.scala +++ b/als-suggestions/shared/src/main/scala/org/mulesoft/als/suggestions/plugins/aml/AMLJsonSchemaStyleDeclarationReferences.scala @@ -2,9 +2,9 @@ package org.mulesoft.als.suggestions.plugins.aml import amf.aml.client.scala.model.document.Dialect import amf.aml.client.scala.model.domain.NodeMapping -import amf.apicontract.internal.metamodel.domain.ResponseModel import amf.apicontract.internal.metamodel.domain.templates.{ResourceTypeModel, TraitModel} -import amf.core.client.scala.model.domain.{AmfElement, AmfObject, DomainElement, Linkable} +import amf.apicontract.internal.metamodel.domain.{MessageModel, RequestModel, ResponseModel} +import amf.core.client.scala.model.domain.{AmfElement, AmfObject, Linkable} import amf.core.internal.annotations.ErrorDeclaration import amf.core.internal.metamodel.domain.templates.AbstractDeclarationModel import amf.core.internal.metamodel.domain.{DomainElementModel, ShapeModel} @@ -136,4 +136,11 @@ object Async2AMLJsonSchemaStyleDeclarationReferences extends AbstractAMLJsonSche TraitModel.`type`.head.iri(), ResourceTypeModel.`type`.head.iri() ) + + // publish and subscribe are both messages (use components/messages) + override protected def getObjectRangeIds(params: AmlCompletionRequest): Seq[String] = + super.getObjectRangeIds(params).map { + case id if RequestModel.`type`.headOption.map(_.iri()).contains(id) => MessageModel.`type`.head.iri() + case id => id + } } diff --git a/als-suggestions/shared/src/test/resources/test/async26/by-directory/messages/expected/message-ref-publish.yaml.json b/als-suggestions/shared/src/test/resources/test/async26/by-directory/messages/expected/message-ref-publish.yaml.json new file mode 100644 index 000000000..703947036 --- /dev/null +++ b/als-suggestions/shared/src/test/resources/test/async26/by-directory/messages/expected/message-ref-publish.yaml.json @@ -0,0 +1,146 @@ +[ + { + "label": "#/components/messages/test", + "kind": [ + + ], + "detail": "unknown", + "documentation": "Reference to #/components/messages/test", + "deprecated": [ + + ], + "preselect": [ + + ], + "sortText": "11#/components/messages/test", + "filterText": "\"#/components/messages/test\"", + "insertText": null, + "insertTextFormat": [ + 1 + ], + "textEdit": { + "range": { + "start": { + "line": 5, + "character": 14 + }, + "end": { + "line": 5, + "character": 14 + } + }, + "newText": "\"#/components/messages/test\"" + }, + "additionalTextEdits": null, + "commitCharacters": null, + "command": null + }, + { + "label": "expected/", + "kind": [ + + ], + "detail": "unknown", + "documentation": "Path suggestion", + "deprecated": [ + + ], + "preselect": [ + + ], + "sortText": "11expected/", + "filterText": "expected/", + "insertText": null, + "insertTextFormat": [ + 1 + ], + "textEdit": { + "range": { + "start": { + "line": 5, + "character": 14 + }, + "end": { + "line": 5, + "character": 14 + } + }, + "newText": "expected/" + }, + "additionalTextEdits": null, + "commitCharacters": null, + "command": null + }, + { + "label": "message-id.yaml", + "kind": [ + + ], + "detail": "unknown", + "documentation": "Path suggestion", + "deprecated": [ + + ], + "preselect": [ + + ], + "sortText": "11message-id.yaml", + "filterText": "message-id.yaml", + "insertText": null, + "insertTextFormat": [ + 1 + ], + "textEdit": { + "range": { + "start": { + "line": 5, + "character": 14 + }, + "end": { + "line": 5, + "character": 14 + } + }, + "newText": "message-id.yaml" + }, + "additionalTextEdits": null, + "commitCharacters": null, + "command": null + }, + { + "label": "message-ref-subscribe.yaml", + "kind": [ + + ], + "detail": "unknown", + "documentation": "Path suggestion", + "deprecated": [ + + ], + "preselect": [ + + ], + "sortText": "11message-ref-subscribe.yaml", + "filterText": "message-ref-subscribe.yaml", + "insertText": null, + "insertTextFormat": [ + 1 + ], + "textEdit": { + "range": { + "start": { + "line": 5, + "character": 14 + }, + "end": { + "line": 5, + "character": 14 + } + }, + "newText": "message-ref-subscribe.yaml" + }, + "additionalTextEdits": null, + "commitCharacters": null, + "command": null + } +] \ No newline at end of file diff --git a/als-suggestions/shared/src/test/resources/test/async26/by-directory/messages/expected/message-ref-subscribe.yaml.json b/als-suggestions/shared/src/test/resources/test/async26/by-directory/messages/expected/message-ref-subscribe.yaml.json new file mode 100644 index 000000000..8304567e2 --- /dev/null +++ b/als-suggestions/shared/src/test/resources/test/async26/by-directory/messages/expected/message-ref-subscribe.yaml.json @@ -0,0 +1,146 @@ +[ + { + "label": "#/components/messages/test", + "kind": [ + + ], + "detail": "unknown", + "documentation": "Reference to #/components/messages/test", + "deprecated": [ + + ], + "preselect": [ + + ], + "sortText": "11#/components/messages/test", + "filterText": "\"#/components/messages/test\"", + "insertText": null, + "insertTextFormat": [ + 1 + ], + "textEdit": { + "range": { + "start": { + "line": 5, + "character": 14 + }, + "end": { + "line": 5, + "character": 14 + } + }, + "newText": "\"#/components/messages/test\"" + }, + "additionalTextEdits": null, + "commitCharacters": null, + "command": null + }, + { + "label": "expected/", + "kind": [ + + ], + "detail": "unknown", + "documentation": "Path suggestion", + "deprecated": [ + + ], + "preselect": [ + + ], + "sortText": "11expected/", + "filterText": "expected/", + "insertText": null, + "insertTextFormat": [ + 1 + ], + "textEdit": { + "range": { + "start": { + "line": 5, + "character": 14 + }, + "end": { + "line": 5, + "character": 14 + } + }, + "newText": "expected/" + }, + "additionalTextEdits": null, + "commitCharacters": null, + "command": null + }, + { + "label": "message-id.yaml", + "kind": [ + + ], + "detail": "unknown", + "documentation": "Path suggestion", + "deprecated": [ + + ], + "preselect": [ + + ], + "sortText": "11message-id.yaml", + "filterText": "message-id.yaml", + "insertText": null, + "insertTextFormat": [ + 1 + ], + "textEdit": { + "range": { + "start": { + "line": 5, + "character": 14 + }, + "end": { + "line": 5, + "character": 14 + } + }, + "newText": "message-id.yaml" + }, + "additionalTextEdits": null, + "commitCharacters": null, + "command": null + }, + { + "label": "message-ref-publish.yaml", + "kind": [ + + ], + "detail": "unknown", + "documentation": "Path suggestion", + "deprecated": [ + + ], + "preselect": [ + + ], + "sortText": "11message-ref-publish.yaml", + "filterText": "message-ref-publish.yaml", + "insertText": null, + "insertTextFormat": [ + 1 + ], + "textEdit": { + "range": { + "start": { + "line": 5, + "character": 14 + }, + "end": { + "line": 5, + "character": 14 + } + }, + "newText": "message-ref-publish.yaml" + }, + "additionalTextEdits": null, + "commitCharacters": null, + "command": null + } +] \ No newline at end of file diff --git a/als-suggestions/shared/src/test/resources/test/async26/by-directory/messages/message-ref-publish.yaml b/als-suggestions/shared/src/test/resources/test/async26/by-directory/messages/message-ref-publish.yaml new file mode 100644 index 000000000..4da107f3a --- /dev/null +++ b/als-suggestions/shared/src/test/resources/test/async26/by-directory/messages/message-ref-publish.yaml @@ -0,0 +1,14 @@ +asyncapi: 2.6.0 +channels: + eastern-books: + publish: + message: + $ref: * +components: + messages: + test: + payload: + type: object + properties: + id: + type: string diff --git a/als-suggestions/shared/src/test/resources/test/async26/by-directory/messages/message-ref-subscribe.yaml b/als-suggestions/shared/src/test/resources/test/async26/by-directory/messages/message-ref-subscribe.yaml new file mode 100644 index 000000000..b70ac7a3e --- /dev/null +++ b/als-suggestions/shared/src/test/resources/test/async26/by-directory/messages/message-ref-subscribe.yaml @@ -0,0 +1,14 @@ +asyncapi: 2.6.0 +channels: + eastern-books: + subscribe: + message: + $ref: * +components: + messages: + test: + payload: + type: object + properties: + id: + type: string From 7e3be38d59a78546b1fd67bc248447bc9724a3e8 Mon Sep 17 00:00:00 2001 From: Leandro Libarona Date: Wed, 29 May 2024 17:00:36 -0300 Subject: [PATCH 04/16] W-15610633: add suggestion for root servers in async2 channel servers --- .../asyncapi20/AsyncApi20ServerObject.scala | 1 - .../async/Async26ChannelServersPlugin.scala | 18 ++++++++- .../expected/servers-inside-array.yaml.json | 37 ++++++++++++++++++- 3 files changed, 52 insertions(+), 4 deletions(-) diff --git a/als-common/shared/src/main/scala/org/mulesoft/amfintegration/dialect/dialects/asyncapi20/AsyncApi20ServerObject.scala b/als-common/shared/src/main/scala/org/mulesoft/amfintegration/dialect/dialects/asyncapi20/AsyncApi20ServerObject.scala index 4b5aec489..f3c3c690e 100644 --- a/als-common/shared/src/main/scala/org/mulesoft/amfintegration/dialect/dialects/asyncapi20/AsyncApi20ServerObject.scala +++ b/als-common/shared/src/main/scala/org/mulesoft/amfintegration/dialect/dialects/asyncapi20/AsyncApi20ServerObject.scala @@ -19,7 +19,6 @@ trait AsyncApiServerObject extends DialectNode { .withId(location + "#/declarations/ServerObject/name") .withName("name") .withNodePropertyMapping(ServerModel.Name.value.iri()) - .withMinCount(1) .withLiteralRange(xsdString.iri()), PropertyMapping() .withId(location + "#/declarations/ServerObject/description") diff --git a/als-suggestions/shared/src/main/scala/org/mulesoft/als/suggestions/plugins/aml/webapi/async/Async26ChannelServersPlugin.scala b/als-suggestions/shared/src/main/scala/org/mulesoft/als/suggestions/plugins/aml/webapi/async/Async26ChannelServersPlugin.scala index 3b016dced..588efc514 100644 --- a/als-suggestions/shared/src/main/scala/org/mulesoft/als/suggestions/plugins/aml/webapi/async/Async26ChannelServersPlugin.scala +++ b/als-suggestions/shared/src/main/scala/org/mulesoft/als/suggestions/plugins/aml/webapi/async/Async26ChannelServersPlugin.scala @@ -1,7 +1,8 @@ package org.mulesoft.als.suggestions.plugins.aml.webapi.async +import amf.apicontract.client.scala.model.domain.api.AsyncApi import amf.apicontract.client.scala.model.domain.{EndPoint, Server} -import amf.core.client.scala.model.document.{BaseUnit, DeclaresModel} +import amf.core.client.scala.model.document.{BaseUnit, DeclaresModel, EncodesModel} import org.mulesoft.als.suggestions.RawSuggestion import org.mulesoft.als.suggestions.aml.AmlCompletionRequest import org.mulesoft.als.suggestions.interfaces.AMLCompletionPlugin @@ -15,12 +16,25 @@ object Async26ChannelServersPlugin extends AMLCompletionPlugin { override def resolve(request: AmlCompletionRequest): Future[Seq[RawSuggestion]] = Future { request.amfObject match { case _: Server if request.branchStack.headOption.exists(_.isInstanceOf[EndPoint]) => - getDeclaredServers(request.baseUnit) + (getDeclaredServers(request.baseUnit) ++ getRootServers(request.baseUnit)).distinct .map(server => RawSuggestion(server, isAKey = false, "Servers", mandatory = false)) case _ => Seq.empty } } + private def getRootServers(baseUnit: BaseUnit): Seq[String] = (for { + encodes <- baseUnit match { + case e: EncodesModel => Some(e) + case _ => None + } + asyncApi <- encodes.encodes match { + case async: AsyncApi => Some(async) + case _ => None + } + } yield { + asyncApi.servers.map(_.name).flatMap(_.option()) + }).getOrElse(Seq.empty) + private def getDeclaredServers(baseUnit: BaseUnit): Seq[String] = baseUnit match { case d: DeclaresModel => diff --git a/als-suggestions/shared/src/test/resources/test/async26/by-directory/channel/expected/servers-inside-array.yaml.json b/als-suggestions/shared/src/test/resources/test/async26/by-directory/channel/expected/servers-inside-array.yaml.json index c9c513b9b..b852dabf8 100644 --- a/als-suggestions/shared/src/test/resources/test/async26/by-directory/channel/expected/servers-inside-array.yaml.json +++ b/als-suggestions/shared/src/test/resources/test/async26/by-directory/channel/expected/servers-inside-array.yaml.json @@ -1,3 +1,38 @@ [ - + { + "label": "myServer", + "kind": [ + + ], + "detail": "Servers", + "documentation": "myServer", + "deprecated": [ + + ], + "preselect": [ + + ], + "sortText": "11myServer", + "filterText": "myServer", + "insertText": null, + "insertTextFormat": [ + 1 + ], + "textEdit": { + "range": { + "start": { + "line": 19, + "character": 8 + }, + "end": { + "line": 19, + "character": 8 + } + }, + "newText": "myServer" + }, + "additionalTextEdits": null, + "commitCharacters": null, + "command": null + } ] \ No newline at end of file From c5c58cec3953782b050b5b4fde12b42202b959d2 Mon Sep 17 00:00:00 2001 From: Leandro Libarona Date: Wed, 29 May 2024 17:23:05 -0300 Subject: [PATCH 05/16] only suggest encoded servers and not declared ones under channels in async 2 --- .../async/Async26ChannelServersPlugin.scala | 15 ++------ .../expected/channel-servers.yaml.json | 37 +------------------ 2 files changed, 4 insertions(+), 48 deletions(-) diff --git a/als-suggestions/shared/src/main/scala/org/mulesoft/als/suggestions/plugins/aml/webapi/async/Async26ChannelServersPlugin.scala b/als-suggestions/shared/src/main/scala/org/mulesoft/als/suggestions/plugins/aml/webapi/async/Async26ChannelServersPlugin.scala index 588efc514..8c40e9773 100644 --- a/als-suggestions/shared/src/main/scala/org/mulesoft/als/suggestions/plugins/aml/webapi/async/Async26ChannelServersPlugin.scala +++ b/als-suggestions/shared/src/main/scala/org/mulesoft/als/suggestions/plugins/aml/webapi/async/Async26ChannelServersPlugin.scala @@ -2,13 +2,13 @@ package org.mulesoft.als.suggestions.plugins.aml.webapi.async import amf.apicontract.client.scala.model.domain.api.AsyncApi import amf.apicontract.client.scala.model.domain.{EndPoint, Server} -import amf.core.client.scala.model.document.{BaseUnit, DeclaresModel, EncodesModel} +import amf.core.client.scala.model.document.{BaseUnit, EncodesModel} import org.mulesoft.als.suggestions.RawSuggestion import org.mulesoft.als.suggestions.aml.AmlCompletionRequest import org.mulesoft.als.suggestions.interfaces.AMLCompletionPlugin -import scala.concurrent.Future import scala.concurrent.ExecutionContext.Implicits.global +import scala.concurrent.Future object Async26ChannelServersPlugin extends AMLCompletionPlugin { override def id: String = "Async26ChannelServersPlugin" @@ -16,7 +16,7 @@ object Async26ChannelServersPlugin extends AMLCompletionPlugin { override def resolve(request: AmlCompletionRequest): Future[Seq[RawSuggestion]] = Future { request.amfObject match { case _: Server if request.branchStack.headOption.exists(_.isInstanceOf[EndPoint]) => - (getDeclaredServers(request.baseUnit) ++ getRootServers(request.baseUnit)).distinct + getRootServers(request.baseUnit) .map(server => RawSuggestion(server, isAKey = false, "Servers", mandatory = false)) case _ => Seq.empty } @@ -34,13 +34,4 @@ object Async26ChannelServersPlugin extends AMLCompletionPlugin { } yield { asyncApi.servers.map(_.name).flatMap(_.option()) }).getOrElse(Seq.empty) - - private def getDeclaredServers(baseUnit: BaseUnit): Seq[String] = - baseUnit match { - case d: DeclaresModel => - d.declares.collect { case s: Server => - s.name.value() - } - case _ => Seq.empty - } } diff --git a/als-suggestions/shared/src/test/resources/test/async26/by-directory/components/expected/channel-servers.yaml.json b/als-suggestions/shared/src/test/resources/test/async26/by-directory/components/expected/channel-servers.yaml.json index 2fe25d1ae..c9c513b9b 100644 --- a/als-suggestions/shared/src/test/resources/test/async26/by-directory/components/expected/channel-servers.yaml.json +++ b/als-suggestions/shared/src/test/resources/test/async26/by-directory/components/expected/channel-servers.yaml.json @@ -1,38 +1,3 @@ [ - { - "label": "myServer", - "kind": [ - - ], - "detail": "Servers", - "documentation": "myServer", - "deprecated": [ - - ], - "preselect": [ - - ], - "sortText": "11myServer", - "filterText": "myServer", - "insertText": null, - "insertTextFormat": [ - 1 - ], - "textEdit": { - "range": { - "start": { - "line": 21, - "character": 8 - }, - "end": { - "line": 21, - "character": 8 - } - }, - "newText": "myServer" - }, - "additionalTextEdits": null, - "commitCharacters": null, - "command": null - } + ] \ No newline at end of file From 383e47c4d7ae680fdf1bf3379274c6e6e8965671 Mon Sep 17 00:00:00 2001 From: Leandro Libarona Date: Thu, 30 May 2024 15:13:06 -0300 Subject: [PATCH 06/16] W-15888081: Missing validation specific for AsyncAPI 2.6 --- .../ALSConfigurationState.scala | 32 +++++++++----- .../ServerCleanDiagnosticTest.scala | 42 ++++++++++++++++++- 2 files changed, 62 insertions(+), 12 deletions(-) diff --git a/als-common/shared/src/main/scala/org/mulesoft/amfintegration/amfconfiguration/ALSConfigurationState.scala b/als-common/shared/src/main/scala/org/mulesoft/amfintegration/amfconfiguration/ALSConfigurationState.scala index f010dfc4e..49796f99e 100644 --- a/als-common/shared/src/main/scala/org/mulesoft/amfintegration/amfconfiguration/ALSConfigurationState.scala +++ b/als-common/shared/src/main/scala/org/mulesoft/amfintegration/amfconfiguration/ALSConfigurationState.scala @@ -58,16 +58,25 @@ case class ALSConfigurationState( } def configForSpec(spec: Spec): AMLSpecificConfiguration = - AMLSpecificConfiguration(getAmlConfig(spec match { - case Spec.RAML10 => projectState.customSetUp(RAMLConfiguration.RAML10()) - case Spec.RAML08 => projectState.customSetUp(RAMLConfiguration.RAML08()) - case Spec.OAS30 => projectState.customSetUp(OASConfiguration.OAS30()) - case Spec.OAS20 => projectState.customSetUp(OASConfiguration.OAS20()) - case Spec.ASYNC20 => projectState.customSetUp(AsyncAPIConfiguration.Async20()) - case Spec.GRAPHQL => projectState.customSetUp(ConfigurationAdapter.adapt(GraphQLConfiguration.GraphQL())) - case Spec.JSONSCHEMA => projectState.customSetUp(ConfigurationAdapter.adapt(JsonSchemaConfiguration.JsonSchema())) - case _ => predefinedWithDialects - })) + AMLSpecificConfiguration( + getAmlConfig(apiConfigurationForSpec(spec).map(projectState.customSetUp).getOrElse(predefinedWithDialects)) + ) + + private def apiConfigurationForSpec(spec: Spec): Option[AMFConfiguration] = + spec match { + case Spec.RAML10 => Some(RAMLConfiguration.RAML10()) + case Spec.RAML08 => Some(RAMLConfiguration.RAML08()) + case Spec.OAS30 => Some(OASConfiguration.OAS30()) + case Spec.OAS20 => Some(OASConfiguration.OAS20()) + case Spec.ASYNC20 => Some(AsyncAPIConfiguration.Async20()) + case Spec.ASYNC26 => Some(AsyncAPIConfiguration.Async20()) + case Spec.GRAPHQL => Some(ConfigurationAdapter.adapt(GraphQLConfiguration.GraphQL())) + case Spec.JSONSCHEMA => Some(ConfigurationAdapter.adapt(JsonSchemaConfiguration.JsonSchema())) + case _ if spec.isAsync => Some(AsyncAPIConfiguration.Async20()) + case _ if spec.id.startsWith("ASYNC 2") => + Some(AsyncAPIConfiguration.Async20()) // isAsync currently not working as it should + case _ => None + } def getAmfConfig(url: String): AMFConfiguration = { val base = @@ -83,7 +92,8 @@ case class ALSConfigurationState( val base = spec match { case GRAPHQL => GraphQLConfiguration.GraphQL() // case GRPC => - case _ => APIConfiguration.fromSpec(spec) + case _ => + APIConfiguration.fromSpec(spec) } getAmfConfig(base) } diff --git a/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/diagnostic/ServerCleanDiagnosticTest.scala b/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/diagnostic/ServerCleanDiagnosticTest.scala index 422ac674d..10be77e6b 100644 --- a/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/diagnostic/ServerCleanDiagnosticTest.scala +++ b/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/diagnostic/ServerCleanDiagnosticTest.scala @@ -202,7 +202,7 @@ class ServerCleanDiagnosticTest extends DiagnosticServerImpl with ChangesWorkspa v1.length should be(1) val fileDiagnostic = v1.head fileDiagnostic.diagnostics.size should be(1) - v1.head.diagnostics.head shouldBe (fileDiagnostic.diagnostics.head) // should be the same for req and notification + fileDiagnostic.diagnostics.head shouldBe (d.diagnostics.head) // should be the same for req and notification } } } @@ -268,4 +268,44 @@ class ServerCleanDiagnosticTest extends DiagnosticServerImpl with ChangesWorkspa } } } + + test("Clean diagnostic test for async 2.6") { + val diagnosticNotifier: MockDiagnosticClientNotifier = new MockDiagnosticClientNotifier(5000) + withServer(buildServer(diagnosticNotifier)) { s => + val mainFilePath = s"file://api.yaml" + + val mainContent = """asyncapi: '2.6.0' + |info: + | title: async + | version: '1.0.0' + |servers: + | server: + | url: s + | protocol: s + | protocolVersion: s + | + |components: + | servers: + | myServer: + | url: url.com + | protocol: https + | protocolVersion: 2 + |channels: + | user: + | servers: + | - server + | - myServer + | - asdasd""".stripMargin + + for { + _ <- openFileNotification(s)(mainFilePath, mainContent) + v1 <- requestCleanDiagnostic(s)(mainFilePath) + + } yield { + s.shutdown() + v1.length should be(1) + v1.head.diagnostics.size should be(2) + } + } + } } From c1483ba8050329d9c7812fc61eef873438cfe681 Mon Sep 17 00:00:00 2001 From: Leandro Libarona Date: Fri, 31 May 2024 02:30:48 -0300 Subject: [PATCH 07/16] W-15860818: adopt amf 5.5.2 with the changes on binding versions --- .../ALSConfigurationState.scala | 11 +- .../asyncapi20/AsyncApi20Dialect.scala | 15 +- .../bindings/BindingObjectNode.scala | 2 +- .../bindings/MessageBindingObjectNode.scala | 60 +++++- .../bindings/OperationBindingObjectNode.scala | 56 +++++- .../bindings/ServerBindingObjectNode.scala | 35 +++- .../asyncapi26/AsyncApi26Dialect.scala | 59 ++++-- .../bindings/ChannelBinding26ObjectNode.scala | 26 ++- .../bindings/MessageBinding26ObjectNode.scala | 56 +++++- .../OperationBinding26ObjectNode.scala | 188 +++++++++++++++--- .../diagnostics/async26/async-api26-full.yaml | 4 +- .../expected/http-binding.yaml.json | 72 +++++++ .../expected/googlepubsub-root.yaml.json | 72 +++++++ .../expected/googlepubsub-schema.yaml.json | 36 ++++ .../expected/solace-root-10.yaml.json | 38 ++++ .../expected/solace-root-30.yaml.json | 38 ++++ .../bindings/operation/solace-root-10.yaml | 8 + .../bindings/operation/solace-root-30.yaml | 8 + dependencies.properties | 2 +- 19 files changed, 694 insertions(+), 92 deletions(-) create mode 100644 als-suggestions/shared/src/test/resources/test/async26/by-directory/bindings/operation/expected/solace-root-10.yaml.json create mode 100644 als-suggestions/shared/src/test/resources/test/async26/by-directory/bindings/operation/expected/solace-root-30.yaml.json create mode 100644 als-suggestions/shared/src/test/resources/test/async26/by-directory/bindings/operation/solace-root-10.yaml create mode 100644 als-suggestions/shared/src/test/resources/test/async26/by-directory/bindings/operation/solace-root-30.yaml diff --git a/als-common/shared/src/main/scala/org/mulesoft/amfintegration/amfconfiguration/ALSConfigurationState.scala b/als-common/shared/src/main/scala/org/mulesoft/amfintegration/amfconfiguration/ALSConfigurationState.scala index 49796f99e..b3925a3d8 100644 --- a/als-common/shared/src/main/scala/org/mulesoft/amfintegration/amfconfiguration/ALSConfigurationState.scala +++ b/als-common/shared/src/main/scala/org/mulesoft/amfintegration/amfconfiguration/ALSConfigurationState.scala @@ -73,9 +73,7 @@ case class ALSConfigurationState( case Spec.GRAPHQL => Some(ConfigurationAdapter.adapt(GraphQLConfiguration.GraphQL())) case Spec.JSONSCHEMA => Some(ConfigurationAdapter.adapt(JsonSchemaConfiguration.JsonSchema())) case _ if spec.isAsync => Some(AsyncAPIConfiguration.Async20()) - case _ if spec.id.startsWith("ASYNC 2") => - Some(AsyncAPIConfiguration.Async20()) // isAsync currently not working as it should - case _ => None + case _ => None } def getAmfConfig(url: String): AMFConfiguration = { @@ -219,11 +217,10 @@ case class ALSConfigurationState( def defaultDefinitionSearch = allDialects(configurationState).find(d => ProfileMatcher.spec(d).contains(bu.sourceSpec.getOrElse(Spec.AMF))) - def overridenSpecs: Option[Dialect] = { - if (bu.sourceSpec.exists(_.id.startsWith("ASYNC 2"))) // the `isAsync` method is not currently working properly + def overwrittenSpecs: Option[Dialect] = + if (bu.sourceSpec.exists(_.isAsync)) allDialects(configurationState).find(d => ProfileMatcher.spec(d).contains(Spec.ASYNC20)) else None - } bu match { case di: DialectInstanceUnit => @@ -240,7 +237,7 @@ case class ALSConfigurationState( .find(d => d.version().option().contains(jsonSchema.schemaVersion.value())) .orElse(defaultDefinitionSearch) case _ => - defaultDefinitionSearch.orElse(overridenSpecs) + defaultDefinitionSearch.orElse(overwrittenSpecs) } } diff --git a/als-common/shared/src/main/scala/org/mulesoft/amfintegration/dialect/dialects/asyncapi20/AsyncApi20Dialect.scala b/als-common/shared/src/main/scala/org/mulesoft/amfintegration/dialect/dialects/asyncapi20/AsyncApi20Dialect.scala index b3077b2a6..5884af66b 100644 --- a/als-common/shared/src/main/scala/org/mulesoft/amfintegration/dialect/dialects/asyncapi20/AsyncApi20Dialect.scala +++ b/als-common/shared/src/main/scala/org/mulesoft/amfintegration/dialect/dialects/asyncapi20/AsyncApi20Dialect.scala @@ -56,19 +56,24 @@ object AsyncApi20Dialect extends BaseDialect { WsChannelBindingObject, LastWillMqttServerBindingObject, KafkaServerBindingObject, - MqttServerBindingObjectNode, + MqttServerBinding10ObjectNode, + MqttServerBinding20ObjectNode, AmqpMessageBindingObjectNode, KafkaMessageBindingObjectNode, KafkaMessageBinding010ObjectNode, KafkaMessageBinding030ObjectNode, - MqttMessageBindingObjectNode, - HttpMessageBindingObjectNode, + MqttMessageBinding10ObjectNode, + MqttMessageBinding20ObjectNode, + HttpMessageBinding20ObjectNode, + HttpMessageBinding30ObjectNode, Amqp091OperationBindingObjectNode, Amqp091OperationBinding010ObjectNode, Amqp091OperationBinding030ObjectNode, KafkaOperationBindingObjectNode, - HttpOperationBindingObjectNode, - MqttOperationBindingObjectNode, + HttpOperationBinding10ObjectNode, + HttpOperationBinding20ObjectNode, + MqttOperationBinding10ObjectNode, + MqttOperationBinding20ObjectNode, QueueAmqpChannelBinding, QueueAmqpChannel010Binding, QueueAmqpChannel020Binding, diff --git a/als-common/shared/src/main/scala/org/mulesoft/amfintegration/dialect/dialects/asyncapi20/bindings/BindingObjectNode.scala b/als-common/shared/src/main/scala/org/mulesoft/amfintegration/dialect/dialects/asyncapi20/bindings/BindingObjectNode.scala index 8212868fb..3d29bd2ed 100644 --- a/als-common/shared/src/main/scala/org/mulesoft/amfintegration/dialect/dialects/asyncapi20/bindings/BindingObjectNode.scala +++ b/als-common/shared/src/main/scala/org/mulesoft/amfintegration/dialect/dialects/asyncapi20/bindings/BindingObjectNode.scala @@ -3,7 +3,7 @@ package org.mulesoft.amfintegration.dialect.dialects.asyncapi20.bindings import amf.aml.client.scala.model.domain.PropertyMapping import amf.apicontract.internal.metamodel.domain.bindings.{BindingType, BindingVersion, GooglePubSubMessageBindingModel} import amf.core.client.scala.vocabulary.Namespace.XsdTypes.xsdString -import org.mulesoft.amfintegration.dialect.dialects.asyncapi26.bindings.GooglePubSubMessageBindingObject.{ +import org.mulesoft.amfintegration.dialect.dialects.asyncapi26.bindings.GooglePubSubMessageBinding10Object.{ location, name } diff --git a/als-common/shared/src/main/scala/org/mulesoft/amfintegration/dialect/dialects/asyncapi20/bindings/MessageBindingObjectNode.scala b/als-common/shared/src/main/scala/org/mulesoft/amfintegration/dialect/dialects/asyncapi20/bindings/MessageBindingObjectNode.scala index 75bf717ad..8444b9f33 100644 --- a/als-common/shared/src/main/scala/org/mulesoft/amfintegration/dialect/dialects/asyncapi20/bindings/MessageBindingObjectNode.scala +++ b/als-common/shared/src/main/scala/org/mulesoft/amfintegration/dialect/dialects/asyncapi20/bindings/MessageBindingObjectNode.scala @@ -3,15 +3,21 @@ package org.mulesoft.amfintegration.dialect.dialects.asyncapi20.bindings import amf.aml.client.scala.model.domain.PropertyMapping import amf.apicontract.internal.metamodel.domain.bindings.{ Amqp091MessageBindingModel, + HttpMessageBinding020Model, + HttpMessageBinding030Model, HttpMessageBindingModel, KafkaMessageBinding010Model, KafkaMessageBinding030Model, KafkaMessageBindingModel, MessageBindingModel, MessageBindingsModel, + MqttMessageBinding010Model, + MqttMessageBinding020Model, MqttMessageBindingModel } -import amf.core.client.scala.vocabulary.Namespace.XsdTypes.xsdString +import amf.core.client.scala.vocabulary.Namespace.XsdTypes.{xsdInteger, xsdString} +import org.mulesoft.amfintegration.dialect.dialects.asyncapi20.bindings.AmqpMessageBindingObjectNode.{location, name} +import org.mulesoft.amfintegration.dialect.dialects.asyncapi20.schema.NodeShapeAsync2Node import org.mulesoft.amfintegration.dialect.dialects.oas.nodes.DialectNode object MessageBindingObjectNode extends BindingObjectNode { @@ -29,7 +35,21 @@ object MessageBindingsObjectNode extends DialectNode { override def properties: Seq[PropertyMapping] = Nil } -object HttpMessageBindingObjectNode extends DialectNode with BindingVersionPropertyMapping { +object HttpMessageBinding20ObjectNode extends BaseHttpMessageBindingObjectNode { + override def nodeTypeMapping: String = HttpMessageBinding020Model.`type`.head.iri() + +} +object HttpMessageBinding30ObjectNode extends BaseHttpMessageBindingObjectNode { + override def nodeTypeMapping: String = HttpMessageBinding030Model.`type`.head.iri() + override def properties: Seq[PropertyMapping] = super.properties ++ Seq( + PropertyMapping() + .withId(location + s"#/declarations/$name/statusCode") + .withName("statusCode") + .withNodePropertyMapping(HttpMessageBinding030Model.StatusCode.value.iri()) + .withLiteralRange(xsdInteger.iri()) + ) +} +trait BaseHttpMessageBindingObjectNode extends DialectNode with BindingVersionPropertyMapping { override def name: String = "HttpMessageBindingObjectNode" override def nodeTypeMapping: String = HttpMessageBindingModel.`type`.head.iri() @@ -101,7 +121,41 @@ object AmqpMessageBindingObjectNode extends DialectNode with BindingVersionPrope ) :+ bindingVersion } -object MqttMessageBindingObjectNode extends DialectNode with BindingVersionPropertyMapping { +object MqttMessageBinding10ObjectNode extends BaseMqttMessageBindingObjectNode { + override def nodeTypeMapping: String = MqttMessageBinding010Model.`type`.head.iri() +} +object MqttMessageBinding20ObjectNode extends BaseMqttMessageBindingObjectNode { + override def nodeTypeMapping: String = MqttMessageBinding020Model.`type`.head.iri() + + override def properties: Seq[PropertyMapping] = super.properties ++ Seq( + PropertyMapping() + .withId(location + s"#/declarations/$name/payloadFormatIndicator") + .withName("payloadFormatIndicator") + .withNodePropertyMapping(MqttMessageBinding020Model.PayloadFormatIndicator.value.iri()) + .withLiteralRange(xsdInteger.iri()), + PropertyMapping() + .withId(location + s"#/declarations/$name/correlationData") + .withName("correlationData") + .withNodePropertyMapping(MqttMessageBinding020Model.CorrelationData.value.iri()) + .withObjectRange(Seq(NodeShapeAsync2Node.id)), + PropertyMapping() + .withId(location + s"#/declarations/$name/contentType") + .withName("contentType") + .withNodePropertyMapping(MqttMessageBinding020Model.ContentType.value.iri()) + .withLiteralRange(xsdString.iri()), + PropertyMapping() + .withId(location + s"#/declarations/$name/responseTopic") + .withName("responseTopic") + .withNodePropertyMapping(MqttMessageBinding020Model.ResponseTopic.value.iri()) + .withLiteralRange(xsdString.iri()), + PropertyMapping() + .withId(location + s"#/declarations/$name/responseTopicSchema") + .withName("responseTopicSchema") + .withNodePropertyMapping(MqttMessageBinding020Model.ResponseTopicSchema.value.iri()) + .withObjectRange(Seq(NodeShapeAsync2Node.id)) + ) +} +trait BaseMqttMessageBindingObjectNode extends DialectNode with BindingVersionPropertyMapping { override def name: String = "MqttMessageBindingObjectNode" override def nodeTypeMapping: String = MqttMessageBindingModel.`type`.head.iri() diff --git a/als-common/shared/src/main/scala/org/mulesoft/amfintegration/dialect/dialects/asyncapi20/bindings/OperationBindingObjectNode.scala b/als-common/shared/src/main/scala/org/mulesoft/amfintegration/dialect/dialects/asyncapi20/bindings/OperationBindingObjectNode.scala index dbca6da0c..0b1cc4616 100644 --- a/als-common/shared/src/main/scala/org/mulesoft/amfintegration/dialect/dialects/asyncapi20/bindings/OperationBindingObjectNode.scala +++ b/als-common/shared/src/main/scala/org/mulesoft/amfintegration/dialect/dialects/asyncapi20/bindings/OperationBindingObjectNode.scala @@ -5,13 +5,18 @@ import amf.apicontract.internal.metamodel.domain.bindings.{ Amqp091OperationBinding010Model, Amqp091OperationBinding030Model, Amqp091OperationBindingModel, + HttpOperationBinding010Model, + HttpOperationBinding020Model, HttpOperationBindingModel, KafkaOperationBindingModel, + MqttOperationBinding010Model, + MqttOperationBinding020Model, MqttOperationBindingModel, OperationBindingModel, OperationBindingsModel } import amf.core.client.scala.vocabulary.Namespace.XsdTypes.{xsdBoolean, xsdInteger, xsdString} +import org.mulesoft.amfintegration.dialect.dialects.asyncapi20.schema.NodeShapeAsync2Node import org.mulesoft.amfintegration.dialect.dialects.oas.nodes.DialectNode object OperationBindingObjectNode extends BindingObjectNode { @@ -29,24 +34,37 @@ object OperationBindingsObjectNode extends DialectNode { override def properties: Seq[PropertyMapping] = Nil } -object HttpOperationBindingObjectNode extends DialectNode with BindingVersionPropertyMapping { +object HttpOperationBinding10ObjectNode extends BaseHttpOperationBindingObjectNode { + override def nodeTypeMapping: String = HttpOperationBinding010Model.`type`.head.iri() + override def properties: Seq[PropertyMapping] = super.properties ++ Seq( + PropertyMapping() + .withId(location + s"#/declarations/$name/type") + .withName("type") + .withNodePropertyMapping(HttpOperationBinding010Model.OperationType.value.iri()) // todo: http node mappings? + .withLiteralRange(xsdString.iri()) + .withEnum(Seq("request", "response")) + ) +} +object HttpOperationBinding20ObjectNode extends BaseHttpOperationBindingObjectNode { + override def nodeTypeMapping: String = HttpOperationBinding020Model.`type`.head.iri() +} +trait BaseHttpOperationBindingObjectNode extends DialectNode with BindingVersionPropertyMapping { override def name: String = "HttpOperationBindingObjectNode" override def nodeTypeMapping: String = HttpOperationBindingModel.`type`.head.iri() override def properties: Seq[PropertyMapping] = Seq( - PropertyMapping() - .withId(location + s"#/declarations/$name/type") - .withName("type") - .withNodePropertyMapping(HttpOperationBindingModel.OperationType.value.iri()) // todo: http node mappings? - .withLiteralRange(xsdString.iri()) - .withEnum(Seq("request", "response")), PropertyMapping() .withId(location + s"#/declarations/$name/method") .withName("method") .withNodePropertyMapping(HttpOperationBindingModel.Method.value.iri()) // todo: http node mappings? .withLiteralRange(xsdString.iri()) - .withEnum(Seq("GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS", "CONNECT", "TRACE")) + .withEnum(Seq("GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS", "CONNECT", "TRACE")), + PropertyMapping() + .withId(location + s"#/declarations/$name/query") + .withName("query") + .withNodePropertyMapping(HttpOperationBindingModel.Query.value.iri()) // todo: http node mappings? + .withObjectRange(Seq(NodeShapeAsync2Node.id)) ) :+ bindingVersion } @@ -152,7 +170,27 @@ object Amqp091OperationBinding030ObjectNode extends AmqpOperationBindingObjectNo ) } -object MqttOperationBindingObjectNode extends DialectNode with BindingVersionPropertyMapping { +object MqttOperationBinding10ObjectNode extends BaseMqttOperationBindingObjectNode { + override def nodeTypeMapping: String = MqttOperationBinding010Model.`type`.head.iri() +} + +object MqttOperationBinding20ObjectNode extends BaseMqttOperationBindingObjectNode { + override def nodeTypeMapping: String = MqttOperationBinding020Model.`type`.head.iri() + override def properties: Seq[PropertyMapping] = Seq( + PropertyMapping() + .withId(location + s"#/declarations/$name/messageExpiryInterval") + .withName("messageExpiryInterval") + .withNodePropertyMapping(MqttOperationBinding020Model.MessageExpiryInterval.value.iri()) + .withLiteralRange(xsdInteger.iri()), + PropertyMapping() + .withId(location + s"#/declarations/$name/messageExpiryIntervalSchema") + .withName("messageExpiryIntervalSchema") + .withNodePropertyMapping(MqttOperationBinding020Model.MessageExpiryIntervalSchema.value.iri()) + .withObjectRange(Seq(NodeShapeAsync2Node.id)) + ) +} + +trait BaseMqttOperationBindingObjectNode extends DialectNode with BindingVersionPropertyMapping { override def name: String = "MqttOperationBindingObjectNode" override def nodeTypeMapping: String = MqttOperationBindingModel.`type`.head.iri() diff --git a/als-common/shared/src/main/scala/org/mulesoft/amfintegration/dialect/dialects/asyncapi20/bindings/ServerBindingObjectNode.scala b/als-common/shared/src/main/scala/org/mulesoft/amfintegration/dialect/dialects/asyncapi20/bindings/ServerBindingObjectNode.scala index 2296b23f7..3a1a3aa5f 100644 --- a/als-common/shared/src/main/scala/org/mulesoft/amfintegration/dialect/dialects/asyncapi20/bindings/ServerBindingObjectNode.scala +++ b/als-common/shared/src/main/scala/org/mulesoft/amfintegration/dialect/dialects/asyncapi20/bindings/ServerBindingObjectNode.scala @@ -2,12 +2,15 @@ package org.mulesoft.amfintegration.dialect.dialects.asyncapi20.bindings import amf.aml.client.scala.model.domain.PropertyMapping import amf.apicontract.internal.metamodel.domain.bindings.{ KafkaServerBindingModel, + MqttServerBinding010Model, + MqttServerBinding020Model, MqttServerBindingModel, MqttServerLastWillModel, ServerBindingModel, ServerBindingsModel } import amf.core.client.scala.vocabulary.Namespace.XsdTypes.{xsdBoolean, xsdInteger, xsdString} +import org.mulesoft.amfintegration.dialect.dialects.asyncapi20.schema.NodeShapeAsync2Node import org.mulesoft.amfintegration.dialect.dialects.oas.nodes.DialectNode object ServerBindingObjectNode extends BindingObjectNode { @@ -23,8 +26,38 @@ object ServerBindingsObjectNode extends DialectNode { override def properties: Seq[PropertyMapping] = Nil } +object MqttServerBinding10ObjectNode extends BaseMqttServerBindingObjectNode { + override def nodeTypeMapping: String = MqttServerBinding010Model.`type`.head.iri() -object MqttServerBindingObjectNode extends DialectNode with BindingVersionPropertyMapping { +} +object MqttServerBinding20ObjectNode extends BaseMqttServerBindingObjectNode { + override def nodeTypeMapping: String = MqttServerBinding020Model.`type`.head.iri() + + override def properties: Seq[PropertyMapping] = super.properties ++ Seq( + PropertyMapping() + .withId(location + s"#/declarations/$name/sessionExpiryInterval") + .withName("sessionExpiryInterval") + .withNodePropertyMapping(MqttServerBinding020Model.SessionExpiryInterval.value.iri()) + .withLiteralRange(xsdInteger.iri()), + PropertyMapping() + .withId(location + s"#/declarations/$name/sessionExpiryIntervalSchema") + .withName("sessionExpiryIntervalSchema") + .withNodePropertyMapping(MqttServerBinding020Model.SessionExpiryIntervalSchema.value.iri()) + .withObjectRange(Seq(NodeShapeAsync2Node.id)), + PropertyMapping() + .withId(location + s"#/declarations/$name/maximumPacketSize") + .withName("maximumPacketSize") + .withNodePropertyMapping(MqttServerBinding020Model.MaximumPacketSize.value.iri()) + .withLiteralRange(xsdInteger.iri()), + PropertyMapping() + .withId(location + s"#/declarations/$name/maximumPacketSizeSchema") + .withName("maximumPacketSizeSchema") + .withNodePropertyMapping(MqttServerBinding020Model.MaximumPacketSizeSchema.value.iri()) + .withObjectRange(Seq(NodeShapeAsync2Node.id)) + ) + +} +trait BaseMqttServerBindingObjectNode extends DialectNode with BindingVersionPropertyMapping { override def name: String = "MqttServerBindingObjectNode" override def nodeTypeMapping: String = MqttServerBindingModel.`type`.head.iri() diff --git a/als-common/shared/src/main/scala/org/mulesoft/amfintegration/dialect/dialects/asyncapi26/AsyncApi26Dialect.scala b/als-common/shared/src/main/scala/org/mulesoft/amfintegration/dialect/dialects/asyncapi26/AsyncApi26Dialect.scala index 99c615ed2..13ebd32b1 100644 --- a/als-common/shared/src/main/scala/org/mulesoft/amfintegration/dialect/dialects/asyncapi26/AsyncApi26Dialect.scala +++ b/als-common/shared/src/main/scala/org/mulesoft/amfintegration/dialect/dialects/asyncapi26/AsyncApi26Dialect.scala @@ -23,10 +23,13 @@ import org.mulesoft.amfintegration.dialect.dialects.asyncapi26.bindings.{ AnypointMQChannelBindingObject, AnypointMQMessageBindingObject, ChannelBinding26ObjectNode, - GooglePubSubChannelBindingObject, - GooglePubSubMessageBindingObject, + GooglePubSubChannelBinding10Object, + GooglePubSubChannelBinding20Object, + GooglePubSubMessageBinding10Object, + GooglePubSubMessageBinding20Object, GooglePubSubMessageStoragePolicyObject, - GooglePubSubSchemaDefinitionObject, + GooglePubSubSchemaDefinition10Object, + GooglePubSubSchemaDefinition20Object, GooglePubSubSchemaSettingsObject, IBMMQChannelBindingObject, IBMMQChannelQueueObject, @@ -39,9 +42,16 @@ import org.mulesoft.amfintegration.dialect.dialects.asyncapi26.bindings.{ PulsarChannelRetentionObject, PulsarServerBindingObject, ServerBinding26ObjectNode, - SolaceOperationBindingObject, - SolaceOperationDestinationObject, - SolaceOperationQueueObject, + SolaceOperationBinding10Object, + SolaceOperationBinding20Object, + SolaceOperationBinding30Object, + SolaceOperationBinding40Object, + SolaceOperationDestination10Object, + SolaceOperationDestination20Object, + SolaceOperationDestination30Object, + SolaceOperationDestination40Object, + SolaceOperationQueue10Object, + SolaceOperationQueue30Object, SolaceOperationTopicObject, SolaceServerBindingObject } @@ -93,19 +103,24 @@ object AsyncApi26Dialect extends BaseDialect { WsChannelBindingObject, LastWillMqttServerBindingObject, KafkaServerBindingObject, - MqttServerBindingObjectNode, + MqttServerBinding10ObjectNode, + MqttServerBinding20ObjectNode, AmqpMessageBindingObjectNode, KafkaMessageBindingObjectNode, KafkaMessageBinding010ObjectNode, KafkaMessageBinding030ObjectNode, - MqttMessageBindingObjectNode, - HttpMessageBindingObjectNode, + MqttMessageBinding10ObjectNode, + MqttMessageBinding20ObjectNode, + HttpMessageBinding20ObjectNode, + HttpMessageBinding30ObjectNode, Amqp091OperationBindingObjectNode, Amqp091OperationBinding010ObjectNode, Amqp091OperationBinding030ObjectNode, KafkaOperationBindingObjectNode, - HttpOperationBindingObjectNode, - MqttOperationBindingObjectNode, + HttpOperationBinding10ObjectNode, + HttpOperationBinding20ObjectNode, + MqttOperationBinding10ObjectNode, + MqttOperationBinding20ObjectNode, QueueAmqpChannelBinding, QueueAmqpChannel010Binding, QueueAmqpChannel020Binding, @@ -128,19 +143,29 @@ object AsyncApi26Dialect extends BaseDialect { IBMMQChannelBindingObject, IBMMQChannelQueueObject, IBMMQChannelTopicObject, - GooglePubSubChannelBindingObject, + GooglePubSubChannelBinding10Object, + GooglePubSubChannelBinding20Object, GooglePubSubMessageStoragePolicyObject, GooglePubSubSchemaSettingsObject, AnypointMQChannelBindingObject, PulsarChannelBindingObject, PulsarChannelRetentionObject, IBMMQMessageBindingObject, - GooglePubSubMessageBindingObject, - GooglePubSubSchemaDefinitionObject, + GooglePubSubMessageBinding10Object, + GooglePubSubMessageBinding20Object, + GooglePubSubSchemaDefinition10Object, + GooglePubSubSchemaDefinition20Object, AnypointMQMessageBindingObject, - SolaceOperationBindingObject, - SolaceOperationDestinationObject, - SolaceOperationQueueObject, + SolaceOperationBinding10Object, + SolaceOperationBinding20Object, + SolaceOperationBinding30Object, + SolaceOperationBinding40Object, + SolaceOperationDestination10Object, + SolaceOperationDestination20Object, + SolaceOperationDestination30Object, + SolaceOperationDestination40Object, + SolaceOperationQueue30Object, + SolaceOperationQueue10Object, SolaceOperationTopicObject, IBMMQServerBindingObject, SolaceServerBindingObject, diff --git a/als-common/shared/src/main/scala/org/mulesoft/amfintegration/dialect/dialects/asyncapi26/bindings/ChannelBinding26ObjectNode.scala b/als-common/shared/src/main/scala/org/mulesoft/amfintegration/dialect/dialects/asyncapi26/bindings/ChannelBinding26ObjectNode.scala index fa3e896b9..e3c6c55a2 100644 --- a/als-common/shared/src/main/scala/org/mulesoft/amfintegration/dialect/dialects/asyncapi26/bindings/ChannelBinding26ObjectNode.scala +++ b/als-common/shared/src/main/scala/org/mulesoft/amfintegration/dialect/dialects/asyncapi26/bindings/ChannelBinding26ObjectNode.scala @@ -4,6 +4,8 @@ import amf.aml.client.scala.model.domain.PropertyMapping import amf.apicontract.internal.metamodel.domain.bindings.{ AnypointMQChannelBindingModel, ChannelBindingModel, + GooglePubSubChannelBinding010Model, + GooglePubSubChannelBinding020Model, GooglePubSubChannelBindingModel, GooglePubSubMessageStoragePolicyModel, GooglePubSubSchemaSettingsModel, @@ -106,7 +108,22 @@ object IBMMQChannelTopicObject extends DialectNode { ) } -object GooglePubSubChannelBindingObject extends DialectNode with BindingVersionPropertyMapping { +object GooglePubSubChannelBinding10Object extends BaseGooglePubSubChannelBindingObject { + override def nodeTypeMapping: String = GooglePubSubChannelBinding010Model.`type`.head.iri() + + override def properties: Seq[PropertyMapping] = super.properties ++ Seq( + PropertyMapping() + .withId(location + s"#/declarations/$name/topic") + .withName("topic") + .withNodePropertyMapping(GooglePubSubChannelBinding010Model.Topic.value.iri()) + .withLiteralRange(xsdString.iri()) + ) +} +object GooglePubSubChannelBinding20Object extends BaseGooglePubSubChannelBindingObject { + override def nodeTypeMapping: String = GooglePubSubChannelBinding020Model.`type`.head.iri() + +} +trait BaseGooglePubSubChannelBindingObject extends DialectNode with BindingVersionPropertyMapping { override def name: String = "GooglePubSubChannelBindingObject" override def nodeTypeMapping: String = GooglePubSubChannelBindingModel.`type`.head.iri() @@ -131,12 +148,7 @@ object GooglePubSubChannelBindingObject extends DialectNode with BindingVersionP .withId(location + s"#/declarations/$name/schemaSettings") .withName("schemaSettings") .withNodePropertyMapping(GooglePubSubChannelBindingModel.SchemaSettings.value.iri()) - .withObjectRange(Seq(GooglePubSubSchemaSettingsObject.id)), - PropertyMapping() - .withId(location + s"#/declarations/$name/topic") - .withName("topic") - .withNodePropertyMapping(GooglePubSubChannelBindingModel.Topic.value.iri()) - .withLiteralRange(xsdString.iri()) + .withObjectRange(Seq(GooglePubSubSchemaSettingsObject.id)) ) :+ bindingVersion } diff --git a/als-common/shared/src/main/scala/org/mulesoft/amfintegration/dialect/dialects/asyncapi26/bindings/MessageBinding26ObjectNode.scala b/als-common/shared/src/main/scala/org/mulesoft/amfintegration/dialect/dialects/asyncapi26/bindings/MessageBinding26ObjectNode.scala index 7a8a5f8df..0a2686380 100644 --- a/als-common/shared/src/main/scala/org/mulesoft/amfintegration/dialect/dialects/asyncapi26/bindings/MessageBinding26ObjectNode.scala +++ b/als-common/shared/src/main/scala/org/mulesoft/amfintegration/dialect/dialects/asyncapi26/bindings/MessageBinding26ObjectNode.scala @@ -3,7 +3,11 @@ package org.mulesoft.amfintegration.dialect.dialects.asyncapi26.bindings import amf.aml.client.scala.model.domain.PropertyMapping import amf.apicontract.internal.metamodel.domain.bindings.{ AnypointMQMessageBindingModel, + GooglePubSubMessageBinding010Model, + GooglePubSubMessageBinding020Model, GooglePubSubMessageBindingModel, + GooglePubSubSchemaDefinition010Model, + GooglePubSubSchemaDefinition020Model, GooglePubSubSchemaDefinitionModel, IBMMQMessageBindingModel, MessageBindingModel @@ -11,6 +15,10 @@ import amf.apicontract.internal.metamodel.domain.bindings.{ import amf.core.client.scala.vocabulary.Namespace.XsdTypes.{xsdInteger, xsdString} import org.mulesoft.amfintegration.dialect.dialects.asyncapi20.bindings.BindingVersionPropertyMapping import org.mulesoft.amfintegration.dialect.dialects.asyncapi20.schema.BaseShapeAsync2Node +import org.mulesoft.amfintegration.dialect.dialects.asyncapi26.bindings.GooglePubSubMessageBinding10Object.{ + location, + name +} import org.mulesoft.amfintegration.dialect.dialects.oas.nodes.DialectNode object MessageBinding26ObjectNode extends BindingObjectNode26 { @@ -55,7 +63,28 @@ object IBMMQMessageBindingObject extends DialectNode { ) } -object GooglePubSubMessageBindingObject extends DialectNode { +object GooglePubSubMessageBinding10Object extends BaseGooglePubSubMessageBindingObject { + override def nodeTypeMapping: String = GooglePubSubMessageBinding010Model.`type`.head.iri() + override def properties: Seq[PropertyMapping] = super.properties ++ Seq( + PropertyMapping() + .withId(location + s"#/declarations/$name/schema") + .withName("schema") + .withNodePropertyMapping(GooglePubSubMessageBinding010Model.Schema.value.iri()) + .withObjectRange(Seq(GooglePubSubSchemaDefinition10Object.id)) + ) +} +object GooglePubSubMessageBinding20Object extends BaseGooglePubSubMessageBindingObject { + override def nodeTypeMapping: String = GooglePubSubMessageBinding020Model.`type`.head.iri() + override def properties: Seq[PropertyMapping] = super.properties ++ Seq( + PropertyMapping() + .withId(location + s"#/declarations/$name/schema") + .withName("schema") + .withNodePropertyMapping(GooglePubSubMessageBinding020Model.Schema.value.iri()) + .withObjectRange(Seq(GooglePubSubSchemaDefinition20Object.id)) + ) +} + +trait BaseGooglePubSubMessageBindingObject extends DialectNode with BindingVersionPropertyMapping { override def name: String = "GooglePubSubMessageBindingObject" override def nodeTypeMapping: String = GooglePubSubMessageBindingModel.`type`.head.iri() @@ -75,11 +104,25 @@ object GooglePubSubMessageBindingObject extends DialectNode { .withId(location + s"#/declarations/$name/schema") .withName("schema") .withNodePropertyMapping(GooglePubSubMessageBindingModel.Schema.value.iri()) - .withObjectRange(Seq(GooglePubSubSchemaDefinitionObject.id)) + .withObjectRange(Seq(GooglePubSubSchemaDefinition10Object.id)) + ) :+ bindingVersion +} +object GooglePubSubSchemaDefinition10Object extends BaseGooglePubSubSchemaDefinitionObject { + override def nodeTypeMapping: String = GooglePubSubSchemaDefinition010Model.`type`.head.iri() + override def properties: Seq[PropertyMapping] = super.properties ++ Seq( + PropertyMapping() + .withId(location + s"#/declarations/$name/fieldType") + .withName("fieldType") + .withNodePropertyMapping(GooglePubSubSchemaDefinition010Model.FieldType.value.iri()) + .withLiteralRange(xsdString.iri()) ) + +} +object GooglePubSubSchemaDefinition20Object extends BaseGooglePubSubSchemaDefinitionObject { + override def nodeTypeMapping: String = GooglePubSubSchemaDefinition020Model.`type`.head.iri() } -object GooglePubSubSchemaDefinitionObject extends DialectNode { +trait BaseGooglePubSubSchemaDefinitionObject extends DialectNode with BindingVersionPropertyMapping { override def name: String = "GooglePubSubSchemaDefinitionObject" override def nodeTypeMapping: String = GooglePubSubSchemaDefinitionModel.`type`.head.iri() @@ -89,13 +132,8 @@ object GooglePubSubSchemaDefinitionObject extends DialectNode { .withId(location + s"#/declarations/$name/name") .withName("name") .withNodePropertyMapping(GooglePubSubSchemaDefinitionModel.Name.value.iri()) - .withLiteralRange(xsdString.iri()), - PropertyMapping() - .withId(location + s"#/declarations/$name/fieldType") - .withName("fieldType") - .withNodePropertyMapping(GooglePubSubSchemaDefinitionModel.FieldType.value.iri()) .withLiteralRange(xsdString.iri()) - ) + ) :+ bindingVersion } object AnypointMQMessageBindingObject extends DialectNode with BindingVersionPropertyMapping { diff --git a/als-common/shared/src/main/scala/org/mulesoft/amfintegration/dialect/dialects/asyncapi26/bindings/OperationBinding26ObjectNode.scala b/als-common/shared/src/main/scala/org/mulesoft/amfintegration/dialect/dialects/asyncapi26/bindings/OperationBinding26ObjectNode.scala index 496ff2c46..c3cff3471 100644 --- a/als-common/shared/src/main/scala/org/mulesoft/amfintegration/dialect/dialects/asyncapi26/bindings/OperationBinding26ObjectNode.scala +++ b/als-common/shared/src/main/scala/org/mulesoft/amfintegration/dialect/dialects/asyncapi26/bindings/OperationBinding26ObjectNode.scala @@ -2,8 +2,23 @@ package org.mulesoft.amfintegration.dialect.dialects.asyncapi26.bindings import amf.aml.client.scala.model.domain.PropertyMapping import amf.apicontract.internal.metamodel.domain.bindings._ -import amf.core.client.scala.vocabulary.Namespace.XsdTypes.xsdString +import amf.core.client.scala.vocabulary.Namespace.XsdTypes.{xsdBoolean, xsdInteger, xsdString} import org.mulesoft.amfintegration.dialect.dialects.asyncapi20.bindings.BindingVersionPropertyMapping +import org.mulesoft.amfintegration.dialect.dialects.asyncapi26.bindings.SolaceOperationBinding10Object.{location, name} +import org.mulesoft.amfintegration.dialect.dialects.asyncapi26.bindings.SolaceOperationBinding20Object.{location, name} +import org.mulesoft.amfintegration.dialect.dialects.asyncapi26.bindings.SolaceOperationBinding30Object.{location, name} +import org.mulesoft.amfintegration.dialect.dialects.asyncapi26.bindings.SolaceOperationDestination10Object.{ + location, + name +} +import org.mulesoft.amfintegration.dialect.dialects.asyncapi26.bindings.SolaceOperationDestination20Object.{ + location, + name +} +import org.mulesoft.amfintegration.dialect.dialects.asyncapi26.bindings.SolaceOperationDestination30Object.{ + location, + name +} import org.mulesoft.amfintegration.dialect.dialects.oas.nodes.DialectNode object OperationBinding26ObjectNode extends BindingObjectNode26 { @@ -15,22 +30,136 @@ object OperationBinding26ObjectNode extends BindingObjectNode26 { override def nodeTypeMapping: String = OperationBindingModel.`type`.head.iri() } -object SolaceOperationBindingObject extends DialectNode with BindingVersionPropertyMapping { - override def name: String = "SolaceOperationBindingObject" - - override def nodeTypeMapping: String = SolaceOperationBindingModel.`type`.head.iri() - - override def properties: Seq[PropertyMapping] = Seq( +object SolaceOperationBinding10Object extends BaseSolaceOperationBindingObject { + override def nodeTypeMapping: String = SolaceOperationBinding010Model.`type`.head.iri() + override def properties: Seq[PropertyMapping] = super.properties ++ Seq( PropertyMapping() .withId(location + s"#/declarations/$name/destinations") .withName("destinations") .withNodePropertyMapping(SolaceOperationBindingModel.Destinations.value.iri()) .withAllowMultiple(true) - .withObjectRange(Seq(SolaceOperationDestinationObject.id)) // id of schemas - ) :+ bindingVersion + .withObjectRange(Seq(SolaceOperationDestination10Object.id)) // id of schemas + ) } +object SolaceOperationBinding20Object extends BaseSolaceOperationBindingObject { + override def nodeTypeMapping: String = SolaceOperationBinding020Model.`type`.head.iri() + override def properties: Seq[PropertyMapping] = super.properties ++ Seq( + PropertyMapping() + .withId(location + s"#/declarations/$name/destinations") + .withName("destinations") + .withNodePropertyMapping(SolaceOperationBinding020Model.Destinations.value.iri()) + .withAllowMultiple(true) + .withObjectRange(Seq(SolaceOperationDestination20Object.id)) // id of schemas + ) +} +object SolaceOperationBinding30Object extends BaseSolaceOperationBindingObject { + override def nodeTypeMapping: String = SolaceOperationBinding030Model.`type`.head.iri() + override def properties: Seq[PropertyMapping] = super.properties ++ Seq( + PropertyMapping() + .withId(location + s"#/declarations/$name/destinations") + .withName("destinations") + .withNodePropertyMapping(SolaceOperationBinding030Model.Destinations.value.iri()) + .withAllowMultiple(true) + .withObjectRange(Seq(SolaceOperationDestination30Object.id)) // id of schemas + ) +} +object SolaceOperationBinding40Object extends BaseSolaceOperationBindingObject { + override def nodeTypeMapping: String = SolaceOperationBinding040Model.`type`.head.iri() + override def properties: Seq[PropertyMapping] = super.properties ++ Seq( + PropertyMapping() + .withId(location + s"#/declarations/$name/destinations") + .withName("destinations") + .withNodePropertyMapping(SolaceOperationBinding040Model.Destinations.value.iri()) + .withAllowMultiple(true) + .withObjectRange(Seq(SolaceOperationDestination40Object.id)), + PropertyMapping() + .withId(location + s"#/declarations/$name/timeToLive") + .withName("timeToLive") + .withNodePropertyMapping(SolaceOperationBinding040Model.TimeToLive.value.iri()) + .withAllowMultiple(true) + .withLiteralRange(xsdInteger.iri()), + PropertyMapping() + .withId(location + s"#/declarations/$name/priority") + .withName("priority") + .withNodePropertyMapping(SolaceOperationBinding040Model.Priority.value.iri()) + .withAllowMultiple(true) + .withLiteralRange(xsdInteger.iri()), + PropertyMapping() + .withId(location + s"#/declarations/$name/dmqEligible") + .withName("dmqEligible") + .withNodePropertyMapping(SolaceOperationBinding040Model.DmqEligible.value.iri()) + .withAllowMultiple(true) + .withLiteralRange(xsdBoolean.iri()) + ) +} +trait BaseSolaceOperationBindingObject extends DialectNode with BindingVersionPropertyMapping { + override def name: String = "SolaceOperationBindingObject" + + override def nodeTypeMapping: String = SolaceOperationBindingModel.`type`.head.iri() -object SolaceOperationDestinationObject extends DialectNode { + override def properties: Seq[PropertyMapping] = Seq(bindingVersion) +} + +object SolaceOperationDestination10Object extends BaseSolaceOperationDestinationObject { + override def nodeTypeMapping: String = SolaceOperationDestination010Model.`type`.head.iri() + + override def properties: Seq[PropertyMapping] = super.properties ++ Seq( + PropertyMapping() + .withId(location + s"#/declarations/$name/queue") + .withName("queue") + .withNodePropertyMapping(SolaceOperationDestination010Model.Queue.value.iri()) + .withObjectRange(Seq(SolaceOperationQueue10Object.id)) + ) +} +object SolaceOperationDestination20Object extends BaseSolaceOperationDestinationObject { + override def nodeTypeMapping: String = SolaceOperationDestination020Model.`type`.head.iri() + + override def properties: Seq[PropertyMapping] = super.properties ++ Seq( + PropertyMapping() + .withId(location + s"#/declarations/$name/queue") + .withName("queue") + .withNodePropertyMapping(SolaceOperationDestination020Model.Queue.value.iri()) + .withObjectRange(Seq(SolaceOperationQueue10Object.id)), + PropertyMapping() + .withId(location + s"#/declarations/$name/topic") + .withName("topic") + .withNodePropertyMapping(SolaceOperationDestination020Model.Topic.value.iri()) + .withObjectRange(Seq(SolaceOperationTopicObject.id)) + ) +} +object SolaceOperationDestination30Object extends BaseSolaceOperationDestinationObject { + override def nodeTypeMapping: String = SolaceOperationDestination030Model.`type`.head.iri() + override def properties: Seq[PropertyMapping] = super.properties ++ Seq( + PropertyMapping() + .withId(location + s"#/declarations/$name/queue") + .withName("queue") + .withNodePropertyMapping(SolaceOperationDestination030Model.Queue.value.iri()) + .withObjectRange(Seq(SolaceOperationQueue30Object.id)), + PropertyMapping() + .withId(location + s"#/declarations/$name/topic") + .withName("topic") + .withNodePropertyMapping(SolaceOperationDestination030Model.Topic.value.iri()) + .withObjectRange(Seq(SolaceOperationTopicObject.id)) + ) +} +object SolaceOperationDestination40Object + extends BaseSolaceOperationDestinationObject + with BindingVersionPropertyMapping { + override def nodeTypeMapping: String = SolaceOperationDestination040Model.`type`.head.iri() + override def properties: Seq[PropertyMapping] = super.properties ++ Seq( + PropertyMapping() + .withId(location + s"#/declarations/$name/queue") + .withName("queue") + .withNodePropertyMapping(SolaceOperationDestination040Model.Queue.value.iri()) + .withObjectRange(Seq(SolaceOperationQueue30Object.id)), + PropertyMapping() + .withId(location + s"#/declarations/$name/topic") + .withName("topic") + .withNodePropertyMapping(SolaceOperationDestination040Model.Topic.value.iri()) + .withObjectRange(Seq(SolaceOperationTopicObject.id)) + ) :+ bindingVersion +} +trait BaseSolaceOperationDestinationObject extends DialectNode { override def name: String = "SolaceOperationDestinationObject" override def nodeTypeMapping: String = SolaceOperationDestinationModel.`type`.head.iri() @@ -45,20 +174,29 @@ object SolaceOperationDestinationObject extends DialectNode { .withId(location + s"#/declarations/$name/deliveryMode") .withName("deliveryMode") .withNodePropertyMapping(SolaceOperationDestinationModel.DeliveryMode.value.iri()) - .withLiteralRange(xsdString.iri()), + .withLiteralRange(xsdString.iri()) + ) +} + +object SolaceOperationQueue10Object extends BaseSolaceOperationQueueObject { + override def nodeTypeMapping: String = SolaceOperationQueue010Model.`type`.head.iri() +} +object SolaceOperationQueue30Object extends BaseSolaceOperationQueueObject { + override def nodeTypeMapping: String = SolaceOperationQueue030Model.`type`.head.iri() + override def properties: Seq[PropertyMapping] = super.properties ++ Seq( PropertyMapping() - .withId(location + s"#/declarations/$name/queue") - .withName("queue") - .withNodePropertyMapping(SolaceOperationDestinationModel.Queue.value.iri()) - .withObjectRange(Seq(SolaceOperationQueueObject.id)), + .withId(location + s"#/declarations/$name/maxMsgSpoolSize") + .withName("maxMsgSpoolSize") + .withNodePropertyMapping(SolaceOperationQueue030Model.MaxMsgSpoolSize.value.iri()) + .withLiteralRange(xsdString.iri()), PropertyMapping() - .withId(location + s"#/declarations/$name/topic") - .withName("topic") - .withNodePropertyMapping(SolaceOperationDestinationModel.Topic.value.iri()) - .withObjectRange(Seq(SolaceOperationTopicObject.id)) + .withId(location + s"#/declarations/$name/maxTtl") + .withName("maxTtl") + .withNodePropertyMapping(SolaceOperationQueue030Model.MaxTtl.value.iri()) + .withLiteralRange(xsdString.iri()) ) } -object SolaceOperationQueueObject extends DialectNode { +trait BaseSolaceOperationQueueObject extends DialectNode { override def name: String = "SolaceOperationQueueObject" override def nodeTypeMapping: String = SolaceOperationQueueModel.`type`.head.iri() @@ -74,16 +212,6 @@ object SolaceOperationQueueObject extends DialectNode { .withId(location + s"#/declarations/$name/accessType") .withName("accessType") .withNodePropertyMapping(SolaceOperationQueueModel.AccessType.value.iri()) - .withLiteralRange(xsdString.iri()), - PropertyMapping() - .withId(location + s"#/declarations/$name/maxMsgSpoolSize") - .withName("maxMsgSpoolSize") - .withNodePropertyMapping(SolaceOperationQueueModel.MaxMsgSpoolSize.value.iri()) - .withLiteralRange(xsdString.iri()), - PropertyMapping() - .withId(location + s"#/declarations/$name/maxTtl") - .withName("maxTtl") - .withNodePropertyMapping(SolaceOperationQueueModel.MaxTtl.value.iri()) .withLiteralRange(xsdString.iri()) ) } diff --git a/als-server/shared/src/test/resources/diagnostics/async26/async-api26-full.yaml b/als-server/shared/src/test/resources/diagnostics/async26/async-api26-full.yaml index 9cdf75d7c..8a0218891 100644 --- a/als-server/shared/src/test/resources/diagnostics/async26/async-api26-full.yaml +++ b/als-server/shared/src/test/resources/diagnostics/async26/async-api26-full.yaml @@ -126,8 +126,8 @@ channels: queue: name: CreatedHREvents accessType: exclusive - maxMsgSpoolSize: test - maxTtl: test + maxMsgSpoolSize: 1 + maxTtl: 1 topicSubscriptions: - person/*/created - diff --git a/als-suggestions/shared/src/test/resources/test/AsyncAPI2/by-directory/components/operation-bindings/expected/http-binding.yaml.json b/als-suggestions/shared/src/test/resources/test/AsyncAPI2/by-directory/components/operation-bindings/expected/http-binding.yaml.json index 6b2e30c97..c125caffb 100644 --- a/als-suggestions/shared/src/test/resources/test/AsyncAPI2/by-directory/components/operation-bindings/expected/http-binding.yaml.json +++ b/als-suggestions/shared/src/test/resources/test/AsyncAPI2/by-directory/components/operation-bindings/expected/http-binding.yaml.json @@ -1,4 +1,40 @@ [ + { + "label": "New query", + "kind": [ + + ], + "detail": "template", + "documentation": "query", + "deprecated": [ + + ], + "preselect": [ + + ], + "sortText": "21New query", + "filterText": "query:\n description: $1\n type: $2", + "insertText": null, + "insertTextFormat": [ + 2 + ], + "textEdit": { + "range": { + "start": { + "line": 6, + "character": 10 + }, + "end": { + "line": 6, + "character": 10 + } + }, + "newText": "query:\n description: $1\n type: $2" + }, + "additionalTextEdits": null, + "commitCharacters": null, + "command": null + }, { "label": "bindingVersion", "kind": [ @@ -71,6 +107,42 @@ "commitCharacters": null, "command": null }, + { + "label": "query", + "kind": [ + + ], + "detail": "unknown", + "documentation": "query", + "deprecated": [ + + ], + "preselect": [ + + ], + "sortText": "11query", + "filterText": "query:\n ", + "insertText": null, + "insertTextFormat": [ + 1 + ], + "textEdit": { + "range": { + "start": { + "line": 6, + "character": 10 + }, + "end": { + "line": 6, + "character": 10 + } + }, + "newText": "query:\n " + }, + "additionalTextEdits": null, + "commitCharacters": null, + "command": null + }, { "label": "type", "kind": [ diff --git a/als-suggestions/shared/src/test/resources/test/async26/by-directory/bindings/message/expected/googlepubsub-root.yaml.json b/als-suggestions/shared/src/test/resources/test/async26/by-directory/bindings/message/expected/googlepubsub-root.yaml.json index f783318b5..ba77b8f77 100644 --- a/als-suggestions/shared/src/test/resources/test/async26/by-directory/bindings/message/expected/googlepubsub-root.yaml.json +++ b/als-suggestions/shared/src/test/resources/test/async26/by-directory/bindings/message/expected/googlepubsub-root.yaml.json @@ -35,6 +35,42 @@ "commitCharacters": null, "command": null }, + { + "label": "bindingVersion", + "kind": [ + + ], + "detail": "unknown", + "documentation": "bindingVersion", + "deprecated": [ + + ], + "preselect": [ + + ], + "sortText": "11bindingVersion", + "filterText": "bindingVersion: ", + "insertText": null, + "insertTextFormat": [ + 1 + ], + "textEdit": { + "range": { + "start": { + "line": 6, + "character": 10 + }, + "end": { + "line": 6, + "character": 10 + } + }, + "newText": "bindingVersion: " + }, + "additionalTextEdits": null, + "commitCharacters": null, + "command": null + }, { "label": "orderingKey", "kind": [ @@ -83,6 +119,42 @@ ], "preselect": [ + ], + "sortText": "11schema", + "filterText": "schema:\n ", + "insertText": null, + "insertTextFormat": [ + 1 + ], + "textEdit": { + "range": { + "start": { + "line": 6, + "character": 10 + }, + "end": { + "line": 6, + "character": 10 + } + }, + "newText": "schema:\n " + }, + "additionalTextEdits": null, + "commitCharacters": null, + "command": null + }, + { + "label": "schema", + "kind": [ + + ], + "detail": "unknown", + "documentation": "schema", + "deprecated": [ + + ], + "preselect": [ + ], "sortText": "11schema", "filterText": "schema:\n ", diff --git a/als-suggestions/shared/src/test/resources/test/async26/by-directory/bindings/message/expected/googlepubsub-schema.yaml.json b/als-suggestions/shared/src/test/resources/test/async26/by-directory/bindings/message/expected/googlepubsub-schema.yaml.json index a02ab205f..8e7b872b6 100644 --- a/als-suggestions/shared/src/test/resources/test/async26/by-directory/bindings/message/expected/googlepubsub-schema.yaml.json +++ b/als-suggestions/shared/src/test/resources/test/async26/by-directory/bindings/message/expected/googlepubsub-schema.yaml.json @@ -1,4 +1,40 @@ [ + { + "label": "bindingVersion", + "kind": [ + + ], + "detail": "unknown", + "documentation": "bindingVersion", + "deprecated": [ + + ], + "preselect": [ + + ], + "sortText": "11bindingVersion", + "filterText": "bindingVersion: ", + "insertText": null, + "insertTextFormat": [ + 1 + ], + "textEdit": { + "range": { + "start": { + "line": 7, + "character": 12 + }, + "end": { + "line": 7, + "character": 12 + } + }, + "newText": "bindingVersion: " + }, + "additionalTextEdits": null, + "commitCharacters": null, + "command": null + }, { "label": "fieldType", "kind": [ diff --git a/als-suggestions/shared/src/test/resources/test/async26/by-directory/bindings/operation/expected/solace-root-10.yaml.json b/als-suggestions/shared/src/test/resources/test/async26/by-directory/bindings/operation/expected/solace-root-10.yaml.json new file mode 100644 index 000000000..900a42071 --- /dev/null +++ b/als-suggestions/shared/src/test/resources/test/async26/by-directory/bindings/operation/expected/solace-root-10.yaml.json @@ -0,0 +1,38 @@ +[ + { + "label": "destinations", + "kind": [ + + ], + "detail": "unknown", + "documentation": "destinations", + "deprecated": [ + + ], + "preselect": [ + + ], + "sortText": "11destinations", + "filterText": "destinations:\n - ", + "insertText": null, + "insertTextFormat": [ + 1 + ], + "textEdit": { + "range": { + "start": { + "line": 7, + "character": 10 + }, + "end": { + "line": 7, + "character": 10 + } + }, + "newText": "destinations:\n - " + }, + "additionalTextEdits": null, + "commitCharacters": null, + "command": null + } +] \ No newline at end of file diff --git a/als-suggestions/shared/src/test/resources/test/async26/by-directory/bindings/operation/expected/solace-root-30.yaml.json b/als-suggestions/shared/src/test/resources/test/async26/by-directory/bindings/operation/expected/solace-root-30.yaml.json new file mode 100644 index 000000000..900a42071 --- /dev/null +++ b/als-suggestions/shared/src/test/resources/test/async26/by-directory/bindings/operation/expected/solace-root-30.yaml.json @@ -0,0 +1,38 @@ +[ + { + "label": "destinations", + "kind": [ + + ], + "detail": "unknown", + "documentation": "destinations", + "deprecated": [ + + ], + "preselect": [ + + ], + "sortText": "11destinations", + "filterText": "destinations:\n - ", + "insertText": null, + "insertTextFormat": [ + 1 + ], + "textEdit": { + "range": { + "start": { + "line": 7, + "character": 10 + }, + "end": { + "line": 7, + "character": 10 + } + }, + "newText": "destinations:\n - " + }, + "additionalTextEdits": null, + "commitCharacters": null, + "command": null + } +] \ No newline at end of file diff --git a/als-suggestions/shared/src/test/resources/test/async26/by-directory/bindings/operation/solace-root-10.yaml b/als-suggestions/shared/src/test/resources/test/async26/by-directory/bindings/operation/solace-root-10.yaml new file mode 100644 index 000000000..50c03cd96 --- /dev/null +++ b/als-suggestions/shared/src/test/resources/test/async26/by-directory/bindings/operation/solace-root-10.yaml @@ -0,0 +1,8 @@ +asyncapi: 2.6.0 +channels: + user/signedup: + subscribe: + bindings: + solace: + bindingVersion: 10 + * diff --git a/als-suggestions/shared/src/test/resources/test/async26/by-directory/bindings/operation/solace-root-30.yaml b/als-suggestions/shared/src/test/resources/test/async26/by-directory/bindings/operation/solace-root-30.yaml new file mode 100644 index 000000000..fb751d214 --- /dev/null +++ b/als-suggestions/shared/src/test/resources/test/async26/by-directory/bindings/operation/solace-root-30.yaml @@ -0,0 +1,8 @@ +asyncapi: 2.6.0 +channels: + user/signedup: + subscribe: + bindings: + solace: + bindingVersion: 30 + * diff --git a/dependencies.properties b/dependencies.properties index 28ee73140..b5f74bdaf 100644 --- a/dependencies.properties +++ b/dependencies.properties @@ -1,5 +1,5 @@ version=6.3.0-SNAPSHOT -amf=5.5.1 +amf=5.5.2 amf.custom-validator.js=1.7.2 amf.custom-validator-scalajs=0.5.11 amf-antlr-parsers=0.7.25 From 4ab88592ed290e0de48332f824a3513774ceb866 Mon Sep 17 00:00:00 2001 From: Leandro Libarona Date: Fri, 31 May 2024 10:05:54 -0300 Subject: [PATCH 08/16] W-15900977: fix duplicated suggestions in message node on async 2.6 --- .../hover/async-api26-full-result.yaml | 16 +- .../Async21MessageExampleNode.scala | 8 +- .../asyncapi26/Message26ObjectNode.scala | 4 +- .../expected/message-ref-publish.yaml.json | 36 + .../expected/message-ref-subscribe.yaml.json | 36 + .../messages/expected/message-root.yaml.json | 686 ++++++++++++++++++ .../by-directory/messages/message-root.yaml | 6 + 7 files changed, 776 insertions(+), 16 deletions(-) create mode 100644 als-suggestions/shared/src/test/resources/test/async26/by-directory/messages/expected/message-root.yaml.json create mode 100644 als-suggestions/shared/src/test/resources/test/async26/by-directory/messages/message-root.yaml diff --git a/als-actions/shared/src/test/resources/actions/hover/async-api26-full-result.yaml b/als-actions/shared/src/test/resources/actions/hover/async-api26-full-result.yaml index 299f9b172..9f485a808 100644 --- a/als-actions/shared/src/test/resources/actions/hover/async-api26-full-result.yaml +++ b/als-actions/shared/src/test/resources/actions/hover/async-api26-full-result.yaml @@ -460,13 +460,13 @@ hovers: (128,32): - "'exclusive' or 'nonexclusive'. Only applicable when destinationType is 'queue'." (129,23): - - The maximum amount of message spool that the given queue may use. Only applicable when destinationType is 'queue'. + - The maximum size of the message spool used by the queue. (129,35): - - The maximum amount of message spool that the given queue may use. Only applicable when destinationType is 'queue'. + - The maximum size of the message spool used by the queue. (130,19): - - The maximum TTL to apply to messages to be spooled. Only applicable when destinationType is 'queue'. + - The maximum time-to-live for messages in the queue. (130,26): - - The maximum TTL to apply to messages to be spooled. Only applicable when destinationType is 'queue'. + - The maximum time-to-live for messages in the queue. (131,25): - A list of topics that the queue subscribes to, only applicable when destinationType is 'queue'. If none is given, the queue subscribes to the topic as represented by the channel name. (131,35): @@ -531,9 +531,9 @@ hovers: (151,23): - "The encoding of the message " (152,12): - - Name of the schema that messages published should be validated against + - Human readable name for the object (152,36): - - Name of the schema that messages published should be validated against + - Human readable name for the object (153,17): - The minimum (inclusive) revision allowed for validating messages (153,29): @@ -634,9 +634,9 @@ hovers: - Define Schema (181,17): [] (182,14): - - The name of the schema + - Human readable name for the object (182,39): - - The name of the schema + - Human readable name for the object (183,14): - The type of the schema (183,20): diff --git a/als-common/shared/src/main/scala/org/mulesoft/amfintegration/dialect/dialects/asyncapi26/Async21MessageExampleNode.scala b/als-common/shared/src/main/scala/org/mulesoft/amfintegration/dialect/dialects/asyncapi26/Async21MessageExampleNode.scala index 4cb6e0216..520fa671f 100644 --- a/als-common/shared/src/main/scala/org/mulesoft/amfintegration/dialect/dialects/asyncapi26/Async21MessageExampleNode.scala +++ b/als-common/shared/src/main/scala/org/mulesoft/amfintegration/dialect/dialects/asyncapi26/Async21MessageExampleNode.scala @@ -6,9 +6,8 @@ import amf.shapes.internal.domain.metamodel.ExampleModel import org.mulesoft.amfintegration.dialect.dialects.asyncapi20.AsyncMessageExampleNode import org.mulesoft.amfintegration.dialect.dialects.asyncapi26.Async21MessageExampleNode.location import org.mulesoft.amfintegration.dialect.dialects.oas.nodes.DialectNode - -trait Async21ExampleMessageMappings { - protected def mappingsMessages21 = Seq( +object Async21MessageExampleNode extends AsyncMessageExampleNode { + override def properties: Seq[PropertyMapping] = super.properties ++ Seq( PropertyMapping() .withId(location + "#/declarations/Message/examples/name") .withName("name") @@ -19,6 +18,3 @@ trait Async21ExampleMessageMappings { .withNodePropertyMapping(MessageModel.HeaderExamples.value.iri()) ) } -object Async21MessageExampleNode extends AsyncMessageExampleNode with Async21ExampleMessageMappings { - override def properties: Seq[PropertyMapping] = super.properties ++ mappingsMessages21 -} diff --git a/als-common/shared/src/main/scala/org/mulesoft/amfintegration/dialect/dialects/asyncapi26/Message26ObjectNode.scala b/als-common/shared/src/main/scala/org/mulesoft/amfintegration/dialect/dialects/asyncapi26/Message26ObjectNode.scala index 2b2b3108c..df640ea0f 100644 --- a/als-common/shared/src/main/scala/org/mulesoft/amfintegration/dialect/dialects/asyncapi26/Message26ObjectNode.scala +++ b/als-common/shared/src/main/scala/org/mulesoft/amfintegration/dialect/dialects/asyncapi26/Message26ObjectNode.scala @@ -6,8 +6,8 @@ import amf.core.client.scala.vocabulary.Namespace.XsdTypes.xsdString import org.mulesoft.amfintegration.dialect.dialects.asyncapi20.ConcreteMessageObjectNode import org.mulesoft.amfintegration.dialect.dialects.asyncapi26.RequestMessage26ObjectNode.location -trait Async21MessageMappings extends Async21ExampleMessageMappings { - override protected def mappingsMessages21: Seq[PropertyMapping] = super.mappingsMessages21 ++ Seq( +trait Async21MessageMappings { + protected def mappingsMessages21: Seq[PropertyMapping] = Seq( PropertyMapping() .withId(location + "#/declarations/Message/messageId") .withName("messageId") diff --git a/als-suggestions/shared/src/test/resources/test/async26/by-directory/messages/expected/message-ref-publish.yaml.json b/als-suggestions/shared/src/test/resources/test/async26/by-directory/messages/expected/message-ref-publish.yaml.json index 703947036..02eae44e2 100644 --- a/als-suggestions/shared/src/test/resources/test/async26/by-directory/messages/expected/message-ref-publish.yaml.json +++ b/als-suggestions/shared/src/test/resources/test/async26/by-directory/messages/expected/message-ref-publish.yaml.json @@ -142,5 +142,41 @@ "additionalTextEdits": null, "commitCharacters": null, "command": null + }, + { + "label": "message-root.yaml", + "kind": [ + + ], + "detail": "unknown", + "documentation": "Path suggestion", + "deprecated": [ + + ], + "preselect": [ + + ], + "sortText": "11message-root.yaml", + "filterText": "message-root.yaml", + "insertText": null, + "insertTextFormat": [ + 1 + ], + "textEdit": { + "range": { + "start": { + "line": 5, + "character": 14 + }, + "end": { + "line": 5, + "character": 14 + } + }, + "newText": "message-root.yaml" + }, + "additionalTextEdits": null, + "commitCharacters": null, + "command": null } ] \ No newline at end of file diff --git a/als-suggestions/shared/src/test/resources/test/async26/by-directory/messages/expected/message-ref-subscribe.yaml.json b/als-suggestions/shared/src/test/resources/test/async26/by-directory/messages/expected/message-ref-subscribe.yaml.json index 8304567e2..eaa29a584 100644 --- a/als-suggestions/shared/src/test/resources/test/async26/by-directory/messages/expected/message-ref-subscribe.yaml.json +++ b/als-suggestions/shared/src/test/resources/test/async26/by-directory/messages/expected/message-ref-subscribe.yaml.json @@ -142,5 +142,41 @@ "additionalTextEdits": null, "commitCharacters": null, "command": null + }, + { + "label": "message-root.yaml", + "kind": [ + + ], + "detail": "unknown", + "documentation": "Path suggestion", + "deprecated": [ + + ], + "preselect": [ + + ], + "sortText": "11message-root.yaml", + "filterText": "message-root.yaml", + "insertText": null, + "insertTextFormat": [ + 1 + ], + "textEdit": { + "range": { + "start": { + "line": 5, + "character": 14 + }, + "end": { + "line": 5, + "character": 14 + } + }, + "newText": "message-root.yaml" + }, + "additionalTextEdits": null, + "commitCharacters": null, + "command": null } ] \ No newline at end of file diff --git a/als-suggestions/shared/src/test/resources/test/async26/by-directory/messages/expected/message-root.yaml.json b/als-suggestions/shared/src/test/resources/test/async26/by-directory/messages/expected/message-root.yaml.json new file mode 100644 index 000000000..66fc00ba3 --- /dev/null +++ b/als-suggestions/shared/src/test/resources/test/async26/by-directory/messages/expected/message-root.yaml.json @@ -0,0 +1,686 @@ +[ + { + "label": "$ref", + "kind": [ + + ], + "detail": "unknown", + "documentation": "reference tag", + "deprecated": [ + + ], + "preselect": [ + + ], + "sortText": "0$ref", + "filterText": "$ref: ", + "insertText": null, + "insertTextFormat": [ + 1 + ], + "textEdit": { + "range": { + "start": { + "line": 5, + "character": 8 + }, + "end": { + "line": 5, + "character": 8 + } + }, + "newText": "$ref: " + }, + "additionalTextEdits": null, + "commitCharacters": null, + "command": null + }, + { + "label": "New externalDocs", + "kind": [ + + ], + "detail": "template", + "documentation": "externalDocs", + "deprecated": [ + + ], + "preselect": [ + + ], + "sortText": "21New externalDocs", + "filterText": "externalDocs:\n url: $1", + "insertText": null, + "insertTextFormat": [ + 2 + ], + "textEdit": { + "range": { + "start": { + "line": 5, + "character": 8 + }, + "end": { + "line": 5, + "character": 8 + } + }, + "newText": "externalDocs:\n url: $1" + }, + "additionalTextEdits": null, + "commitCharacters": null, + "command": null + }, + { + "label": "New headers", + "kind": [ + + ], + "detail": "template", + "documentation": "headers", + "deprecated": [ + + ], + "preselect": [ + + ], + "sortText": "21New headers", + "filterText": "headers:\n description: $1\n type: $2", + "insertText": null, + "insertTextFormat": [ + 2 + ], + "textEdit": { + "range": { + "start": { + "line": 5, + "character": 8 + }, + "end": { + "line": 5, + "character": 8 + } + }, + "newText": "headers:\n description: $1\n type: $2" + }, + "additionalTextEdits": null, + "commitCharacters": null, + "command": null + }, + { + "label": "New tags", + "kind": [ + + ], + "detail": "template", + "documentation": "tags", + "deprecated": [ + + ], + "preselect": [ + + ], + "sortText": "21New tags", + "filterText": "tags:\n -\n name: $1", + "insertText": null, + "insertTextFormat": [ + 2 + ], + "textEdit": { + "range": { + "start": { + "line": 5, + "character": 8 + }, + "end": { + "line": 5, + "character": 8 + } + }, + "newText": "tags:\n -\n name: $1" + }, + "additionalTextEdits": null, + "commitCharacters": null, + "command": null + }, + { + "label": "bindings", + "kind": [ + + ], + "detail": "unknown", + "documentation": "bindings", + "deprecated": [ + + ], + "preselect": [ + + ], + "sortText": "11bindings", + "filterText": "bindings:\n ", + "insertText": null, + "insertTextFormat": [ + 1 + ], + "textEdit": { + "range": { + "start": { + "line": 5, + "character": 8 + }, + "end": { + "line": 5, + "character": 8 + } + }, + "newText": "bindings:\n " + }, + "additionalTextEdits": null, + "commitCharacters": null, + "command": null + }, + { + "label": "contentType", + "kind": [ + + ], + "detail": "unknown", + "documentation": "contentType", + "deprecated": [ + + ], + "preselect": [ + + ], + "sortText": "11contentType", + "filterText": "contentType: ", + "insertText": null, + "insertTextFormat": [ + 1 + ], + "textEdit": { + "range": { + "start": { + "line": 5, + "character": 8 + }, + "end": { + "line": 5, + "character": 8 + } + }, + "newText": "contentType: " + }, + "additionalTextEdits": null, + "commitCharacters": null, + "command": null + }, + { + "label": "correlationId", + "kind": [ + + ], + "detail": "unknown", + "documentation": "correlationId", + "deprecated": [ + + ], + "preselect": [ + + ], + "sortText": "11correlationId", + "filterText": "correlationId:\n ", + "insertText": null, + "insertTextFormat": [ + 1 + ], + "textEdit": { + "range": { + "start": { + "line": 5, + "character": 8 + }, + "end": { + "line": 5, + "character": 8 + } + }, + "newText": "correlationId:\n " + }, + "additionalTextEdits": null, + "commitCharacters": null, + "command": null + }, + { + "label": "description", + "kind": [ + + ], + "detail": "docs", + "documentation": "description", + "deprecated": [ + + ], + "preselect": [ + + ], + "sortText": "11description", + "filterText": "description: ", + "insertText": null, + "insertTextFormat": [ + 1 + ], + "textEdit": { + "range": { + "start": { + "line": 5, + "character": 8 + }, + "end": { + "line": 5, + "character": 8 + } + }, + "newText": "description: " + }, + "additionalTextEdits": null, + "commitCharacters": null, + "command": null + }, + { + "label": "examples", + "kind": [ + + ], + "detail": "docs", + "documentation": "examples", + "deprecated": [ + + ], + "preselect": [ + + ], + "sortText": "11examples", + "filterText": "examples:\n ", + "insertText": null, + "insertTextFormat": [ + 1 + ], + "textEdit": { + "range": { + "start": { + "line": 5, + "character": 8 + }, + "end": { + "line": 5, + "character": 8 + } + }, + "newText": "examples:\n " + }, + "additionalTextEdits": null, + "commitCharacters": null, + "command": null + }, + { + "label": "externalDocs", + "kind": [ + + ], + "detail": "docs", + "documentation": "externalDocs", + "deprecated": [ + + ], + "preselect": [ + + ], + "sortText": "11externalDocs", + "filterText": "externalDocs:\n ", + "insertText": null, + "insertTextFormat": [ + 1 + ], + "textEdit": { + "range": { + "start": { + "line": 5, + "character": 8 + }, + "end": { + "line": 5, + "character": 8 + } + }, + "newText": "externalDocs:\n " + }, + "additionalTextEdits": null, + "commitCharacters": null, + "command": null + }, + { + "label": "headers", + "kind": [ + + ], + "detail": "parameters", + "documentation": "headers", + "deprecated": [ + + ], + "preselect": [ + + ], + "sortText": "11headers", + "filterText": "headers:\n ", + "insertText": null, + "insertTextFormat": [ + 1 + ], + "textEdit": { + "range": { + "start": { + "line": 5, + "character": 8 + }, + "end": { + "line": 5, + "character": 8 + } + }, + "newText": "headers:\n " + }, + "additionalTextEdits": null, + "commitCharacters": null, + "command": null + }, + { + "label": "messageId", + "kind": [ + + ], + "detail": "unknown", + "documentation": "messageId", + "deprecated": [ + + ], + "preselect": [ + + ], + "sortText": "11messageId", + "filterText": "messageId: ", + "insertText": null, + "insertTextFormat": [ + 1 + ], + "textEdit": { + "range": { + "start": { + "line": 5, + "character": 8 + }, + "end": { + "line": 5, + "character": 8 + } + }, + "newText": "messageId: " + }, + "additionalTextEdits": null, + "commitCharacters": null, + "command": null + }, + { + "label": "name", + "kind": [ + + ], + "detail": "docs", + "documentation": "name", + "deprecated": [ + + ], + "preselect": [ + + ], + "sortText": "11name", + "filterText": "name: ", + "insertText": null, + "insertTextFormat": [ + 1 + ], + "textEdit": { + "range": { + "start": { + "line": 5, + "character": 8 + }, + "end": { + "line": 5, + "character": 8 + } + }, + "newText": "name: " + }, + "additionalTextEdits": null, + "commitCharacters": null, + "command": null + }, + { + "label": "payload", + "kind": [ + + ], + "detail": "unknown", + "documentation": "payload", + "deprecated": [ + + ], + "preselect": [ + + ], + "sortText": "11payload", + "filterText": "payload:\n ", + "insertText": null, + "insertTextFormat": [ + 1 + ], + "textEdit": { + "range": { + "start": { + "line": 5, + "character": 8 + }, + "end": { + "line": 5, + "character": 8 + } + }, + "newText": "payload:\n " + }, + "additionalTextEdits": null, + "commitCharacters": null, + "command": null + }, + { + "label": "schemaFormat", + "kind": [ + + ], + "detail": "unknown", + "documentation": "schemaFormat", + "deprecated": [ + + ], + "preselect": [ + + ], + "sortText": "11schemaFormat", + "filterText": "schemaFormat: ", + "insertText": null, + "insertTextFormat": [ + 1 + ], + "textEdit": { + "range": { + "start": { + "line": 5, + "character": 8 + }, + "end": { + "line": 5, + "character": 8 + } + }, + "newText": "schemaFormat: " + }, + "additionalTextEdits": null, + "commitCharacters": null, + "command": null + }, + { + "label": "summary", + "kind": [ + + ], + "detail": "unknown", + "documentation": "summary", + "deprecated": [ + + ], + "preselect": [ + + ], + "sortText": "11summary", + "filterText": "summary: ", + "insertText": null, + "insertTextFormat": [ + 1 + ], + "textEdit": { + "range": { + "start": { + "line": 5, + "character": 8 + }, + "end": { + "line": 5, + "character": 8 + } + }, + "newText": "summary: " + }, + "additionalTextEdits": null, + "commitCharacters": null, + "command": null + }, + { + "label": "tags", + "kind": [ + + ], + "detail": "unknown", + "documentation": "tags", + "deprecated": [ + + ], + "preselect": [ + + ], + "sortText": "11tags", + "filterText": "tags:\n - ", + "insertText": null, + "insertTextFormat": [ + 1 + ], + "textEdit": { + "range": { + "start": { + "line": 5, + "character": 8 + }, + "end": { + "line": 5, + "character": 8 + } + }, + "newText": "tags:\n - " + }, + "additionalTextEdits": null, + "commitCharacters": null, + "command": null + }, + { + "label": "title", + "kind": [ + + ], + "detail": "docs", + "documentation": "title", + "deprecated": [ + + ], + "preselect": [ + + ], + "sortText": "11title", + "filterText": "title: ", + "insertText": null, + "insertTextFormat": [ + 1 + ], + "textEdit": { + "range": { + "start": { + "line": 5, + "character": 8 + }, + "end": { + "line": 5, + "character": 8 + } + }, + "newText": "title: " + }, + "additionalTextEdits": null, + "commitCharacters": null, + "command": null + }, + { + "label": "traits", + "kind": [ + + ], + "detail": "schemas", + "documentation": "traits", + "deprecated": [ + + ], + "preselect": [ + + ], + "sortText": "11traits", + "filterText": "traits:\n - ", + "insertText": null, + "insertTextFormat": [ + 1 + ], + "textEdit": { + "range": { + "start": { + "line": 5, + "character": 8 + }, + "end": { + "line": 5, + "character": 8 + } + }, + "newText": "traits:\n - " + }, + "additionalTextEdits": null, + "commitCharacters": null, + "command": null + } +] \ No newline at end of file diff --git a/als-suggestions/shared/src/test/resources/test/async26/by-directory/messages/message-root.yaml b/als-suggestions/shared/src/test/resources/test/async26/by-directory/messages/message-root.yaml new file mode 100644 index 000000000..97fe63f41 --- /dev/null +++ b/als-suggestions/shared/src/test/resources/test/async26/by-directory/messages/message-root.yaml @@ -0,0 +1,6 @@ +asyncapi: '2.6.0' +channels: + chan: + subscribe: + message: + * From 04b179e280a3ed8acf069be1d1a9fb3536718175 Mon Sep 17 00:00:00 2001 From: Leandro Libarona Date: Fri, 31 May 2024 10:45:13 -0300 Subject: [PATCH 09/16] bump custom-validator-scalajs version --- dependencies.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dependencies.properties b/dependencies.properties index b5f74bdaf..0d1a37883 100644 --- a/dependencies.properties +++ b/dependencies.properties @@ -1,5 +1,5 @@ version=6.3.0-SNAPSHOT amf=5.5.2 amf.custom-validator.js=1.7.2 -amf.custom-validator-scalajs=0.5.11 +amf.custom-validator-scalajs=0.5.12 amf-antlr-parsers=0.7.25 From 13323b1fcacfd51f15e38bfe5f31eca984abeb61 Mon Sep 17 00:00:00 2001 From: Leandro Libarona Date: Fri, 31 May 2024 14:53:08 -0300 Subject: [PATCH 10/16] override ProfileName for Async 2.6 support --- .../amfconfiguration/ProfileMatcher.scala | 2 +- .../override/OverrideProfileNames.scala | 174 ++++++++++++++++++ .../CleanDiagnosticTreeManager.scala | 7 +- .../diagnostic/BasicCleanDiagnosticTest.scala | 2 + 4 files changed, 181 insertions(+), 4 deletions(-) create mode 100644 als-common/shared/src/main/scala/org/mulesoft/amfintegration/override/OverrideProfileNames.scala diff --git a/als-common/shared/src/main/scala/org/mulesoft/amfintegration/amfconfiguration/ProfileMatcher.scala b/als-common/shared/src/main/scala/org/mulesoft/amfintegration/amfconfiguration/ProfileMatcher.scala index 25e91ac25..7504e7d27 100644 --- a/als-common/shared/src/main/scala/org/mulesoft/amfintegration/amfconfiguration/ProfileMatcher.scala +++ b/als-common/shared/src/main/scala/org/mulesoft/amfintegration/amfconfiguration/ProfileMatcher.scala @@ -36,7 +36,7 @@ object ProfileMatcher { case Spec.ASYNC23 => ProfileNames.ASYNC20 case Spec.ASYNC24 => ProfileNames.ASYNC20 case Spec.ASYNC25 => ProfileNames.ASYNC20 - case Spec.ASYNC26 => ProfileNames.ASYNC20 + case Spec.ASYNC26 => ProfileNames.ASYNC26 case Spec.AML => ProfileNames.AML case Spec.GRAPHQL => ProfileNames.GRPC case Spec.JSONSCHEMA => ProfileNames.JSONSCHEMA diff --git a/als-common/shared/src/main/scala/org/mulesoft/amfintegration/override/OverrideProfileNames.scala b/als-common/shared/src/main/scala/org/mulesoft/amfintegration/override/OverrideProfileNames.scala new file mode 100644 index 000000000..4377b89b4 --- /dev/null +++ b/als-common/shared/src/main/scala/org/mulesoft/amfintegration/override/OverrideProfileNames.scala @@ -0,0 +1,174 @@ +package amf.core.client.common.validation + +import amf.core.internal.remote._ + +import scala.scalajs.js.annotation.{JSExportAll, JSExportTopLevel} + +// delete as soon as Async26Profile is created on amf-side +@JSExportAll +@JSExportTopLevel("ProfileNames") +object ProfileNames { + val AMF: ProfileName = AmfProfile + val OAS20: ProfileName = Oas20Profile + val OAS30: ProfileName = Oas30Profile + val RAML10: ProfileName = Raml10Profile + val RAML08: ProfileName = Raml08Profile + val ASYNC: ProfileName = AsyncProfile + val ASYNC20: ProfileName = Async20Profile + val ASYNC26: ProfileName = Async26Profile + val AML: ProfileName = AmlProfile + val PAYLOAD: ProfileName = PayloadProfile + val GRPC: ProfileName = GrpcProfile + val GRAPHQL: ProfileName = GraphQLProfile + val GRAPHQL_FEDERATION: ProfileName = GraphQLFederationProfile + val JSONSCHEMA: ProfileName = JsonSchemaProfile + + lazy val specProfiles: Seq[ProfileName] = + Seq( + AmfProfile, + Oas20Profile, + Oas30Profile, + Raml08Profile, + Raml10Profile, + AsyncProfile, + Async20Profile, + Async26Profile, + GraphQLProfile, + GraphQLFederationProfile, + GrpcProfile, + JsonSchemaProfile + ) +} + +@JSExportAll +case class ProfileName(private[amf] val p: String, private val m: MessageStyle = AMFStyle) { + @JSExportTopLevel("ProfileName") + def this(profile: String) = this(profile, AMFStyle) + def profile: String = p + def messageStyle: MessageStyle = m + override def toString: String = p + def isOas(): Boolean = false + def isRaml(): Boolean = false +} + +object AmfProfile extends ProfileName(Amf.id) +object AmlProfile extends ProfileName(Aml.id) +object UnknownProfile extends ProfileName("") + +object Oas20Profile extends ProfileName(Oas20.id, OASStyle) { + override def isOas(): Boolean = true +} + +object Oas30Profile extends ProfileName(Oas30.id, OASStyle) { + override def isOas(): Boolean = true +} + +object Raml08Profile extends ProfileName(Raml08.id, RAMLStyle) { + override def isRaml(): Boolean = true +} + +object Raml10Profile extends ProfileName(Raml10.id, RAMLStyle) { + override def isRaml(): Boolean = true +} + +object AsyncProfile extends ProfileName(AsyncApi.id, OASStyle) +object Async20Profile extends ProfileName(AsyncApi20.id, OASStyle) +object Async26Profile extends ProfileName(AsyncApi26.id, OASStyle) +object PayloadProfile extends ProfileName(Payload.id) + +object GrpcProfile extends ProfileName(Grpc.id, AMFStyle) { + override def isRaml(): Boolean = false +} + +object GraphQLProfile extends ProfileName(GraphQL.id, AMFStyle) { + override def isOas(): Boolean = false + override def isRaml(): Boolean = false +} + +object GraphQLFederationProfile extends ProfileName(GraphQLFederation.id, AMFStyle) { + override def isOas(): Boolean = false + override def isRaml(): Boolean = false +} + +object JsonSchemaProfile extends ProfileName(JsonSchema.id, AMFStyle) { + override def isOas(): Boolean = false + override def isRaml(): Boolean = false +} + +object ProfileName { + def unapply(name: String): Option[ProfileName] = + name match { + case AmfProfile.p => Some(AmfProfile) + case Oas30Profile.p => Some(Oas30Profile) + case Raml08Profile.p => Some(Raml08Profile) + case AsyncProfile.p => Some(AsyncProfile) + case Async20Profile.p => Some(Async20Profile) + case Async26Profile.p => Some(Async26Profile) + case GrpcProfile.p => Some(GrpcProfile) + case GraphQLProfile.p => Some(GraphQLProfile) + case GraphQLFederationProfile.p => Some(GraphQLFederationProfile) + case JsonSchemaProfile.p => Some(JsonSchemaProfile) + case _ => None + } + + def apply(profile: String): ProfileName = profile match { + case Amf.id => AmfProfile + case "OAS" | Oas20.id => Oas20Profile // for compatibility + case Oas30.id => Oas30Profile + case Raml08.id => Raml08Profile + case "RAML" | Raml10.id => Raml10Profile // for compatibility + case AsyncApi.id => AsyncProfile + case AsyncApi20.id => Async20Profile + case AsyncApi21.id => Async20Profile + case AsyncApi22.id => Async20Profile + case AsyncApi23.id => Async20Profile + case AsyncApi24.id => Async20Profile + case AsyncApi25.id => Async20Profile + case AsyncApi26.id => Async26Profile + case Grpc.id => GrpcProfile + case GraphQL.id => GraphQLProfile + case GraphQLFederation.id => GraphQLFederationProfile + case JsonSchema.id => JsonSchemaProfile + case custom => new ProfileName(custom) + } +} + +object MessageStyle { + def apply(name: String): MessageStyle = name match { + case Raml10.id | Raml08.id => RAMLStyle + case Oas20.id | Oas30.id => OASStyle + case AsyncApi.id | AsyncApi20.id | AsyncApi21.id | AsyncApi22.id | AsyncApi23.id | AsyncApi24.id | AsyncApi25.id | + AsyncApi26.id => + OASStyle + case _ => AMFStyle + } +} + +@JSExportAll +trait MessageStyle { + def profileName: ProfileName +} + +@JSExportAll +@JSExportTopLevel("MessageStyles") +object MessageStyles { + val RAML: MessageStyle = RAMLStyle + val OAS: MessageStyle = OASStyle + val ASYNC: MessageStyle = AsyncStyle + val AMF: MessageStyle = AMFStyle +} + +object RAMLStyle extends MessageStyle { + override def profileName: ProfileName = Raml10Profile +} +object OASStyle extends MessageStyle { + override def profileName: ProfileName = Oas20Profile +} + +object AsyncStyle extends MessageStyle { + override def profileName: ProfileName = AsyncProfile +} + +object AMFStyle extends MessageStyle { + override def profileName: ProfileName = AmfProfile +} diff --git a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/diagnostic/CleanDiagnosticTreeManager.scala b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/diagnostic/CleanDiagnosticTreeManager.scala index 219741ad7..cb595ba06 100644 --- a/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/diagnostic/CleanDiagnosticTreeManager.scala +++ b/als-server/shared/src/main/scala/org/mulesoft/als/server/modules/diagnostic/CleanDiagnosticTreeManager.scala @@ -1,6 +1,7 @@ package org.mulesoft.als.server.modules.diagnostic -import amf.core.client.scala.AMFResult +import amf.core.client.common.validation.{ProfileName, ProfileNames} +import amf.core.client.scala.{AMFParseResult, AMFResult} import amf.core.client.scala.model.document.BaseUnit import amf.core.client.scala.validation.AMFValidationReport import org.mulesoft.als.common.URIImplicits._ @@ -11,7 +12,7 @@ import org.mulesoft.als.server.modules.CleanAmfProcess import org.mulesoft.als.server.modules.configuration.WorkspaceConfigurationProvider import org.mulesoft.als.server.modules.diagnostic.custom.CustomValidationManager import org.mulesoft.als.server.textsync.EnvironmentProvider -import org.mulesoft.amfintegration.amfconfiguration.{ALSConfigurationState, AmfResult => AmfResultWrap} +import org.mulesoft.amfintegration.amfconfiguration.{ALSConfigurationState, ProfileMatcher, AmfResult => AmfResultWrap} import org.mulesoft.common.collections._ import org.mulesoft.lsp.ConfigType import org.mulesoft.lsp.feature.TelemeteredRequestHandler @@ -80,7 +81,7 @@ class CleanDiagnosticTreeManager( .map(r => CleanValidationPartialResult(pr, r, resolutionResult)) partialResult <- runCustomValidations(uri, report, alsConfigurationState) } yield { - val profile = partialResult.resolutionResult.profile + val profile = pr.result.baseUnit.sourceSpec.map(ProfileMatcher.profile).getOrElse(ProfileNames.AMF) val list = partialResult.parseResult.tree val ge: Map[String, Seq[AlsValidationResult]] = partialResult.parseResult.groupedErrors.map(t => (t._1, t._2.map(new AlsValidationResult(_)))) diff --git a/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/diagnostic/BasicCleanDiagnosticTest.scala b/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/diagnostic/BasicCleanDiagnosticTest.scala index fd431b238..92e206c74 100644 --- a/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/diagnostic/BasicCleanDiagnosticTest.scala +++ b/als-server/shared/src/test/scala/org/mulesoft/als/server/modules/diagnostic/BasicCleanDiagnosticTest.scala @@ -1,5 +1,6 @@ package org.mulesoft.als.server.modules.diagnostic +import amf.core.client.common.validation.ProfileNames import org.mulesoft.als.server.client.scala.LanguageServerBuilder import org.mulesoft.als.server.modules.WorkspaceManagerFactoryBuilder import org.mulesoft.als.server.protocol.LanguageServer @@ -21,6 +22,7 @@ class BasicCleanDiagnosticTest extends LanguageServerBaseTest { assert(d.size == 1) assert(d.head.diagnostics.size == 1) assert(d.head.diagnostics.head.message == "Property 'error' not supported in a ASYNC 2.6 webApi node") + assert(d.head.profile == ProfileNames.ASYNC26) } } } From 0bd58136acf3e63e7ccfbed14ad123c7fd3c37cf Mon Sep 17 00:00:00 2001 From: Leandro Libarona Date: Wed, 5 Jun 2024 10:39:18 -0300 Subject: [PATCH 11/16] fix facet for google binding in async 2.6 --- .../bindings/MessageBinding26ObjectNode.scala | 20 +++------------- .../expected/googlepubsub-schema.yaml.json | 24 +++++++++---------- 2 files changed, 15 insertions(+), 29 deletions(-) diff --git a/als-common/shared/src/main/scala/org/mulesoft/amfintegration/dialect/dialects/asyncapi26/bindings/MessageBinding26ObjectNode.scala b/als-common/shared/src/main/scala/org/mulesoft/amfintegration/dialect/dialects/asyncapi26/bindings/MessageBinding26ObjectNode.scala index 0a2686380..bd87006dc 100644 --- a/als-common/shared/src/main/scala/org/mulesoft/amfintegration/dialect/dialects/asyncapi26/bindings/MessageBinding26ObjectNode.scala +++ b/als-common/shared/src/main/scala/org/mulesoft/amfintegration/dialect/dialects/asyncapi26/bindings/MessageBinding26ObjectNode.scala @@ -1,24 +1,10 @@ package org.mulesoft.amfintegration.dialect.dialects.asyncapi26.bindings import amf.aml.client.scala.model.domain.PropertyMapping -import amf.apicontract.internal.metamodel.domain.bindings.{ - AnypointMQMessageBindingModel, - GooglePubSubMessageBinding010Model, - GooglePubSubMessageBinding020Model, - GooglePubSubMessageBindingModel, - GooglePubSubSchemaDefinition010Model, - GooglePubSubSchemaDefinition020Model, - GooglePubSubSchemaDefinitionModel, - IBMMQMessageBindingModel, - MessageBindingModel -} +import amf.apicontract.internal.metamodel.domain.bindings._ import amf.core.client.scala.vocabulary.Namespace.XsdTypes.{xsdInteger, xsdString} import org.mulesoft.amfintegration.dialect.dialects.asyncapi20.bindings.BindingVersionPropertyMapping import org.mulesoft.amfintegration.dialect.dialects.asyncapi20.schema.BaseShapeAsync2Node -import org.mulesoft.amfintegration.dialect.dialects.asyncapi26.bindings.GooglePubSubMessageBinding10Object.{ - location, - name -} import org.mulesoft.amfintegration.dialect.dialects.oas.nodes.DialectNode object MessageBinding26ObjectNode extends BindingObjectNode26 { @@ -111,8 +97,8 @@ object GooglePubSubSchemaDefinition10Object extends BaseGooglePubSubSchemaDefini override def nodeTypeMapping: String = GooglePubSubSchemaDefinition010Model.`type`.head.iri() override def properties: Seq[PropertyMapping] = super.properties ++ Seq( PropertyMapping() - .withId(location + s"#/declarations/$name/fieldType") - .withName("fieldType") + .withId(location + s"#/declarations/$name/type") + .withName("type") .withNodePropertyMapping(GooglePubSubSchemaDefinition010Model.FieldType.value.iri()) .withLiteralRange(xsdString.iri()) ) diff --git a/als-suggestions/shared/src/test/resources/test/async26/by-directory/bindings/message/expected/googlepubsub-schema.yaml.json b/als-suggestions/shared/src/test/resources/test/async26/by-directory/bindings/message/expected/googlepubsub-schema.yaml.json index 8e7b872b6..e242ea485 100644 --- a/als-suggestions/shared/src/test/resources/test/async26/by-directory/bindings/message/expected/googlepubsub-schema.yaml.json +++ b/als-suggestions/shared/src/test/resources/test/async26/by-directory/bindings/message/expected/googlepubsub-schema.yaml.json @@ -36,20 +36,20 @@ "command": null }, { - "label": "fieldType", + "label": "name", "kind": [ ], - "detail": "unknown", - "documentation": "fieldType", + "detail": "docs", + "documentation": "name", "deprecated": [ ], "preselect": [ ], - "sortText": "11fieldType", - "filterText": "fieldType: ", + "sortText": "11name", + "filterText": "name: ", "insertText": null, "insertTextFormat": [ 1 @@ -65,27 +65,27 @@ "character": 12 } }, - "newText": "fieldType: " + "newText": "name: " }, "additionalTextEdits": null, "commitCharacters": null, "command": null }, { - "label": "name", + "label": "type", "kind": [ ], - "detail": "docs", - "documentation": "name", + "detail": "schemas", + "documentation": "type", "deprecated": [ ], "preselect": [ ], - "sortText": "11name", - "filterText": "name: ", + "sortText": "11type", + "filterText": "type: ", "insertText": null, "insertTextFormat": [ 1 @@ -101,7 +101,7 @@ "character": 12 } }, - "newText": "name: " + "newText": "type: " }, "additionalTextEdits": null, "commitCharacters": null, From 4213098b90ed2dbdc12b7ca32b0ce3fd2fd30e57 Mon Sep 17 00:00:00 2001 From: Leandro Libarona Date: Tue, 28 May 2024 18:50:48 -0300 Subject: [PATCH 12/16] W-15832103: added test and golden for async2 endpoint/operation suggestions, needs fix in amf --- .../expected/subscribe-with-publish.yaml.json | 146 ++++++++++++++++++ .../channel/subscribe-with-publish.yaml | 22 +++ 2 files changed, 168 insertions(+) create mode 100644 als-suggestions/shared/src/test/resources/test/async26/by-directory/channel/expected/subscribe-with-publish.yaml.json create mode 100644 als-suggestions/shared/src/test/resources/test/async26/by-directory/channel/subscribe-with-publish.yaml diff --git a/als-suggestions/shared/src/test/resources/test/async26/by-directory/channel/expected/subscribe-with-publish.yaml.json b/als-suggestions/shared/src/test/resources/test/async26/by-directory/channel/expected/subscribe-with-publish.yaml.json new file mode 100644 index 000000000..57d60a7c7 --- /dev/null +++ b/als-suggestions/shared/src/test/resources/test/async26/by-directory/channel/expected/subscribe-with-publish.yaml.json @@ -0,0 +1,146 @@ +[ + { + "label": "bindings", + "kind": [ + + ], + "detail": "unknown", + "documentation": "bindings", + "deprecated": [ + + ], + "preselect": [ + + ], + "sortText": "11bindings", + "filterText": "bindings:\n ", + "insertText": null, + "insertTextFormat": [ + 1 + ], + "textEdit": { + "range": { + "start": { + "line": 21, + "character": 4 + }, + "end": { + "line": 21, + "character": 4 + } + }, + "newText": "bindings:\n " + }, + "additionalTextEdits": null, + "commitCharacters": null, + "command": null + }, + { + "label": "parameters", + "kind": [ + + ], + "detail": "unknown", + "documentation": "parameters", + "deprecated": [ + + ], + "preselect": [ + + ], + "sortText": "11parameters", + "filterText": "parameters:\n ", + "insertText": null, + "insertTextFormat": [ + 1 + ], + "textEdit": { + "range": { + "start": { + "line": 21, + "character": 4 + }, + "end": { + "line": 21, + "character": 4 + } + }, + "newText": "parameters:\n " + }, + "additionalTextEdits": null, + "commitCharacters": null, + "command": null + }, + { + "label": "servers", + "kind": [ + + ], + "detail": "unknown", + "documentation": "servers", + "deprecated": [ + + ], + "preselect": [ + + ], + "sortText": "11servers", + "filterText": "servers:\n - ", + "insertText": null, + "insertTextFormat": [ + 1 + ], + "textEdit": { + "range": { + "start": { + "line": 21, + "character": 4 + }, + "end": { + "line": 21, + "character": 4 + } + }, + "newText": "servers:\n - " + }, + "additionalTextEdits": null, + "commitCharacters": null, + "command": null + }, + { + "label": "subscribe", + "kind": [ + + ], + "detail": "unknown", + "documentation": "subscribe", + "deprecated": [ + + ], + "preselect": [ + + ], + "sortText": "11subscribe", + "filterText": "subscribe:\n ", + "insertText": null, + "insertTextFormat": [ + 1 + ], + "textEdit": { + "range": { + "start": { + "line": 21, + "character": 4 + }, + "end": { + "line": 21, + "character": 4 + } + }, + "newText": "subscribe:\n " + }, + "additionalTextEdits": null, + "commitCharacters": null, + "command": null + } +] \ No newline at end of file diff --git a/als-suggestions/shared/src/test/resources/test/async26/by-directory/channel/subscribe-with-publish.yaml b/als-suggestions/shared/src/test/resources/test/async26/by-directory/channel/subscribe-with-publish.yaml new file mode 100644 index 000000000..1a783e33f --- /dev/null +++ b/als-suggestions/shared/src/test/resources/test/async26/by-directory/channel/subscribe-with-publish.yaml @@ -0,0 +1,22 @@ +asyncapi: 2.6.0 +info: + title: Async 2.2 new fields + version: 1.0.0 + description: Async 2.2 new fields +servers: + myServer: + url: some.com + protocol: ibmmq + bindings: + ibmmq: + groupId: test + ccdtQueueManagerName: test + cipherSpec: test + multiEndpointServer: true + heartBeatInterval: 123 +channels: + myChannel: + publish: + message: {} + description: "" + * From a878151dc04652c6c097511fee5b867ec723e6bd Mon Sep 17 00:00:00 2001 From: Leandro Libarona Date: Wed, 5 Jun 2024 16:46:38 -0300 Subject: [PATCH 13/16] adopt AMF 5.5.2-0 --- dependencies.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dependencies.properties b/dependencies.properties index 0d1a37883..baf7c4560 100644 --- a/dependencies.properties +++ b/dependencies.properties @@ -1,5 +1,5 @@ version=6.3.0-SNAPSHOT -amf=5.5.2 +amf=5.5.2-0 amf.custom-validator.js=1.7.2 amf.custom-validator-scalajs=0.5.12 amf-antlr-parsers=0.7.25 From 260bb5468cf7e621cfd3eb415ef8b40423fe97cb Mon Sep 17 00:00:00 2001 From: Leandro Libarona Date: Wed, 5 Jun 2024 17:15:09 -0300 Subject: [PATCH 14/16] fix golden for async 2.x hover tests --- .../resources/actions/hover/async-api20-full-result.yaml | 2 +- .../resources/actions/hover/async-api26-full-result.yaml | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/als-actions/shared/src/test/resources/actions/hover/async-api20-full-result.yaml b/als-actions/shared/src/test/resources/actions/hover/async-api20-full-result.yaml index c7d97a9ba..d554aba5d 100644 --- a/als-actions/shared/src/test/resources/actions/hover/async-api20-full-result.yaml +++ b/als-actions/shared/src/test/resources/actions/hover/async-api20-full-result.yaml @@ -128,7 +128,7 @@ hovers: (38,8): - EndPoint in the API holding a number of executable operations (38,16): - - Action that can be executed using a particular HTTP invocation + - EndPoint in the API holding a number of executable operations (39,9): - Human readable description of an element (39,21): diff --git a/als-actions/shared/src/test/resources/actions/hover/async-api26-full-result.yaml b/als-actions/shared/src/test/resources/actions/hover/async-api26-full-result.yaml index 9f485a808..459fd1d88 100644 --- a/als-actions/shared/src/test/resources/actions/hover/async-api26-full-result.yaml +++ b/als-actions/shared/src/test/resources/actions/hover/async-api26-full-result.yaml @@ -168,7 +168,7 @@ hovers: (46,8): - EndPoint in the API holding a number of executable operations (46,16): - - Action that can be executed using a particular HTTP invocation + - EndPoint in the API holding a number of executable operations (47,8): - Action that can be executed using a particular HTTP invocation (47,14): @@ -259,7 +259,7 @@ hovers: (72,9): - EndPoint in the API holding a number of executable operations (72,17): - - Action that can be executed using a particular HTTP invocation + - EndPoint in the API holding a number of executable operations (73,8): - Bindings for this endpoint (73,13): [] @@ -349,7 +349,7 @@ hovers: (97,8): - EndPoint in the API holding a number of executable operations (97,16): - - Action that can be executed using a particular HTTP invocation + - EndPoint in the API holding a number of executable operations (98,8): - Bindings for this endpoint (98,13): [] @@ -426,7 +426,7 @@ hovers: (118,8): - EndPoint in the API holding a number of executable operations (118,16): - - Action that can be executed using a particular HTTP invocation + - EndPoint in the API holding a number of executable operations (119,7): - Action that can be executed using a particular HTTP invocation (119,12): From b9bc787f2994bf1253eae7c1ad373fa9b66552b5 Mon Sep 17 00:00:00 2001 From: emilianoascona Date: Thu, 6 Jun 2024 10:38:31 -0300 Subject: [PATCH 15/16] Create RC --- dependencies.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dependencies.properties b/dependencies.properties index baf7c4560..ecf4ede16 100644 --- a/dependencies.properties +++ b/dependencies.properties @@ -1,4 +1,4 @@ -version=6.3.0-SNAPSHOT +version=6.2.1-RC amf=5.5.2-0 amf.custom-validator.js=1.7.2 amf.custom-validator-scalajs=0.5.12 From 26541169a6b5e870592b0b438fb9d57529a2bbf3 Mon Sep 17 00:00:00 2001 From: emilianoascona Date: Thu, 6 Jun 2024 11:41:59 -0300 Subject: [PATCH 16/16] Bump to stable version 6.2.1 --- dependencies.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dependencies.properties b/dependencies.properties index ecf4ede16..8e4102ca1 100644 --- a/dependencies.properties +++ b/dependencies.properties @@ -1,4 +1,4 @@ -version=6.2.1-RC +version=6.2.1 amf=5.5.2-0 amf.custom-validator.js=1.7.2 amf.custom-validator-scalajs=0.5.12