diff --git a/amf-antlr-syntax/js/package-lock.json b/amf-antlr-syntax/js/package-lock.json index 4512abbd2a..4c2dc7a11f 100644 --- a/amf-antlr-syntax/js/package-lock.json +++ b/amf-antlr-syntax/js/package-lock.json @@ -9,14 +9,14 @@ "version": "4.0.0", "license": "Apache-2.0", "dependencies": { - "@aml-org/amf-antlr-parsers": "0.6.21", + "@aml-org/amf-antlr-parsers": "0.6.22", "ajv": "6.12.6" } }, "node_modules/@aml-org/amf-antlr-parsers": { - "version": "0.6.21", - "resolved": "https://registry.npmjs.org/@aml-org/amf-antlr-parsers/-/amf-antlr-parsers-0.6.21.tgz", - "integrity": "sha512-QhVGMCeaLG0LqgTodJXflMl6gjr2ls0FeRBmUR5RQQWeT0YZWPE+kTRNGk810UbgvE1pnWKj7ERHyGxoMy/HXg==" + "version": "0.6.22", + "resolved": "https://registry.npmjs.org/@aml-org/amf-antlr-parsers/-/amf-antlr-parsers-0.6.22.tgz", + "integrity": "sha512-29ZCQiNsa2DZ4CEE+FXMuro+sg+UIYDNLCj/ovlWSL1F7PBlDCMQ2DK5shd/pwM904jwSjPDQmPGFl2Z4wUFKQ==" }, "node_modules/ajv": { "version": "6.12.6", @@ -67,9 +67,9 @@ }, "dependencies": { "@aml-org/amf-antlr-parsers": { - "version": "0.6.21", - "resolved": "https://registry.npmjs.org/@aml-org/amf-antlr-parsers/-/amf-antlr-parsers-0.6.21.tgz", - "integrity": "sha512-QhVGMCeaLG0LqgTodJXflMl6gjr2ls0FeRBmUR5RQQWeT0YZWPE+kTRNGk810UbgvE1pnWKj7ERHyGxoMy/HXg==" + "version": "0.6.22", + "resolved": "https://registry.npmjs.org/@aml-org/amf-antlr-parsers/-/amf-antlr-parsers-0.6.22.tgz", + "integrity": "sha512-29ZCQiNsa2DZ4CEE+FXMuro+sg+UIYDNLCj/ovlWSL1F7PBlDCMQ2DK5shd/pwM904jwSjPDQmPGFl2Z4wUFKQ==" }, "ajv": { "version": "6.12.6", diff --git a/amf-antlr-syntax/js/package.json b/amf-antlr-syntax/js/package.json index a934f94442..b1f711132c 100644 --- a/amf-antlr-syntax/js/package.json +++ b/amf-antlr-syntax/js/package.json @@ -11,7 +11,7 @@ "url": "https://github.com/aml-org/amf" }, "dependencies": { - "@aml-org/amf-antlr-parsers": "0.6.21", + "@aml-org/amf-antlr-parsers": "0.6.22", "ajv": "6.12.6" } } diff --git a/amf-api-contract/js/package-lock.json b/amf-api-contract/js/package-lock.json index 806a56bbad..5481832d3c 100644 --- a/amf-api-contract/js/package-lock.json +++ b/amf-api-contract/js/package-lock.json @@ -9,14 +9,14 @@ "version": "4.0.0", "license": "Apache-2.0", "dependencies": { - "@aml-org/amf-antlr-parsers": "0.6.21", + "@aml-org/amf-antlr-parsers": "0.6.22", "ajv": "6.12.6" } }, "node_modules/@aml-org/amf-antlr-parsers": { - "version": "0.6.21", - "resolved": "https://registry.npmjs.org/@aml-org/amf-antlr-parsers/-/amf-antlr-parsers-0.6.21.tgz", - "integrity": "sha512-QhVGMCeaLG0LqgTodJXflMl6gjr2ls0FeRBmUR5RQQWeT0YZWPE+kTRNGk810UbgvE1pnWKj7ERHyGxoMy/HXg==" + "version": "0.6.22", + "resolved": "https://registry.npmjs.org/@aml-org/amf-antlr-parsers/-/amf-antlr-parsers-0.6.22.tgz", + "integrity": "sha512-29ZCQiNsa2DZ4CEE+FXMuro+sg+UIYDNLCj/ovlWSL1F7PBlDCMQ2DK5shd/pwM904jwSjPDQmPGFl2Z4wUFKQ==" }, "node_modules/ajv": { "version": "6.12.6", @@ -67,9 +67,9 @@ }, "dependencies": { "@aml-org/amf-antlr-parsers": { - "version": "0.6.21", - "resolved": "https://registry.npmjs.org/@aml-org/amf-antlr-parsers/-/amf-antlr-parsers-0.6.21.tgz", - "integrity": "sha512-QhVGMCeaLG0LqgTodJXflMl6gjr2ls0FeRBmUR5RQQWeT0YZWPE+kTRNGk810UbgvE1pnWKj7ERHyGxoMy/HXg==" + "version": "0.6.22", + "resolved": "https://registry.npmjs.org/@aml-org/amf-antlr-parsers/-/amf-antlr-parsers-0.6.22.tgz", + "integrity": "sha512-29ZCQiNsa2DZ4CEE+FXMuro+sg+UIYDNLCj/ovlWSL1F7PBlDCMQ2DK5shd/pwM904jwSjPDQmPGFl2Z4wUFKQ==" }, "ajv": { "version": "6.12.6", diff --git a/amf-api-contract/js/package.json b/amf-api-contract/js/package.json index c70912e2fd..aeb6a257e0 100644 --- a/amf-api-contract/js/package.json +++ b/amf-api-contract/js/package.json @@ -11,7 +11,7 @@ "url": "https://github.com/aml-org/amf" }, "dependencies": { - "@aml-org/amf-antlr-parsers": "0.6.21", + "@aml-org/amf-antlr-parsers": "0.6.22", "ajv": "6.12.6" } } diff --git a/amf-api-contract/shared/src/main/scala/amf/apicontract/client/scala/model/domain/templates/ResourceType.scala b/amf-api-contract/shared/src/main/scala/amf/apicontract/client/scala/model/domain/templates/ResourceType.scala index e8974b158e..cbcdafb209 100644 --- a/amf-api-contract/shared/src/main/scala/amf/apicontract/client/scala/model/domain/templates/ResourceType.scala +++ b/amf-api-contract/shared/src/main/scala/amf/apicontract/client/scala/model/domain/templates/ResourceType.scala @@ -1,15 +1,10 @@ package amf.apicontract.client.scala.model.domain.templates -import amf.apicontract.client.scala.model.domain.EndPoint -import amf.core.client.common.validation.{ProfileName, Raml10Profile} -import amf.core.client.scala.errorhandling.{AMFErrorHandler, UnhandledErrorHandler} -import amf.core.client.scala.model.document.BaseUnit +import amf.apicontract.internal.metamodel.domain.templates.ResourceTypeModel import amf.core.client.scala.model.domain.templates.AbstractDeclaration -import amf.core.client.scala.model.domain.{DataNode, DomainElement, Linkable} +import amf.core.client.scala.model.domain.{DomainElement, Linkable} import amf.core.internal.parser.domain.{Annotations, Fields} -import amf.apicontract.internal.metamodel.domain.templates.ResourceTypeModel -import amf.apicontract.internal.spec.common.transformation.ExtendsHelper -import org.yaml.model.{YMapEntry, YPart} +import org.yaml.model.YPart class ResourceType(override val fields: Fields, override val annotations: Annotations) extends AbstractDeclaration(fields, annotations) { diff --git a/amf-api-contract/shared/src/main/scala/amf/apicontract/client/scala/model/domain/templates/Trait.scala b/amf-api-contract/shared/src/main/scala/amf/apicontract/client/scala/model/domain/templates/Trait.scala index 22852915c4..11d29135ba 100644 --- a/amf-api-contract/shared/src/main/scala/amf/apicontract/client/scala/model/domain/templates/Trait.scala +++ b/amf-api-contract/shared/src/main/scala/amf/apicontract/client/scala/model/domain/templates/Trait.scala @@ -1,15 +1,10 @@ package amf.apicontract.client.scala.model.domain.templates -import amf.apicontract.client.scala.model.domain.Operation -import amf.core.client.common.validation.{ProfileName, Raml10Profile} -import amf.core.client.scala.errorhandling.{AMFErrorHandler, UnhandledErrorHandler} -import amf.core.client.scala.model.document.BaseUnit +import amf.apicontract.internal.metamodel.domain.templates.TraitModel import amf.core.client.scala.model.domain.templates.AbstractDeclaration import amf.core.client.scala.model.domain.{DomainElement, Linkable} import amf.core.internal.parser.domain.{Annotations, Fields} -import amf.apicontract.internal.metamodel.domain.templates.TraitModel -import amf.apicontract.internal.spec.common.transformation.ExtendsHelper -import org.yaml.model.{YMapEntry, YPart} +import org.yaml.model.YPart class Trait(override val fields: Fields, override val annotations: Annotations) extends AbstractDeclaration(fields, annotations) { diff --git a/amf-api-contract/shared/src/main/scala/amf/apicontract/client/scala/transform/AbstractElementTransformer.scala b/amf-api-contract/shared/src/main/scala/amf/apicontract/client/scala/transform/AbstractElementTransformer.scala index c38c5154cf..c5721e3655 100644 --- a/amf-api-contract/shared/src/main/scala/amf/apicontract/client/scala/transform/AbstractElementTransformer.scala +++ b/amf-api-contract/shared/src/main/scala/amf/apicontract/client/scala/transform/AbstractElementTransformer.scala @@ -1,14 +1,14 @@ package amf.apicontract.client.scala.transform -import amf.apicontract.client.scala.model.domain.{EndPoint, Operation} import amf.apicontract.client.scala.model.domain.templates.{ResourceType, Trait} +import amf.apicontract.client.scala.model.domain.{EndPoint, Operation} import amf.apicontract.internal.spec.common.transformation.ExtendsHelper +import amf.apicontract.internal.transformation.BaseUnitSourceLocationIndex import amf.core.client.common.validation.{ProfileName, Raml10Profile} import amf.core.client.scala.AMFGraphConfiguration import amf.core.client.scala.errorhandling.{AMFErrorHandler, UnhandledErrorHandler} import amf.core.client.scala.model.document.BaseUnit import amf.core.client.scala.model.domain.DataNode -import amf.core.internal.parser.domain.Annotations import org.yaml.model.YMapEntry /** Temporally object to respect new domain internfaces. Probably this will be agroupated at some Domain Element client @@ -30,7 +30,7 @@ object AbstractElementTransformer { case _ => Option(rt.dataNode) .map { dataNode => - val extendsHelper = ExtendsHelper(profile, keepEditingInfo = false, errorHandler, configuration) + val extendsHelper = ExtendsHelper(profile, keepEditingInfo = false, errorHandler, configuration, BaseUnitSourceLocationIndex.build(unit)) extendsHelper.asEndpoint(unit, dataNode, rt.annotations, rt.name.value(), rt.id, configuration) } .getOrElse(EndPoint()) @@ -46,7 +46,7 @@ object AbstractElementTransformer { errorHandler: AMFErrorHandler = UnhandledErrorHandler, profile: ProfileName = Raml10Profile ): EndPoint = { - val helper = ExtendsHelper(profile, keepEditingInfo = false, errorHandler, configuration) + val helper = ExtendsHelper(profile, keepEditingInfo = false, errorHandler, configuration, BaseUnitSourceLocationIndex.build(unit)) helper.entryAsEndpoint(unit, node, rt.name.option().getOrElse(""), rt.id, entry, configuration) } @@ -67,7 +67,7 @@ object AbstractElementTransformer { case _ => Option(tr.dataNode) .map { dataNode => - val extendsHelper = ExtendsHelper(profile, keepEditingInfo = false, errorHandler, configuration) + val extendsHelper = ExtendsHelper(profile, keepEditingInfo = false, errorHandler, configuration, BaseUnitSourceLocationIndex.build(unit)) extendsHelper.asOperation( dataNode, unit, @@ -89,7 +89,7 @@ object AbstractElementTransformer { profile: ProfileName = Raml10Profile, errorHandler: AMFErrorHandler = UnhandledErrorHandler ): Operation = { - val extendsHelper = ExtendsHelper(profile, keepEditingInfo = false, errorHandler, configuration) + val extendsHelper = ExtendsHelper(profile, keepEditingInfo = false, errorHandler, configuration, BaseUnitSourceLocationIndex.build(unit)) extendsHelper.entryAsOperation(unit, tr.name.option().getOrElse(""), tr.id, entry, configuration) } } diff --git a/amf-api-contract/shared/src/main/scala/amf/apicontract/internal/spec/common/transformation/ExtendsHelper.scala b/amf-api-contract/shared/src/main/scala/amf/apicontract/internal/spec/common/transformation/ExtendsHelper.scala index 554476bbd2..bf15217316 100644 --- a/amf-api-contract/shared/src/main/scala/amf/apicontract/internal/spec/common/transformation/ExtendsHelper.scala +++ b/amf-api-contract/shared/src/main/scala/amf/apicontract/internal/spec/common/transformation/ExtendsHelper.scala @@ -6,18 +6,19 @@ import amf.apicontract.client.scala.model.domain.{EndPoint, Operation} import amf.apicontract.internal.spec.common.WebApiDeclarations.ErrorEndPoint import amf.apicontract.internal.spec.common.parser.WebApiContext import amf.apicontract.internal.spec.raml.parser.context.{Raml08WebApiContext, Raml10WebApiContext, RamlWebApiContext} +import amf.apicontract.internal.transformation.BaseUnitSourceLocationIndex import amf.apicontract.internal.validation.definitions.ResolutionSideValidations.ParseResourceTypeFail import amf.core.client.common.validation.{ProfileName, Raml08Profile} import amf.core.client.scala.AMFGraphConfiguration import amf.core.client.scala.errorhandling.{AMFErrorHandler, IgnoringErrorHandler} import amf.core.client.scala.model.document.{BaseUnit, DeclaresModel, Fragment, Module} -import amf.core.client.scala.model.domain.{AmfElement, DataNode, DomainElement, NamedDomainElement} +import amf.core.client.scala.model.domain.{DataNode, DomainElement, NamedDomainElement} import amf.core.client.scala.parse.document.ParserContext import amf.core.internal.adoption.IdAdopter import amf.core.internal.annotations._ import amf.core.internal.datanode.DataNodeEmitter -import amf.core.internal.parser.{LimitedParseConfig, ParseConfig} import amf.core.internal.parser.domain.{Annotations, FragmentRef} +import amf.core.internal.parser.{LimitedParseConfig, ParseConfig} import amf.core.internal.render.SpecOrdering import amf.core.internal.transform.stages.ReferenceResolutionStage import amf.core.internal.transform.stages.helpers.ResolvedNamedEntity @@ -33,6 +34,7 @@ case class ExtendsHelper( keepEditingInfo: Boolean, errorHandler: AMFErrorHandler, config: AMFGraphConfiguration, + index: BaseUnitSourceLocationIndex, context: Option[RamlWebApiContext] = None ) { def custom(profile: ProfileName): RamlWebApiContext = profile match { @@ -207,23 +209,6 @@ case class ExtendsHelper( } } - private def getDeclaringUnit(refs: List[BaseUnit], sourceName: String): Option[BaseUnit] = refs match { - case (f: Fragment) :: _ if sourceNameMatch(f, sourceName) => Some(f) - case (m: Module) :: _ if sourceNameMatch(m, sourceName) => Some(m) - case unit :: tail => - getDeclaringUnit(tail, sourceName) match { - case ref @ Some(_) => ref - case _ => getDeclaringUnit(unit.references.toList, sourceName) - } - case _ => None - } - - private def sourceNameMatch(f: AmfElement, sourceName: String): Boolean = - f.annotations - .find(classOf[SourceLocation]) - .map(_.location) - .contains(sourceName) - private def extractFilteredDeclarations( unit: BaseUnit, filterCondition: DomainElement => Boolean @@ -244,7 +229,7 @@ case class ExtendsHelper( * context to populate with declarations */ private def extractContextDeclarationsFrom(root: BaseUnit, sourceName: String)(ctx: RamlWebApiContext): Unit = { - val declaringUnit = getDeclaringUnit(root.references.toList, sourceName).getOrElse(root) + val declaringUnit = index.get(sourceName).getOrElse(root) val libraries = extractFilteredDeclarations(declaringUnit, _.isInstanceOf[Module]).map((_, declaringUnit)) val otherDeclarations = extractFilteredDeclarations(root, !_.isInstanceOf[Module]).map((_, root)) diff --git a/amf-api-contract/shared/src/main/scala/amf/apicontract/internal/transformation/BaseUnitSourceLocationIndex.scala b/amf-api-contract/shared/src/main/scala/amf/apicontract/internal/transformation/BaseUnitSourceLocationIndex.scala new file mode 100644 index 0000000000..df0945d6c7 --- /dev/null +++ b/amf-api-contract/shared/src/main/scala/amf/apicontract/internal/transformation/BaseUnitSourceLocationIndex.scala @@ -0,0 +1,27 @@ +package amf.apicontract.internal.transformation + +import amf.core.client.scala.model.document.BaseUnit +import amf.core.internal.annotations.SourceLocation + +/** Indexes Base Units by their SourceLocation + */ +sealed case class BaseUnitSourceLocationIndex(index: Map[String, BaseUnit]) { + def get(sourceLocation: String): Option[BaseUnit] = index.get(sourceLocation) +} + +object BaseUnitSourceLocationIndex { + def build(root: BaseUnit): BaseUnitSourceLocationIndex = { + val index = flattenReferencesTree(root) + .flatMap(bu => + bu.annotations + .find(classOf[SourceLocation]) + .map(annotation => annotation.location -> bu) + ) + .toMap + BaseUnitSourceLocationIndex(index) + } + + private def flattenReferencesTree(root: BaseUnit): Seq[BaseUnit] = + root +: (root.references ++ root.references.flatMap(_.references)) + +} diff --git a/amf-api-contract/shared/src/main/scala/amf/apicontract/internal/transformation/stages/ExtendsResolutionStage.scala b/amf-api-contract/shared/src/main/scala/amf/apicontract/internal/transformation/stages/ExtendsResolutionStage.scala index 34dbc392f9..76a772ed9f 100644 --- a/amf-api-contract/shared/src/main/scala/amf/apicontract/internal/transformation/stages/ExtendsResolutionStage.scala +++ b/amf-api-contract/shared/src/main/scala/amf/apicontract/internal/transformation/stages/ExtendsResolutionStage.scala @@ -1,11 +1,6 @@ package amf.apicontract.internal.transformation.stages -import amf.apicontract.client.scala.model.domain.templates.{ - ParametrizedResourceType, - ParametrizedTrait, - ResourceType, - Trait -} +import amf.apicontract.client.scala.model.domain.templates.{ParametrizedResourceType, ParametrizedTrait, ResourceType, Trait} import amf.apicontract.client.scala.model.domain.{EndPoint, Operation} import amf.apicontract.internal.spec.common.WebApiDeclarations.{ErrorEndPoint, ErrorTrait} import amf.apicontract.internal.spec.common.emitter.{Raml10EndPointEmitter, Raml10OperationEmitter} @@ -13,6 +8,7 @@ import amf.apicontract.internal.spec.common.transformation.ExtendsHelper import amf.apicontract.internal.spec.common.transformation.stage.DomainElementMerging import amf.apicontract.internal.spec.raml.emitter.context.Raml10SpecEmitterContext import amf.apicontract.internal.spec.raml.parser.context.{Raml08WebApiContext, Raml10WebApiContext, RamlWebApiContext} +import amf.apicontract.internal.transformation.BaseUnitSourceLocationIndex import amf.core.client.common.validation.{ProfileName, Raml08Profile} import amf.core.client.scala.AMFGraphConfiguration import amf.core.client.scala.errorhandling.{AMFErrorHandler, IgnoringErrorHandler} @@ -20,7 +16,7 @@ import amf.core.client.scala.model.document.BaseUnit import amf.core.client.scala.model.domain.{DataNode, DomainElement, ElementTree} import amf.core.client.scala.parse.document.ParserContext import amf.core.client.scala.transform.TransformationStep -import amf.core.internal.annotations.{ErrorDeclaration, SourceAST, SourceYPart} +import amf.core.internal.annotations.{ErrorDeclaration, SourceYPart} import amf.core.internal.metamodel.domain.DomainElementModel import amf.core.internal.parser.{ParseConfig, YNodeLikeOps} import amf.core.internal.plugins.render.RenderConfiguration @@ -49,16 +45,19 @@ class ExtendsResolutionStage(profile: ProfileName, val keepEditingInfo: Boolean, model: BaseUnit, errorHandler: AMFErrorHandler, configuration: AMFGraphConfiguration - ): BaseUnit = - new ExtendsResolution(profile, keepEditingInfo, fromOverlay, config = configuration)(errorHandler) + ): BaseUnit = { + val index = BaseUnitSourceLocationIndex.build(model) + new ExtendsResolution(profile, keepEditingInfo, fromOverlay, config = configuration, index = index)(errorHandler) .transform(model, configuration) + } class ExtendsResolution( profile: ProfileName, val keepEditingInfo: Boolean, val fromOverlay: Boolean = false, visited: mutable.Set[String] = mutable.Set(), - config: AMFGraphConfiguration + config: AMFGraphConfiguration, + index: BaseUnitSourceLocationIndex )(implicit val errorHandler: AMFErrorHandler) { /** Default to raml10 context. */ @@ -86,7 +85,7 @@ class ExtendsResolutionStage(profile: ProfileName, val keepEditingInfo: Boolean, apiContext.eh.violation(TransformationValidation, r.id, None, message, r.position(), r.location()) ) val extendsHelper = - ExtendsHelper(profile, keepEditingInfo = keepEditingInfo, errorHandler, configuration, Some(apiContext)) + ExtendsHelper(profile, keepEditingInfo = keepEditingInfo, errorHandler, configuration, index, Some(apiContext)) val result = extendsHelper.asEndpoint( context.model, node, @@ -352,7 +351,7 @@ class ExtendsResolutionStage(profile: ProfileName, val keepEditingInfo: Boolean, }) val extendsHelper = - ExtendsHelper(profile, keepEditingInfo = true, errorHandler, configuration, Some(apiContext)) + ExtendsHelper(profile, keepEditingInfo = true, errorHandler, configuration, index, Some(apiContext)) val op = extendsHelper.asOperation( node, context.model, diff --git a/amf-api-contract/shared/src/main/scala/amf/apicontract/internal/validation/payload/APIPayloadValidationPlugin.scala b/amf-api-contract/shared/src/main/scala/amf/apicontract/internal/validation/payload/APIPayloadValidationPlugin.scala index edf4a1e73b..7b4b987d11 100644 --- a/amf-api-contract/shared/src/main/scala/amf/apicontract/internal/validation/payload/APIPayloadValidationPlugin.scala +++ b/amf-api-contract/shared/src/main/scala/amf/apicontract/internal/validation/payload/APIPayloadValidationPlugin.scala @@ -5,12 +5,7 @@ import amf.apicontract.internal.validation.plugin.BaseApiValidationPlugin import amf.core.client.common.validation.ProfileName import amf.core.internal.plugins.validation.ValidationInfo import amf.shapes.internal.validation.payload.BasePayloadValidationPlugin -import amf.shapes.internal.validation.payload.collector.{ - EnumInShapesCollector, - ExtensionsCollector, - PayloadsCollector, - ValidationCandidateCollector -} +import amf.shapes.internal.validation.payload.collector.{DiscriminatorValuesCollector, EnumInShapesCollector, ExtensionsCollector, PayloadsCollector, ValidationCandidateCollector} object APIPayloadValidationPlugin { @@ -25,7 +20,7 @@ class APIPayloadValidationPlugin(override val profile: ProfileName) with BaseApiValidationPlugin { override val collectors: Seq[ValidationCandidateCollector] = - Seq(PayloadsCollector, EnumInShapesCollector, ShapeFacetsCollector, ExtensionsCollector) + Seq(PayloadsCollector, EnumInShapesCollector, ShapeFacetsCollector, ExtensionsCollector, DiscriminatorValuesCollector) override val id: String = APIPayloadValidationPlugin.id diff --git a/amf-apicontract.versions b/amf-apicontract.versions index e682565c7d..e38b336fa5 100644 --- a/amf-apicontract.versions +++ b/amf-apicontract.versions @@ -1,6 +1,6 @@ -amf.apicontract=5.2.4 -amf.aml=6.2.4 +amf.apicontract=5.2.5 +amf.aml=6.2.5 amf.model=3.8.1 -antlr4Version=0.6.21 -amf.validation.profile.dialect=1.4.0-SNAPSHOT -amf.validation.report.dialect=1.2.0-SNAPSHOT +antlr4Version=0.6.22 +amf.validation.profile.dialect=1.4.0 +amf.validation.report.dialect=1.1.0 diff --git a/amf-cli/js/package.json b/amf-cli/js/package.json index c2b555fb88..9181b87be0 100644 --- a/amf-cli/js/package.json +++ b/amf-cli/js/package.json @@ -16,7 +16,7 @@ "types": "./typings/amf-client-js.d.ts", "typings": "./typings/amf-client-js.d.ts", "dependencies": { - "@aml-org/amf-antlr-parsers": "0.6.21", + "@aml-org/amf-antlr-parsers": "0.6.22", "ajv": "6.12.6" } } diff --git a/amf-cli/js/typings/amf-client-js.d.ts b/amf-cli/js/typings/amf-client-js.d.ts index ac3c013d11..678c9cfc33 100644 --- a/amf-cli/js/typings/amf-client-js.d.ts +++ b/amf-cli/js/typings/amf-client-js.d.ts @@ -828,9 +828,6 @@ declare module "amf-client-js" { export interface Annotable { annotations(): Annotations; } - export interface JsonLDElement extends Annotable { - annotations(): Annotations; - } export class AnnotationMapping implements DomainElement { customDomainProperties: Array; extendsNode: Array; @@ -2641,7 +2638,7 @@ declare module "amf-client-js" { withSelfEncoded(selfEncoded: boolean): DocumentsModel; } - export interface DomainElement extends CustomizableElement { + export interface DomainElement extends AmfObjectWrapper, CustomizableElement { customDomainProperties: Array; extendsNode: Array; id: string; @@ -3199,6 +3196,9 @@ declare module "amf-client-js" { export class GraphQLFederationConfiguration { static GraphQLFederation(): AMFConfiguration; } + export class GRPCConfiguration { + static GRPC(): AMFConfiguration; + } export class HighPriority extends PluginPriority {} export class HttpApiKeySettings extends Settings { in: StrField; @@ -3416,13 +3416,19 @@ declare module "amf-client-js" { configuration: AMFGraphConfiguration ): BaseUnit; } - export class JsonLDArray { + export class JsonLDArray implements JsonLDElement { jsonLDElements: Array; constructor(); + annotations(): Annotations; } - export class JsonLDError { + export interface JsonLDElement extends Annotable { + annotations(): Annotations; + } + export class JsonLDError implements JsonLDElement { constructor(); + + annotations(): Annotations; } export class JsonLDInstanceDocument implements BaseUnit { encodes: Array; @@ -3475,7 +3481,7 @@ declare module "amf-client-js" { export class JsonLDInstanceResult extends AMFParseResult { readonly instance: JsonLDInstanceDocument; } - export class JsonLDObject implements DomainElement { + export class JsonLDObject implements DomainElement, JsonLDElement { componentId: string; customDomainProperties: Array; extendsNode: Array; @@ -3530,7 +3536,7 @@ declare module "amf-client-js" { values: Array ): JsonLDObject; } - export class JsonLDScalar { + export class JsonLDScalar implements JsonLDElement { readonly dataType: string; readonly value: any; diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-!-token.graphql b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-!-token.graphql new file mode 100644 index 0000000000..af2fde1e6b --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-!-token.graphql @@ -0,0 +1,7 @@ +type Query { + name!: String +} + +type Person { + name: String +} \ No newline at end of file diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-!-token.jsonld b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-!-token.jsonld new file mode 100644 index 0000000000..1df9551b2c --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-!-token.jsonld @@ -0,0 +1,114 @@ +[ + { + "@id": "", + "@type": [ + "doc:Document", + "doc:Fragment", + "doc:Module", + "doc:Unit" + ], + "doc:encodes": [ + { + "@id": "#/web-api", + "@type": [ + "apiContract:WebAPI", + "apiContract:API", + "doc:RootDomainElement", + "doc:DomainElement" + ], + "core:name": [ + { + "@value": "extraneous-!-token.graphql" + } + ], + "apiContract:endpoint": [] + } + ], + "doc:root": [ + { + "@value": true + } + ], + "doc:processingData": [ + { + "@id": "#/BaseUnitProcessingData", + "@type": [ + "doc:APIContractProcessingData" + ], + "apiContract:modelVersion": [ + { + "@value": "3.8.1" + } + ], + "doc:sourceSpec": [ + { + "@value": "GraphQL" + } + ] + } + ], + "doc:declares": [ + { + "@id": "#/declares/shape/Person", + "@type": [ + "shacl:NodeShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "shacl:property": [ + { + "@id": "#/declares/shape/Person/property/property/name", + "@type": [ + "shacl:PropertyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "raml-shapes:range": [ + { + "@id": "#/declares/shape/Person/property/property/name/scalar/default-scalar", + "@type": [ + "raml-shapes:ScalarShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "shacl:datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + ], + "shacl:minCount": [ + { + "@value": 0 + } + ], + "shacl:name": [ + { + "@value": "name" + } + ] + } + ], + "shacl:name": [ + { + "@value": "Person" + } + ] + } + ], + "@context": { + "@base": "file://amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-!-token.graphql", + "raml-shapes": "http://a.ml/vocabularies/shapes#", + "shacl": "http://www.w3.org/ns/shacl#", + "doc": "http://a.ml/vocabularies/document#", + "apiContract": "http://a.ml/vocabularies/apiContract#", + "core": "http://a.ml/vocabularies/core#" + } + } +] diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-!-token.report b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-!-token.report new file mode 100644 index 0000000000..26cee53afa --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-!-token.report @@ -0,0 +1,14 @@ +ModelId: file://amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-!-token.graphql +Profile: GraphQL +Conforms: false +Number of results: 1 + +Level: Violation + +- Constraint: http://a.ml/vocabularies/amf/parser#antlr-error + Message: Syntax error in the following text: '!' + Severity: Violation + Target: + Property: + Range: [(2,8)-(2,9)] + Location: diff --git "a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-\"-token.graphql" "b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-\"-token.graphql" new file mode 100644 index 0000000000..ce676fb8f1 --- /dev/null +++ "b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-\"-token.graphql" @@ -0,0 +1,7 @@ +type Query { + name": String +} + +type Person { + name: String +} \ No newline at end of file diff --git "a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-\"-token.jsonld" "b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-\"-token.jsonld" new file mode 100644 index 0000000000..1676c7ffd5 --- /dev/null +++ "b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-\"-token.jsonld" @@ -0,0 +1,57 @@ +[ + { + "@id": "", + "@type": [ + "doc:Document", + "doc:Fragment", + "doc:Module", + "doc:Unit" + ], + "doc:encodes": [ + { + "@id": "#/web-api", + "@type": [ + "apiContract:WebAPI", + "apiContract:API", + "doc:RootDomainElement", + "doc:DomainElement" + ], + "core:name": [ + { + "@value": "extraneous-%22-token.graphql" + } + ], + "apiContract:endpoint": [] + } + ], + "doc:root": [ + { + "@value": true + } + ], + "doc:processingData": [ + { + "@id": "#/BaseUnitProcessingData", + "@type": [ + "doc:APIContractProcessingData" + ], + "apiContract:modelVersion": [ + { + "@value": "3.8.1" + } + ], + "doc:sourceSpec": [ + { + "@value": "GraphQL" + } + ] + } + ], + "@context": { + "@base": "file://amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-%22-token.graphql", + "doc": "http://a.ml/vocabularies/document#", + "apiContract": "http://a.ml/vocabularies/apiContract#", + "core": "http://a.ml/vocabularies/core#" + } + } +] diff --git "a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-\"-token.report" "b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-\"-token.report" new file mode 100644 index 0000000000..9654262973 --- /dev/null +++ "b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-\"-token.report" @@ -0,0 +1,22 @@ +ModelId: file://amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-"-token.graphql +Profile: GraphQL +Conforms: false +Number of results: 2 + +Level: Violation + +- Constraint: http://a.ml/vocabularies/amf/parser#antlr-error + Message: Syntax error in the following text: '": String\n}\n\ntype Person {\n name: String\n}' + Severity: Violation + Target: + Property: + Range: + Location: + +- Constraint: http://a.ml/vocabularies/amf/parser#antlr-error + Message: Syntax error: Unexpected end of file + Severity: Violation + Target: + Property: + Range: [(7,1)-(7,1)] + Location: diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-&-token.graphql b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-&-token.graphql new file mode 100644 index 0000000000..ca24a7a09b --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-&-token.graphql @@ -0,0 +1,7 @@ +type Query { + name&: String +} + +type Person { + name: String +} \ No newline at end of file diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-&-token.jsonld b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-&-token.jsonld new file mode 100644 index 0000000000..7fa9d1c0ac --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-&-token.jsonld @@ -0,0 +1,114 @@ +[ + { + "@id": "", + "@type": [ + "doc:Document", + "doc:Fragment", + "doc:Module", + "doc:Unit" + ], + "doc:encodes": [ + { + "@id": "#/web-api", + "@type": [ + "apiContract:WebAPI", + "apiContract:API", + "doc:RootDomainElement", + "doc:DomainElement" + ], + "core:name": [ + { + "@value": "extraneous-&-token.graphql" + } + ], + "apiContract:endpoint": [] + } + ], + "doc:root": [ + { + "@value": true + } + ], + "doc:processingData": [ + { + "@id": "#/BaseUnitProcessingData", + "@type": [ + "doc:APIContractProcessingData" + ], + "apiContract:modelVersion": [ + { + "@value": "3.8.1" + } + ], + "doc:sourceSpec": [ + { + "@value": "GraphQL" + } + ] + } + ], + "doc:declares": [ + { + "@id": "#/declares/shape/Person", + "@type": [ + "shacl:NodeShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "shacl:property": [ + { + "@id": "#/declares/shape/Person/property/property/name", + "@type": [ + "shacl:PropertyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "raml-shapes:range": [ + { + "@id": "#/declares/shape/Person/property/property/name/scalar/default-scalar", + "@type": [ + "raml-shapes:ScalarShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "shacl:datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + ], + "shacl:minCount": [ + { + "@value": 0 + } + ], + "shacl:name": [ + { + "@value": "name" + } + ] + } + ], + "shacl:name": [ + { + "@value": "Person" + } + ] + } + ], + "@context": { + "@base": "file://amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-&-token.graphql", + "raml-shapes": "http://a.ml/vocabularies/shapes#", + "shacl": "http://www.w3.org/ns/shacl#", + "doc": "http://a.ml/vocabularies/document#", + "apiContract": "http://a.ml/vocabularies/apiContract#", + "core": "http://a.ml/vocabularies/core#" + } + } +] diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-&-token.report b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-&-token.report new file mode 100644 index 0000000000..9b77eb9bd1 --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-&-token.report @@ -0,0 +1,14 @@ +ModelId: file://amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-&-token.graphql +Profile: GraphQL +Conforms: false +Number of results: 1 + +Level: Violation + +- Constraint: http://a.ml/vocabularies/amf/parser#antlr-error + Message: Syntax error in the following text: '&' + Severity: Violation + Target: + Property: + Range: [(2,8)-(2,9)] + Location: diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-*-token.graphql b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-*-token.graphql new file mode 100644 index 0000000000..895e5f396f --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-*-token.graphql @@ -0,0 +1,7 @@ +type Query { + name*: String +} + +type Person { + name: String +} \ No newline at end of file diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-*-token.jsonld b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-*-token.jsonld new file mode 100644 index 0000000000..34a0594487 --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-*-token.jsonld @@ -0,0 +1,237 @@ +[ + { + "@id": "", + "@type": [ + "doc:Document", + "doc:Fragment", + "doc:Module", + "doc:Unit" + ], + "doc:encodes": [ + { + "@id": "#/web-api", + "@type": [ + "apiContract:WebAPI", + "apiContract:API", + "doc:RootDomainElement", + "doc:DomainElement" + ], + "core:name": [ + { + "@value": "extraneous-*-token.graphql" + } + ], + "apiContract:endpoint": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname", + "@type": [ + "apiContract:EndPoint", + "doc:DomainElement" + ], + "apiContract:path": [ + { + "@value": "/query/name" + } + ], + "core:name": [ + { + "@value": "Query.name" + } + ], + "apiContract:supportedOperation": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name", + "@type": [ + "apiContract:Operation", + "core:Operation", + "doc:DomainElement" + ], + "apiContract:method": [ + { + "@value": "query" + } + ], + "core:name": [ + { + "@value": "Query.name" + } + ], + "apiContract:expects": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name/expects/request", + "@type": [ + "apiContract:Request", + "core:Request", + "apiContract:Message", + "doc:DomainElement" + ] + } + ], + "apiContract:returns": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name/returns/resp/default", + "@type": [ + "apiContract:Response", + "core:Response", + "apiContract:Message", + "doc:DomainElement" + ], + "apiContract:statusCode": [ + { + "@value": "200" + } + ], + "core:name": [ + { + "@value": "default" + } + ], + "apiContract:payload": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name/returns/resp/default/payload/default", + "@type": [ + "apiContract:Payload", + "core:Payload", + "doc:DomainElement" + ], + "raml-shapes:schema": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name/returns/resp/default/payload/default/union/default-union", + "@type": [ + "raml-shapes:UnionShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "raml-shapes:anyOf": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name/returns/resp/default/payload/default/union/default-union/anyOf/nil/default-nil", + "@type": [ + "raml-shapes:NilShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ] + }, + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name/returns/resp/default/payload/default/union/default-union/anyOf/scalar/default-scalar", + "@type": [ + "raml-shapes:ScalarShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "shacl:datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + ] + } + ] + } + ] + } + ], + "apiContract:operationId": [ + { + "@value": "Query.name" + } + ] + } + ] + } + ] + } + ], + "doc:root": [ + { + "@value": true + } + ], + "doc:processingData": [ + { + "@id": "#/BaseUnitProcessingData", + "@type": [ + "doc:APIContractProcessingData" + ], + "apiContract:modelVersion": [ + { + "@value": "3.8.1" + } + ], + "doc:sourceSpec": [ + { + "@value": "GraphQL" + } + ] + } + ], + "doc:declares": [ + { + "@id": "#/declares/shape/Person", + "@type": [ + "shacl:NodeShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "shacl:property": [ + { + "@id": "#/declares/shape/Person/property/property/name", + "@type": [ + "shacl:PropertyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "raml-shapes:range": [ + { + "@id": "#/declares/shape/Person/property/property/name/scalar/default-scalar", + "@type": [ + "raml-shapes:ScalarShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "shacl:datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + ], + "shacl:minCount": [ + { + "@value": 0 + } + ], + "shacl:name": [ + { + "@value": "name" + } + ] + } + ], + "shacl:name": [ + { + "@value": "Person" + } + ] + } + ], + "@context": { + "@base": "file://amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-*-token.graphql", + "shacl": "http://www.w3.org/ns/shacl#", + "raml-shapes": "http://a.ml/vocabularies/shapes#", + "doc": "http://a.ml/vocabularies/document#", + "apiContract": "http://a.ml/vocabularies/apiContract#", + "core": "http://a.ml/vocabularies/core#" + } + } +] diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-*-token.report b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-*-token.report new file mode 100644 index 0000000000..5743c3b3e0 --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-*-token.report @@ -0,0 +1,14 @@ +ModelId: file://amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-*-token.graphql +Profile: GraphQL +Conforms: false +Number of results: 1 + +Level: Violation + +- Constraint: http://a.ml/vocabularies/amf/parser#antlr-error + Message: Syntax error in the following text: '*' + Severity: Violation + Target: + Property: + Range: + Location: diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous---token.graphql b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous---token.graphql new file mode 100644 index 0000000000..fcdbc121a1 --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous---token.graphql @@ -0,0 +1,7 @@ +type Query { + name-: String +} + +type Person { + name: String +} \ No newline at end of file diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous---token.jsonld b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous---token.jsonld new file mode 100644 index 0000000000..c92334ab0e --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous---token.jsonld @@ -0,0 +1,114 @@ +[ + { + "@id": "", + "@type": [ + "doc:Document", + "doc:Fragment", + "doc:Module", + "doc:Unit" + ], + "doc:encodes": [ + { + "@id": "#/web-api", + "@type": [ + "apiContract:WebAPI", + "apiContract:API", + "doc:RootDomainElement", + "doc:DomainElement" + ], + "core:name": [ + { + "@value": "extraneous---token.graphql" + } + ], + "apiContract:endpoint": [] + } + ], + "doc:root": [ + { + "@value": true + } + ], + "doc:processingData": [ + { + "@id": "#/BaseUnitProcessingData", + "@type": [ + "doc:APIContractProcessingData" + ], + "apiContract:modelVersion": [ + { + "@value": "3.8.1" + } + ], + "doc:sourceSpec": [ + { + "@value": "GraphQL" + } + ] + } + ], + "doc:declares": [ + { + "@id": "#/declares/shape/Person", + "@type": [ + "shacl:NodeShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "shacl:property": [ + { + "@id": "#/declares/shape/Person/property/property/name", + "@type": [ + "shacl:PropertyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "raml-shapes:range": [ + { + "@id": "#/declares/shape/Person/property/property/name/scalar/default-scalar", + "@type": [ + "raml-shapes:ScalarShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "shacl:datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + ], + "shacl:minCount": [ + { + "@value": 0 + } + ], + "shacl:name": [ + { + "@value": "name" + } + ] + } + ], + "shacl:name": [ + { + "@value": "Person" + } + ] + } + ], + "@context": { + "@base": "file://amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous---token.graphql", + "raml-shapes": "http://a.ml/vocabularies/shapes#", + "shacl": "http://www.w3.org/ns/shacl#", + "doc": "http://a.ml/vocabularies/document#", + "apiContract": "http://a.ml/vocabularies/apiContract#", + "core": "http://a.ml/vocabularies/core#" + } + } +] diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous---token.report b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous---token.report new file mode 100644 index 0000000000..95968b35a1 --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous---token.report @@ -0,0 +1,14 @@ +ModelId: file://amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous---token.graphql +Profile: GraphQL +Conforms: false +Number of results: 1 + +Level: Violation + +- Constraint: http://a.ml/vocabularies/amf/parser#antlr-error + Message: Syntax error in the following text: '-:' + Severity: Violation + Target: + Property: + Range: + Location: diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-:-token.graphql b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-:-token.graphql new file mode 100644 index 0000000000..b4e61f64c6 --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-:-token.graphql @@ -0,0 +1,7 @@ +type Query { + name:: String +} + +type Person { + name: String +} \ No newline at end of file diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-:-token.jsonld b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-:-token.jsonld new file mode 100644 index 0000000000..265dea6651 --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-:-token.jsonld @@ -0,0 +1,114 @@ +[ + { + "@id": "", + "@type": [ + "doc:Document", + "doc:Fragment", + "doc:Module", + "doc:Unit" + ], + "doc:encodes": [ + { + "@id": "#/web-api", + "@type": [ + "apiContract:WebAPI", + "apiContract:API", + "doc:RootDomainElement", + "doc:DomainElement" + ], + "core:name": [ + { + "@value": "extraneous-:-token.graphql" + } + ], + "apiContract:endpoint": [] + } + ], + "doc:root": [ + { + "@value": true + } + ], + "doc:processingData": [ + { + "@id": "#/BaseUnitProcessingData", + "@type": [ + "doc:APIContractProcessingData" + ], + "apiContract:modelVersion": [ + { + "@value": "3.8.1" + } + ], + "doc:sourceSpec": [ + { + "@value": "GraphQL" + } + ] + } + ], + "doc:declares": [ + { + "@id": "#/declares/shape/Person", + "@type": [ + "shacl:NodeShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "shacl:property": [ + { + "@id": "#/declares/shape/Person/property/property/name", + "@type": [ + "shacl:PropertyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "raml-shapes:range": [ + { + "@id": "#/declares/shape/Person/property/property/name/scalar/default-scalar", + "@type": [ + "raml-shapes:ScalarShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "shacl:datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + ], + "shacl:minCount": [ + { + "@value": 0 + } + ], + "shacl:name": [ + { + "@value": "name" + } + ] + } + ], + "shacl:name": [ + { + "@value": "Person" + } + ] + } + ], + "@context": { + "@base": "file://amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-:-token.graphql", + "raml-shapes": "http://a.ml/vocabularies/shapes#", + "shacl": "http://www.w3.org/ns/shacl#", + "doc": "http://a.ml/vocabularies/document#", + "apiContract": "http://a.ml/vocabularies/apiContract#", + "core": "http://a.ml/vocabularies/core#" + } + } +] diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-:-token.report b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-:-token.report new file mode 100644 index 0000000000..488b6063a8 --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-:-token.report @@ -0,0 +1,14 @@ +ModelId: file://amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-:-token.graphql +Profile: GraphQL +Conforms: false +Number of results: 1 + +Level: Violation + +- Constraint: http://a.ml/vocabularies/amf/parser#antlr-error + Message: Syntax error in the following text: ':' + Severity: Violation + Target: + Property: + Range: [(2,9)-(2,10)] + Location: diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-;-token.graphql b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-;-token.graphql new file mode 100644 index 0000000000..498fd922df --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-;-token.graphql @@ -0,0 +1,7 @@ +type Query { + name;: String +} + +type Person { + name: String +} \ No newline at end of file diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-;-token.jsonld b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-;-token.jsonld new file mode 100644 index 0000000000..8b32875e22 --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-;-token.jsonld @@ -0,0 +1,237 @@ +[ + { + "@id": "", + "@type": [ + "doc:Document", + "doc:Fragment", + "doc:Module", + "doc:Unit" + ], + "doc:encodes": [ + { + "@id": "#/web-api", + "@type": [ + "apiContract:WebAPI", + "apiContract:API", + "doc:RootDomainElement", + "doc:DomainElement" + ], + "core:name": [ + { + "@value": "extraneous-;-token.graphql" + } + ], + "apiContract:endpoint": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname", + "@type": [ + "apiContract:EndPoint", + "doc:DomainElement" + ], + "apiContract:path": [ + { + "@value": "/query/name" + } + ], + "core:name": [ + { + "@value": "Query.name" + } + ], + "apiContract:supportedOperation": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name", + "@type": [ + "apiContract:Operation", + "core:Operation", + "doc:DomainElement" + ], + "apiContract:method": [ + { + "@value": "query" + } + ], + "core:name": [ + { + "@value": "Query.name" + } + ], + "apiContract:expects": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name/expects/request", + "@type": [ + "apiContract:Request", + "core:Request", + "apiContract:Message", + "doc:DomainElement" + ] + } + ], + "apiContract:returns": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name/returns/resp/default", + "@type": [ + "apiContract:Response", + "core:Response", + "apiContract:Message", + "doc:DomainElement" + ], + "apiContract:statusCode": [ + { + "@value": "200" + } + ], + "core:name": [ + { + "@value": "default" + } + ], + "apiContract:payload": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name/returns/resp/default/payload/default", + "@type": [ + "apiContract:Payload", + "core:Payload", + "doc:DomainElement" + ], + "raml-shapes:schema": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name/returns/resp/default/payload/default/union/default-union", + "@type": [ + "raml-shapes:UnionShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "raml-shapes:anyOf": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name/returns/resp/default/payload/default/union/default-union/anyOf/nil/default-nil", + "@type": [ + "raml-shapes:NilShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ] + }, + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name/returns/resp/default/payload/default/union/default-union/anyOf/scalar/default-scalar", + "@type": [ + "raml-shapes:ScalarShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "shacl:datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + ] + } + ] + } + ] + } + ], + "apiContract:operationId": [ + { + "@value": "Query.name" + } + ] + } + ] + } + ] + } + ], + "doc:root": [ + { + "@value": true + } + ], + "doc:processingData": [ + { + "@id": "#/BaseUnitProcessingData", + "@type": [ + "doc:APIContractProcessingData" + ], + "apiContract:modelVersion": [ + { + "@value": "3.8.1" + } + ], + "doc:sourceSpec": [ + { + "@value": "GraphQL" + } + ] + } + ], + "doc:declares": [ + { + "@id": "#/declares/shape/Person", + "@type": [ + "shacl:NodeShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "shacl:property": [ + { + "@id": "#/declares/shape/Person/property/property/name", + "@type": [ + "shacl:PropertyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "raml-shapes:range": [ + { + "@id": "#/declares/shape/Person/property/property/name/scalar/default-scalar", + "@type": [ + "raml-shapes:ScalarShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "shacl:datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + ], + "shacl:minCount": [ + { + "@value": 0 + } + ], + "shacl:name": [ + { + "@value": "name" + } + ] + } + ], + "shacl:name": [ + { + "@value": "Person" + } + ] + } + ], + "@context": { + "@base": "file://amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-;-token.graphql", + "shacl": "http://www.w3.org/ns/shacl#", + "raml-shapes": "http://a.ml/vocabularies/shapes#", + "doc": "http://a.ml/vocabularies/document#", + "apiContract": "http://a.ml/vocabularies/apiContract#", + "core": "http://a.ml/vocabularies/core#" + } + } +] diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-;-token.report b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-;-token.report new file mode 100644 index 0000000000..e3b1d4fbb5 --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-;-token.report @@ -0,0 +1,14 @@ +ModelId: file://amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-;-token.graphql +Profile: GraphQL +Conforms: false +Number of results: 1 + +Level: Violation + +- Constraint: http://a.ml/vocabularies/amf/parser#antlr-error + Message: Syntax error in the following text: ';' + Severity: Violation + Target: + Property: + Range: + Location: diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-@-token.graphql b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-@-token.graphql new file mode 100644 index 0000000000..3001065408 --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-@-token.graphql @@ -0,0 +1,7 @@ +type Query { + name@: String +} + +type Person { + name: String +} \ No newline at end of file diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-@-token.jsonld b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-@-token.jsonld new file mode 100644 index 0000000000..74fd5e6065 --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-@-token.jsonld @@ -0,0 +1,114 @@ +[ + { + "@id": "", + "@type": [ + "doc:Document", + "doc:Fragment", + "doc:Module", + "doc:Unit" + ], + "doc:encodes": [ + { + "@id": "#/web-api", + "@type": [ + "apiContract:WebAPI", + "apiContract:API", + "doc:RootDomainElement", + "doc:DomainElement" + ], + "core:name": [ + { + "@value": "extraneous-@-token.graphql" + } + ], + "apiContract:endpoint": [] + } + ], + "doc:root": [ + { + "@value": true + } + ], + "doc:processingData": [ + { + "@id": "#/BaseUnitProcessingData", + "@type": [ + "doc:APIContractProcessingData" + ], + "apiContract:modelVersion": [ + { + "@value": "3.8.1" + } + ], + "doc:sourceSpec": [ + { + "@value": "GraphQL" + } + ] + } + ], + "doc:declares": [ + { + "@id": "#/declares/shape/Person", + "@type": [ + "shacl:NodeShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "shacl:property": [ + { + "@id": "#/declares/shape/Person/property/property/name", + "@type": [ + "shacl:PropertyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "raml-shapes:range": [ + { + "@id": "#/declares/shape/Person/property/property/name/scalar/default-scalar", + "@type": [ + "raml-shapes:ScalarShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "shacl:datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + ], + "shacl:minCount": [ + { + "@value": 0 + } + ], + "shacl:name": [ + { + "@value": "name" + } + ] + } + ], + "shacl:name": [ + { + "@value": "Person" + } + ] + } + ], + "@context": { + "@base": "file://amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-@-token.graphql", + "raml-shapes": "http://a.ml/vocabularies/shapes#", + "shacl": "http://www.w3.org/ns/shacl#", + "doc": "http://a.ml/vocabularies/document#", + "apiContract": "http://a.ml/vocabularies/apiContract#", + "core": "http://a.ml/vocabularies/core#" + } + } +] diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-@-token.report b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-@-token.report new file mode 100644 index 0000000000..e19b6c9101 --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-@-token.report @@ -0,0 +1,14 @@ +ModelId: file://amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-@-token.graphql +Profile: GraphQL +Conforms: false +Number of results: 1 + +Level: Violation + +- Constraint: http://a.ml/vocabularies/amf/parser#antlr-error + Message: Syntax error in the following text: ':' + Severity: Violation + Target: + Property: + Range: [(2,9)-(2,10)] + Location: diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-tokens.graphql b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-tokens.graphql new file mode 100644 index 0000000000..bf06b4f697 --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-tokens.graphql @@ -0,0 +1,7 @@ +type Query { + !@$%^&* +} + +type Person { + name: String +} \ No newline at end of file diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-tokens.jsonld b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-tokens.jsonld new file mode 100644 index 0000000000..9cdc659aac --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-tokens.jsonld @@ -0,0 +1,114 @@ +[ + { + "@id": "", + "@type": [ + "doc:Document", + "doc:Fragment", + "doc:Module", + "doc:Unit" + ], + "doc:encodes": [ + { + "@id": "#/web-api", + "@type": [ + "apiContract:WebAPI", + "apiContract:API", + "doc:RootDomainElement", + "doc:DomainElement" + ], + "core:name": [ + { + "@value": "extraneous-tokens.graphql" + } + ], + "apiContract:endpoint": [] + } + ], + "doc:root": [ + { + "@value": true + } + ], + "doc:processingData": [ + { + "@id": "#/BaseUnitProcessingData", + "@type": [ + "doc:APIContractProcessingData" + ], + "apiContract:modelVersion": [ + { + "@value": "3.8.1" + } + ], + "doc:sourceSpec": [ + { + "@value": "GraphQL" + } + ] + } + ], + "doc:declares": [ + { + "@id": "#/declares/shape/Person", + "@type": [ + "shacl:NodeShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "shacl:property": [ + { + "@id": "#/declares/shape/Person/property/property/name", + "@type": [ + "shacl:PropertyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "raml-shapes:range": [ + { + "@id": "#/declares/shape/Person/property/property/name/scalar/default-scalar", + "@type": [ + "raml-shapes:ScalarShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "shacl:datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + ], + "shacl:minCount": [ + { + "@value": 0 + } + ], + "shacl:name": [ + { + "@value": "name" + } + ] + } + ], + "shacl:name": [ + { + "@value": "Person" + } + ] + } + ], + "@context": { + "@base": "file://amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-tokens.graphql", + "raml-shapes": "http://a.ml/vocabularies/shapes#", + "shacl": "http://www.w3.org/ns/shacl#", + "doc": "http://a.ml/vocabularies/document#", + "apiContract": "http://a.ml/vocabularies/apiContract#", + "core": "http://a.ml/vocabularies/core#" + } + } +] diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-tokens.report b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-tokens.report new file mode 100644 index 0000000000..8406bab4a1 --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-tokens.report @@ -0,0 +1,38 @@ +ModelId: file://amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-tokens.graphql +Profile: GraphQL +Conforms: false +Number of results: 4 + +Level: Violation + +- Constraint: http://a.ml/vocabularies/amf/parser#antlr-error + Message: Syntax error in the following text: '%' + Severity: Violation + Target: + Property: + Range: + Location: + +- Constraint: http://a.ml/vocabularies/amf/parser#antlr-error + Message: Syntax error in the following text: '*' + Severity: Violation + Target: + Property: + Range: + Location: + +- Constraint: http://a.ml/vocabularies/amf/parser#antlr-error + Message: Syntax error in the following text: '^' + Severity: Violation + Target: + Property: + Range: + Location: + +- Constraint: http://a.ml/vocabularies/amf/parser#antlr-error + Message: Syntax error in the following text: '!' + Severity: Violation + Target: + Property: + Range: [(2,4)-(2,5)] + Location: diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-|-token.graphql b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-|-token.graphql new file mode 100644 index 0000000000..304ef353d0 --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-|-token.graphql @@ -0,0 +1,7 @@ +type Query { + name|: String +} + +type Person { + name: String +} \ No newline at end of file diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-|-token.jsonld b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-|-token.jsonld new file mode 100644 index 0000000000..aaafde443a --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-|-token.jsonld @@ -0,0 +1,114 @@ +[ + { + "@id": "", + "@type": [ + "doc:Document", + "doc:Fragment", + "doc:Module", + "doc:Unit" + ], + "doc:encodes": [ + { + "@id": "#/web-api", + "@type": [ + "apiContract:WebAPI", + "apiContract:API", + "doc:RootDomainElement", + "doc:DomainElement" + ], + "core:name": [ + { + "@value": "extraneous-%7C-token.graphql" + } + ], + "apiContract:endpoint": [] + } + ], + "doc:root": [ + { + "@value": true + } + ], + "doc:processingData": [ + { + "@id": "#/BaseUnitProcessingData", + "@type": [ + "doc:APIContractProcessingData" + ], + "apiContract:modelVersion": [ + { + "@value": "3.8.1" + } + ], + "doc:sourceSpec": [ + { + "@value": "GraphQL" + } + ] + } + ], + "doc:declares": [ + { + "@id": "#/declares/shape/Person", + "@type": [ + "shacl:NodeShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "shacl:property": [ + { + "@id": "#/declares/shape/Person/property/property/name", + "@type": [ + "shacl:PropertyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "raml-shapes:range": [ + { + "@id": "#/declares/shape/Person/property/property/name/scalar/default-scalar", + "@type": [ + "raml-shapes:ScalarShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "shacl:datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + ], + "shacl:minCount": [ + { + "@value": 0 + } + ], + "shacl:name": [ + { + "@value": "name" + } + ] + } + ], + "shacl:name": [ + { + "@value": "Person" + } + ] + } + ], + "@context": { + "@base": "file://amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-%7C-token.graphql", + "raml-shapes": "http://a.ml/vocabularies/shapes#", + "shacl": "http://www.w3.org/ns/shacl#", + "doc": "http://a.ml/vocabularies/document#", + "apiContract": "http://a.ml/vocabularies/apiContract#", + "core": "http://a.ml/vocabularies/core#" + } + } +] diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-|-token.report b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-|-token.report new file mode 100644 index 0000000000..fb060dc4ef --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-|-token.report @@ -0,0 +1,14 @@ +ModelId: file://amf-cli/shared/src/test/resources/graphql/syntax-recovery/extraneous-|-token.graphql +Profile: GraphQL +Conforms: false +Number of results: 1 + +Level: Violation + +- Constraint: http://a.ml/vocabularies/amf/parser#antlr-error + Message: Syntax error in the following text: '|' + Severity: Violation + Target: + Property: + Range: [(2,8)-(2,9)] + Location: diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-colon.graphql b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-colon.graphql new file mode 100644 index 0000000000..0641545aa5 --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-colon.graphql @@ -0,0 +1,7 @@ +type Query { + name String +} + +type Person { + name: String +} \ No newline at end of file diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-colon.jsonld b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-colon.jsonld new file mode 100644 index 0000000000..332ab0c417 --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-colon.jsonld @@ -0,0 +1,114 @@ +[ + { + "@id": "", + "@type": [ + "doc:Document", + "doc:Fragment", + "doc:Module", + "doc:Unit" + ], + "doc:encodes": [ + { + "@id": "#/web-api", + "@type": [ + "apiContract:WebAPI", + "apiContract:API", + "doc:RootDomainElement", + "doc:DomainElement" + ], + "core:name": [ + { + "@value": "missing-colon.graphql" + } + ], + "apiContract:endpoint": [] + } + ], + "doc:root": [ + { + "@value": true + } + ], + "doc:processingData": [ + { + "@id": "#/BaseUnitProcessingData", + "@type": [ + "doc:APIContractProcessingData" + ], + "apiContract:modelVersion": [ + { + "@value": "3.8.1" + } + ], + "doc:sourceSpec": [ + { + "@value": "GraphQL" + } + ] + } + ], + "doc:declares": [ + { + "@id": "#/declares/shape/Person", + "@type": [ + "shacl:NodeShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "shacl:property": [ + { + "@id": "#/declares/shape/Person/property/property/name", + "@type": [ + "shacl:PropertyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "raml-shapes:range": [ + { + "@id": "#/declares/shape/Person/property/property/name/scalar/default-scalar", + "@type": [ + "raml-shapes:ScalarShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "shacl:datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + ], + "shacl:minCount": [ + { + "@value": 0 + } + ], + "shacl:name": [ + { + "@value": "name" + } + ] + } + ], + "shacl:name": [ + { + "@value": "Person" + } + ] + } + ], + "@context": { + "@base": "file://amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-colon.graphql", + "raml-shapes": "http://a.ml/vocabularies/shapes#", + "shacl": "http://www.w3.org/ns/shacl#", + "doc": "http://a.ml/vocabularies/document#", + "apiContract": "http://a.ml/vocabularies/apiContract#", + "core": "http://a.ml/vocabularies/core#" + } + } +] diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-colon.report b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-colon.report new file mode 100644 index 0000000000..616b225673 --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-colon.report @@ -0,0 +1,4 @@ +ModelId: file://amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-colon.graphql +Profile: GraphQL +Conforms: true +Number of results: 0 diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-0.graphql b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-0.graphql new file mode 100644 index 0000000000..4518190c8b --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-0.graphql @@ -0,0 +1,7 @@ +type Query { + name: +} + +type Person { + name: String +} \ No newline at end of file diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-0.jsonld b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-0.jsonld new file mode 100644 index 0000000000..faac73b219 --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-0.jsonld @@ -0,0 +1,210 @@ +[ + { + "@id": "", + "@type": [ + "doc:Document", + "doc:Fragment", + "doc:Module", + "doc:Unit" + ], + "doc:encodes": [ + { + "@id": "#/web-api", + "@type": [ + "apiContract:WebAPI", + "apiContract:API", + "doc:RootDomainElement", + "doc:DomainElement" + ], + "core:name": [ + { + "@value": "missing-field-type-0.graphql" + } + ], + "apiContract:endpoint": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname", + "@type": [ + "apiContract:EndPoint", + "doc:DomainElement" + ], + "apiContract:path": [ + { + "@value": "/query/name" + } + ], + "core:name": [ + { + "@value": "Query.name" + } + ], + "apiContract:supportedOperation": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name", + "@type": [ + "apiContract:Operation", + "core:Operation", + "doc:DomainElement" + ], + "apiContract:method": [ + { + "@value": "query" + } + ], + "core:name": [ + { + "@value": "Query.name" + } + ], + "apiContract:expects": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name/expects/request", + "@type": [ + "apiContract:Request", + "core:Request", + "apiContract:Message", + "doc:DomainElement" + ] + } + ], + "apiContract:returns": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name/returns/resp/default", + "@type": [ + "apiContract:Response", + "core:Response", + "apiContract:Message", + "doc:DomainElement" + ], + "apiContract:statusCode": [ + { + "@value": "200" + } + ], + "core:name": [ + { + "@value": "default" + } + ], + "apiContract:payload": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name/returns/resp/default/payload/default", + "@type": [ + "apiContract:Payload", + "core:Payload", + "doc:DomainElement" + ], + "raml-shapes:schema": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name/returns/resp/default/payload/default/any/default-any", + "@type": [ + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ] + } + ] + } + ] + } + ], + "apiContract:operationId": [ + { + "@value": "Query.name" + } + ] + } + ] + } + ] + } + ], + "doc:root": [ + { + "@value": true + } + ], + "doc:processingData": [ + { + "@id": "#/BaseUnitProcessingData", + "@type": [ + "doc:APIContractProcessingData" + ], + "apiContract:modelVersion": [ + { + "@value": "3.8.1" + } + ], + "doc:sourceSpec": [ + { + "@value": "GraphQL" + } + ] + } + ], + "doc:declares": [ + { + "@id": "#/declares/shape/Person", + "@type": [ + "shacl:NodeShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "shacl:property": [ + { + "@id": "#/declares/shape/Person/property/property/name", + "@type": [ + "shacl:PropertyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "raml-shapes:range": [ + { + "@id": "#/declares/shape/Person/property/property/name/scalar/default-scalar", + "@type": [ + "raml-shapes:ScalarShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "shacl:datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + ], + "shacl:minCount": [ + { + "@value": 0 + } + ], + "shacl:name": [ + { + "@value": "name" + } + ] + } + ], + "shacl:name": [ + { + "@value": "Person" + } + ] + } + ], + "@context": { + "@base": "file://amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-0.graphql", + "shacl": "http://www.w3.org/ns/shacl#", + "raml-shapes": "http://a.ml/vocabularies/shapes#", + "doc": "http://a.ml/vocabularies/document#", + "apiContract": "http://a.ml/vocabularies/apiContract#", + "core": "http://a.ml/vocabularies/core#" + } + } +] diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-0.report b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-0.report new file mode 100644 index 0000000000..87e312b83b --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-0.report @@ -0,0 +1,14 @@ +ModelId: file://amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-0.graphql +Profile: GraphQL +Conforms: false +Number of results: 1 + +Level: Violation + +- Constraint: http://a.ml/vocabularies/amf/parser#antlr-error + Message: Field 'name' missing field type + Severity: Violation + Target: + Property: + Range: [(2,4)-(2,8)] + Location: diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-1.graphql b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-1.graphql new file mode 100644 index 0000000000..6a26f080bb --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-1.graphql @@ -0,0 +1,7 @@ +type Query { + name: * +} + +type Person { + name: String +} \ No newline at end of file diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-1.jsonld b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-1.jsonld new file mode 100644 index 0000000000..8903096de3 --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-1.jsonld @@ -0,0 +1,210 @@ +[ + { + "@id": "", + "@type": [ + "doc:Document", + "doc:Fragment", + "doc:Module", + "doc:Unit" + ], + "doc:encodes": [ + { + "@id": "#/web-api", + "@type": [ + "apiContract:WebAPI", + "apiContract:API", + "doc:RootDomainElement", + "doc:DomainElement" + ], + "core:name": [ + { + "@value": "missing-field-type-1.graphql" + } + ], + "apiContract:endpoint": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname", + "@type": [ + "apiContract:EndPoint", + "doc:DomainElement" + ], + "apiContract:path": [ + { + "@value": "/query/name" + } + ], + "core:name": [ + { + "@value": "Query.name" + } + ], + "apiContract:supportedOperation": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name", + "@type": [ + "apiContract:Operation", + "core:Operation", + "doc:DomainElement" + ], + "apiContract:method": [ + { + "@value": "query" + } + ], + "core:name": [ + { + "@value": "Query.name" + } + ], + "apiContract:expects": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name/expects/request", + "@type": [ + "apiContract:Request", + "core:Request", + "apiContract:Message", + "doc:DomainElement" + ] + } + ], + "apiContract:returns": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name/returns/resp/default", + "@type": [ + "apiContract:Response", + "core:Response", + "apiContract:Message", + "doc:DomainElement" + ], + "apiContract:statusCode": [ + { + "@value": "200" + } + ], + "core:name": [ + { + "@value": "default" + } + ], + "apiContract:payload": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name/returns/resp/default/payload/default", + "@type": [ + "apiContract:Payload", + "core:Payload", + "doc:DomainElement" + ], + "raml-shapes:schema": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name/returns/resp/default/payload/default/any/default-any", + "@type": [ + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ] + } + ] + } + ] + } + ], + "apiContract:operationId": [ + { + "@value": "Query.name" + } + ] + } + ] + } + ] + } + ], + "doc:root": [ + { + "@value": true + } + ], + "doc:processingData": [ + { + "@id": "#/BaseUnitProcessingData", + "@type": [ + "doc:APIContractProcessingData" + ], + "apiContract:modelVersion": [ + { + "@value": "3.8.1" + } + ], + "doc:sourceSpec": [ + { + "@value": "GraphQL" + } + ] + } + ], + "doc:declares": [ + { + "@id": "#/declares/shape/Person", + "@type": [ + "shacl:NodeShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "shacl:property": [ + { + "@id": "#/declares/shape/Person/property/property/name", + "@type": [ + "shacl:PropertyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "raml-shapes:range": [ + { + "@id": "#/declares/shape/Person/property/property/name/scalar/default-scalar", + "@type": [ + "raml-shapes:ScalarShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "shacl:datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + ], + "shacl:minCount": [ + { + "@value": 0 + } + ], + "shacl:name": [ + { + "@value": "name" + } + ] + } + ], + "shacl:name": [ + { + "@value": "Person" + } + ] + } + ], + "@context": { + "@base": "file://amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-1.graphql", + "shacl": "http://www.w3.org/ns/shacl#", + "raml-shapes": "http://a.ml/vocabularies/shapes#", + "doc": "http://a.ml/vocabularies/document#", + "apiContract": "http://a.ml/vocabularies/apiContract#", + "core": "http://a.ml/vocabularies/core#" + } + } +] diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-1.report b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-1.report new file mode 100644 index 0000000000..9d02e3d3a1 --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-1.report @@ -0,0 +1,22 @@ +ModelId: file://amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-1.graphql +Profile: GraphQL +Conforms: false +Number of results: 2 + +Level: Violation + +- Constraint: http://a.ml/vocabularies/amf/parser#antlr-error + Message: Syntax error in the following text: '*' + Severity: Violation + Target: + Property: + Range: + Location: + +- Constraint: http://a.ml/vocabularies/amf/parser#antlr-error + Message: Field 'name' missing field type + Severity: Violation + Target: + Property: + Range: [(2,4)-(2,8)] + Location: diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-2.graphql b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-2.graphql new file mode 100644 index 0000000000..7500fe7986 --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-2.graphql @@ -0,0 +1,8 @@ +type Query { + name: + another: String +} + +type Person { + name: String +} \ No newline at end of file diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-2.jsonld b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-2.jsonld new file mode 100644 index 0000000000..59a7351f05 --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-2.jsonld @@ -0,0 +1,332 @@ +[ + { + "@id": "", + "@type": [ + "doc:Document", + "doc:Fragment", + "doc:Module", + "doc:Unit" + ], + "doc:encodes": [ + { + "@id": "#/web-api", + "@type": [ + "apiContract:WebAPI", + "apiContract:API", + "doc:RootDomainElement", + "doc:DomainElement" + ], + "core:name": [ + { + "@value": "missing-field-type-2.graphql" + } + ], + "apiContract:endpoint": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname", + "@type": [ + "apiContract:EndPoint", + "doc:DomainElement" + ], + "apiContract:path": [ + { + "@value": "/query/name" + } + ], + "core:name": [ + { + "@value": "Query.name" + } + ], + "apiContract:supportedOperation": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name", + "@type": [ + "apiContract:Operation", + "core:Operation", + "doc:DomainElement" + ], + "apiContract:method": [ + { + "@value": "query" + } + ], + "core:name": [ + { + "@value": "Query.name" + } + ], + "apiContract:expects": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name/expects/request", + "@type": [ + "apiContract:Request", + "core:Request", + "apiContract:Message", + "doc:DomainElement" + ] + } + ], + "apiContract:returns": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name/returns/resp/default", + "@type": [ + "apiContract:Response", + "core:Response", + "apiContract:Message", + "doc:DomainElement" + ], + "apiContract:statusCode": [ + { + "@value": "200" + } + ], + "core:name": [ + { + "@value": "default" + } + ], + "apiContract:payload": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name/returns/resp/default/payload/default", + "@type": [ + "apiContract:Payload", + "core:Payload", + "doc:DomainElement" + ], + "raml-shapes:schema": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name/returns/resp/default/payload/default/any/default-any", + "@type": [ + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ] + } + ] + } + ] + } + ], + "apiContract:operationId": [ + { + "@value": "Query.name" + } + ] + } + ] + }, + { + "@id": "#/web-api/endpoint/%2Fquery%2Fanother", + "@type": [ + "apiContract:EndPoint", + "doc:DomainElement" + ], + "apiContract:path": [ + { + "@value": "/query/another" + } + ], + "core:name": [ + { + "@value": "Query.another" + } + ], + "apiContract:supportedOperation": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fanother/supportedOperation/query/Query.another", + "@type": [ + "apiContract:Operation", + "core:Operation", + "doc:DomainElement" + ], + "apiContract:method": [ + { + "@value": "query" + } + ], + "core:name": [ + { + "@value": "Query.another" + } + ], + "apiContract:expects": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fanother/supportedOperation/query/Query.another/expects/request", + "@type": [ + "apiContract:Request", + "core:Request", + "apiContract:Message", + "doc:DomainElement" + ] + } + ], + "apiContract:returns": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fanother/supportedOperation/query/Query.another/returns/resp/default", + "@type": [ + "apiContract:Response", + "core:Response", + "apiContract:Message", + "doc:DomainElement" + ], + "apiContract:statusCode": [ + { + "@value": "200" + } + ], + "core:name": [ + { + "@value": "default" + } + ], + "apiContract:payload": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fanother/supportedOperation/query/Query.another/returns/resp/default/payload/default", + "@type": [ + "apiContract:Payload", + "core:Payload", + "doc:DomainElement" + ], + "raml-shapes:schema": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fanother/supportedOperation/query/Query.another/returns/resp/default/payload/default/union/default-union", + "@type": [ + "raml-shapes:UnionShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "raml-shapes:anyOf": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fanother/supportedOperation/query/Query.another/returns/resp/default/payload/default/union/default-union/anyOf/nil/default-nil", + "@type": [ + "raml-shapes:NilShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ] + }, + { + "@id": "#/web-api/endpoint/%2Fquery%2Fanother/supportedOperation/query/Query.another/returns/resp/default/payload/default/union/default-union/anyOf/scalar/default-scalar", + "@type": [ + "raml-shapes:ScalarShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "shacl:datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + ] + } + ] + } + ] + } + ], + "apiContract:operationId": [ + { + "@value": "Query.another" + } + ] + } + ] + } + ] + } + ], + "doc:root": [ + { + "@value": true + } + ], + "doc:processingData": [ + { + "@id": "#/BaseUnitProcessingData", + "@type": [ + "doc:APIContractProcessingData" + ], + "apiContract:modelVersion": [ + { + "@value": "3.8.1" + } + ], + "doc:sourceSpec": [ + { + "@value": "GraphQL" + } + ] + } + ], + "doc:declares": [ + { + "@id": "#/declares/shape/Person", + "@type": [ + "shacl:NodeShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "shacl:property": [ + { + "@id": "#/declares/shape/Person/property/property/name", + "@type": [ + "shacl:PropertyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "raml-shapes:range": [ + { + "@id": "#/declares/shape/Person/property/property/name/scalar/default-scalar", + "@type": [ + "raml-shapes:ScalarShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "shacl:datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + ], + "shacl:minCount": [ + { + "@value": 0 + } + ], + "shacl:name": [ + { + "@value": "name" + } + ] + } + ], + "shacl:name": [ + { + "@value": "Person" + } + ] + } + ], + "@context": { + "@base": "file://amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-2.graphql", + "shacl": "http://www.w3.org/ns/shacl#", + "raml-shapes": "http://a.ml/vocabularies/shapes#", + "doc": "http://a.ml/vocabularies/document#", + "apiContract": "http://a.ml/vocabularies/apiContract#", + "core": "http://a.ml/vocabularies/core#" + } + } +] diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-2.report b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-2.report new file mode 100644 index 0000000000..426b2674c7 --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-2.report @@ -0,0 +1,14 @@ +ModelId: file://amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-2.graphql +Profile: GraphQL +Conforms: false +Number of results: 1 + +Level: Violation + +- Constraint: http://a.ml/vocabularies/amf/parser#antlr-error + Message: Field 'name' missing field type + Severity: Violation + Target: + Property: + Range: [(2,4)-(2,8)] + Location: diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-3.graphql b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-3.graphql new file mode 100644 index 0000000000..857c9058b7 --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-3.graphql @@ -0,0 +1,8 @@ +type Query { + name: String +} + +type Person { + name: + another: String +} \ No newline at end of file diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-3.jsonld b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-3.jsonld new file mode 100644 index 0000000000..7fd72453bf --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-3.jsonld @@ -0,0 +1,267 @@ +[ + { + "@id": "", + "@type": [ + "doc:Document", + "doc:Fragment", + "doc:Module", + "doc:Unit" + ], + "doc:encodes": [ + { + "@id": "#/web-api", + "@type": [ + "apiContract:WebAPI", + "apiContract:API", + "doc:RootDomainElement", + "doc:DomainElement" + ], + "core:name": [ + { + "@value": "missing-field-type-3.graphql" + } + ], + "apiContract:endpoint": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname", + "@type": [ + "apiContract:EndPoint", + "doc:DomainElement" + ], + "apiContract:path": [ + { + "@value": "/query/name" + } + ], + "core:name": [ + { + "@value": "Query.name" + } + ], + "apiContract:supportedOperation": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name", + "@type": [ + "apiContract:Operation", + "core:Operation", + "doc:DomainElement" + ], + "apiContract:method": [ + { + "@value": "query" + } + ], + "core:name": [ + { + "@value": "Query.name" + } + ], + "apiContract:expects": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name/expects/request", + "@type": [ + "apiContract:Request", + "core:Request", + "apiContract:Message", + "doc:DomainElement" + ] + } + ], + "apiContract:returns": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name/returns/resp/default", + "@type": [ + "apiContract:Response", + "core:Response", + "apiContract:Message", + "doc:DomainElement" + ], + "apiContract:statusCode": [ + { + "@value": "200" + } + ], + "core:name": [ + { + "@value": "default" + } + ], + "apiContract:payload": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name/returns/resp/default/payload/default", + "@type": [ + "apiContract:Payload", + "core:Payload", + "doc:DomainElement" + ], + "raml-shapes:schema": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name/returns/resp/default/payload/default/union/default-union", + "@type": [ + "raml-shapes:UnionShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "raml-shapes:anyOf": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name/returns/resp/default/payload/default/union/default-union/anyOf/nil/default-nil", + "@type": [ + "raml-shapes:NilShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ] + }, + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name/returns/resp/default/payload/default/union/default-union/anyOf/scalar/default-scalar", + "@type": [ + "raml-shapes:ScalarShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "shacl:datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + ] + } + ] + } + ] + } + ], + "apiContract:operationId": [ + { + "@value": "Query.name" + } + ] + } + ] + } + ] + } + ], + "doc:root": [ + { + "@value": true + } + ], + "doc:processingData": [ + { + "@id": "#/BaseUnitProcessingData", + "@type": [ + "doc:APIContractProcessingData" + ], + "apiContract:modelVersion": [ + { + "@value": "3.8.1" + } + ], + "doc:sourceSpec": [ + { + "@value": "GraphQL" + } + ] + } + ], + "doc:declares": [ + { + "@id": "#/declares/shape/Person", + "@type": [ + "shacl:NodeShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "shacl:property": [ + { + "@id": "#/declares/shape/Person/property/property/name", + "@type": [ + "shacl:PropertyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "raml-shapes:range": [ + { + "@id": "#/declares/shape/Person/property/property/name/any/default-any", + "@type": [ + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ] + } + ], + "shacl:minCount": [ + { + "@value": 1 + } + ], + "shacl:name": [ + { + "@value": "name" + } + ] + }, + { + "@id": "#/declares/shape/Person/property/property/another", + "@type": [ + "shacl:PropertyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "raml-shapes:range": [ + { + "@id": "#/declares/shape/Person/property/property/another/scalar/default-scalar", + "@type": [ + "raml-shapes:ScalarShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "shacl:datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + ], + "shacl:minCount": [ + { + "@value": 0 + } + ], + "shacl:name": [ + { + "@value": "another" + } + ] + } + ], + "shacl:name": [ + { + "@value": "Person" + } + ] + } + ], + "@context": { + "@base": "file://amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-3.graphql", + "shacl": "http://www.w3.org/ns/shacl#", + "raml-shapes": "http://a.ml/vocabularies/shapes#", + "doc": "http://a.ml/vocabularies/document#", + "apiContract": "http://a.ml/vocabularies/apiContract#", + "core": "http://a.ml/vocabularies/core#" + } + } +] diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-3.report b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-3.report new file mode 100644 index 0000000000..eef47b5659 --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-3.report @@ -0,0 +1,14 @@ +ModelId: file://amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-3.graphql +Profile: GraphQL +Conforms: false +Number of results: 1 + +Level: Violation + +- Constraint: http://a.ml/vocabularies/amf/parser#antlr-error + Message: Field 'name' missing field type + Severity: Violation + Target: + Property: + Range: [(6,4)-(6,8)] + Location: diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-4.graphql b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-4.graphql new file mode 100644 index 0000000000..5c388dcb9d --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-4.graphql @@ -0,0 +1,8 @@ +type Query { + name: String +} + +type Person { + type: + another: String +} \ No newline at end of file diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-4.jsonld b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-4.jsonld new file mode 100644 index 0000000000..ce1d43fc51 --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-4.jsonld @@ -0,0 +1,267 @@ +[ + { + "@id": "", + "@type": [ + "doc:Document", + "doc:Fragment", + "doc:Module", + "doc:Unit" + ], + "doc:encodes": [ + { + "@id": "#/web-api", + "@type": [ + "apiContract:WebAPI", + "apiContract:API", + "doc:RootDomainElement", + "doc:DomainElement" + ], + "core:name": [ + { + "@value": "missing-field-type-4.graphql" + } + ], + "apiContract:endpoint": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname", + "@type": [ + "apiContract:EndPoint", + "doc:DomainElement" + ], + "apiContract:path": [ + { + "@value": "/query/name" + } + ], + "core:name": [ + { + "@value": "Query.name" + } + ], + "apiContract:supportedOperation": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name", + "@type": [ + "apiContract:Operation", + "core:Operation", + "doc:DomainElement" + ], + "apiContract:method": [ + { + "@value": "query" + } + ], + "core:name": [ + { + "@value": "Query.name" + } + ], + "apiContract:expects": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name/expects/request", + "@type": [ + "apiContract:Request", + "core:Request", + "apiContract:Message", + "doc:DomainElement" + ] + } + ], + "apiContract:returns": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name/returns/resp/default", + "@type": [ + "apiContract:Response", + "core:Response", + "apiContract:Message", + "doc:DomainElement" + ], + "apiContract:statusCode": [ + { + "@value": "200" + } + ], + "core:name": [ + { + "@value": "default" + } + ], + "apiContract:payload": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name/returns/resp/default/payload/default", + "@type": [ + "apiContract:Payload", + "core:Payload", + "doc:DomainElement" + ], + "raml-shapes:schema": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name/returns/resp/default/payload/default/union/default-union", + "@type": [ + "raml-shapes:UnionShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "raml-shapes:anyOf": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name/returns/resp/default/payload/default/union/default-union/anyOf/nil/default-nil", + "@type": [ + "raml-shapes:NilShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ] + }, + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name/returns/resp/default/payload/default/union/default-union/anyOf/scalar/default-scalar", + "@type": [ + "raml-shapes:ScalarShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "shacl:datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + ] + } + ] + } + ] + } + ], + "apiContract:operationId": [ + { + "@value": "Query.name" + } + ] + } + ] + } + ] + } + ], + "doc:root": [ + { + "@value": true + } + ], + "doc:processingData": [ + { + "@id": "#/BaseUnitProcessingData", + "@type": [ + "doc:APIContractProcessingData" + ], + "apiContract:modelVersion": [ + { + "@value": "3.8.1" + } + ], + "doc:sourceSpec": [ + { + "@value": "GraphQL" + } + ] + } + ], + "doc:declares": [ + { + "@id": "#/declares/shape/Person", + "@type": [ + "shacl:NodeShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "shacl:property": [ + { + "@id": "#/declares/shape/Person/property/property/type", + "@type": [ + "shacl:PropertyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "raml-shapes:range": [ + { + "@id": "#/declares/shape/Person/property/property/type/any/default-any", + "@type": [ + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ] + } + ], + "shacl:minCount": [ + { + "@value": 1 + } + ], + "shacl:name": [ + { + "@value": "type" + } + ] + }, + { + "@id": "#/declares/shape/Person/property/property/another", + "@type": [ + "shacl:PropertyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "raml-shapes:range": [ + { + "@id": "#/declares/shape/Person/property/property/another/scalar/default-scalar", + "@type": [ + "raml-shapes:ScalarShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "shacl:datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + ], + "shacl:minCount": [ + { + "@value": 0 + } + ], + "shacl:name": [ + { + "@value": "another" + } + ] + } + ], + "shacl:name": [ + { + "@value": "Person" + } + ] + } + ], + "@context": { + "@base": "file://amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-4.graphql", + "shacl": "http://www.w3.org/ns/shacl#", + "raml-shapes": "http://a.ml/vocabularies/shapes#", + "doc": "http://a.ml/vocabularies/document#", + "apiContract": "http://a.ml/vocabularies/apiContract#", + "core": "http://a.ml/vocabularies/core#" + } + } +] diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-4.report b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-4.report new file mode 100644 index 0000000000..8d9298a6a5 --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-4.report @@ -0,0 +1,14 @@ +ModelId: file://amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-4.graphql +Profile: GraphQL +Conforms: false +Number of results: 1 + +Level: Violation + +- Constraint: http://a.ml/vocabularies/amf/parser#antlr-error + Message: Field 'type' missing field type + Severity: Violation + Target: + Property: + Range: [(6,4)-(6,8)] + Location: diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-5.graphql b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-5.graphql new file mode 100644 index 0000000000..3678e8ad89 --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-5.graphql @@ -0,0 +1,8 @@ +type Query { + name: String +} + +type Person { + type(param: String): + another: String +} \ No newline at end of file diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-5.jsonld b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-5.jsonld new file mode 100644 index 0000000000..e248169a15 --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-5.jsonld @@ -0,0 +1,345 @@ +[ + { + "@id": "", + "@type": [ + "doc:Document", + "doc:Fragment", + "doc:Module", + "doc:Unit" + ], + "doc:encodes": [ + { + "@id": "#/web-api", + "@type": [ + "apiContract:WebAPI", + "apiContract:API", + "doc:RootDomainElement", + "doc:DomainElement" + ], + "core:name": [ + { + "@value": "missing-field-type-5.graphql" + } + ], + "apiContract:endpoint": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname", + "@type": [ + "apiContract:EndPoint", + "doc:DomainElement" + ], + "apiContract:path": [ + { + "@value": "/query/name" + } + ], + "core:name": [ + { + "@value": "Query.name" + } + ], + "apiContract:supportedOperation": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name", + "@type": [ + "apiContract:Operation", + "core:Operation", + "doc:DomainElement" + ], + "apiContract:method": [ + { + "@value": "query" + } + ], + "core:name": [ + { + "@value": "Query.name" + } + ], + "apiContract:expects": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name/expects/request", + "@type": [ + "apiContract:Request", + "core:Request", + "apiContract:Message", + "doc:DomainElement" + ] + } + ], + "apiContract:returns": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name/returns/resp/default", + "@type": [ + "apiContract:Response", + "core:Response", + "apiContract:Message", + "doc:DomainElement" + ], + "apiContract:statusCode": [ + { + "@value": "200" + } + ], + "core:name": [ + { + "@value": "default" + } + ], + "apiContract:payload": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name/returns/resp/default/payload/default", + "@type": [ + "apiContract:Payload", + "core:Payload", + "doc:DomainElement" + ], + "raml-shapes:schema": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name/returns/resp/default/payload/default/union/default-union", + "@type": [ + "raml-shapes:UnionShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "raml-shapes:anyOf": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name/returns/resp/default/payload/default/union/default-union/anyOf/nil/default-nil", + "@type": [ + "raml-shapes:NilShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ] + }, + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name/returns/resp/default/payload/default/union/default-union/anyOf/scalar/default-scalar", + "@type": [ + "raml-shapes:ScalarShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "shacl:datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + ] + } + ] + } + ] + } + ], + "apiContract:operationId": [ + { + "@value": "Query.name" + } + ] + } + ] + } + ] + } + ], + "doc:root": [ + { + "@value": true + } + ], + "doc:processingData": [ + { + "@id": "#/BaseUnitProcessingData", + "@type": [ + "doc:APIContractProcessingData" + ], + "apiContract:modelVersion": [ + { + "@value": "3.8.1" + } + ], + "doc:sourceSpec": [ + { + "@value": "GraphQL" + } + ] + } + ], + "doc:declares": [ + { + "@id": "#/declares/shape/Person", + "@type": [ + "shacl:NodeShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "shacl:property": [ + { + "@id": "#/declares/shape/Person/property/property/another", + "@type": [ + "shacl:PropertyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "raml-shapes:range": [ + { + "@id": "#/declares/shape/Person/property/property/another/scalar/default-scalar", + "@type": [ + "raml-shapes:ScalarShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "shacl:datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + ], + "shacl:minCount": [ + { + "@value": 0 + } + ], + "shacl:name": [ + { + "@value": "another" + } + ] + } + ], + "raml-shapes:supportedOperation": [ + { + "@id": "#/declares/shape/Person/supportedOperation/type", + "@type": [ + "raml-shapes:Operation", + "core:Operation", + "doc:DomainElement" + ], + "core:name": [ + { + "@value": "type" + } + ], + "raml-shapes:expects": [ + { + "@id": "#/declares/shape/Person/supportedOperation/type/expects/request", + "@type": [ + "raml-shapes:Request", + "core:Request", + "doc:DomainElement" + ], + "raml-shapes:parameter": [ + { + "@id": "#/declares/shape/Person/supportedOperation/type/expects/request/parameter/parameter/param", + "@type": [ + "raml-shapes:Parameter", + "core:Parameter", + "doc:DomainElement" + ], + "core:name": [ + { + "@value": "param" + } + ], + "raml-shapes:binding": [ + { + "@value": "query" + } + ], + "raml-shapes:required": [ + { + "@value": false + } + ], + "raml-shapes:schema": [ + { + "@id": "#/declares/shape/Person/supportedOperation/type/expects/request/parameter/parameter/param/scalar/default-scalar", + "@type": [ + "raml-shapes:ScalarShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "shacl:datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + ] + } + ] + } + ], + "raml-shapes:returns": [ + { + "@id": "#/declares/shape/Person/supportedOperation/type/returns/response", + "@type": [ + "raml-shapes:Response", + "core:Response", + "doc:DomainElement" + ], + "core:name": [ + { + "@value": "default" + } + ], + "raml-shapes:payload": [ + { + "@id": "#/declares/shape/Person/supportedOperation/type/returns/response/default", + "@type": [ + "raml-shapes:Payload", + "core:Payload", + "doc:DomainElement" + ], + "core:name": [ + { + "@value": "default" + } + ], + "raml-shapes:schema": [ + { + "@id": "#/declares/shape/Person/supportedOperation/type/returns/response/default/any/default-any", + "@type": [ + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ] + } + ] + } + ] + } + ] + } + ], + "shacl:name": [ + { + "@value": "Person" + } + ] + } + ], + "@context": { + "@base": "file://amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-5.graphql", + "shacl": "http://www.w3.org/ns/shacl#", + "raml-shapes": "http://a.ml/vocabularies/shapes#", + "doc": "http://a.ml/vocabularies/document#", + "apiContract": "http://a.ml/vocabularies/apiContract#", + "core": "http://a.ml/vocabularies/core#" + } + } +] diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-5.report b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-5.report new file mode 100644 index 0000000000..e196b9a336 --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-5.report @@ -0,0 +1,14 @@ +ModelId: file://amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-5.graphql +Profile: GraphQL +Conforms: false +Number of results: 1 + +Level: Violation + +- Constraint: http://a.ml/vocabularies/amf/parser#antlr-error + Message: Field 'type' missing field type + Severity: Violation + Target: + Property: + Range: [(6,4)-(6,8)] + Location: diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-6.graphql b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-6.graphql new file mode 100644 index 0000000000..2855408b02 --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-6.graphql @@ -0,0 +1,8 @@ +type Query { + type(param: String): + name: String +} + +type Person { + another: String +} \ No newline at end of file diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-6.jsonld b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-6.jsonld new file mode 100644 index 0000000000..405fb5196f --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-6.jsonld @@ -0,0 +1,374 @@ +[ + { + "@id": "", + "@type": [ + "doc:Document", + "doc:Fragment", + "doc:Module", + "doc:Unit" + ], + "doc:encodes": [ + { + "@id": "#/web-api", + "@type": [ + "apiContract:WebAPI", + "apiContract:API", + "doc:RootDomainElement", + "doc:DomainElement" + ], + "core:name": [ + { + "@value": "missing-field-type-6.graphql" + } + ], + "apiContract:endpoint": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Ftype", + "@type": [ + "apiContract:EndPoint", + "doc:DomainElement" + ], + "apiContract:path": [ + { + "@value": "/query/type" + } + ], + "core:name": [ + { + "@value": "Query.type" + } + ], + "apiContract:supportedOperation": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Ftype/supportedOperation/query/Query.type", + "@type": [ + "apiContract:Operation", + "core:Operation", + "doc:DomainElement" + ], + "apiContract:method": [ + { + "@value": "query" + } + ], + "core:name": [ + { + "@value": "Query.type" + } + ], + "apiContract:expects": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Ftype/supportedOperation/query/Query.type/expects/request", + "@type": [ + "apiContract:Request", + "core:Request", + "apiContract:Message", + "doc:DomainElement" + ], + "apiContract:parameter": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Ftype/supportedOperation/query/Query.type/expects/request/parameter/parameter/query/param", + "@type": [ + "apiContract:Parameter", + "core:Parameter", + "doc:DomainElement" + ], + "core:name": [ + { + "@value": "param" + } + ], + "apiContract:required": [ + { + "@value": false + } + ], + "apiContract:binding": [ + { + "@value": "query" + } + ], + "raml-shapes:schema": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Ftype/supportedOperation/query/Query.type/expects/request/parameter/parameter/query/param/scalar/default-scalar", + "@type": [ + "raml-shapes:ScalarShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "shacl:datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + ] + } + ] + } + ], + "apiContract:returns": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Ftype/supportedOperation/query/Query.type/returns/resp/default", + "@type": [ + "apiContract:Response", + "core:Response", + "apiContract:Message", + "doc:DomainElement" + ], + "apiContract:statusCode": [ + { + "@value": "200" + } + ], + "core:name": [ + { + "@value": "default" + } + ], + "apiContract:payload": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Ftype/supportedOperation/query/Query.type/returns/resp/default/payload/default", + "@type": [ + "apiContract:Payload", + "core:Payload", + "doc:DomainElement" + ], + "raml-shapes:schema": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Ftype/supportedOperation/query/Query.type/returns/resp/default/payload/default/any/default-any", + "@type": [ + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ] + } + ] + } + ] + } + ], + "apiContract:operationId": [ + { + "@value": "Query.type" + } + ] + } + ] + }, + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname", + "@type": [ + "apiContract:EndPoint", + "doc:DomainElement" + ], + "apiContract:path": [ + { + "@value": "/query/name" + } + ], + "core:name": [ + { + "@value": "Query.name" + } + ], + "apiContract:supportedOperation": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name", + "@type": [ + "apiContract:Operation", + "core:Operation", + "doc:DomainElement" + ], + "apiContract:method": [ + { + "@value": "query" + } + ], + "core:name": [ + { + "@value": "Query.name" + } + ], + "apiContract:expects": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name/expects/request", + "@type": [ + "apiContract:Request", + "core:Request", + "apiContract:Message", + "doc:DomainElement" + ] + } + ], + "apiContract:returns": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name/returns/resp/default", + "@type": [ + "apiContract:Response", + "core:Response", + "apiContract:Message", + "doc:DomainElement" + ], + "apiContract:statusCode": [ + { + "@value": "200" + } + ], + "core:name": [ + { + "@value": "default" + } + ], + "apiContract:payload": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name/returns/resp/default/payload/default", + "@type": [ + "apiContract:Payload", + "core:Payload", + "doc:DomainElement" + ], + "raml-shapes:schema": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name/returns/resp/default/payload/default/union/default-union", + "@type": [ + "raml-shapes:UnionShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "raml-shapes:anyOf": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name/returns/resp/default/payload/default/union/default-union/anyOf/nil/default-nil", + "@type": [ + "raml-shapes:NilShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ] + }, + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name/returns/resp/default/payload/default/union/default-union/anyOf/scalar/default-scalar", + "@type": [ + "raml-shapes:ScalarShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "shacl:datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + ] + } + ] + } + ] + } + ], + "apiContract:operationId": [ + { + "@value": "Query.name" + } + ] + } + ] + } + ] + } + ], + "doc:root": [ + { + "@value": true + } + ], + "doc:processingData": [ + { + "@id": "#/BaseUnitProcessingData", + "@type": [ + "doc:APIContractProcessingData" + ], + "apiContract:modelVersion": [ + { + "@value": "3.8.1" + } + ], + "doc:sourceSpec": [ + { + "@value": "GraphQL" + } + ] + } + ], + "doc:declares": [ + { + "@id": "#/declares/shape/Person", + "@type": [ + "shacl:NodeShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "shacl:property": [ + { + "@id": "#/declares/shape/Person/property/property/another", + "@type": [ + "shacl:PropertyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "raml-shapes:range": [ + { + "@id": "#/declares/shape/Person/property/property/another/scalar/default-scalar", + "@type": [ + "raml-shapes:ScalarShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "shacl:datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + ], + "shacl:minCount": [ + { + "@value": 0 + } + ], + "shacl:name": [ + { + "@value": "another" + } + ] + } + ], + "shacl:name": [ + { + "@value": "Person" + } + ] + } + ], + "@context": { + "@base": "file://amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-6.graphql", + "shacl": "http://www.w3.org/ns/shacl#", + "raml-shapes": "http://a.ml/vocabularies/shapes#", + "doc": "http://a.ml/vocabularies/document#", + "apiContract": "http://a.ml/vocabularies/apiContract#", + "core": "http://a.ml/vocabularies/core#" + } + } +] diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-6.report b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-6.report new file mode 100644 index 0000000000..26ec0448b4 --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-6.report @@ -0,0 +1,14 @@ +ModelId: file://amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-6.graphql +Profile: GraphQL +Conforms: false +Number of results: 1 + +Level: Violation + +- Constraint: http://a.ml/vocabularies/amf/parser#antlr-error + Message: Field 'type' missing field type + Severity: Violation + Target: + Property: + Range: [(2,4)-(2,8)] + Location: diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-7.graphql b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-7.graphql new file mode 100644 index 0000000000..0a8bfa9d46 --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-7.graphql @@ -0,0 +1,9 @@ +type Query { + name1: + name2: + name3: +} + +type Person { + another: String +} \ No newline at end of file diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-7.jsonld b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-7.jsonld new file mode 100644 index 0000000000..4738201e41 --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-7.jsonld @@ -0,0 +1,400 @@ +[ + { + "@id": "", + "@type": [ + "doc:Document", + "doc:Fragment", + "doc:Module", + "doc:Unit" + ], + "doc:encodes": [ + { + "@id": "#/web-api", + "@type": [ + "apiContract:WebAPI", + "apiContract:API", + "doc:RootDomainElement", + "doc:DomainElement" + ], + "core:name": [ + { + "@value": "missing-field-type-7.graphql" + } + ], + "apiContract:endpoint": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname1", + "@type": [ + "apiContract:EndPoint", + "doc:DomainElement" + ], + "apiContract:path": [ + { + "@value": "/query/name1" + } + ], + "core:name": [ + { + "@value": "Query.name1" + } + ], + "apiContract:supportedOperation": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname1/supportedOperation/query/Query.name1", + "@type": [ + "apiContract:Operation", + "core:Operation", + "doc:DomainElement" + ], + "apiContract:method": [ + { + "@value": "query" + } + ], + "core:name": [ + { + "@value": "Query.name1" + } + ], + "apiContract:expects": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname1/supportedOperation/query/Query.name1/expects/request", + "@type": [ + "apiContract:Request", + "core:Request", + "apiContract:Message", + "doc:DomainElement" + ] + } + ], + "apiContract:returns": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname1/supportedOperation/query/Query.name1/returns/resp/default", + "@type": [ + "apiContract:Response", + "core:Response", + "apiContract:Message", + "doc:DomainElement" + ], + "apiContract:statusCode": [ + { + "@value": "200" + } + ], + "core:name": [ + { + "@value": "default" + } + ], + "apiContract:payload": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname1/supportedOperation/query/Query.name1/returns/resp/default/payload/default", + "@type": [ + "apiContract:Payload", + "core:Payload", + "doc:DomainElement" + ], + "raml-shapes:schema": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname1/supportedOperation/query/Query.name1/returns/resp/default/payload/default/any/default-any", + "@type": [ + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ] + } + ] + } + ] + } + ], + "apiContract:operationId": [ + { + "@value": "Query.name1" + } + ] + } + ] + }, + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname2", + "@type": [ + "apiContract:EndPoint", + "doc:DomainElement" + ], + "apiContract:path": [ + { + "@value": "/query/name2" + } + ], + "core:name": [ + { + "@value": "Query.name2" + } + ], + "apiContract:supportedOperation": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname2/supportedOperation/query/Query.name2", + "@type": [ + "apiContract:Operation", + "core:Operation", + "doc:DomainElement" + ], + "apiContract:method": [ + { + "@value": "query" + } + ], + "core:name": [ + { + "@value": "Query.name2" + } + ], + "apiContract:expects": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname2/supportedOperation/query/Query.name2/expects/request", + "@type": [ + "apiContract:Request", + "core:Request", + "apiContract:Message", + "doc:DomainElement" + ] + } + ], + "apiContract:returns": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname2/supportedOperation/query/Query.name2/returns/resp/default", + "@type": [ + "apiContract:Response", + "core:Response", + "apiContract:Message", + "doc:DomainElement" + ], + "apiContract:statusCode": [ + { + "@value": "200" + } + ], + "core:name": [ + { + "@value": "default" + } + ], + "apiContract:payload": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname2/supportedOperation/query/Query.name2/returns/resp/default/payload/default", + "@type": [ + "apiContract:Payload", + "core:Payload", + "doc:DomainElement" + ], + "raml-shapes:schema": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname2/supportedOperation/query/Query.name2/returns/resp/default/payload/default/any/default-any", + "@type": [ + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ] + } + ] + } + ] + } + ], + "apiContract:operationId": [ + { + "@value": "Query.name2" + } + ] + } + ] + }, + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname3", + "@type": [ + "apiContract:EndPoint", + "doc:DomainElement" + ], + "apiContract:path": [ + { + "@value": "/query/name3" + } + ], + "core:name": [ + { + "@value": "Query.name3" + } + ], + "apiContract:supportedOperation": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname3/supportedOperation/query/Query.name3", + "@type": [ + "apiContract:Operation", + "core:Operation", + "doc:DomainElement" + ], + "apiContract:method": [ + { + "@value": "query" + } + ], + "core:name": [ + { + "@value": "Query.name3" + } + ], + "apiContract:expects": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname3/supportedOperation/query/Query.name3/expects/request", + "@type": [ + "apiContract:Request", + "core:Request", + "apiContract:Message", + "doc:DomainElement" + ] + } + ], + "apiContract:returns": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname3/supportedOperation/query/Query.name3/returns/resp/default", + "@type": [ + "apiContract:Response", + "core:Response", + "apiContract:Message", + "doc:DomainElement" + ], + "apiContract:statusCode": [ + { + "@value": "200" + } + ], + "core:name": [ + { + "@value": "default" + } + ], + "apiContract:payload": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname3/supportedOperation/query/Query.name3/returns/resp/default/payload/default", + "@type": [ + "apiContract:Payload", + "core:Payload", + "doc:DomainElement" + ], + "raml-shapes:schema": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname3/supportedOperation/query/Query.name3/returns/resp/default/payload/default/any/default-any", + "@type": [ + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ] + } + ] + } + ] + } + ], + "apiContract:operationId": [ + { + "@value": "Query.name3" + } + ] + } + ] + } + ] + } + ], + "doc:root": [ + { + "@value": true + } + ], + "doc:processingData": [ + { + "@id": "#/BaseUnitProcessingData", + "@type": [ + "doc:APIContractProcessingData" + ], + "apiContract:modelVersion": [ + { + "@value": "3.8.1" + } + ], + "doc:sourceSpec": [ + { + "@value": "GraphQL" + } + ] + } + ], + "doc:declares": [ + { + "@id": "#/declares/shape/Person", + "@type": [ + "shacl:NodeShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "shacl:property": [ + { + "@id": "#/declares/shape/Person/property/property/another", + "@type": [ + "shacl:PropertyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "raml-shapes:range": [ + { + "@id": "#/declares/shape/Person/property/property/another/scalar/default-scalar", + "@type": [ + "raml-shapes:ScalarShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "shacl:datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + ], + "shacl:minCount": [ + { + "@value": 0 + } + ], + "shacl:name": [ + { + "@value": "another" + } + ] + } + ], + "shacl:name": [ + { + "@value": "Person" + } + ] + } + ], + "@context": { + "@base": "file://amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-7.graphql", + "shacl": "http://www.w3.org/ns/shacl#", + "raml-shapes": "http://a.ml/vocabularies/shapes#", + "doc": "http://a.ml/vocabularies/document#", + "apiContract": "http://a.ml/vocabularies/apiContract#", + "core": "http://a.ml/vocabularies/core#" + } + } +] diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-7.report b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-7.report new file mode 100644 index 0000000000..1dcda7a542 --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-7.report @@ -0,0 +1,30 @@ +ModelId: file://amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-7.graphql +Profile: GraphQL +Conforms: false +Number of results: 3 + +Level: Violation + +- Constraint: http://a.ml/vocabularies/amf/parser#antlr-error + Message: Field 'name1' missing field type + Severity: Violation + Target: + Property: + Range: [(2,4)-(2,9)] + Location: + +- Constraint: http://a.ml/vocabularies/amf/parser#antlr-error + Message: Field 'name2' missing field type + Severity: Violation + Target: + Property: + Range: [(3,4)-(3,9)] + Location: + +- Constraint: http://a.ml/vocabularies/amf/parser#antlr-error + Message: Field 'name3' missing field type + Severity: Violation + Target: + Property: + Range: [(4,4)-(4,9)] + Location: diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-8.graphql b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-8.graphql new file mode 100644 index 0000000000..b35c29c686 --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-8.graphql @@ -0,0 +1,9 @@ +type Query { + name: String +} + +type Person { + name1: + name2: + name3: +} \ No newline at end of file diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-8.jsonld b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-8.jsonld new file mode 100644 index 0000000000..0da2122e46 --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-8.jsonld @@ -0,0 +1,291 @@ +[ + { + "@id": "", + "@type": [ + "doc:Document", + "doc:Fragment", + "doc:Module", + "doc:Unit" + ], + "doc:encodes": [ + { + "@id": "#/web-api", + "@type": [ + "apiContract:WebAPI", + "apiContract:API", + "doc:RootDomainElement", + "doc:DomainElement" + ], + "core:name": [ + { + "@value": "missing-field-type-8.graphql" + } + ], + "apiContract:endpoint": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname", + "@type": [ + "apiContract:EndPoint", + "doc:DomainElement" + ], + "apiContract:path": [ + { + "@value": "/query/name" + } + ], + "core:name": [ + { + "@value": "Query.name" + } + ], + "apiContract:supportedOperation": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name", + "@type": [ + "apiContract:Operation", + "core:Operation", + "doc:DomainElement" + ], + "apiContract:method": [ + { + "@value": "query" + } + ], + "core:name": [ + { + "@value": "Query.name" + } + ], + "apiContract:expects": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name/expects/request", + "@type": [ + "apiContract:Request", + "core:Request", + "apiContract:Message", + "doc:DomainElement" + ] + } + ], + "apiContract:returns": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name/returns/resp/default", + "@type": [ + "apiContract:Response", + "core:Response", + "apiContract:Message", + "doc:DomainElement" + ], + "apiContract:statusCode": [ + { + "@value": "200" + } + ], + "core:name": [ + { + "@value": "default" + } + ], + "apiContract:payload": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name/returns/resp/default/payload/default", + "@type": [ + "apiContract:Payload", + "core:Payload", + "doc:DomainElement" + ], + "raml-shapes:schema": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name/returns/resp/default/payload/default/union/default-union", + "@type": [ + "raml-shapes:UnionShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "raml-shapes:anyOf": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name/returns/resp/default/payload/default/union/default-union/anyOf/nil/default-nil", + "@type": [ + "raml-shapes:NilShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ] + }, + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name/returns/resp/default/payload/default/union/default-union/anyOf/scalar/default-scalar", + "@type": [ + "raml-shapes:ScalarShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "shacl:datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + ] + } + ] + } + ] + } + ], + "apiContract:operationId": [ + { + "@value": "Query.name" + } + ] + } + ] + } + ] + } + ], + "doc:root": [ + { + "@value": true + } + ], + "doc:processingData": [ + { + "@id": "#/BaseUnitProcessingData", + "@type": [ + "doc:APIContractProcessingData" + ], + "apiContract:modelVersion": [ + { + "@value": "3.8.1" + } + ], + "doc:sourceSpec": [ + { + "@value": "GraphQL" + } + ] + } + ], + "doc:declares": [ + { + "@id": "#/declares/shape/Person", + "@type": [ + "shacl:NodeShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "shacl:property": [ + { + "@id": "#/declares/shape/Person/property/property/name1", + "@type": [ + "shacl:PropertyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "raml-shapes:range": [ + { + "@id": "#/declares/shape/Person/property/property/name1/any/default-any", + "@type": [ + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ] + } + ], + "shacl:minCount": [ + { + "@value": 1 + } + ], + "shacl:name": [ + { + "@value": "name1" + } + ] + }, + { + "@id": "#/declares/shape/Person/property/property/name2", + "@type": [ + "shacl:PropertyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "raml-shapes:range": [ + { + "@id": "#/declares/shape/Person/property/property/name2/any/default-any", + "@type": [ + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ] + } + ], + "shacl:minCount": [ + { + "@value": 1 + } + ], + "shacl:name": [ + { + "@value": "name2" + } + ] + }, + { + "@id": "#/declares/shape/Person/property/property/name3", + "@type": [ + "shacl:PropertyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "raml-shapes:range": [ + { + "@id": "#/declares/shape/Person/property/property/name3/any/default-any", + "@type": [ + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ] + } + ], + "shacl:minCount": [ + { + "@value": 1 + } + ], + "shacl:name": [ + { + "@value": "name3" + } + ] + } + ], + "shacl:name": [ + { + "@value": "Person" + } + ] + } + ], + "@context": { + "@base": "file://amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-8.graphql", + "shacl": "http://www.w3.org/ns/shacl#", + "raml-shapes": "http://a.ml/vocabularies/shapes#", + "doc": "http://a.ml/vocabularies/document#", + "apiContract": "http://a.ml/vocabularies/apiContract#", + "core": "http://a.ml/vocabularies/core#" + } + } +] diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-8.report b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-8.report new file mode 100644 index 0000000000..dff6f5ea79 --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-8.report @@ -0,0 +1,30 @@ +ModelId: file://amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-field-type-8.graphql +Profile: GraphQL +Conforms: false +Number of results: 3 + +Level: Violation + +- Constraint: http://a.ml/vocabularies/amf/parser#antlr-error + Message: Field 'name1' missing field type + Severity: Violation + Target: + Property: + Range: [(6,4)-(6,9)] + Location: + +- Constraint: http://a.ml/vocabularies/amf/parser#antlr-error + Message: Field 'name2' missing field type + Severity: Violation + Target: + Property: + Range: [(7,4)-(7,9)] + Location: + +- Constraint: http://a.ml/vocabularies/amf/parser#antlr-error + Message: Field 'name3' missing field type + Severity: Violation + Target: + Property: + Range: [(8,4)-(8,9)] + Location: diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-lbracket-and-lparen.graphql b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-lbracket-and-lparen.graphql new file mode 100644 index 0000000000..62cf389178 --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-lbracket-and-lparen.graphql @@ -0,0 +1,7 @@ +type Query + namea: String): String +} + +type Person { + name: String +} \ No newline at end of file diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-lbracket-and-lparen.jsonld b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-lbracket-and-lparen.jsonld new file mode 100644 index 0000000000..6c8a902d1d --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-lbracket-and-lparen.jsonld @@ -0,0 +1,114 @@ +[ + { + "@id": "", + "@type": [ + "doc:Document", + "doc:Fragment", + "doc:Module", + "doc:Unit" + ], + "doc:encodes": [ + { + "@id": "#/web-api", + "@type": [ + "apiContract:WebAPI", + "apiContract:API", + "doc:RootDomainElement", + "doc:DomainElement" + ], + "core:name": [ + { + "@value": "missing-lbracket-and-lparen.graphql" + } + ], + "apiContract:endpoint": [] + } + ], + "doc:root": [ + { + "@value": true + } + ], + "doc:processingData": [ + { + "@id": "#/BaseUnitProcessingData", + "@type": [ + "doc:APIContractProcessingData" + ], + "apiContract:modelVersion": [ + { + "@value": "3.8.1" + } + ], + "doc:sourceSpec": [ + { + "@value": "GraphQL" + } + ] + } + ], + "doc:declares": [ + { + "@id": "#/declares/shape/Person", + "@type": [ + "shacl:NodeShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "shacl:property": [ + { + "@id": "#/declares/shape/Person/property/property/name", + "@type": [ + "shacl:PropertyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "raml-shapes:range": [ + { + "@id": "#/declares/shape/Person/property/property/name/scalar/default-scalar", + "@type": [ + "raml-shapes:ScalarShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "shacl:datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + ], + "shacl:minCount": [ + { + "@value": 0 + } + ], + "shacl:name": [ + { + "@value": "name" + } + ] + } + ], + "shacl:name": [ + { + "@value": "Person" + } + ] + } + ], + "@context": { + "@base": "file://amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-lbracket-and-lparen.graphql", + "raml-shapes": "http://a.ml/vocabularies/shapes#", + "shacl": "http://www.w3.org/ns/shacl#", + "doc": "http://a.ml/vocabularies/document#", + "apiContract": "http://a.ml/vocabularies/apiContract#", + "core": "http://a.ml/vocabularies/core#" + } + } +] diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-lbracket-and-lparen.report b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-lbracket-and-lparen.report new file mode 100644 index 0000000000..f93346c78e --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-lbracket-and-lparen.report @@ -0,0 +1,14 @@ +ModelId: file://amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-lbracket-and-lparen.graphql +Profile: GraphQL +Conforms: false +Number of results: 1 + +Level: Violation + +- Constraint: http://a.ml/vocabularies/amf/parser#antlr-error + Message: Syntax error in the following text: 'namea' + Severity: Violation + Target: + Property: + Range: [(2,4)-(2,9)] + Location: diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-lbracket.graphql b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-lbracket.graphql new file mode 100644 index 0000000000..e9e7ee9eb8 --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-lbracket.graphql @@ -0,0 +1,7 @@ +type Query + name: String +} + +type Person { + name: String +} \ No newline at end of file diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-lbracket.jsonld b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-lbracket.jsonld new file mode 100644 index 0000000000..d74ab7ea8b --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-lbracket.jsonld @@ -0,0 +1,114 @@ +[ + { + "@id": "", + "@type": [ + "doc:Document", + "doc:Fragment", + "doc:Module", + "doc:Unit" + ], + "doc:encodes": [ + { + "@id": "#/web-api", + "@type": [ + "apiContract:WebAPI", + "apiContract:API", + "doc:RootDomainElement", + "doc:DomainElement" + ], + "core:name": [ + { + "@value": "missing-lbracket.graphql" + } + ], + "apiContract:endpoint": [] + } + ], + "doc:root": [ + { + "@value": true + } + ], + "doc:processingData": [ + { + "@id": "#/BaseUnitProcessingData", + "@type": [ + "doc:APIContractProcessingData" + ], + "apiContract:modelVersion": [ + { + "@value": "3.8.1" + } + ], + "doc:sourceSpec": [ + { + "@value": "GraphQL" + } + ] + } + ], + "doc:declares": [ + { + "@id": "#/declares/shape/Person", + "@type": [ + "shacl:NodeShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "shacl:property": [ + { + "@id": "#/declares/shape/Person/property/property/name", + "@type": [ + "shacl:PropertyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "raml-shapes:range": [ + { + "@id": "#/declares/shape/Person/property/property/name/scalar/default-scalar", + "@type": [ + "raml-shapes:ScalarShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "shacl:datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + ], + "shacl:minCount": [ + { + "@value": 0 + } + ], + "shacl:name": [ + { + "@value": "name" + } + ] + } + ], + "shacl:name": [ + { + "@value": "Person" + } + ] + } + ], + "@context": { + "@base": "file://amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-lbracket.graphql", + "raml-shapes": "http://a.ml/vocabularies/shapes#", + "shacl": "http://www.w3.org/ns/shacl#", + "doc": "http://a.ml/vocabularies/document#", + "apiContract": "http://a.ml/vocabularies/apiContract#", + "core": "http://a.ml/vocabularies/core#" + } + } +] diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-lbracket.report b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-lbracket.report new file mode 100644 index 0000000000..c2baae8863 --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-lbracket.report @@ -0,0 +1,14 @@ +ModelId: file://amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-lbracket.graphql +Profile: GraphQL +Conforms: false +Number of results: 1 + +Level: Violation + +- Constraint: http://a.ml/vocabularies/amf/parser#antlr-error + Message: Syntax error in the following text: 'name' + Severity: Violation + Target: + Property: + Range: [(2,4)-(2,8)] + Location: diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-rbracket-and-rparen.graphql b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-rbracket-and-rparen.graphql new file mode 100644 index 0000000000..081523d2cc --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-rbracket-and-rparen.graphql @@ -0,0 +1,6 @@ +type Query { + name(a: String: String + +type Person { + name: String +} \ No newline at end of file diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-rbracket-and-rparen.jsonld b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-rbracket-and-rparen.jsonld new file mode 100644 index 0000000000..6fda04119e --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-rbracket-and-rparen.jsonld @@ -0,0 +1,57 @@ +[ + { + "@id": "", + "@type": [ + "doc:Document", + "doc:Fragment", + "doc:Module", + "doc:Unit" + ], + "doc:encodes": [ + { + "@id": "#/web-api", + "@type": [ + "apiContract:WebAPI", + "apiContract:API", + "doc:RootDomainElement", + "doc:DomainElement" + ], + "core:name": [ + { + "@value": "missing-rbracket-and-rparen.graphql" + } + ], + "apiContract:endpoint": [] + } + ], + "doc:root": [ + { + "@value": true + } + ], + "doc:processingData": [ + { + "@id": "#/BaseUnitProcessingData", + "@type": [ + "doc:APIContractProcessingData" + ], + "apiContract:modelVersion": [ + { + "@value": "3.8.1" + } + ], + "doc:sourceSpec": [ + { + "@value": "GraphQL" + } + ] + } + ], + "@context": { + "@base": "file://amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-rbracket-and-rparen.graphql", + "doc": "http://a.ml/vocabularies/document#", + "apiContract": "http://a.ml/vocabularies/apiContract#", + "core": "http://a.ml/vocabularies/core#" + } + } +] diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-rbracket-and-rparen.report b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-rbracket-and-rparen.report new file mode 100644 index 0000000000..ef131ec3dd --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-rbracket-and-rparen.report @@ -0,0 +1,38 @@ +ModelId: file://amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-rbracket-and-rparen.graphql +Profile: GraphQL +Conforms: false +Number of results: 4 + +Level: Violation + +- Constraint: http://a.ml/vocabularies/amf/parser#antlr-error + Message: Syntax error in the following text: ':' + Severity: Violation + Target: + Property: + Range: [(2,18)-(2,19)] + Location: + +- Constraint: http://a.ml/vocabularies/amf/parser#antlr-error + Message: Syntax error in the following text: 'type' + Severity: Violation + Target: + Property: + Range: [(4,0)-(4,4)] + Location: + +- Constraint: http://a.ml/vocabularies/amf/parser#antlr-error + Message: Syntax error in the following text: '{' + Severity: Violation + Target: + Property: + Range: [(4,12)-(4,13)] + Location: + +- Constraint: http://a.ml/vocabularies/amf/parser#antlr-error + Message: Syntax error: Unexpected end of file + Severity: Violation + Target: + Property: + Range: [(6,1)-(6,1)] + Location: diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-rbracket.graphql b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-rbracket.graphql new file mode 100644 index 0000000000..283d13c544 --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-rbracket.graphql @@ -0,0 +1,6 @@ +type Query { + name: String + +type Person { + name: String +} \ No newline at end of file diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-rbracket.jsonld b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-rbracket.jsonld new file mode 100644 index 0000000000..d91f6134d0 --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-rbracket.jsonld @@ -0,0 +1,57 @@ +[ + { + "@id": "", + "@type": [ + "doc:Document", + "doc:Fragment", + "doc:Module", + "doc:Unit" + ], + "doc:encodes": [ + { + "@id": "#/web-api", + "@type": [ + "apiContract:WebAPI", + "apiContract:API", + "doc:RootDomainElement", + "doc:DomainElement" + ], + "core:name": [ + { + "@value": "missing-rbracket.graphql" + } + ], + "apiContract:endpoint": [] + } + ], + "doc:root": [ + { + "@value": true + } + ], + "doc:processingData": [ + { + "@id": "#/BaseUnitProcessingData", + "@type": [ + "doc:APIContractProcessingData" + ], + "apiContract:modelVersion": [ + { + "@value": "3.8.1" + } + ], + "doc:sourceSpec": [ + { + "@value": "GraphQL" + } + ] + } + ], + "@context": { + "@base": "file://amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-rbracket.graphql", + "doc": "http://a.ml/vocabularies/document#", + "apiContract": "http://a.ml/vocabularies/apiContract#", + "core": "http://a.ml/vocabularies/core#" + } + } +] diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-rbracket.report b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-rbracket.report new file mode 100644 index 0000000000..10f7cf2579 --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-rbracket.report @@ -0,0 +1,14 @@ +ModelId: file://amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-rbracket.graphql +Profile: GraphQL +Conforms: false +Number of results: 1 + +Level: Violation + +- Constraint: http://a.ml/vocabularies/amf/parser#antlr-error + Message: Syntax error: Unexpected end of file + Severity: Violation + Target: + Property: + Range: [(6,1)-(6,1)] + Location: diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-rparen.graphql b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-rparen.graphql new file mode 100644 index 0000000000..ae91916187 --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-rparen.graphql @@ -0,0 +1,7 @@ +type Query { + namea: String): String +} + +type Person { + name: String +} \ No newline at end of file diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-rparen.jsonld b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-rparen.jsonld new file mode 100644 index 0000000000..f9a0f664a1 --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-rparen.jsonld @@ -0,0 +1,114 @@ +[ + { + "@id": "", + "@type": [ + "doc:Document", + "doc:Fragment", + "doc:Module", + "doc:Unit" + ], + "doc:encodes": [ + { + "@id": "#/web-api", + "@type": [ + "apiContract:WebAPI", + "apiContract:API", + "doc:RootDomainElement", + "doc:DomainElement" + ], + "core:name": [ + { + "@value": "missing-rparen.graphql" + } + ], + "apiContract:endpoint": [] + } + ], + "doc:root": [ + { + "@value": true + } + ], + "doc:processingData": [ + { + "@id": "#/BaseUnitProcessingData", + "@type": [ + "doc:APIContractProcessingData" + ], + "apiContract:modelVersion": [ + { + "@value": "3.8.1" + } + ], + "doc:sourceSpec": [ + { + "@value": "GraphQL" + } + ] + } + ], + "doc:declares": [ + { + "@id": "#/declares/shape/Person", + "@type": [ + "shacl:NodeShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "shacl:property": [ + { + "@id": "#/declares/shape/Person/property/property/name", + "@type": [ + "shacl:PropertyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "raml-shapes:range": [ + { + "@id": "#/declares/shape/Person/property/property/name/scalar/default-scalar", + "@type": [ + "raml-shapes:ScalarShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "shacl:datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + ], + "shacl:minCount": [ + { + "@value": 0 + } + ], + "shacl:name": [ + { + "@value": "name" + } + ] + } + ], + "shacl:name": [ + { + "@value": "Person" + } + ] + } + ], + "@context": { + "@base": "file://amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-rparen.graphql", + "raml-shapes": "http://a.ml/vocabularies/shapes#", + "shacl": "http://www.w3.org/ns/shacl#", + "doc": "http://a.ml/vocabularies/document#", + "apiContract": "http://a.ml/vocabularies/apiContract#", + "core": "http://a.ml/vocabularies/core#" + } + } +] diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-rparen.report b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-rparen.report new file mode 100644 index 0000000000..470769feea --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-rparen.report @@ -0,0 +1,14 @@ +ModelId: file://amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-rparen.graphql +Profile: GraphQL +Conforms: false +Number of results: 1 + +Level: Violation + +- Constraint: http://a.ml/vocabularies/amf/parser#antlr-error + Message: Syntax error in the following text: ')' + Severity: Violation + Target: + Property: + Range: [(2,17)-(2,18)] + Location: diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-slbracket.graphql b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-slbracket.graphql new file mode 100644 index 0000000000..42df57eb06 --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-slbracket.graphql @@ -0,0 +1,7 @@ +type Query { + names: String] +} + +type Person { + name: String +} \ No newline at end of file diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-slbracket.jsonld b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-slbracket.jsonld new file mode 100644 index 0000000000..af7e372a48 --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-slbracket.jsonld @@ -0,0 +1,114 @@ +[ + { + "@id": "", + "@type": [ + "doc:Document", + "doc:Fragment", + "doc:Module", + "doc:Unit" + ], + "doc:encodes": [ + { + "@id": "#/web-api", + "@type": [ + "apiContract:WebAPI", + "apiContract:API", + "doc:RootDomainElement", + "doc:DomainElement" + ], + "core:name": [ + { + "@value": "missing-slbracket.graphql" + } + ], + "apiContract:endpoint": [] + } + ], + "doc:root": [ + { + "@value": true + } + ], + "doc:processingData": [ + { + "@id": "#/BaseUnitProcessingData", + "@type": [ + "doc:APIContractProcessingData" + ], + "apiContract:modelVersion": [ + { + "@value": "3.8.1" + } + ], + "doc:sourceSpec": [ + { + "@value": "GraphQL" + } + ] + } + ], + "doc:declares": [ + { + "@id": "#/declares/shape/Person", + "@type": [ + "shacl:NodeShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "shacl:property": [ + { + "@id": "#/declares/shape/Person/property/property/name", + "@type": [ + "shacl:PropertyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "raml-shapes:range": [ + { + "@id": "#/declares/shape/Person/property/property/name/scalar/default-scalar", + "@type": [ + "raml-shapes:ScalarShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "shacl:datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + ], + "shacl:minCount": [ + { + "@value": 0 + } + ], + "shacl:name": [ + { + "@value": "name" + } + ] + } + ], + "shacl:name": [ + { + "@value": "Person" + } + ] + } + ], + "@context": { + "@base": "file://amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-slbracket.graphql", + "raml-shapes": "http://a.ml/vocabularies/shapes#", + "shacl": "http://www.w3.org/ns/shacl#", + "doc": "http://a.ml/vocabularies/document#", + "apiContract": "http://a.ml/vocabularies/apiContract#", + "core": "http://a.ml/vocabularies/core#" + } + } +] diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-slbracket.report b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-slbracket.report new file mode 100644 index 0000000000..3339e30596 --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-slbracket.report @@ -0,0 +1,14 @@ +ModelId: file://amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-slbracket.graphql +Profile: GraphQL +Conforms: false +Number of results: 1 + +Level: Violation + +- Constraint: http://a.ml/vocabularies/amf/parser#antlr-error + Message: Syntax error in the following text: ']' + Severity: Violation + Target: + Property: + Range: [(2,17)-(2,18)] + Location: diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-srbracket.graphql b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-srbracket.graphql new file mode 100644 index 0000000000..b2df21f585 --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-srbracket.graphql @@ -0,0 +1,7 @@ +type Query { + names: [String +} + +type Person { + name: String +} \ No newline at end of file diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-srbracket.jsonld b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-srbracket.jsonld new file mode 100644 index 0000000000..aa131ac62f --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-srbracket.jsonld @@ -0,0 +1,270 @@ +[ + { + "@id": "", + "@type": [ + "doc:Document", + "doc:Fragment", + "doc:Module", + "doc:Unit" + ], + "doc:encodes": [ + { + "@id": "#/web-api", + "@type": [ + "apiContract:WebAPI", + "apiContract:API", + "doc:RootDomainElement", + "doc:DomainElement" + ], + "core:name": [ + { + "@value": "missing-srbracket.graphql" + } + ], + "apiContract:endpoint": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fnames", + "@type": [ + "apiContract:EndPoint", + "doc:DomainElement" + ], + "apiContract:path": [ + { + "@value": "/query/names" + } + ], + "core:name": [ + { + "@value": "Query.names" + } + ], + "apiContract:supportedOperation": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fnames/supportedOperation/query/Query.names", + "@type": [ + "apiContract:Operation", + "core:Operation", + "doc:DomainElement" + ], + "apiContract:method": [ + { + "@value": "query" + } + ], + "core:name": [ + { + "@value": "Query.names" + } + ], + "apiContract:expects": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fnames/supportedOperation/query/Query.names/expects/request", + "@type": [ + "apiContract:Request", + "core:Request", + "apiContract:Message", + "doc:DomainElement" + ] + } + ], + "apiContract:returns": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fnames/supportedOperation/query/Query.names/returns/resp/default", + "@type": [ + "apiContract:Response", + "core:Response", + "apiContract:Message", + "doc:DomainElement" + ], + "apiContract:statusCode": [ + { + "@value": "200" + } + ], + "core:name": [ + { + "@value": "default" + } + ], + "apiContract:payload": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fnames/supportedOperation/query/Query.names/returns/resp/default/payload/default", + "@type": [ + "apiContract:Payload", + "core:Payload", + "doc:DomainElement" + ], + "raml-shapes:schema": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fnames/supportedOperation/query/Query.names/returns/resp/default/payload/default/union/default-union", + "@type": [ + "raml-shapes:UnionShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "raml-shapes:anyOf": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fnames/supportedOperation/query/Query.names/returns/resp/default/payload/default/union/default-union/anyOf/nil/default-nil", + "@type": [ + "raml-shapes:NilShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ] + }, + { + "@id": "#/web-api/endpoint/%2Fquery%2Fnames/supportedOperation/query/Query.names/returns/resp/default/payload/default/union/default-union/anyOf/array/default-array", + "@type": [ + "raml-shapes:ArrayShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "raml-shapes:items": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fnames/supportedOperation/query/Query.names/returns/resp/default/payload/default/union/default-union/anyOf/array/default-array/union/default-union", + "@type": [ + "raml-shapes:UnionShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "raml-shapes:anyOf": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fnames/supportedOperation/query/Query.names/returns/resp/default/payload/default/union/default-union/anyOf/array/default-array/union/default-union/anyOf/nil/default-nil", + "@type": [ + "raml-shapes:NilShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ] + }, + { + "@id": "#/web-api/endpoint/%2Fquery%2Fnames/supportedOperation/query/Query.names/returns/resp/default/payload/default/union/default-union/anyOf/array/default-array/union/default-union/anyOf/scalar/default-scalar", + "@type": [ + "raml-shapes:ScalarShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "shacl:datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] + } + ], + "apiContract:operationId": [ + { + "@value": "Query.names" + } + ] + } + ] + } + ] + } + ], + "doc:root": [ + { + "@value": true + } + ], + "doc:processingData": [ + { + "@id": "#/BaseUnitProcessingData", + "@type": [ + "doc:APIContractProcessingData" + ], + "apiContract:modelVersion": [ + { + "@value": "3.8.1" + } + ], + "doc:sourceSpec": [ + { + "@value": "GraphQL" + } + ] + } + ], + "doc:declares": [ + { + "@id": "#/declares/shape/Person", + "@type": [ + "shacl:NodeShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "shacl:property": [ + { + "@id": "#/declares/shape/Person/property/property/name", + "@type": [ + "shacl:PropertyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "raml-shapes:range": [ + { + "@id": "#/declares/shape/Person/property/property/name/scalar/default-scalar", + "@type": [ + "raml-shapes:ScalarShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "shacl:datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + ], + "shacl:minCount": [ + { + "@value": 0 + } + ], + "shacl:name": [ + { + "@value": "name" + } + ] + } + ], + "shacl:name": [ + { + "@value": "Person" + } + ] + } + ], + "@context": { + "@base": "file://amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-srbracket.graphql", + "shacl": "http://www.w3.org/ns/shacl#", + "raml-shapes": "http://a.ml/vocabularies/shapes#", + "doc": "http://a.ml/vocabularies/document#", + "apiContract": "http://a.ml/vocabularies/apiContract#", + "core": "http://a.ml/vocabularies/core#" + } + } +] diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-srbracket.report b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-srbracket.report new file mode 100644 index 0000000000..a9c80e083a --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-srbracket.report @@ -0,0 +1,14 @@ +ModelId: file://amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-srbracket.graphql +Profile: GraphQL +Conforms: false +Number of results: 1 + +Level: Violation + +- Constraint: http://a.ml/vocabularies/amf/parser#antlr-error + Message: Syntax error in the following text: '}' + Severity: Violation + Target: + Property: + Range: [(3,0)-(3,1)] + Location: diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-union-member-remixed.graphql b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-union-member-remixed.graphql new file mode 100644 index 0000000000..0000127df3 --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-union-member-remixed.graphql @@ -0,0 +1,21 @@ +type Query { + name: String +} + +union UnionType = AType | BType | + +type AType { + a: String +} + +type BType { + b: String +} + +type CType { + c: String +} + +type DType { + D: String +} \ No newline at end of file diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-union-member-remixed.jsonld b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-union-member-remixed.jsonld new file mode 100644 index 0000000000..46ef14d2fb --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-union-member-remixed.jsonld @@ -0,0 +1,394 @@ +[ + { + "@id": "", + "@type": [ + "doc:Document", + "doc:Fragment", + "doc:Module", + "doc:Unit" + ], + "doc:encodes": [ + { + "@id": "#/web-api", + "@type": [ + "apiContract:WebAPI", + "apiContract:API", + "doc:RootDomainElement", + "doc:DomainElement" + ], + "core:name": [ + { + "@value": "missing-union-member-remixed.graphql" + } + ], + "apiContract:endpoint": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname", + "@type": [ + "apiContract:EndPoint", + "doc:DomainElement" + ], + "apiContract:path": [ + { + "@value": "/query/name" + } + ], + "core:name": [ + { + "@value": "Query.name" + } + ], + "apiContract:supportedOperation": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name", + "@type": [ + "apiContract:Operation", + "core:Operation", + "doc:DomainElement" + ], + "apiContract:method": [ + { + "@value": "query" + } + ], + "core:name": [ + { + "@value": "Query.name" + } + ], + "apiContract:expects": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name/expects/request", + "@type": [ + "apiContract:Request", + "core:Request", + "apiContract:Message", + "doc:DomainElement" + ] + } + ], + "apiContract:returns": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name/returns/resp/default", + "@type": [ + "apiContract:Response", + "core:Response", + "apiContract:Message", + "doc:DomainElement" + ], + "apiContract:statusCode": [ + { + "@value": "200" + } + ], + "core:name": [ + { + "@value": "default" + } + ], + "apiContract:payload": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name/returns/resp/default/payload/default", + "@type": [ + "apiContract:Payload", + "core:Payload", + "doc:DomainElement" + ], + "raml-shapes:schema": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name/returns/resp/default/payload/default/union/default-union", + "@type": [ + "raml-shapes:UnionShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "raml-shapes:anyOf": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name/returns/resp/default/payload/default/union/default-union/anyOf/nil/default-nil", + "@type": [ + "raml-shapes:NilShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ] + }, + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name/returns/resp/default/payload/default/union/default-union/anyOf/scalar/default-scalar", + "@type": [ + "raml-shapes:ScalarShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "shacl:datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + ] + } + ] + } + ] + } + ], + "apiContract:operationId": [ + { + "@value": "Query.name" + } + ] + } + ] + } + ] + } + ], + "doc:root": [ + { + "@value": true + } + ], + "doc:processingData": [ + { + "@id": "#/BaseUnitProcessingData", + "@type": [ + "doc:APIContractProcessingData" + ], + "apiContract:modelVersion": [ + { + "@value": "3.8.1" + } + ], + "doc:sourceSpec": [ + { + "@value": "GraphQL" + } + ] + } + ], + "doc:declares": [ + { + "@id": "#/declares/shape/BType", + "@type": [ + "shacl:NodeShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "shacl:property": [ + { + "@id": "#/declares/shape/BType/property/property/b", + "@type": [ + "shacl:PropertyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "raml-shapes:range": [ + { + "@id": "#/declares/shape/BType/property/property/b/scalar/default-scalar", + "@type": [ + "raml-shapes:ScalarShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "shacl:datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + ], + "shacl:minCount": [ + { + "@value": 0 + } + ], + "shacl:name": [ + { + "@value": "b" + } + ] + } + ], + "shacl:name": [ + { + "@value": "BType" + } + ] + }, + { + "@id": "#/declares/shape/CType", + "@type": [ + "shacl:NodeShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "shacl:property": [ + { + "@id": "#/declares/shape/CType/property/property/c", + "@type": [ + "shacl:PropertyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "raml-shapes:range": [ + { + "@id": "#/declares/shape/CType/property/property/c/scalar/default-scalar", + "@type": [ + "raml-shapes:ScalarShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "shacl:datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + ], + "shacl:minCount": [ + { + "@value": 0 + } + ], + "shacl:name": [ + { + "@value": "c" + } + ] + } + ], + "shacl:name": [ + { + "@value": "CType" + } + ] + }, + { + "@id": "#/declares/shape/DType", + "@type": [ + "shacl:NodeShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "shacl:property": [ + { + "@id": "#/declares/shape/DType/property/property/D", + "@type": [ + "shacl:PropertyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "raml-shapes:range": [ + { + "@id": "#/declares/shape/DType/property/property/D/scalar/default-scalar", + "@type": [ + "raml-shapes:ScalarShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "shacl:datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + ], + "shacl:minCount": [ + { + "@value": 0 + } + ], + "shacl:name": [ + { + "@value": "D" + } + ] + } + ], + "shacl:name": [ + { + "@value": "DType" + } + ] + }, + { + "@id": "#/declares/union/UnionType", + "@type": [ + "raml-shapes:UnionShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "raml-shapes:anyOf": [ + { + "@id": "#/declares/union/UnionType/anyOf/unresolved", + "@type": [ + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ] + }, + { + "@id": "#/declares/union/UnionType/anyOf/shape/BType", + "@type": [ + "shacl:NodeShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "doc:link-target": [ + { + "@id": "#/declares/shape/BType" + } + ], + "doc:link-label": [ + { + "@value": "BType" + } + ], + "shacl:name": [ + { + "@value": "BType" + } + ] + } + ], + "shacl:name": [ + { + "@value": "UnionType" + } + ] + } + ], + "@context": { + "@base": "file://amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-union-member-remixed.graphql", + "shacl": "http://www.w3.org/ns/shacl#", + "raml-shapes": "http://a.ml/vocabularies/shapes#", + "doc": "http://a.ml/vocabularies/document#", + "apiContract": "http://a.ml/vocabularies/apiContract#", + "core": "http://a.ml/vocabularies/core#" + } + } +] diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-union-member-remixed.report b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-union-member-remixed.report new file mode 100644 index 0000000000..cb4d81ccd0 --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-union-member-remixed.report @@ -0,0 +1,30 @@ +ModelId: file://amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-union-member-remixed.graphql +Profile: GraphQL +Conforms: false +Number of results: 3 + +Level: Violation + +- Constraint: http://a.ml/vocabularies/amf/core#unresolved-reference + Message: Unresolved reference 'AType' + Severity: Violation + Target: file://amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-union-member-remixed.graphql#/declares/union/UnionType/anyOf/unresolved + Property: + Range: [(5,18)-(5,23)] + Location: file://amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-union-member-remixed.graphql + +- Constraint: http://a.ml/vocabularies/amf/parser#invalid-ast + Message: Missing union member + Severity: Violation + Target: + Property: + Range: [(7,0)-(7,4)] + Location: + +- Constraint: http://a.ml/vocabularies/amf/parser#antlr-error + Message: Syntax error in the following text: 'AType' + Severity: Violation + Target: + Property: + Range: [(7,5)-(7,10)] + Location: diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-union-member.graphql b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-union-member.graphql new file mode 100644 index 0000000000..1fa230a62d --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-union-member.graphql @@ -0,0 +1,21 @@ +type Query { + name: String +} + +type AType { + a: String +} + +type BType { + b: String +} + +type CType { + c: String +} + +union UnionType = AType | BType | + +type DType { + D: String +} \ No newline at end of file diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-union-member.jsonld b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-union-member.jsonld new file mode 100644 index 0000000000..a241306cdf --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-union-member.jsonld @@ -0,0 +1,410 @@ +[ + { + "@id": "", + "@type": [ + "doc:Document", + "doc:Fragment", + "doc:Module", + "doc:Unit" + ], + "doc:encodes": [ + { + "@id": "#/web-api", + "@type": [ + "apiContract:WebAPI", + "apiContract:API", + "doc:RootDomainElement", + "doc:DomainElement" + ], + "core:name": [ + { + "@value": "missing-union-member.graphql" + } + ], + "apiContract:endpoint": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname", + "@type": [ + "apiContract:EndPoint", + "doc:DomainElement" + ], + "apiContract:path": [ + { + "@value": "/query/name" + } + ], + "core:name": [ + { + "@value": "Query.name" + } + ], + "apiContract:supportedOperation": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name", + "@type": [ + "apiContract:Operation", + "core:Operation", + "doc:DomainElement" + ], + "apiContract:method": [ + { + "@value": "query" + } + ], + "core:name": [ + { + "@value": "Query.name" + } + ], + "apiContract:expects": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name/expects/request", + "@type": [ + "apiContract:Request", + "core:Request", + "apiContract:Message", + "doc:DomainElement" + ] + } + ], + "apiContract:returns": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name/returns/resp/default", + "@type": [ + "apiContract:Response", + "core:Response", + "apiContract:Message", + "doc:DomainElement" + ], + "apiContract:statusCode": [ + { + "@value": "200" + } + ], + "core:name": [ + { + "@value": "default" + } + ], + "apiContract:payload": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name/returns/resp/default/payload/default", + "@type": [ + "apiContract:Payload", + "core:Payload", + "doc:DomainElement" + ], + "raml-shapes:schema": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name/returns/resp/default/payload/default/union/default-union", + "@type": [ + "raml-shapes:UnionShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "raml-shapes:anyOf": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name/returns/resp/default/payload/default/union/default-union/anyOf/nil/default-nil", + "@type": [ + "raml-shapes:NilShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ] + }, + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name/returns/resp/default/payload/default/union/default-union/anyOf/scalar/default-scalar", + "@type": [ + "raml-shapes:ScalarShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "shacl:datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + ] + } + ] + } + ] + } + ], + "apiContract:operationId": [ + { + "@value": "Query.name" + } + ] + } + ] + } + ] + } + ], + "doc:root": [ + { + "@value": true + } + ], + "doc:processingData": [ + { + "@id": "#/BaseUnitProcessingData", + "@type": [ + "doc:APIContractProcessingData" + ], + "apiContract:modelVersion": [ + { + "@value": "3.8.1" + } + ], + "doc:sourceSpec": [ + { + "@value": "GraphQL" + } + ] + } + ], + "doc:declares": [ + { + "@id": "#/declares/shape/AType", + "@type": [ + "shacl:NodeShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "shacl:property": [ + { + "@id": "#/declares/shape/AType/property/property/a", + "@type": [ + "shacl:PropertyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "raml-shapes:range": [ + { + "@id": "#/declares/shape/AType/property/property/a/scalar/default-scalar", + "@type": [ + "raml-shapes:ScalarShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "shacl:datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + ], + "shacl:minCount": [ + { + "@value": 0 + } + ], + "shacl:name": [ + { + "@value": "a" + } + ] + } + ], + "shacl:name": [ + { + "@value": "AType" + } + ] + }, + { + "@id": "#/declares/shape/BType", + "@type": [ + "shacl:NodeShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "shacl:property": [ + { + "@id": "#/declares/shape/BType/property/property/b", + "@type": [ + "shacl:PropertyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "raml-shapes:range": [ + { + "@id": "#/declares/shape/BType/property/property/b/scalar/default-scalar", + "@type": [ + "raml-shapes:ScalarShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "shacl:datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + ], + "shacl:minCount": [ + { + "@value": 0 + } + ], + "shacl:name": [ + { + "@value": "b" + } + ] + } + ], + "shacl:name": [ + { + "@value": "BType" + } + ] + }, + { + "@id": "#/declares/shape/CType", + "@type": [ + "shacl:NodeShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "shacl:property": [ + { + "@id": "#/declares/shape/CType/property/property/c", + "@type": [ + "shacl:PropertyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "raml-shapes:range": [ + { + "@id": "#/declares/shape/CType/property/property/c/scalar/default-scalar", + "@type": [ + "raml-shapes:ScalarShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "shacl:datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + ], + "shacl:minCount": [ + { + "@value": 0 + } + ], + "shacl:name": [ + { + "@value": "c" + } + ] + } + ], + "shacl:name": [ + { + "@value": "CType" + } + ] + }, + { + "@id": "#/declares/union/UnionType", + "@type": [ + "raml-shapes:UnionShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "raml-shapes:anyOf": [ + { + "@id": "#/declares/union/UnionType/anyOf/shape/AType", + "@type": [ + "shacl:NodeShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "doc:link-target": [ + { + "@id": "#/declares/shape/AType" + } + ], + "doc:link-label": [ + { + "@value": "AType" + } + ], + "shacl:name": [ + { + "@value": "AType" + } + ] + }, + { + "@id": "#/declares/union/UnionType/anyOf/shape/BType", + "@type": [ + "shacl:NodeShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "doc:link-target": [ + { + "@id": "#/declares/shape/BType" + } + ], + "doc:link-label": [ + { + "@value": "BType" + } + ], + "shacl:name": [ + { + "@value": "BType" + } + ] + } + ], + "shacl:name": [ + { + "@value": "UnionType" + } + ] + } + ], + "@context": { + "@base": "file://amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-union-member.graphql", + "shacl": "http://www.w3.org/ns/shacl#", + "raml-shapes": "http://a.ml/vocabularies/shapes#", + "doc": "http://a.ml/vocabularies/document#", + "apiContract": "http://a.ml/vocabularies/apiContract#", + "core": "http://a.ml/vocabularies/core#" + } + } +] diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-union-member.report b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-union-member.report new file mode 100644 index 0000000000..87014901e7 --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-union-member.report @@ -0,0 +1,22 @@ +ModelId: file://amf-cli/shared/src/test/resources/graphql/syntax-recovery/missing-union-member.graphql +Profile: GraphQL +Conforms: false +Number of results: 2 + +Level: Violation + +- Constraint: http://a.ml/vocabularies/amf/parser#invalid-ast + Message: Missing union member + Severity: Violation + Target: + Property: + Range: [(19,0)-(19,4)] + Location: + +- Constraint: http://a.ml/vocabularies/amf/parser#antlr-error + Message: Syntax error in the following text: 'DType' + Severity: Violation + Target: + Property: + Range: [(19,5)-(19,10)] + Location: diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/misspelling-type.graphql b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/misspelling-type.graphql new file mode 100644 index 0000000000..c0879ca9a6 --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/misspelling-type.graphql @@ -0,0 +1,11 @@ +type Query { + name: String +} + +typee Person { + name: String +} + +type Dog { + name: String +} \ No newline at end of file diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/misspelling-type.jsonld b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/misspelling-type.jsonld new file mode 100644 index 0000000000..ddf2932bda --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/misspelling-type.jsonld @@ -0,0 +1,237 @@ +[ + { + "@id": "", + "@type": [ + "doc:Document", + "doc:Fragment", + "doc:Module", + "doc:Unit" + ], + "doc:encodes": [ + { + "@id": "#/web-api", + "@type": [ + "apiContract:WebAPI", + "apiContract:API", + "doc:RootDomainElement", + "doc:DomainElement" + ], + "core:name": [ + { + "@value": "misspelling-type.graphql" + } + ], + "apiContract:endpoint": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname", + "@type": [ + "apiContract:EndPoint", + "doc:DomainElement" + ], + "apiContract:path": [ + { + "@value": "/query/name" + } + ], + "core:name": [ + { + "@value": "Query.name" + } + ], + "apiContract:supportedOperation": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name", + "@type": [ + "apiContract:Operation", + "core:Operation", + "doc:DomainElement" + ], + "apiContract:method": [ + { + "@value": "query" + } + ], + "core:name": [ + { + "@value": "Query.name" + } + ], + "apiContract:expects": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name/expects/request", + "@type": [ + "apiContract:Request", + "core:Request", + "apiContract:Message", + "doc:DomainElement" + ] + } + ], + "apiContract:returns": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name/returns/resp/default", + "@type": [ + "apiContract:Response", + "core:Response", + "apiContract:Message", + "doc:DomainElement" + ], + "apiContract:statusCode": [ + { + "@value": "200" + } + ], + "core:name": [ + { + "@value": "default" + } + ], + "apiContract:payload": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name/returns/resp/default/payload/default", + "@type": [ + "apiContract:Payload", + "core:Payload", + "doc:DomainElement" + ], + "raml-shapes:schema": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name/returns/resp/default/payload/default/union/default-union", + "@type": [ + "raml-shapes:UnionShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "raml-shapes:anyOf": [ + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name/returns/resp/default/payload/default/union/default-union/anyOf/nil/default-nil", + "@type": [ + "raml-shapes:NilShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ] + }, + { + "@id": "#/web-api/endpoint/%2Fquery%2Fname/supportedOperation/query/Query.name/returns/resp/default/payload/default/union/default-union/anyOf/scalar/default-scalar", + "@type": [ + "raml-shapes:ScalarShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "shacl:datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + ] + } + ] + } + ] + } + ], + "apiContract:operationId": [ + { + "@value": "Query.name" + } + ] + } + ] + } + ] + } + ], + "doc:root": [ + { + "@value": true + } + ], + "doc:processingData": [ + { + "@id": "#/BaseUnitProcessingData", + "@type": [ + "doc:APIContractProcessingData" + ], + "apiContract:modelVersion": [ + { + "@value": "3.8.1" + } + ], + "doc:sourceSpec": [ + { + "@value": "GraphQL" + } + ] + } + ], + "doc:declares": [ + { + "@id": "#/declares/shape/Dog", + "@type": [ + "shacl:NodeShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "shacl:property": [ + { + "@id": "#/declares/shape/Dog/property/property/name", + "@type": [ + "shacl:PropertyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "raml-shapes:range": [ + { + "@id": "#/declares/shape/Dog/property/property/name/scalar/default-scalar", + "@type": [ + "raml-shapes:ScalarShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "shacl:datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + ], + "shacl:minCount": [ + { + "@value": 0 + } + ], + "shacl:name": [ + { + "@value": "name" + } + ] + } + ], + "shacl:name": [ + { + "@value": "Dog" + } + ] + } + ], + "@context": { + "@base": "file://amf-cli/shared/src/test/resources/graphql/syntax-recovery/misspelling-type.graphql", + "shacl": "http://www.w3.org/ns/shacl#", + "raml-shapes": "http://a.ml/vocabularies/shapes#", + "doc": "http://a.ml/vocabularies/document#", + "apiContract": "http://a.ml/vocabularies/apiContract#", + "core": "http://a.ml/vocabularies/core#" + } + } +] diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/misspelling-type.report b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/misspelling-type.report new file mode 100644 index 0000000000..cafddb8ae3 --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/misspelling-type.report @@ -0,0 +1,14 @@ +ModelId: file://amf-cli/shared/src/test/resources/graphql/syntax-recovery/misspelling-type.graphql +Profile: GraphQL +Conforms: false +Number of results: 1 + +Level: Violation + +- Constraint: http://a.ml/vocabularies/amf/parser#antlr-error + Message: Syntax error in the following text: 'typee' + Severity: Violation + Target: + Property: + Range: [(5,0)-(5,5)] + Location: diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/replace-{-with-[.graphql b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/replace-{-with-[.graphql new file mode 100644 index 0000000000..e4c2f02fb9 --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/replace-{-with-[.graphql @@ -0,0 +1,7 @@ +type Query [ + name: String +] + +type Person { + name: String +} \ No newline at end of file diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/replace-{-with-[.jsonld b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/replace-{-with-[.jsonld new file mode 100644 index 0000000000..cfaf70f241 --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/replace-{-with-[.jsonld @@ -0,0 +1,114 @@ +[ + { + "@id": "", + "@type": [ + "doc:Document", + "doc:Fragment", + "doc:Module", + "doc:Unit" + ], + "doc:encodes": [ + { + "@id": "#/web-api", + "@type": [ + "apiContract:WebAPI", + "apiContract:API", + "doc:RootDomainElement", + "doc:DomainElement" + ], + "core:name": [ + { + "@value": "replace-%7B-with-%5B.graphql" + } + ], + "apiContract:endpoint": [] + } + ], + "doc:root": [ + { + "@value": true + } + ], + "doc:processingData": [ + { + "@id": "#/BaseUnitProcessingData", + "@type": [ + "doc:APIContractProcessingData" + ], + "apiContract:modelVersion": [ + { + "@value": "3.8.1" + } + ], + "doc:sourceSpec": [ + { + "@value": "GraphQL" + } + ] + } + ], + "doc:declares": [ + { + "@id": "#/declares/shape/Person", + "@type": [ + "shacl:NodeShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "shacl:property": [ + { + "@id": "#/declares/shape/Person/property/property/name", + "@type": [ + "shacl:PropertyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "raml-shapes:range": [ + { + "@id": "#/declares/shape/Person/property/property/name/scalar/default-scalar", + "@type": [ + "raml-shapes:ScalarShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "shacl:datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + ], + "shacl:minCount": [ + { + "@value": 0 + } + ], + "shacl:name": [ + { + "@value": "name" + } + ] + } + ], + "shacl:name": [ + { + "@value": "Person" + } + ] + } + ], + "@context": { + "@base": "file://amf-cli/shared/src/test/resources/graphql/syntax-recovery/replace-%7B-with-%5B.graphql", + "raml-shapes": "http://a.ml/vocabularies/shapes#", + "shacl": "http://www.w3.org/ns/shacl#", + "doc": "http://a.ml/vocabularies/document#", + "apiContract": "http://a.ml/vocabularies/apiContract#", + "core": "http://a.ml/vocabularies/core#" + } + } +] diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/replace-{-with-[.report b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/replace-{-with-[.report new file mode 100644 index 0000000000..396053da2c --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/replace-{-with-[.report @@ -0,0 +1,14 @@ +ModelId: file://amf-cli/shared/src/test/resources/graphql/syntax-recovery/replace-{-with-[.graphql +Profile: GraphQL +Conforms: false +Number of results: 1 + +Level: Violation + +- Constraint: http://a.ml/vocabularies/amf/parser#antlr-error + Message: Syntax error in the following text: '[' + Severity: Violation + Target: + Property: + Range: [(1,11)-(1,12)] + Location: diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/scalar-inside-type.graphql b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/scalar-inside-type.graphql new file mode 100644 index 0000000000..4dff96e158 --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/scalar-inside-type.graphql @@ -0,0 +1,8 @@ +type Query { + name: String + scalar Another +} + +type Person { + name: String +} \ No newline at end of file diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/scalar-inside-type.jsonld b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/scalar-inside-type.jsonld new file mode 100644 index 0000000000..67a46c5b84 --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/scalar-inside-type.jsonld @@ -0,0 +1,114 @@ +[ + { + "@id": "", + "@type": [ + "doc:Document", + "doc:Fragment", + "doc:Module", + "doc:Unit" + ], + "doc:encodes": [ + { + "@id": "#/web-api", + "@type": [ + "apiContract:WebAPI", + "apiContract:API", + "doc:RootDomainElement", + "doc:DomainElement" + ], + "core:name": [ + { + "@value": "scalar-inside-type.graphql" + } + ], + "apiContract:endpoint": [] + } + ], + "doc:root": [ + { + "@value": true + } + ], + "doc:processingData": [ + { + "@id": "#/BaseUnitProcessingData", + "@type": [ + "doc:APIContractProcessingData" + ], + "apiContract:modelVersion": [ + { + "@value": "3.8.1" + } + ], + "doc:sourceSpec": [ + { + "@value": "GraphQL" + } + ] + } + ], + "doc:declares": [ + { + "@id": "#/declares/shape/Person", + "@type": [ + "shacl:NodeShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "shacl:property": [ + { + "@id": "#/declares/shape/Person/property/property/name", + "@type": [ + "shacl:PropertyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "raml-shapes:range": [ + { + "@id": "#/declares/shape/Person/property/property/name/scalar/default-scalar", + "@type": [ + "raml-shapes:ScalarShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "shacl:datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + ], + "shacl:minCount": [ + { + "@value": 0 + } + ], + "shacl:name": [ + { + "@value": "name" + } + ] + } + ], + "shacl:name": [ + { + "@value": "Person" + } + ] + } + ], + "@context": { + "@base": "file://amf-cli/shared/src/test/resources/graphql/syntax-recovery/scalar-inside-type.graphql", + "raml-shapes": "http://a.ml/vocabularies/shapes#", + "shacl": "http://www.w3.org/ns/shacl#", + "doc": "http://a.ml/vocabularies/document#", + "apiContract": "http://a.ml/vocabularies/apiContract#", + "core": "http://a.ml/vocabularies/core#" + } + } +] diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/scalar-inside-type.report b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/scalar-inside-type.report new file mode 100644 index 0000000000..f211b23937 --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/scalar-inside-type.report @@ -0,0 +1,4 @@ +ModelId: file://amf-cli/shared/src/test/resources/graphql/syntax-recovery/scalar-inside-type.graphql +Profile: GraphQL +Conforms: true +Number of results: 0 diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/type-inside-type.graphql b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/type-inside-type.graphql new file mode 100644 index 0000000000..76a6a4bbce --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/type-inside-type.graphql @@ -0,0 +1,10 @@ +type Query { + name: String + type Another { + name: String + } +} + +type Person { + name: String +} \ No newline at end of file diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/type-inside-type.jsonld b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/type-inside-type.jsonld new file mode 100644 index 0000000000..1df2bb637d --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/type-inside-type.jsonld @@ -0,0 +1,114 @@ +[ + { + "@id": "", + "@type": [ + "doc:Document", + "doc:Fragment", + "doc:Module", + "doc:Unit" + ], + "doc:encodes": [ + { + "@id": "#/web-api", + "@type": [ + "apiContract:WebAPI", + "apiContract:API", + "doc:RootDomainElement", + "doc:DomainElement" + ], + "core:name": [ + { + "@value": "type-inside-type.graphql" + } + ], + "apiContract:endpoint": [] + } + ], + "doc:root": [ + { + "@value": true + } + ], + "doc:processingData": [ + { + "@id": "#/BaseUnitProcessingData", + "@type": [ + "doc:APIContractProcessingData" + ], + "apiContract:modelVersion": [ + { + "@value": "3.8.1" + } + ], + "doc:sourceSpec": [ + { + "@value": "GraphQL" + } + ] + } + ], + "doc:declares": [ + { + "@id": "#/declares/shape/Person", + "@type": [ + "shacl:NodeShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "shacl:property": [ + { + "@id": "#/declares/shape/Person/property/property/name", + "@type": [ + "shacl:PropertyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "raml-shapes:range": [ + { + "@id": "#/declares/shape/Person/property/property/name/scalar/default-scalar", + "@type": [ + "raml-shapes:ScalarShape", + "raml-shapes:AnyShape", + "shacl:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "shacl:datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + ], + "shacl:minCount": [ + { + "@value": 0 + } + ], + "shacl:name": [ + { + "@value": "name" + } + ] + } + ], + "shacl:name": [ + { + "@value": "Person" + } + ] + } + ], + "@context": { + "@base": "file://amf-cli/shared/src/test/resources/graphql/syntax-recovery/type-inside-type.graphql", + "raml-shapes": "http://a.ml/vocabularies/shapes#", + "shacl": "http://www.w3.org/ns/shacl#", + "doc": "http://a.ml/vocabularies/document#", + "apiContract": "http://a.ml/vocabularies/apiContract#", + "core": "http://a.ml/vocabularies/core#" + } + } +] diff --git a/amf-cli/shared/src/test/resources/graphql/syntax-recovery/type-inside-type.report b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/type-inside-type.report new file mode 100644 index 0000000000..50407c08d1 --- /dev/null +++ b/amf-cli/shared/src/test/resources/graphql/syntax-recovery/type-inside-type.report @@ -0,0 +1,4 @@ +ModelId: file://amf-cli/shared/src/test/resources/graphql/syntax-recovery/type-inside-type.graphql +Profile: GraphQL +Conforms: true +Number of results: 0 diff --git a/amf-cli/shared/src/test/resources/validations/json-schema-lexical/allOf-sourceypart-is-ast.json b/amf-cli/shared/src/test/resources/validations/json-schema-lexical/allOf-sourceypart-is-ast.json new file mode 100644 index 0000000000..d59ed0e16f --- /dev/null +++ b/amf-cli/shared/src/test/resources/validations/json-schema-lexical/allOf-sourceypart-is-ast.json @@ -0,0 +1,18 @@ +{ + "$schema": "http://json-schema.org/draft/2019-09/schema#", + "definitions": { + "Test": { + "type": "string" + }, + "Test2": { + "allOf": [ + { + "$ref": "#/definitions/Test" + }, + { + "properties": {} + } + ] + } + } +} \ No newline at end of file diff --git a/amf-cli/shared/src/test/resources/validations/json-schema-lexical/anyOf-sourceypart-is-ast.json b/amf-cli/shared/src/test/resources/validations/json-schema-lexical/anyOf-sourceypart-is-ast.json new file mode 100644 index 0000000000..2b121e966d --- /dev/null +++ b/amf-cli/shared/src/test/resources/validations/json-schema-lexical/anyOf-sourceypart-is-ast.json @@ -0,0 +1,18 @@ +{ + "$schema": "http://json-schema.org/draft/2019-09/schema#", + "definitions": { + "Test": { + "type": "string" + }, + "Test2": { + "anyOf": [ + { + "$ref": "#/definitions/Test" + }, + { + "properties": {} + } + ] + } + } +} \ No newline at end of file diff --git a/amf-cli/shared/src/test/resources/validations/json-schema-lexical/oneOf-sourceypart-is-ast.json b/amf-cli/shared/src/test/resources/validations/json-schema-lexical/oneOf-sourceypart-is-ast.json new file mode 100644 index 0000000000..590db5d24f --- /dev/null +++ b/amf-cli/shared/src/test/resources/validations/json-schema-lexical/oneOf-sourceypart-is-ast.json @@ -0,0 +1,18 @@ +{ + "$schema": "http://json-schema.org/draft/2019-09/schema#", + "definitions": { + "Test": { + "type": "string" + }, + "Test2": { + "oneOf": [ + { + "$ref": "#/definitions/Test" + }, + { + "properties": {} + } + ] + } + } +} \ No newline at end of file diff --git a/amf-cli/shared/src/test/resources/validations/raml/discriminator-value-conforms-against-discriminator-property/api.raml b/amf-cli/shared/src/test/resources/validations/raml/discriminator-value-conforms-against-discriminator-property/api.raml new file mode 100644 index 0000000000..f2eb8d3af7 --- /dev/null +++ b/amf-cli/shared/src/test/resources/validations/raml/discriminator-value-conforms-against-discriminator-property/api.raml @@ -0,0 +1,10 @@ +#%RAML 1.0 +title: Pets API + +types: + Pet: + type: object + discriminator: type + discriminatorValue: true + properties: + type: integer diff --git a/amf-cli/shared/src/test/resources/validations/raml/empty-array-in-union-type-expression.raml b/amf-cli/shared/src/test/resources/validations/raml/empty-array-in-union-type-expression.raml new file mode 100644 index 0000000000..d25cd041b6 --- /dev/null +++ b/amf-cli/shared/src/test/resources/validations/raml/empty-array-in-union-type-expression.raml @@ -0,0 +1,9 @@ +#%RAML 1.0 +title: Something +version: 1.0 + +/test: + post: + body: + multipart/form-data: + type: file[] | [] \ No newline at end of file diff --git a/amf-cli/shared/src/test/resources/validations/raml/raml-with-invalid-json-schema/api.raml b/amf-cli/shared/src/test/resources/validations/raml/raml-with-invalid-json-schema/api.raml new file mode 100644 index 0000000000..2c40873f9a --- /dev/null +++ b/amf-cli/shared/src/test/resources/validations/raml/raml-with-invalid-json-schema/api.raml @@ -0,0 +1,9 @@ +#%RAML 1.0 +title: API body demo +version: v1 +baseUri: http://api.domain.com/ + +types: + JsonSchema: + type: !include person.json + example: !include person-example.json diff --git a/amf-cli/shared/src/test/resources/validations/raml/raml-with-invalid-json-schema/person-example.json b/amf-cli/shared/src/test/resources/validations/raml/raml-with-invalid-json-schema/person-example.json new file mode 100644 index 0000000000..2c960eb27c --- /dev/null +++ b/amf-cli/shared/src/test/resources/validations/raml/raml-with-invalid-json-schema/person-example.json @@ -0,0 +1,14 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "@context": "nowhere.json", + "name": "John Smith", + "birthday": "1990-10-12", + "gender": "male", + "url": "https://www.domain.com/people/Qawer63J73HJ6khjswuqyq62382jG21s", + "image": { + "url": "https://www.domain.com/people/Qawer63J73HJ6khjswuqyq62382jG21s/image", + "thumb": "https://www.domain.com/people/Qawer63J73HJ6khjswuqyq62382jG21s/image/thumb" + }, + "tagline": "Hi, I'm John!", + "language": "en_US" +} diff --git a/amf-cli/shared/src/test/resources/validations/raml/raml-with-invalid-json-schema/person.json b/amf-cli/shared/src/test/resources/validations/raml/raml-with-invalid-json-schema/person.json new file mode 100644 index 0000000000..3b14953fe3 --- /dev/null +++ b/amf-cli/shared/src/test/resources/validations/raml/raml-with-invalid-json-schema/person.json @@ -0,0 +1,48 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "birthday": { + "type": "string" + }, + "gender": { + "type": "string" + }, + "url": { + "type": "string" + }, + "image": { + "type": "object", + "properties": { + "url": { + "type": "string" + }, + "thumb": { + "type": "string" + } + }, + "required": [ + "url", + "thumb" + ] + }, + "tagline": { + "type": "string" + }, + "language": { + "type": "string" + } + }, + "required": [ + "name", + "birthday", + "gender", + "url", + "image", + "tagline", + "language" + ] +} diff --git a/amf-cli/shared/src/test/resources/validations/raml/standalone-array-as-type.raml b/amf-cli/shared/src/test/resources/validations/raml/standalone-array-as-type.raml new file mode 100644 index 0000000000..f326fab4c0 --- /dev/null +++ b/amf-cli/shared/src/test/resources/validations/raml/standalone-array-as-type.raml @@ -0,0 +1,12 @@ +#%RAML 1.0 +title: Something +version: 1.0 + +/test: + post: + body: + multipart/form-data: + type: [] + +types: + EmptyArray: [] \ No newline at end of file diff --git a/amf-cli/shared/src/test/resources/validations/reports/graphql/sudden-eof.report b/amf-cli/shared/src/test/resources/validations/reports/graphql/sudden-eof.report index 7ca70c0fd7..9a3bd8a9f5 100644 --- a/amf-cli/shared/src/test/resources/validations/reports/graphql/sudden-eof.report +++ b/amf-cli/shared/src/test/resources/validations/reports/graphql/sudden-eof.report @@ -10,11 +10,11 @@ Level: Violation Severity: Violation Target: Property: - Range: [(6,4)-(6,38)] + Range: [(6,4)-(5,18)] Location: - Constraint: http://a.ml/vocabularies/amf/parser#invalid-ast - Message: Unknown input type syntax + Message: Missing name for root type field Severity: Violation Target: Property: diff --git a/amf-cli/shared/src/test/resources/validations/reports/model/raml/empty-array-in-union-type-expression.report b/amf-cli/shared/src/test/resources/validations/reports/model/raml/empty-array-in-union-type-expression.report new file mode 100644 index 0000000000..cd9c3494fa --- /dev/null +++ b/amf-cli/shared/src/test/resources/validations/reports/model/raml/empty-array-in-union-type-expression.report @@ -0,0 +1,14 @@ +ModelId: file://amf-cli/shared/src/test/resources/validations/raml/empty-array-in-union-type-expression.raml +Profile: +Conforms: false +Number of results: 1 + +Level: Violation + +- Constraint: http://a.ml/vocabularies/amf/parser#invalid-type-expression + Message: Syntax error, generating empty array + Severity: Violation + Target: + Property: + Range: [(9,23)-(9,24)] + Location: file://amf-cli/shared/src/test/resources/validations/raml/empty-array-in-union-type-expression.raml diff --git a/amf-cli/shared/src/test/resources/validations/reports/model/raml/standalone-array-as-type.report b/amf-cli/shared/src/test/resources/validations/reports/model/raml/standalone-array-as-type.report new file mode 100644 index 0000000000..53d703444b --- /dev/null +++ b/amf-cli/shared/src/test/resources/validations/reports/model/raml/standalone-array-as-type.report @@ -0,0 +1,22 @@ +ModelId: file://amf-cli/shared/src/test/resources/validations/raml/standalone-array-as-type.raml +Profile: +Conforms: false +Number of results: 2 + +Level: Violation + +- Constraint: http://a.ml/vocabularies/amf/parser#empty-type-expression-array + Message: [] is not a valid type + Severity: Violation + Target: + Property: + Range: [(9,14)-(9,16)] + Location: file://amf-cli/shared/src/test/resources/validations/raml/standalone-array-as-type.raml + +- Constraint: http://a.ml/vocabularies/amf/parser#empty-type-expression-array + Message: [] is not a valid type + Severity: Violation + Target: + Property: + Range: [(12,14)-(12,16)] + Location: file://amf-cli/shared/src/test/resources/validations/raml/standalone-array-as-type.raml diff --git a/amf-cli/shared/src/test/resources/validations/reports/multi-plat-model/discriminator-value-conforms-against-discriminator-property.report.js b/amf-cli/shared/src/test/resources/validations/reports/multi-plat-model/discriminator-value-conforms-against-discriminator-property.report.js new file mode 100644 index 0000000000..c4420816ad --- /dev/null +++ b/amf-cli/shared/src/test/resources/validations/reports/multi-plat-model/discriminator-value-conforms-against-discriminator-property.report.js @@ -0,0 +1,14 @@ +ModelId: file://amf-cli/shared/src/test/resources/validations/raml/discriminator-value-conforms-against-discriminator-property/api.raml +Profile: RAML 1.0 +Conforms: false +Number of results: 1 + +Level: Violation + +- Constraint: http://a.ml/vocabularies/amf/validation#example-validation-error + Message: should be integer + Severity: Violation + Target: http://test.com/payload/data-node + Property: http://test.com/payload/data-node + Range: + Location: diff --git a/amf-cli/shared/src/test/resources/validations/reports/multi-plat-model/discriminator-value-conforms-against-discriminator-property.report.jvm b/amf-cli/shared/src/test/resources/validations/reports/multi-plat-model/discriminator-value-conforms-against-discriminator-property.report.jvm new file mode 100644 index 0000000000..e8b072e184 --- /dev/null +++ b/amf-cli/shared/src/test/resources/validations/reports/multi-plat-model/discriminator-value-conforms-against-discriminator-property.report.jvm @@ -0,0 +1,14 @@ +ModelId: file://amf-cli/shared/src/test/resources/validations/raml/discriminator-value-conforms-against-discriminator-property/api.raml +Profile: RAML 1.0 +Conforms: false +Number of results: 1 + +Level: Violation + +- Constraint: http://a.ml/vocabularies/amf/validation#example-validation-error + Message: expected type: Integer, found: String + Severity: Violation + Target: http://test.com/payload/data-node + Property: http://test.com/payload/data-node + Range: + Location: diff --git a/amf-cli/shared/src/test/scala/amf/cycle/JsonSchemaCycle.scala b/amf-cli/shared/src/test/scala/amf/cycle/JsonSchemaCycle.scala index 7c0b7eef31..c280a34d28 100644 --- a/amf-cli/shared/src/test/scala/amf/cycle/JsonSchemaCycle.scala +++ b/amf-cli/shared/src/test/scala/amf/cycle/JsonSchemaCycle.scala @@ -259,10 +259,10 @@ object JsonSchemaTestEmitters { val DRAFT_6_EMITTER: JsonSchemaTestEmitter = JsonSchemaTestEmitter(JSONSchemaDraft6SchemaVersion) } -case class JsonSchemaTestEmitter(to: JSONSchemaVersion) extends SchemaEmitter { +case class JsonSchemaTestEmitter(to: JSONSchemaVersion, baseOptions: RenderOptions = RenderOptions()) + extends SchemaEmitter { - private val options = - RenderOptions().withSchemaVersion(SchemaVersion.toClientOptions(to)) + private val options = baseOptions.withSchemaVersion(SchemaVersion.toClientOptions(to)) override def emitSchema(fragment: DataTypeFragment)(implicit executionContext: ExecutionContext): String = { val config = EmptyRenderConfiguration(UnhandledErrorHandler, options) diff --git a/amf-cli/shared/src/test/scala/amf/parser/GraphQLSyntaxRecoveryTest.scala b/amf-cli/shared/src/test/scala/amf/parser/GraphQLSyntaxRecoveryTest.scala new file mode 100644 index 0000000000..3b45015a10 --- /dev/null +++ b/amf-cli/shared/src/test/scala/amf/parser/GraphQLSyntaxRecoveryTest.scala @@ -0,0 +1,45 @@ +package amf.parser + +import amf.core.client.scala.config.RenderOptions +import amf.core.internal.remote.Mimes.`application/ld+json` +import amf.graphql.client.scala.GraphQLConfiguration + +import scala.concurrent.Future + +class GraphQLSyntaxRecoveryTest extends GraphQLValidationTest { + override def basePath: String = "amf-cli/shared/src/test/resources/graphql/syntax-recovery" + + fs.syncFile(basePath) + .list + .groupBy(apiName) + .values + .collect { + case toValidate if toValidate.length > 1 => + apiName(toValidate.head) // contains the API and it's report, thus should be validated + } + .foreach { api => + test(s"GraphQL TCK > Apis > Invalid > $api: should not conform") { + for { + _ <- dumpJsonLDFor(api) + assertion <- assertReport(s"$basePath/$api.graphql") + } yield { + assertion + } + } + } + + private def apiName(api: String): String = api.split('.').dropRight(1).mkString(".") + + def dumpJsonLDFor(api: String): Future[Unit] = { + val ro = RenderOptions().withPrettyPrint.withCompactUris.withoutFlattenedJsonLd + val client = GraphQLConfiguration.GraphQL().withRenderOptions(ro).baseUnitClient() + for { + parsing <- client.parse(s"file://$basePath/$api.graphql") + content <- Future.successful(client.render(parsing.baseUnit, `application/ld+json`)) + _ <- fs.asyncFile(s"$basePath/$api.jsonld").write(content) + } yield { + Unit + } + + } +} diff --git a/amf-cli/shared/src/test/scala/amf/parser/GraphQLTCKValidationTest.scala b/amf-cli/shared/src/test/scala/amf/parser/GraphQLTCKValidationTest.scala index 58a48dbc63..3d6f4378e1 100644 --- a/amf-cli/shared/src/test/scala/amf/parser/GraphQLTCKValidationTest.scala +++ b/amf-cli/shared/src/test/scala/amf/parser/GraphQLTCKValidationTest.scala @@ -1,15 +1,6 @@ package amf.parser -import amf.core.client.common.transform.PipelineId -import amf.core.client.common.validation.GraphQLProfile -import amf.core.client.scala.validation.AMFValidationReport -import amf.cycle.GraphQLFunSuiteCycleTests -import amf.graphql.client.scala.GraphQLConfiguration -import org.scalatest.Assertion - -import scala.concurrent.Future - -class GraphQLTCKValidationTest extends GraphQLFunSuiteCycleTests { +class GraphQLTCKValidationTest extends GraphQLValidationTest { override def basePath: String = "amf-cli/shared/src/test/resources/graphql/tck/apis" // Test valid APIs @@ -42,35 +33,5 @@ class GraphQLTCKValidationTest extends GraphQLFunSuiteCycleTests { assertConforms(s"$basePath/valid/interface-chain-covariant.graphql") } - def assertConforms(api: String): Future[Assertion] = { - val client = GraphQLConfiguration.GraphQL().baseUnitClient() - for { - parsing <- client.parse(s"file://$api") - transformation <- Future.successful(client.transform(parsing.baseUnit, PipelineId.Cache)) - validation <- client.validate(transformation.baseUnit) - } yield { - assert(parsing.conforms && transformation.conforms && validation.conforms) - } - } - - def assertReport(api: String): Future[Assertion] = { - val client = GraphQLConfiguration.GraphQL().baseUnitClient() - val apiUri = s"file://$api" - val report = api.replace(".graphql", ".report") - for { - parsing <- client.parse(apiUri) - transformation <- Future.successful(client.transform(parsing.baseUnit, PipelineId.Cache)) - validation <- client.validate(transformation.baseUnit) - actualFile <- { - val combinedResults = parsing.results ++ transformation.results ++ validation.results - val actual = AMFValidationReport(apiUri, GraphQLProfile, combinedResults) - writeTemporaryFile(report)(actual.toString) - } - assertion <- assertDifferences(actualFile, report) - } yield { - assertion - } - } - private def apiName(api: String): String = api.split('.').dropRight(1).mkString(".") } diff --git a/amf-cli/shared/src/test/scala/amf/parser/GraphQLValidationTest.scala b/amf-cli/shared/src/test/scala/amf/parser/GraphQLValidationTest.scala new file mode 100644 index 0000000000..8e055d66aa --- /dev/null +++ b/amf-cli/shared/src/test/scala/amf/parser/GraphQLValidationTest.scala @@ -0,0 +1,45 @@ +package amf.parser + +import amf.core.client.common.transform.PipelineId +import amf.core.client.common.validation.GraphQLProfile +import amf.core.client.scala.validation.AMFValidationReport +import amf.cycle.GraphQLFunSuiteCycleTests +import amf.graphql.client.scala.GraphQLConfiguration +import org.scalatest.Assertion + +import scala.concurrent.Future + +trait GraphQLValidationTest extends GraphQLFunSuiteCycleTests { + + + def assertConforms(api: String): Future[Assertion] = { + val client = GraphQLConfiguration.GraphQL().baseUnitClient() + for { + parsing <- client.parse(s"file://$api") + transformation <- Future.successful(client.transform(parsing.baseUnit, PipelineId.Cache)) + validation <- client.validate(transformation.baseUnit) + } yield { + assert(parsing.conforms && transformation.conforms && validation.conforms) + } + } + + def assertReport(api: String): Future[Assertion] = { + val client = GraphQLConfiguration.GraphQL().baseUnitClient() + val apiUri = s"file://$api" + val report = api.replace(".graphql", ".report") + for { + parsing <- client.parse(apiUri) + transformation <- Future.successful(client.transform(parsing.baseUnit, PipelineId.Cache)) + validation <- client.validate(transformation.baseUnit) + actualFile <- { + val combinedResults = parsing.results ++ transformation.results ++ validation.results + val actual = AMFValidationReport(apiUri, GraphQLProfile, combinedResults) + writeTemporaryFile(report)(actual.toString) + } + assertion <- assertDifferences(actualFile, report) + } yield { + assertion + } + } + +} diff --git a/amf-cli/shared/src/test/scala/amf/validation/AMFModelAssertionTest.scala b/amf-cli/shared/src/test/scala/amf/validation/AMFModelAssertionTest.scala index 85c1b9cde7..8fad9376d0 100644 --- a/amf-cli/shared/src/test/scala/amf/validation/AMFModelAssertionTest.scala +++ b/amf-cli/shared/src/test/scala/amf/validation/AMFModelAssertionTest.scala @@ -7,10 +7,12 @@ import amf.core.client.common.transform.PipelineId import amf.core.client.scala.config.RenderOptions import amf.core.client.scala.model.document.{BaseUnit, Document} import amf.core.client.scala.model.domain.extensions.PropertyShape -import amf.core.client.scala.model.domain.{AmfArray, Annotation, ExternalSourceElement} -import amf.core.internal.annotations.{DeclaredElement, Inferred, VirtualElement, VirtualNode} +import amf.core.client.scala.model.domain.{AmfArray, Annotation, ExternalSourceElement, Shape} +import amf.core.internal.annotations.{DeclaredElement, Inferred, SourceYPart, VirtualElement, VirtualNode} import amf.core.internal.parser.domain.Annotations import amf.graphql.client.scala.GraphQLConfiguration +import amf.shapes.client.scala.config.JsonSchemaConfiguration +import amf.shapes.client.scala.model.document.JsonSchemaDocument import amf.shapes.client.scala.model.domain._ import amf.shapes.internal.annotations.{BaseVirtualNode, TargetName} import amf.shapes.internal.domain.metamodel.AnyShapeModel @@ -42,7 +44,7 @@ class AMFModelAssertionTest extends AsyncFunSuite with Matchers { path: String, pipelineId: String = PipelineId.Default, transform: Boolean = true, - client: AMFBaseUnitClient = APIConfiguration.API().baseUnitClient() + client: AMFBaseUnitClient = APIConfiguration.APIWithJsonSchema().baseUnitClient() )(assertion: BaseUnit => Assertion): Future[Assertion] = { client.parse(path) flatMap { parseResult => if (!transform) assertion(parseResult.baseUnit) @@ -452,4 +454,39 @@ class AMFModelAssertionTest extends AsyncFunSuite with Matchers { getFirstRequestPayload(bu).annotations.lexical() shouldBe PositionRange(Position(13, 6), Position(15, 0)) } } + + test("Assert ast annotations aren't modified in allOf") { + val api = s"$basePath/json-schema-lexical/allOf-sourceypart-is-ast.json" + modelAssertion(api, transform = false) { unit => + val obtainedAst: String = sourcePartOf(unit, _.declares(1).asInstanceOf[Shape].and(1)) + val expectedAst = """{"properties": {}}""" + obtainedAst.trim shouldEqual expectedAst.trim + } + } + + test("Assert ast annotations aren't modified in anyOf") { + val api = s"$basePath/json-schema-lexical/anyOf-sourceypart-is-ast.json" + modelAssertion(api, transform = false) { unit => + val obtainedAst: String = sourcePartOf(unit, _.declares(1).asInstanceOf[Shape].or(1)) + val expectedAst = """{"properties": {}}""" + obtainedAst.trim shouldEqual expectedAst.trim + } + } + + test("Assert ast annotations aren't modified in oneOf") { + val api = s"$basePath/json-schema-lexical/oneOf-sourceypart-is-ast.json" + modelAssertion(api, transform = false) { unit => + val obtainedAst: String = sourcePartOf(unit, _.declares(1).asInstanceOf[Shape].xone(1)) + val expectedAst = """{"properties": {}}""" + obtainedAst.trim shouldEqual expectedAst.trim + } + } + + private def sourcePartOf(unit: BaseUnit, extract: JsonSchemaDocument => Shape) = { + val doc = unit.asInstanceOf[JsonSchemaDocument] + val shapeOfInterest = extract(doc) + val sourceYPart = shapeOfInterest.annotations.find(_.isInstanceOf[SourceYPart]).get.asInstanceOf[SourceYPart] + val obtainedAst = sourceYPart.ast.toString + obtainedAst + } } diff --git a/amf-cli/shared/src/test/scala/amf/validation/RamlModelMultiPlatformReportTest.scala b/amf-cli/shared/src/test/scala/amf/validation/RamlModelMultiPlatformReportTest.scala index 1f8092641a..287a4d35c6 100644 --- a/amf-cli/shared/src/test/scala/amf/validation/RamlModelMultiPlatformReportTest.scala +++ b/amf-cli/shared/src/test/scala/amf/validation/RamlModelMultiPlatformReportTest.scala @@ -1,8 +1,5 @@ package amf.validation -import amf.core.client.common.validation.{Raml08Profile, Raml10Profile} -import amf.core.internal.remote.{Hint, Raml08YamlHint, Raml10YamlHint} - class RamlModelMultiPlatformReportTest extends MultiPlatformReportGenTest { test("Test non existing include in type def") { @@ -84,6 +81,13 @@ class RamlModelMultiPlatformReportTest extends MultiPlatformReportGenTest { ) } + test("Validate discriminator value conforms against discriminator property") { + validate( + "/raml/discriminator-value-conforms-against-discriminator-property/api.raml", + Some("discriminator-value-conforms-against-discriminator-property.report") + ) + } + override val basePath = "file://amf-cli/shared/src/test/resources/validations/" override val reportsPath = "amf-cli/shared/src/test/resources/validations/reports/multi-plat-model/" diff --git a/amf-cli/shared/src/test/scala/amf/validation/RamlModelUniquePlatformReportTest.scala b/amf-cli/shared/src/test/scala/amf/validation/RamlModelUniquePlatformReportTest.scala index 04385d2f90..53533cd4fd 100644 --- a/amf-cli/shared/src/test/scala/amf/validation/RamlModelUniquePlatformReportTest.scala +++ b/amf-cli/shared/src/test/scala/amf/validation/RamlModelUniquePlatformReportTest.scala @@ -712,4 +712,20 @@ class RamlModelUniquePlatformReportTest extends UniquePlatformReportGenTest { test("nested JSON Schema reference by id in draft 4") { validate("/raml/nested-json-schema-ref/api.raml", Some("raml/nested-json-schema-ref.report")) } + + test("empty array expression in union should be invalid") { + validate( + "/raml/empty-array-in-union-type-expression.raml", + Some("raml/empty-array-in-union-type-expression.report") + ) + } + + test("Standalone array as type") { + validate("/raml/standalone-array-as-type.raml", Some("raml/standalone-array-as-type.report")) + } + + // W-11680259 + test("a json example with @context that points to nowhere should not throw an error") { + validate("/raml/raml-with-json-schema/api.raml") + } } diff --git a/amf-graphql/js/package-lock.json b/amf-graphql/js/package-lock.json index 4625ec5d39..1cd3981ad0 100644 --- a/amf-graphql/js/package-lock.json +++ b/amf-graphql/js/package-lock.json @@ -9,14 +9,14 @@ "version": "4.0.0", "license": "Apache-2.0", "dependencies": { - "@aml-org/amf-antlr-parsers": "0.6.21", + "@aml-org/amf-antlr-parsers": "0.6.22", "ajv": "6.12.6" } }, "node_modules/@aml-org/amf-antlr-parsers": { - "version": "0.6.21", - "resolved": "https://registry.npmjs.org/@aml-org/amf-antlr-parsers/-/amf-antlr-parsers-0.6.21.tgz", - "integrity": "sha512-QhVGMCeaLG0LqgTodJXflMl6gjr2ls0FeRBmUR5RQQWeT0YZWPE+kTRNGk810UbgvE1pnWKj7ERHyGxoMy/HXg==" + "version": "0.6.22", + "resolved": "https://registry.npmjs.org/@aml-org/amf-antlr-parsers/-/amf-antlr-parsers-0.6.22.tgz", + "integrity": "sha512-29ZCQiNsa2DZ4CEE+FXMuro+sg+UIYDNLCj/ovlWSL1F7PBlDCMQ2DK5shd/pwM904jwSjPDQmPGFl2Z4wUFKQ==" }, "node_modules/ajv": { "version": "6.12.6", @@ -67,9 +67,9 @@ }, "dependencies": { "@aml-org/amf-antlr-parsers": { - "version": "0.6.21", - "resolved": "https://registry.npmjs.org/@aml-org/amf-antlr-parsers/-/amf-antlr-parsers-0.6.21.tgz", - "integrity": "sha512-QhVGMCeaLG0LqgTodJXflMl6gjr2ls0FeRBmUR5RQQWeT0YZWPE+kTRNGk810UbgvE1pnWKj7ERHyGxoMy/HXg==" + "version": "0.6.22", + "resolved": "https://registry.npmjs.org/@aml-org/amf-antlr-parsers/-/amf-antlr-parsers-0.6.22.tgz", + "integrity": "sha512-29ZCQiNsa2DZ4CEE+FXMuro+sg+UIYDNLCj/ovlWSL1F7PBlDCMQ2DK5shd/pwM904jwSjPDQmPGFl2Z4wUFKQ==" }, "ajv": { "version": "6.12.6", diff --git a/amf-graphql/js/package.json b/amf-graphql/js/package.json index 68cfee1e29..9151d50d01 100644 --- a/amf-graphql/js/package.json +++ b/amf-graphql/js/package.json @@ -11,7 +11,7 @@ "url": "https://github.com/aml-org/amf" }, "dependencies": { - "@aml-org/amf-antlr-parsers": "0.6.21", + "@aml-org/amf-antlr-parsers": "0.6.22", "ajv": "6.12.6" } } diff --git a/amf-graphql/shared/src/main/scala/amf/graphql/internal/spec/parser/syntax/GraphQLASTParserHelper.scala b/amf-graphql/shared/src/main/scala/amf/graphql/internal/spec/parser/syntax/GraphQLASTParserHelper.scala index 0313557e22..c290195fe6 100644 --- a/amf-graphql/shared/src/main/scala/amf/graphql/internal/spec/parser/syntax/GraphQLASTParserHelper.scala +++ b/amf-graphql/shared/src/main/scala/amf/graphql/internal/spec/parser/syntax/GraphQLASTParserHelper.scala @@ -104,10 +104,7 @@ trait GraphQLASTParserHelper extends AntlrASTParserHelper { } } shape - case _ => - astError("Unknown input type syntax", toAnnotations(n)) - val shape = AnyShape(toAnnotations(n)) - shape + case _ => AnyShape(toAnnotations(n)) } } diff --git a/amf-grpc/js/package-lock.json b/amf-grpc/js/package-lock.json index c093878a08..004f73bc5f 100644 --- a/amf-grpc/js/package-lock.json +++ b/amf-grpc/js/package-lock.json @@ -9,14 +9,14 @@ "version": "4.0.0", "license": "Apache-2.0", "dependencies": { - "@aml-org/amf-antlr-parsers": "0.6.21", + "@aml-org/amf-antlr-parsers": "0.6.22", "ajv": "6.12.6" } }, "node_modules/@aml-org/amf-antlr-parsers": { - "version": "0.6.21", - "resolved": "https://registry.npmjs.org/@aml-org/amf-antlr-parsers/-/amf-antlr-parsers-0.6.21.tgz", - "integrity": "sha512-QhVGMCeaLG0LqgTodJXflMl6gjr2ls0FeRBmUR5RQQWeT0YZWPE+kTRNGk810UbgvE1pnWKj7ERHyGxoMy/HXg==" + "version": "0.6.22", + "resolved": "https://registry.npmjs.org/@aml-org/amf-antlr-parsers/-/amf-antlr-parsers-0.6.22.tgz", + "integrity": "sha512-29ZCQiNsa2DZ4CEE+FXMuro+sg+UIYDNLCj/ovlWSL1F7PBlDCMQ2DK5shd/pwM904jwSjPDQmPGFl2Z4wUFKQ==" }, "node_modules/ajv": { "version": "6.12.6", @@ -67,9 +67,9 @@ }, "dependencies": { "@aml-org/amf-antlr-parsers": { - "version": "0.6.21", - "resolved": "https://registry.npmjs.org/@aml-org/amf-antlr-parsers/-/amf-antlr-parsers-0.6.21.tgz", - "integrity": "sha512-QhVGMCeaLG0LqgTodJXflMl6gjr2ls0FeRBmUR5RQQWeT0YZWPE+kTRNGk810UbgvE1pnWKj7ERHyGxoMy/HXg==" + "version": "0.6.22", + "resolved": "https://registry.npmjs.org/@aml-org/amf-antlr-parsers/-/amf-antlr-parsers-0.6.22.tgz", + "integrity": "sha512-29ZCQiNsa2DZ4CEE+FXMuro+sg+UIYDNLCj/ovlWSL1F7PBlDCMQ2DK5shd/pwM904jwSjPDQmPGFl2Z4wUFKQ==" }, "ajv": { "version": "6.12.6", diff --git a/amf-grpc/js/package.json b/amf-grpc/js/package.json index 55426474e1..2f35eddaeb 100644 --- a/amf-grpc/js/package.json +++ b/amf-grpc/js/package.json @@ -11,7 +11,7 @@ "url": "https://github.com/aml-org/amf" }, "dependencies": { - "@aml-org/amf-antlr-parsers": "0.6.21", + "@aml-org/amf-antlr-parsers": "0.6.22", "ajv": "6.12.6" } } diff --git a/amf-shapes/js/package-lock.json b/amf-shapes/js/package-lock.json index e67159da1e..df3197e76a 100644 --- a/amf-shapes/js/package-lock.json +++ b/amf-shapes/js/package-lock.json @@ -9,14 +9,14 @@ "version": "4.0.0", "license": "Apache-2.0", "dependencies": { - "@aml-org/amf-antlr-parsers": "0.6.21", + "@aml-org/amf-antlr-parsers": "0.6.22", "ajv": "6.12.6" } }, "node_modules/@aml-org/amf-antlr-parsers": { - "version": "0.6.21", - "resolved": "https://registry.npmjs.org/@aml-org/amf-antlr-parsers/-/amf-antlr-parsers-0.6.21.tgz", - "integrity": "sha512-QhVGMCeaLG0LqgTodJXflMl6gjr2ls0FeRBmUR5RQQWeT0YZWPE+kTRNGk810UbgvE1pnWKj7ERHyGxoMy/HXg==" + "version": "0.6.22", + "resolved": "https://registry.npmjs.org/@aml-org/amf-antlr-parsers/-/amf-antlr-parsers-0.6.22.tgz", + "integrity": "sha512-29ZCQiNsa2DZ4CEE+FXMuro+sg+UIYDNLCj/ovlWSL1F7PBlDCMQ2DK5shd/pwM904jwSjPDQmPGFl2Z4wUFKQ==" }, "node_modules/ajv": { "version": "6.12.6", @@ -67,9 +67,9 @@ }, "dependencies": { "@aml-org/amf-antlr-parsers": { - "version": "0.6.21", - "resolved": "https://registry.npmjs.org/@aml-org/amf-antlr-parsers/-/amf-antlr-parsers-0.6.21.tgz", - "integrity": "sha512-QhVGMCeaLG0LqgTodJXflMl6gjr2ls0FeRBmUR5RQQWeT0YZWPE+kTRNGk810UbgvE1pnWKj7ERHyGxoMy/HXg==" + "version": "0.6.22", + "resolved": "https://registry.npmjs.org/@aml-org/amf-antlr-parsers/-/amf-antlr-parsers-0.6.22.tgz", + "integrity": "sha512-29ZCQiNsa2DZ4CEE+FXMuro+sg+UIYDNLCj/ovlWSL1F7PBlDCMQ2DK5shd/pwM904jwSjPDQmPGFl2Z4wUFKQ==" }, "ajv": { "version": "6.12.6", diff --git a/amf-shapes/js/package.json b/amf-shapes/js/package.json index dc76234b59..d4f767e159 100644 --- a/amf-shapes/js/package.json +++ b/amf-shapes/js/package.json @@ -11,7 +11,7 @@ "url": "https://github.com/aml-org/amf" }, "dependencies": { - "@aml-org/amf-antlr-parsers": "0.6.21", + "@aml-org/amf-antlr-parsers": "0.6.22", "ajv": "6.12.6" } } diff --git a/amf-shapes/shared/src/main/scala/amf/shapes/internal/spec/oas/parser/Draft4AllOfParser.scala b/amf-shapes/shared/src/main/scala/amf/shapes/internal/spec/oas/parser/Draft4AllOfParser.scala index 187d17d571..a060a4339d 100644 --- a/amf-shapes/shared/src/main/scala/amf/shapes/internal/spec/oas/parser/Draft4AllOfParser.scala +++ b/amf-shapes/shared/src/main/scala/amf/shapes/internal/spec/oas/parser/Draft4AllOfParser.scala @@ -5,7 +5,7 @@ import amf.core.internal.metamodel.domain.ShapeModel import amf.core.internal.parser.YMapOps import amf.core.internal.parser.domain.Annotations import amf.shapes.internal.spec.common.SchemaVersion -import amf.shapes.internal.spec.common.parser.ShapeParserContext +import amf.shapes.internal.spec.common.parser.{ShapeParserContext, YMapEntryLike} import amf.shapes.internal.validation.definitions.ShapeParserSideValidations.InvalidAndType import org.yaml.model.{YMap, YMapEntry, YNode} @@ -21,12 +21,10 @@ case class AndConstraintParser(map: YMap, shape: Shape, adopt: Shape => Unit, ve entry.value.to[Seq[YNode]] match { case Right(seq) => val andNodes = seq.zipWithIndex - .map { case (node, index) => - val entry = YMapEntry(YNode(s"item$index"), node) - OasTypeParser(entry, item => Unit, version).parse() + .flatMap { case (node, index) => + val entry = YMapEntryLike(node) + OasTypeParser(entry, s"item$index", _ => Unit, version).parse() } - .filter(_.isDefined) - .map(_.get) shape.fields.setWithoutId(ShapeModel.And, AmfArray(andNodes, Annotations(entry.value)), Annotations(entry)) case _ => ctx.eh.violation( diff --git a/amf-shapes/shared/src/main/scala/amf/shapes/internal/spec/oas/parser/InlineOasTypeParser.scala b/amf-shapes/shared/src/main/scala/amf/shapes/internal/spec/oas/parser/InlineOasTypeParser.scala index 9b79dfcc27..bab2da1f22 100644 --- a/amf-shapes/shared/src/main/scala/amf/shapes/internal/spec/oas/parser/InlineOasTypeParser.scala +++ b/amf-shapes/shared/src/main/scala/amf/shapes/internal/spec/oas/parser/InlineOasTypeParser.scala @@ -56,7 +56,7 @@ case class InlineOasTypeParser( private val ast: YPart = entryOrNode.ast - private val nameAnnotations: Annotations = entryOrNode.key.map(n => Annotations(n)).getOrElse(Annotations()) + private val nameAnnotations: Annotations = entryOrNode.key.map(n => Annotations(n)).getOrElse(Annotations.virtual()) def parse(): Option[AnyShape] = { @@ -450,14 +450,10 @@ case class InlineOasTypeParser( entry.value.to[Seq[YNode]] match { case Right(seq) => val unionNodes = seq.zipWithIndex - .map { case (node, index) => - val entry = YMapEntry(YNode(s"item$index"), node) - parser - .OasTypeParser(entry, item => Unit, version) - .parse() + .flatMap { case (node, index) => + val entry = YMapEntryLike(node) + OasTypeParser(entry, s"item$index", _ => Unit, version).parse() } - .filter(_.isDefined) - .map(_.get) shape.fields .setWithoutId(ShapeModel.Or, AmfArray(unionNodes, Annotations(entry.value)), Annotations(entry)) case _ => @@ -484,12 +480,10 @@ case class InlineOasTypeParser( entry.value.to[Seq[YNode]] match { case Right(seq) => val nodes = seq.zipWithIndex - .map { case (node, index) => - val entry = YMapEntry(YNode(s"item$index"), node) - parser.OasTypeParser(entry, item => Unit, version).parse() + .flatMap { case (node, index) => + val entry = YMapEntryLike(node) + OasTypeParser(entry, s"item$index", _ => Unit, version).parse() } - .filter(_.isDefined) - .map(_.get) shape.fields.setWithoutId(ShapeModel.Xone, AmfArray(nodes, Annotations(entry.value)), Annotations(entry)) case _ => ctx.eh.violation( diff --git a/amf-shapes/shared/src/main/scala/amf/shapes/internal/spec/oas/parser/OasTypeParser.scala b/amf-shapes/shared/src/main/scala/amf/shapes/internal/spec/oas/parser/OasTypeParser.scala index 82c9a17304..de81fd3a00 100644 --- a/amf-shapes/shared/src/main/scala/amf/shapes/internal/spec/oas/parser/OasTypeParser.scala +++ b/amf-shapes/shared/src/main/scala/amf/shapes/internal/spec/oas/parser/OasTypeParser.scala @@ -150,7 +150,7 @@ case class Draft4TypeParser( )(implicit val ctx: ShapeParserContext) { private val ast: YPart = entryOrNode.ast - private val nameAnnotations: Annotations = entryOrNode.key.map(n => Annotations(n)).getOrElse(Annotations()) + private val nameAnnotations: Annotations = entryOrNode.key.map(n => Annotations(n)).getOrElse(Annotations.virtual()) def parse: Option[AnyShape] = { val hasLink = LinkCriteria.detect(map).isDefined diff --git a/amf-shapes/shared/src/main/scala/amf/shapes/internal/spec/raml/parser/RamlTypeDetector.scala b/amf-shapes/shared/src/main/scala/amf/shapes/internal/spec/raml/parser/RamlTypeDetector.scala index 1a3764c912..258556f6fb 100644 --- a/amf-shapes/shared/src/main/scala/amf/shapes/internal/spec/raml/parser/RamlTypeDetector.scala +++ b/amf-shapes/shared/src/main/scala/amf/shapes/internal/spec/raml/parser/RamlTypeDetector.scala @@ -52,15 +52,18 @@ case class RamlTypeDetector( )(implicit ctx: ShapeParserContext) extends RamlTypeSyntax { - def detect(node: YNode): Option[TypeDef] = node.tagType match { + def detect(node: YNode): Option[TypeDef] = node.value match { - case YType.Seq => - val sequence = node.as[Seq[YNode]] - InheritsTypeDetecter(collectTypeDefs(sequence), node).orElse(Some(ObjectType)) // type expression type? + case sequence: YSequence if sequence.isEmpty => + ctx.eh.violation(EmptyTypeExpressionArray, "", "[] is not a valid type", node.location) + Some(ObjectType) // keep compatibility with non empty case - case YType.Map => detectOrInferType(node) + case sequence: YSequence => + InheritsTypeDetecter(collectTypeDefs(sequence.nodes), node).orElse(Some(ObjectType)) // type expression type? - case YType.Null => Some(defaultType.typeDef) + case _: YMap => detectOrInferType(node) + + case _ if node.tagType == YType.Null => Some(defaultType.typeDef) case _ => val scalar = node.as[YScalar] @@ -123,7 +126,7 @@ case class RamlTypeDetector( private def parseAndMatchTypeExpression(node: YNode, text: String) = { RamlExpressionParser - .check(shape => shape.withId("/"), text) + .check(shape => shape.withId("/"), text, node) .flatMap(s => ShapeClassTypeDefMatcher(s, node, recursive)) .map { case TypeDef.UnionType | TypeDef.ArrayType if !recursive => TypeExpressionType diff --git a/amf-shapes/shared/src/main/scala/amf/shapes/internal/spec/raml/parser/expression/AbstractParser.scala b/amf-shapes/shared/src/main/scala/amf/shapes/internal/spec/raml/parser/expression/AbstractParser.scala index 132734a2e4..e4f644d0a1 100644 --- a/amf-shapes/shared/src/main/scala/amf/shapes/internal/spec/raml/parser/expression/AbstractParser.scala +++ b/amf-shapes/shared/src/main/scala/amf/shapes/internal/spec/raml/parser/expression/AbstractParser.scala @@ -9,29 +9,31 @@ private[expression] trait AbstractParser { previous() } - protected def check(token: String) = { + protected def expect(token: String) = { if (isAtEnd) false - else peek().token == token + else peek().exists(_.token == token) } - protected def peek() = tokens(current) + protected def peek() = tokens.lift(current) protected def previous(): Token = tokens(current - 1) + protected def expectPrevious(token: String) = tokens.lift(current - 2).exists(_.token == token) + protected def consume(token: String) = { - if (check(token)) Some(advance()) + if (expect(token)) Some(advance()) else None } protected def consumeToEnd(): Seq[Token] = { - val rest = tokens.splitAt(current)._2 + val (_, rest) = tokens.splitAt(current) current = tokens.size rest } protected def consumeUntil(token: String): Seq[Token] = { var accumulated = Seq[Token]() - while (!check(token) && !isAtEnd) { + while (!expect(token) && !isAtEnd) { accumulated = accumulated :+ advance() } accumulated diff --git a/amf-shapes/shared/src/main/scala/amf/shapes/internal/spec/raml/parser/expression/AnnotationHelper.scala b/amf-shapes/shared/src/main/scala/amf/shapes/internal/spec/raml/parser/expression/AnnotationHelper.scala index d3563a7789..85c2a442a6 100644 --- a/amf-shapes/shared/src/main/scala/amf/shapes/internal/spec/raml/parser/expression/AnnotationHelper.scala +++ b/amf-shapes/shared/src/main/scala/amf/shapes/internal/spec/raml/parser/expression/AnnotationHelper.scala @@ -20,9 +20,9 @@ private[expression] trait AnnotationHelper { } protected def setShapeAnnotation(shapeToAnnotate: Shape, leftShape: Shape, rightShape: Shape): Shape = { - val leftLexical = leftShape.annotations.find(classOf[LexicalInformation]).get - val rightLexical = rightShape.annotations.find(classOf[LexicalInformation]).get - val nextAnnotations = annotations.copy() += LexicalInformation(leftLexical.range.start, rightLexical.range.`end`) + val leftLexical = leftShape.annotations.lexical() + val rightLexical = rightShape.annotations.lexical() + val nextAnnotations = annotations.copy() += LexicalInformation(leftLexical.start, rightLexical.`end`) shapeToAnnotate.annotations ++= nextAnnotations shapeToAnnotate } diff --git a/amf-shapes/shared/src/main/scala/amf/shapes/internal/spec/raml/parser/expression/RamlExpressionASTBuilder.scala b/amf-shapes/shared/src/main/scala/amf/shapes/internal/spec/raml/parser/expression/RamlExpressionASTBuilder.scala index cb9e61d55b..c495a3ecbb 100644 --- a/amf-shapes/shared/src/main/scala/amf/shapes/internal/spec/raml/parser/expression/RamlExpressionASTBuilder.scala +++ b/amf-shapes/shared/src/main/scala/amf/shapes/internal/spec/raml/parser/expression/RamlExpressionASTBuilder.scala @@ -22,53 +22,56 @@ private[expression] class RamlExpressionASTBuilder( extends AbstractParser with AnnotationHelper { - private val parsedShapes = mutable.Stack[Shape]() - - def build(): Option[Shape] = { - if (tokens.isEmpty) return None + def build(previous: Option[Shape] = None): Option[Shape] = { + var result = previous + if (tokens.isEmpty) return result while (!isAtEnd) { val current = advance() - val maybeShape = current.token match { + result = current.token match { case SYMBOL => Some(parseSymbol(current)) - case START_ARRAY => Some(parseArray(current)) - case UNION => Some(parseUnion(current)) - case START_GROUP => parseGroup(current) - case _ => None + case START_ARRAY => Some(parseArray(current, result)) + case UNION => Some(parseUnion(current, result)) + case START_GROUP => parseGroup(current, result) + case _ => result } - maybeShape.foreach(parsedShapes.push) } - parsedShapes.headOption + result } - private def parseGroup(token: Token): Option[Shape] = { + private def parseGroup(token: Token, previous: Option[Shape]): Option[Shape] = { val tokens = consumeUntil(END_GROUP) val maybeEndGroup = consume(END_GROUP) - val optionalShape = - new RamlExpressionASTBuilder(tokens, declarationFinder, annotations, unresolvedRegister).build() + val optionalShape = parse(tokens, previous) optionalShape.foreach(s => s.annotations += GroupedTypeExpression()) optionalShape.foreach(s => setShapeAnnotation(s, token, maybeEndGroup)) optionalShape } - private def parseUnion(token: Token): Shape = { + private def parseUnion(token: Token, previous: Option[Shape]): Shape = { val union = UnionShape() - if (parsedShapes.isEmpty) { - throwError("Syntax error, cannot create empty Union", token) - return union - } - val tokens = consumeToEnd() - val optionalShape = - new RamlExpressionASTBuilder(tokens, declarationFinder, annotations, unresolvedRegister).build() - val previousShape = parsedShapes.pop() - optionalShape match { - case Some(shape) => - val nextAnyOf = calculateAnyOf(previousShape, shape) - union.setWithoutId(UnionShapeModel.AnyOf, AmfArray(nextAnyOf), Annotations(SingleExpression())) - setShapeAnnotation(union, previousShape, shape) - case None => union + previous match { + case None => + throwError("Syntax error, cannot create empty Union", token) + union + case Some(previousShape) => + val tokens = consumeToEnd() + val optionalShape = parse(tokens) + optionalShape match { + case Some(shape) => + val nextAnyOf = calculateAnyOf(previousShape, shape) + union.setWithoutId(UnionShapeModel.AnyOf, AmfArray(nextAnyOf), Annotations(SingleExpression())) + setShapeAnnotation(union, previousShape, shape) + case None => union + } } } + private def parse(tokens: Seq[Token]): Option[Shape] = parse(tokens, None) + + private def parse(tokens: Seq[Token], previous: Option[Shape]): Option[Shape] = { + new RamlExpressionASTBuilder(tokens, declarationFinder, annotations, unresolvedRegister).build(previous) + } + private def calculateAnyOf(previousShape: Shape, nextShape: Shape): Seq[Shape] = { val atLeastOneIsDeclaredElement = linksToDeclaredElement(previousShape) || linksToDeclaredElement(nextShape) if (atLeastOneIsDeclaredElement) return Seq(previousShape, nextShape) @@ -80,26 +83,27 @@ private[expression] class RamlExpressionASTBuilder( } } - private def parseArray(token: Token): Shape = { + private def parseArray(token: Token, previous: Option[Shape]): Shape = { val array = ArrayShape() - if (parsedShapes.isEmpty) { - throwError("Syntax error, generating empty array", token) - return array - } - val maybeEndToken = consume(END_ARRAY) - if (maybeEndToken.isEmpty) { - throwError("Syntax error, expected ]", token) - return array - } - val previousShape = parsedShapes.pop() - val finalShape = previousShape match { - case _: ArrayShape => - ArrayShape() - .setWithoutId(ArrayShapeModel.Items, previousShape, Annotations(SingleExpression())) - .toMatrixShapeWithoutId - case _ => ArrayShape().setWithoutId(ArrayShapeModel.Items, previousShape, Annotations(SingleExpression())) + previous match { + case None => + throwError("Syntax error, generating empty array", token) + array + case Some(previousShape) => + val maybeEndToken = consume(END_ARRAY) + if (maybeEndToken.isEmpty) { + throwError("Syntax error, expected ]", token) + return array + } + val finalShape = previousShape match { + case _: ArrayShape => + ArrayShape() + .setWithoutId(ArrayShapeModel.Items, previousShape, Annotations(SingleExpression())) + .toMatrixShapeWithoutId + case _ => ArrayShape().setWithoutId(ArrayShapeModel.Items, previousShape, Annotations(SingleExpression())) + } + setShapeAnnotation(finalShape, token, maybeEndToken) } - setShapeAnnotation(finalShape, token, maybeEndToken) } private def parseSymbol(token: Token): Shape = { diff --git a/amf-shapes/shared/src/main/scala/amf/shapes/internal/spec/raml/parser/expression/RamlExpressionParser.scala b/amf-shapes/shared/src/main/scala/amf/shapes/internal/spec/raml/parser/expression/RamlExpressionParser.scala index 31ee2a526c..e878dcf5e1 100644 --- a/amf-shapes/shared/src/main/scala/amf/shapes/internal/spec/raml/parser/expression/RamlExpressionParser.scala +++ b/amf-shapes/shared/src/main/scala/amf/shapes/internal/spec/raml/parser/expression/RamlExpressionParser.scala @@ -11,15 +11,14 @@ import org.yaml.model._ object RamlExpressionParser { def parse(adopt: Shape => Unit, expression: String, part: YPart)(implicit ctx: ShapeParserContext): Option[Shape] = { - val node = getValue(part) - val annotations = Annotations(node).reject(a => a.isInstanceOf[LexicalInformation]) - val position = Position(node.location.lineFrom, node.location.columnFrom) - val tokens = new RamlExpressionLexer(expression, position).lex() + val node = getValue(part) + val position = Position(node.location.lineFrom, node.location.columnFrom) + val tokens = new RamlExpressionLexer(expression, position).lex() val builder = new RamlExpressionASTBuilder( tokens, ContextDeclarationFinder(ctx), - annotations, + annotations(node), ContextRegister(ctx, Some(node)) )(ctx.eh) val result = builder @@ -29,15 +28,27 @@ object RamlExpressionParser { result } - def check(adopt: Shape => Unit, expression: String)(implicit ctx: ShapeParserContext): Option[Shape] = { - val tokens = new RamlExpressionLexer(expression, Position.ZERO).lex() + def check(adopt: Shape => Unit, expression: String, part: YPart = YNode.Empty)(implicit + ctx: ShapeParserContext + ): Option[Shape] = { + val tokens = new RamlExpressionLexer(expression, part.location.from).lex() val builder = - new RamlExpressionASTBuilder(tokens, ContextDeclarationFinder(ctx), unresolvedRegister = EmptyRegister())(ctx.eh) + new RamlExpressionASTBuilder( + tokens, + ContextDeclarationFinder(ctx), + annotations(getValue(part)), + unresolvedRegister = EmptyRegister() + )(ctx.eh) val result = builder.build() result.foreach(adopt(_)) result } + private def annotations(node: YValue) = { + val annotations = Annotations(node).reject(a => a.isInstanceOf[LexicalInformation]) + annotations + } + private def addAnnotations(shape: Shape, part: YPart, expression: String): Shape = { shape.annotations.reject(a => a.isInstanceOf[LexicalInformation] || a.isInstanceOf[SourceNode] || a.isInstanceOf[SourceAST] || a diff --git a/amf-shapes/shared/src/main/scala/amf/shapes/internal/validation/definitions/ShapeParserSideValidations.scala b/amf-shapes/shared/src/main/scala/amf/shapes/internal/validation/definitions/ShapeParserSideValidations.scala index bb06803f78..05873ac904 100644 --- a/amf-shapes/shared/src/main/scala/amf/shapes/internal/validation/definitions/ShapeParserSideValidations.scala +++ b/amf-shapes/shared/src/main/scala/amf/shapes/internal/validation/definitions/ShapeParserSideValidations.scala @@ -387,6 +387,11 @@ object ShapeParserSideValidations extends Validations { "The definition key present in the ref is not the correct for the JSON Schema" ) + val EmptyTypeExpressionArray = validation( + "empty-type-expression-array", + "Empty type expression array" + ) + override val levels: Map[String, Map[ProfileName, String]] = Map( InvalidShapeFormat.id -> all(WARNING), JsonSchemaInheritanceWarning.id -> all(WARNING), @@ -442,6 +447,7 @@ object ShapeParserSideValidations extends Validations { JsonSchemaDefinitionNotFound, InvalidJsonSchemaReference, MultipleDefinitionKey, - IncorrectDefinitionKey + IncorrectDefinitionKey, + EmptyTypeExpressionArray ) } diff --git a/amf-shapes/shared/src/main/scala/amf/shapes/internal/validation/payload/JsonSchemaPayloadValidationPlugin.scala b/amf-shapes/shared/src/main/scala/amf/shapes/internal/validation/payload/JsonSchemaPayloadValidationPlugin.scala index 939ff528a3..a026c8b8a7 100644 --- a/amf-shapes/shared/src/main/scala/amf/shapes/internal/validation/payload/JsonSchemaPayloadValidationPlugin.scala +++ b/amf-shapes/shared/src/main/scala/amf/shapes/internal/validation/payload/JsonSchemaPayloadValidationPlugin.scala @@ -2,12 +2,7 @@ package amf.shapes.internal.validation.payload import amf.core.client.common.validation.{ProfileName, ProfileNames} import amf.core.internal.plugins.validation.ValidationInfo -import amf.shapes.internal.validation.payload.collector.{ - EnumInShapesCollector, - ExtensionsCollector, - PayloadsCollector, - ValidationCandidateCollector -} +import amf.shapes.internal.validation.payload.collector.{DiscriminatorValuesCollector, EnumInShapesCollector, ExtensionsCollector, PayloadsCollector, ValidationCandidateCollector} import amf.shapes.internal.validation.plugin.JsonSchemaModelValidationPlugin object JsonSchemaPayloadValidationPlugin { @@ -23,7 +18,7 @@ class JsonSchemaPayloadValidationPlugin() extends BasePayloadValidationPlugin wi override val profile: ProfileName = ProfileNames.JSONSCHEMA override val collectors: Seq[ValidationCandidateCollector] = - Seq(PayloadsCollector, EnumInShapesCollector, ExtensionsCollector) + Seq(PayloadsCollector, EnumInShapesCollector, ExtensionsCollector, DiscriminatorValuesCollector) override val id: String = JsonSchemaPayloadValidationPlugin.id diff --git a/amf-shapes/shared/src/main/scala/amf/shapes/internal/validation/payload/collector/DiscriminatorValuesCollector.scala b/amf-shapes/shared/src/main/scala/amf/shapes/internal/validation/payload/collector/DiscriminatorValuesCollector.scala new file mode 100644 index 0000000000..12217157e1 --- /dev/null +++ b/amf-shapes/shared/src/main/scala/amf/shapes/internal/validation/payload/collector/DiscriminatorValuesCollector.scala @@ -0,0 +1,37 @@ +package amf.shapes.internal.validation.payload.collector + +import amf.core.client.scala.model.document.PayloadFragment +import amf.core.client.scala.model.domain.extensions.PropertyShape +import amf.core.client.scala.model.domain.{AmfElement, DataNode, ScalarNode, Shape} +import amf.core.internal.metamodel.domain.ShapeModel +import amf.core.internal.remote.Mimes.`application/json` +import amf.core.internal.utils.MediaTypeMatcher +import amf.core.internal.validation.ValidationCandidate +import amf.shapes.client.scala.model.domain.{AnyShape, NodeShape, ScalarShape} + +object DiscriminatorValuesCollector extends ValidationCandidateCollector { + + override def collect(element: AmfElement): Seq[ValidationCandidate] = { + element match { + case node: NodeShape if hasDiscriminator(node) && hasDiscriminatorValue(node) => discriminatorValueCandidate(node) + case _ => Nil + } + } + private def discriminatorValueCandidate(node: NodeShape): Seq[ValidationCandidate] = { + findDiscriminatorProperty(node) match { + case Some(prop) => + val schema = prop.range + val value = node.discriminatorValue.value() + ValidationCandidate(schema, PayloadFragment(value, `application/json`)) :: Nil + case None => Nil + } + } + + private def hasDiscriminator(node: NodeShape): Boolean = node.discriminator.nonEmpty + private def hasDiscriminatorValue(node: NodeShape): Boolean = node.discriminatorValue.nonEmpty + + private def findDiscriminatorProperty(node: NodeShape): Option[PropertyShape] = { + val discriminatorPropertyName = node.discriminator.value() + node.properties.find(_.name.value() == discriminatorPropertyName) + } +}