Skip to content

Commit

Permalink
Merge pull request #147 from aml-org/publish-23.0.0-2.7.0
Browse files Browse the repository at this point in the history
Publish 23.0.0 2.7.0
  • Loading branch information
hghianni authored May 4, 2022
2 parents a0429b5 + e7350ac commit d2172ed
Show file tree
Hide file tree
Showing 26 changed files with 576 additions and 269 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,6 @@ project/plugins/project/
.lib/
# Ignore Gradle build output directory
build
.bsp
.bsp
.metals
.vscode
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@ import java.io.{File, FileWriter, StringWriter, Writer}
import amf.core.internal.metamodel.Type.Scalar
import amf.core.internal.metamodel.document.BaseUnitModel
import amf.core.internal.metamodel.{Field, Obj, Type}
import amf.core.internal.metamodel.domain.{DataNodeModel, DomainElementModel, LinkableElementModel, ModelDoc, ModelVocabularies, ObjectNodeModel}
import amf.core.internal.metamodel.domain.{
DataNodeModel,
DomainElementModel,
LinkableElementModel,
ModelDoc,
ModelVocabularies,
ObjectNodeModel
}
import org.reflections.Reflections
import org.reflections.scanners.SubTypesScanner
import org.yaml.model.YPart
Expand Down Expand Up @@ -200,10 +207,6 @@ class CanonicalWebAPISpecDialectExporter(logger: Logger = ConsoleLogger) {
DomainElementModel.CustomDomainProperties.value.iri(),
BaseUnitModel.ProcessingData.value.iri(),
BaseUnitModel.SourceInformation.value.iri(),

// graphQL model that is still not definitive
NodeShapeModel.Operations.value.iri(),
NodeShapeModel.IsAbstract.value.iri()
)

val blocklistedSupertypes: Set[String] = Set(
Expand All @@ -226,14 +229,6 @@ class CanonicalWebAPISpecDialectExporter(logger: Logger = ConsoleLogger) {
(Namespace.Document + "BaseUnitProcessingData").iri(),
(Namespace.Document + "BaseUnitSourceInformation").iri(),
(Namespace.Document + "LocationInformation").iri(),

// graphQL model that is still not definitive
(Namespace.Shapes + "Operation").iri(),
(Namespace.Shapes + "Parameter").iri(),
(Namespace.Shapes + "Payload").iri(),
(Namespace.Shapes + "Request").iri(),
(Namespace.Shapes + "Response").iri(),

)

val shapeUnionDeclaration = "DataShapesUnion"
Expand Down Expand Up @@ -359,6 +354,9 @@ class CanonicalWebAPISpecDialectExporter(logger: Logger = ConsoleLogger) {
| allowMultiple: true
""".stripMargin

val requestExtends: String = messageExtends
val responseExtends: String = messageExtends

val dataNodeUnionDeclaration = "DataNodeUnion"
val dataNodeUnion: String =
s"""
Expand Down Expand Up @@ -477,7 +475,7 @@ class CanonicalWebAPISpecDialectExporter(logger: Logger = ConsoleLogger) {

val channelBindingUnionDeclaration: String = "ChannelBindingUnion"
val channelBindingUnion: String =
s""" $channelBindingUnionDeclaration:
s""" $channelBindingUnionDeclaration:
| typeDiscriminatorName: bindingType
| typeDiscriminator:
| WebSockets: WebSocketsChannelBinding
Expand Down Expand Up @@ -619,6 +617,10 @@ class CanonicalWebAPISpecDialectExporter(logger: Logger = ConsoleLogger) {
stringBuilder.append(operationExtends + "\n")
} else if (dialectNodeMapping.classTerm == (Namespace.ApiContract + "Message").iri()) {
stringBuilder.append(messageExtends + "\n")
} else if (dialectNodeMapping.classTerm == (Namespace.ApiContract + "Request").iri()) {
stringBuilder.append(requestExtends + "\n")
} else if (dialectNodeMapping.classTerm == (Namespace.ApiContract + "Response").iri()) {
stringBuilder.append(responseExtends + "\n")
} else if (dialectNodeMapping.classTerm == (Namespace.Document + "Unit").iri()) {
stringBuilder.append(baseUnitLocation)
}
Expand Down Expand Up @@ -681,7 +683,8 @@ class CanonicalWebAPISpecDialectExporter(logger: Logger = ConsoleLogger) {
stringBuilder.append(s" range: link\n")
}

val annotationMapping = dialectNodeMapping.propertyMappings.find(_.propertyTerm == DomainElementModel.CustomDomainProperties.value.iri())
val annotationMapping = dialectNodeMapping.propertyMappings.find(
_.propertyTerm == DomainElementModel.CustomDomainProperties.value.iri())
if (annotationMapping.isDefined) {
stringBuilder.append(s" designAnnotations:\n")
val (compacted, _, _) = compact(DesignAnnotationField.value.iri())
Expand Down Expand Up @@ -761,15 +764,14 @@ class CanonicalWebAPISpecDialectExporter(logger: Logger = ConsoleLogger) {
}
}


object CanonicalWebAPISpecDialectExporter {

val DIALECT_FILE = "vocabulary/src/main/resources/dialects/canonical_webapi_spec.yaml"

def main(args: Array[String]): Unit = {
val exporter = new CanonicalWebAPISpecDialectExporter()
val f = new File(DIALECT_FILE)
val writer = new FileWriter(f)
val f = new File(DIALECT_FILE)
val writer = new FileWriter(f)
exporter.dumpDialect(writer)
}
}
Loading

0 comments on commit d2172ed

Please sign in to comment.