Skip to content

Commit

Permalink
Merge pull request #1767 from aml-org/publish-5.2.6
Browse files Browse the repository at this point in the history
Publish 5.2.6
  • Loading branch information
looseale authored Apr 4, 2023
2 parents cda9e79 + c4e3c01 commit 0671099
Show file tree
Hide file tree
Showing 1,057 changed files with 2,417 additions and 1,540 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
FROM ghcr.io/aml-org/amf-ci-tools-base-image:1.2.0
FROM ghcr.io/aml-org/amf-ci-tools-base-image:1.3.0
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ import amf.shapes.internal.spec.raml.parser.{
RamlTypeEntryParser,
RamlTypeSyntax,
RamlWebApiContextType,
StringDefaultType
StringDefaultType,
TypeInfo
}
import amf.shapes.internal.validation.definitions.ShapeParserSideValidations.{
ExclusiveSchemasType,
Expand Down Expand Up @@ -428,7 +429,8 @@ abstract class RamlBaseDocumentParser(implicit ctx: RamlWebApiContext) extends R
}
val parser = Raml10TypeParser(
entry,
_ => {}
_ => {},
TypeInfo(isDeclaredType = true)
)
parser.parse() match {
case Some(shape) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,13 @@ object APIRawValidations extends CommonValidationDefinitions {
owlClass = security("SecurityScheme"),
owlProperty = doc("-"),
constraint = shape("exclusiveQueryStringAndQueryParametersProperties")
),
AMFValidation(
uri = amfParser("inheritance-from-json-schema"),
owlClass = shape("AnyShape"),
owlProperty = doc("-"),
constraint = shape("inheritanceFromJsonSchema"),
severity = SeverityLevels.WARNING
)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ import amf.core.internal.metamodel.domain.extensions.{CustomDomainPropertyModel,
import amf.core.internal.parser.domain.Annotations
import amf.shapes.client.scala.model.domain._
import amf.shapes.client.scala.model.domain.operations.AbstractParameter
import amf.shapes.internal.annotations.DirectiveArguments
import amf.shapes.internal.annotations.{DirectiveArguments, ParsedJSONSchema}
import amf.shapes.internal.domain.metamodel._
import amf.shapes.internal.domain.metamodel.operations.{AbstractParameterModel, ShapeRequestModel}
import amf.shapes.internal.validation.shacl.{BaseCustomShaclFunctions, ShapesCustomShaclFunctions}
import amf.validation.internal.shacl.custom.CustomShaclValidator.ValidationInfo.validationInfo
import amf.validation.internal.shacl.custom.CustomShaclValidator.{CustomShaclFunction, ValidationInfo}

object APICustomShaclFunctions extends BaseCustomShaclFunctions {
Expand Down Expand Up @@ -229,12 +230,10 @@ object APICustomShaclFunctions extends BaseCustomShaclFunctions {
else if (isInput) "Input Type"
else "Type"
validate(
Some(
ValidationInfo(
NodeShapeModel.Properties,
Some(s"$nodeType definitions must have at least one field"),
Some(element.annotations)
)
validationInfo(
NodeShapeModel.Properties,
s"$nodeType definitions must have at least one field",
element.annotations
)
)
}
Expand Down Expand Up @@ -688,10 +687,57 @@ object APICustomShaclFunctions extends BaseCustomShaclFunctions {
}
},
DuplicatedOas3EndpointPathValidation(),
DuplicatedCommonEndpointPathValidation()
DuplicatedCommonEndpointPathValidation(),
new CustomShaclFunction {
override val name: String = "inheritanceFromJsonSchema"

def isJsonSchema(s: Shape): Boolean = s.annotations.contains(classOf[ParsedJSONSchema])

override def run(element: AmfObject, validate: Option[ValidationInfo] => Unit): Unit = {
element match {
case s: ScalarShape if s.inherits.nonEmpty =>
s.inherits
.filter(isJsonSchema)
.foreach(s =>
validate(
validationInfo(
ShapeModel.Inherits,
s"JSON Schemas can't be used in type expressions or type inheritance",
s.annotations
)
)
)

case u: UnionShape if u.anyOf.nonEmpty =>
u.anyOf
.filter(isJsonSchema)
.foreach(s =>
validate(
validationInfo(
UnionShapeModel.AnyOf,
s"${s.name} is a JSON Schema and can't be used in type expressions or type inheritance",
u.annotations
)
)
)

case arr: ArrayShape if Option(arr.items).isDefined =>
if (isJsonSchema(arr.items))
validate(
validationInfo(
ArrayShapeModel.Items,
s"JSON Schemas can't be used in type expressions or type inheritance",
arr.annotations
)
)

case _ => // ignore
}
}
}
)

private def validateObjectAndHasProperties(element: AmfElement) = {
private def validateObjectAndHasProperties(element: AmfElement): Boolean = {
element match {
case element: NodeShape =>
element.properties.exists(p => p.patternName.option().isEmpty) || element.fields.exists(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@ package amf.apicontract.internal.validation.shacl.graphql
import amf.apicontract.internal.validation.shacl.graphql.values.ValueValidator
import amf.core.client.scala.model.domain.extensions.PropertyShape
import amf.core.client.scala.model.domain._
import amf.core.internal.metamodel.Field
import amf.core.internal.metamodel.domain.{DomainElementModel, ScalarNodeModel}
import amf.core.internal.metamodel.domain.DomainElementModel
import amf.core.internal.metamodel.domain.extensions.{DomainExtensionModel, PropertyShapePathModel}
import amf.core.internal.parser.domain.Annotations
import amf.shapes.client.scala.model.domain._
import amf.shapes.client.scala.model.domain.federation.Key
import amf.shapes.internal.domain.metamodel.NodeShapeModel
import amf.shapes.internal.domain.metamodel.operations.AbstractParameterModel
import amf.validation.internal.shacl.custom.CustomShaclValidator.ValidationInfo
import amf.validation.internal.shacl.custom.CustomShaclValidator.ValidationInfo.validationInfo

import scala.annotation.tailrec

Expand Down Expand Up @@ -311,8 +310,4 @@ object GraphQLValidator {
case arr: ArrayShape => s"[${getShapeName(arr.items)}]"
case s => s.name.value()
}

private def validationInfo(field: Field, message: String, annotations: Annotations): Some[ValidationInfo] = {
Some(ValidationInfo(field, Some(message), Some(annotations)))
}
}
6 changes: 3 additions & 3 deletions amf-apicontract.versions
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
amf.apicontract=5.2.5
amf.aml=6.2.5
amf.model=3.8.1
amf.apicontract=5.2.6
amf.aml=6.2.6
amf.model=3.8.2
antlr4Version=0.6.22
amf.validation.profile.dialect=1.4.0
amf.validation.report.dialect=1.1.0
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"@type": [
"http://a.ml/vocabularies/document#APIContractProcessingData"
],
"http://a.ml/vocabularies/apiContract#modelVersion": "3.8.1"
"http://a.ml/vocabularies/apiContract#modelVersion": "3.8.2"
},
{
"@id": "root/async-api",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"@type": [
"http://a.ml/vocabularies/document#APIContractProcessingData"
],
"http://a.ml/vocabularies/apiContract#modelVersion": "3.8.1"
"http://a.ml/vocabularies/apiContract#modelVersion": "3.8.2"
},
{
"@id": "root/web-api",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"@type": [
"doc:APIContractProcessingData"
],
"apiContract:modelVersion": "3.8.1",
"apiContract:modelVersion": "3.8.2",
"doc:transformed": true,
"doc:sourceSpec": "GraphQLFederation"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
],
"http://a.ml/vocabularies/apiContract#modelVersion": [
{
"@value": "3.8.1"
"@value": "3.8.2"
}
],
"http://a.ml/vocabularies/document#sourceSpec": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
],
"http://a.ml/vocabularies/apiContract#modelVersion": [
{
"@value": "3.8.1"
"@value": "3.8.2"
}
],
"http://a.ml/vocabularies/document#sourceSpec": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
],
"http://a.ml/vocabularies/apiContract#modelVersion": [
{
"@value": "3.8.1"
"@value": "3.8.2"
}
],
"http://a.ml/vocabularies/document#sourceSpec": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
],
"http://a.ml/vocabularies/apiContract#modelVersion": [
{
"@value": "3.8.1"
"@value": "3.8.2"
}
],
"http://a.ml/vocabularies/document#sourceSpec": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@
],
"http://a.ml/vocabularies/apiContract#modelVersion": [
{
"@value": "3.8.1"
"@value": "3.8.2"
}
],
"http://a.ml/vocabularies/document#sourceSpec": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
],
"http://a.ml/vocabularies/apiContract#modelVersion": [
{
"@value": "3.8.1"
"@value": "3.8.2"
}
],
"http://a.ml/vocabularies/document#sourceSpec": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
],
"http://a.ml/vocabularies/apiContract#modelVersion": [
{
"@value": "3.8.1"
"@value": "3.8.2"
}
],
"http://a.ml/vocabularies/document#sourceSpec": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
],
"http://a.ml/vocabularies/apiContract#modelVersion": [
{
"@value": "3.8.1"
"@value": "3.8.2"
}
],
"http://a.ml/vocabularies/document#sourceSpec": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
],
"http://a.ml/vocabularies/apiContract#modelVersion": [
{
"@value": "3.8.1"
"@value": "3.8.2"
}
],
"http://a.ml/vocabularies/document#sourceSpec": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
],
"http://a.ml/vocabularies/apiContract#modelVersion": [
{
"@value": "3.8.1"
"@value": "3.8.2"
}
],
"http://a.ml/vocabularies/document#sourceSpec": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
],
"http://a.ml/vocabularies/apiContract#modelVersion": [
{
"@value": "3.8.1"
"@value": "3.8.2"
}
],
"http://a.ml/vocabularies/document#sourceSpec": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
],
"http://a.ml/vocabularies/apiContract#modelVersion": [
{
"@value": "3.8.1"
"@value": "3.8.2"
}
],
"http://a.ml/vocabularies/document#sourceSpec": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
],
"http://a.ml/vocabularies/apiContract#modelVersion": [
{
"@value": "3.8.1"
"@value": "3.8.2"
}
],
"http://a.ml/vocabularies/document#sourceSpec": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
],
"http://a.ml/vocabularies/apiContract#modelVersion": [
{
"@value": "3.8.1"
"@value": "3.8.2"
}
],
"http://a.ml/vocabularies/document#sourceSpec": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
],
"http://a.ml/vocabularies/apiContract#modelVersion": [
{
"@value": "3.8.1"
"@value": "3.8.2"
}
],
"http://a.ml/vocabularies/document#sourceSpec": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
],
"http://a.ml/vocabularies/apiContract#modelVersion": [
{
"@value": "3.8.1"
"@value": "3.8.2"
}
],
"http://a.ml/vocabularies/document#sourceSpec": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
],
"http://a.ml/vocabularies/apiContract#modelVersion": [
{
"@value": "3.8.1"
"@value": "3.8.2"
}
],
"http://a.ml/vocabularies/document#sourceSpec": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
],
"http://a.ml/vocabularies/apiContract#modelVersion": [
{
"@value": "3.8.1"
"@value": "3.8.2"
}
],
"http://a.ml/vocabularies/document#sourceSpec": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
],
"http://a.ml/vocabularies/apiContract#modelVersion": [
{
"@value": "3.8.1"
"@value": "3.8.2"
}
],
"http://a.ml/vocabularies/document#sourceSpec": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
],
"http://a.ml/vocabularies/apiContract#modelVersion": [
{
"@value": "3.8.1"
"@value": "3.8.2"
}
],
"http://a.ml/vocabularies/document#sourceSpec": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
],
"http://a.ml/vocabularies/apiContract#modelVersion": [
{
"@value": "3.8.1"
"@value": "3.8.2"
}
],
"http://a.ml/vocabularies/document#sourceSpec": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
],
"http://a.ml/vocabularies/apiContract#modelVersion": [
{
"@value": "3.8.1"
"@value": "3.8.2"
}
],
"http://a.ml/vocabularies/document#sourceSpec": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
],
"http://a.ml/vocabularies/apiContract#modelVersion": [
{
"@value": "3.8.1"
"@value": "3.8.2"
}
],
"http://a.ml/vocabularies/document#sourceSpec": [
Expand Down
Loading

0 comments on commit 0671099

Please sign in to comment.