Skip to content

Commit

Permalink
Merge pull request #54 from aml-org/release/4.6.0
Browse files Browse the repository at this point in the history
Publish amf-transform 1.6.0 with AMF 4.6.0
  • Loading branch information
tomsfernandez authored Jan 11, 2021
2 parents 7b4b39d + 76fd29b commit 035dc00
Show file tree
Hide file tree
Showing 12 changed files with 47 additions and 47 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ organization in ThisBuild := "com.github.amlorg"
scalaVersion in ThisBuild := "2.12.11"

lazy val amfVocabularyVersion = majorVersionOrSnapshot(6)
val amfCanonicalVersion = versionOrSnapshot(1, 5)
val amfCanonicalVersion = versionOrSnapshot(1, 6)

val ivyLocal = Resolver.file("ivy", file(Path.userHome.absolutePath + "/.ivy2/local"))(Resolver.ivyStylePatterns)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ case class ExtendedDialectNodeMapping(id: String,
isShape: Boolean)

// The actual exporter
class CanonicalWebAPISpecDialectExporter(logger: Logger = new ConsoleLogger()) {
class CanonicalWebAPISpecDialectExporter(logger: Logger = ConsoleLogger) {

val WELL_KNOWN_VOCABULARIES: Map[String, String] = Map[String, String](
"http://a.ml/vocabularies/document#" -> "../vocabularies/aml_doc.yaml",
Expand Down
4 changes: 2 additions & 2 deletions exporters/src/main/scala/amf/exporters/Logger.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ trait Logger {
def log(toLog: String): Unit
}

class ConsoleLogger extends Logger {
object ConsoleLogger extends Logger {
override def log(toLog: String): Unit = println(toLog)
}

class DummyLogger extends Logger {
object TestLogger extends Logger {
override def log(toLog: String): Unit = Unit
}
24 changes: 12 additions & 12 deletions exporters/src/main/scala/amf/exporters/VocabularyExporter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ object VocabularyExporter {

def main(args: Array[String]): Unit = {

dumpVocabularies(createFileWriter)
dumpVocabularies(createFileWriter, logger = ConsoleLogger)

def createFileWriter: ExportedVocabulary => Unit = exported => {
val ExportedVocabulary(vocab, export) = exported
Expand All @@ -678,25 +678,25 @@ object VocabularyExporter {
}
}

def getVocabularyFileUrl(vocab: ModelVocabulary) = {
def getVocabularyFileUrl(vocab: ModelVocabulary): String = {
if (ExternalModelVocabularies.all.contains(vocab)) {
s"vocabulary/src/main/resources/vocabularies/external/${vocab.filename}"
} else {
s"vocabulary/src/main/resources/vocabularies/${vocab.filename}"
}
}

def dumpVocabularies(writeVocabulary: ExportedVocabulary => Unit, vocabularies: Seq[ModelVocabulary] = exportableVocabularies): Unit = {
generateVocabularies(vocabularies).foreach(exported => writeVocabulary(exported))
def dumpVocabularies(writeVocabulary: ExportedVocabulary => Unit, vocabularies: Seq[ModelVocabulary] = exportableVocabularies, logger: Logger): Unit = {
generateVocabularies(vocabularies, logger).foreach(exported => writeVocabulary(exported))
}

def generateVocabularies(vocabularies: Seq[ModelVocabulary] = exportableVocabularies): Seq[ExportedVocabulary] = {
println("*** Starting")
private def generateVocabularies(vocabularies: Seq[ModelVocabulary] = exportableVocabularies, logger: Logger): Seq[ExportedVocabulary] = {
logger.log("*** Starting")

// let's initialize the files
fillInitialFiles()

println("*** Processing classes")
logger.log("*** Processing classes")
metaObjects(reflectionsExtensions, parseMetaObject)
metaObjects(reflectionsCoreDoc, parseMetaObject)
metaObjects(reflectionsCoreDomain, parseMetaObject)
Expand All @@ -709,14 +709,14 @@ object VocabularyExporter {
metaObjects(reflectionsExtModel, parseMetaObject)

// review
println(s"*** Parsed classes: ${classes.keys.toSeq.size}")
logger.log(s"*** Parsed classes: ${classes.keys.toSeq.size}")
//classes.keys.toSeq.sorted.foreach(k => println(s" - ${k}"))

println(s"*** Parsed properties: ${properties.keys.toSeq.size}")
logger.log(s"*** Parsed properties: ${properties.keys.toSeq.size}")
//properties.keys.toSeq.sorted.foreach(k => println(s" - ${k}"))

vocabularies.map { vocab =>
println(s"**** RENDERING ${vocab.filename}")
logger.log(s"**** RENDERING ${vocab.filename}")
val text = renderVocabulary(vocab)
ExportedVocabulary(vocab, text)
}
Expand All @@ -735,9 +735,9 @@ object VocabularyExporter {
ModelVocabularies.Meta
) ++ ExternalModelVocabularies.all

def getVocabulariesAsString: Seq[ExportedVocabulary] = {
def getVocabulariesAsString(logger: Logger): Seq[ExportedVocabulary] = {
var accumulated = Seq[ExportedVocabulary]()
dumpVocabularies(exported => accumulated = accumulated :+ exported)
dumpVocabularies(exported => accumulated = accumulated :+ exported, logger = logger)
accumulated
}
}
8 changes: 4 additions & 4 deletions exporters/src/test/scala/amf/exporters/ExportersTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@ package amf.exporters

import amf.core.metamodel.domain.ModelVocabulary
import amf.helpers.FileAssertionTest
import org.scalatest.{Assertion, Succeeded}
import org.scalatest.funsuite.AsyncFunSuite
import org.scalatest.{Assertion, Succeeded}

import scala.concurrent.{ExecutionContext, Future}
import scala.concurrent.Future

class ExportersTest extends AsyncFunSuite with FileAssertionTest{

test("Canonical WebApi Spec Export Test") {
val exporter = new CanonicalWebAPISpecDialectExporter(new DummyLogger())
val exporter = new CanonicalWebAPISpecDialectExporter(TestLogger)
validateExport(exporter.writeToString, "vocabulary/src/main/resources/dialects/canonical_webapi_spec.yaml")
}

test("Validation Profile Exporter Test") {
val exports: Map[ModelVocabulary, String] = VocabularyExporter.getVocabulariesAsString.map(x => (x.vocab, x.exported)).toMap
val exports: Map[ModelVocabulary, String] = VocabularyExporter.getVocabulariesAsString(TestLogger).map(x => (x.vocab, x.exported)).toMap
val exportableVocabularies = VocabularyExporter.exportableVocabularies

if (exports.size != exportableVocabularies.size) Future.successful { fail("Exportable vocabularies and exported vocabularies have different size") }
Expand Down
2 changes: 1 addition & 1 deletion transform/dependencies.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Leave here for the publication process to detect if amf-transform has to be published!
# Because we publish a version of amf-transform for each version of amf-client publish.
amf.client=4.5.1
amf.client=4.6.0
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
],
"http://a.ml/vocabularies/apiContract#parameter": [
{
"@id": "file://transform/src/test/resources/transformations/fragments/raml/security-scheme/api.raml#/fragment/parameter/access_token",
"@id": "file://transform/src/test/resources/transformations/fragments/raml/security-scheme/api.raml#/fragment/parameter/query/access_token",
"@type": [
"http://a.ml/vocabularies/apiContract#Parameter",
"file://vocabulary/src/main/resources/dialects/canonical_webapi_spec.yaml#/declarations/Parameter",
Expand Down Expand Up @@ -77,7 +77,7 @@
],
"http://a.ml/vocabularies/shapes#schema": [
{
"@id": "file://transform/src/test/resources/transformations/fragments/raml/security-scheme/api.raml#/fragment/parameter/access_token/scalar/schema",
"@id": "file://transform/src/test/resources/transformations/fragments/raml/security-scheme/api.raml#/fragment/parameter/default-binding/access_token/scalar/schema",
"@type": [
"http://a.ml/vocabularies/shapes#ScalarShape",
"file://vocabulary/src/main/resources/dialects/canonical_webapi_spec.yaml#/declarations/ScalarShape",
Expand Down Expand Up @@ -202,7 +202,7 @@
],
"http://a.ml/vocabularies/apiContract#header": [
{
"@id": "file://transform/src/test/resources/transformations/fragments/raml/security-scheme/api.raml#/fragment/parameter/Authorization",
"@id": "file://transform/src/test/resources/transformations/fragments/raml/security-scheme/api.raml#/fragment/parameter/header/Authorization",
"@type": [
"http://a.ml/vocabularies/apiContract#Parameter",
"file://vocabulary/src/main/resources/dialects/canonical_webapi_spec.yaml#/declarations/Parameter",
Expand Down Expand Up @@ -236,7 +236,7 @@
],
"http://a.ml/vocabularies/shapes#schema": [
{
"@id": "file://transform/src/test/resources/transformations/fragments/raml/security-scheme/api.raml#/fragment/parameter/Authorization/scalar/schema",
"@id": "file://transform/src/test/resources/transformations/fragments/raml/security-scheme/api.raml#/fragment/parameter/default-binding/Authorization/scalar/schema",
"@type": [
"http://a.ml/vocabularies/shapes#ScalarShape",
"file://vocabulary/src/main/resources/dialects/canonical_webapi_spec.yaml#/declarations/ScalarShape",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ encodes:
$id: file://transform/src/test/resources/transformations/fragments/raml/security-scheme/api.raml#fragment
parameter:
-
$id: file://transform/src/test/resources/transformations/fragments/raml/security-scheme/api.raml#/fragment/parameter/access_token
$id: file://transform/src/test/resources/transformations/fragments/raml/security-scheme/api.raml#/fragment/parameter/query/access_token
required: true
paramName: access_token
name: access_token
Expand All @@ -18,7 +18,7 @@ encodes:
binding: query
schema:
shapeType: Scalar
$id: file://transform/src/test/resources/transformations/fragments/raml/security-scheme/api.raml#/fragment/parameter/access_token/scalar/schema
$id: file://transform/src/test/resources/transformations/fragments/raml/security-scheme/api.raml#/fragment/parameter/default-binding/access_token/scalar/schema
name: schema
description: |
Used to send a valid OAuth 2 access token. Do not use together with the "Authorization" header.
Expand Down Expand Up @@ -50,7 +50,7 @@ encodes:
- authorization_code
header:
-
$id: file://transform/src/test/resources/transformations/fragments/raml/security-scheme/api.raml#/fragment/parameter/Authorization
$id: file://transform/src/test/resources/transformations/fragments/raml/security-scheme/api.raml#/fragment/parameter/header/Authorization
required: true
paramName: Authorization
name: Authorization
Expand All @@ -59,7 +59,7 @@ encodes:
binding: header
schema:
shapeType: Scalar
$id: file://transform/src/test/resources/transformations/fragments/raml/security-scheme/api.raml#/fragment/parameter/Authorization/scalar/schema
$id: file://transform/src/test/resources/transformations/fragments/raml/security-scheme/api.raml#/fragment/parameter/default-binding/Authorization/scalar/schema
name: schema
description: |
Used to send a valid OAuth 2 access token. Do not use with the "access_token" query. string parameter.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
],
"http://a.ml/vocabularies/apiContract#parameter": [
{
"@id": "file://transform/src/test/resources/transformations/raml-overlay/base.raml#/web-api/end-points/%2Fbooks%2F%7Bcustomer_id%7D/parameter/customer_id",
"@id": "file://transform/src/test/resources/transformations/raml-overlay/base.raml#/web-api/end-points/%2Fbooks%2F%7Bcustomer_id%7D/parameter/path/customer_id",
"@type": [
"http://a.ml/vocabularies/apiContract#Parameter",
"file://vocabulary/src/main/resources/dialects/canonical_webapi_spec.yaml#/declarations/Parameter",
Expand Down Expand Up @@ -90,7 +90,7 @@
],
"http://a.ml/vocabularies/shapes#schema": [
{
"@id": "file://transform/src/test/resources/transformations/raml-overlay/base.raml#/web-api/end-points/%2Fbooks%2F%7Bcustomer_id%7D/parameter/customer_id/scalar/schema",
"@id": "file://transform/src/test/resources/transformations/raml-overlay/base.raml#/web-api/end-points/%2Fbooks%2F%7Bcustomer_id%7D/parameter/default-binding/customer_id/scalar/schema",
"@type": [
"http://a.ml/vocabularies/shapes#ScalarShape",
"file://vocabulary/src/main/resources/dialects/canonical_webapi_spec.yaml#/declarations/ScalarShape",
Expand Down Expand Up @@ -231,7 +231,7 @@
],
"http://a.ml/vocabularies/apiContract#parameter": [
{
"@id": "file://transform/src/test/resources/transformations/raml-overlay/base.raml#/web-api/end-points/%2Fbooks%2F%7Bcustomer_id%7D/parameter/customer_id",
"@id": "file://transform/src/test/resources/transformations/raml-overlay/base.raml#/web-api/end-points/%2Fbooks%2F%7Bcustomer_id%7D/parameter/path/customer_id",
"@type": [
"http://a.ml/vocabularies/apiContract#Parameter",
"file://vocabulary/src/main/resources/dialects/canonical_webapi_spec.yaml#/declarations/Parameter",
Expand Down Expand Up @@ -260,7 +260,7 @@
],
"http://a.ml/vocabularies/shapes#schema": [
{
"@id": "file://transform/src/test/resources/transformations/raml-overlay/base.raml#/web-api/end-points/%2Fbooks%2F%7Bcustomer_id%7D/parameter/customer_id/scalar/schema",
"@id": "file://transform/src/test/resources/transformations/raml-overlay/base.raml#/web-api/end-points/%2Fbooks%2F%7Bcustomer_id%7D/parameter/default-binding/customer_id/scalar/schema",
"@type": [
"http://a.ml/vocabularies/shapes#ScalarShape",
"file://vocabulary/src/main/resources/dialects/canonical_webapi_spec.yaml#/declarations/ScalarShape",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ references:
$id: file://transform/src/test/resources/transformations/raml-overlay/base.raml#/web-api/end-points/%2Fbooks%2F%7Bcustomer_id%7D
parameter:
-
$id: file://transform/src/test/resources/transformations/raml-overlay/base.raml#/web-api/end-points/%2Fbooks%2F%7Bcustomer_id%7D/parameter/customer_id
$id: file://transform/src/test/resources/transformations/raml-overlay/base.raml#/web-api/end-points/%2Fbooks%2F%7Bcustomer_id%7D/parameter/path/customer_id
required: true
paramName: customer_id
name: customer_id
binding: path
schema:
shapeType: Scalar
$id: file://transform/src/test/resources/transformations/raml-overlay/base.raml#/web-api/end-points/%2Fbooks%2F%7Bcustomer_id%7D/parameter/customer_id/scalar/schema
$id: file://transform/src/test/resources/transformations/raml-overlay/base.raml#/web-api/end-points/%2Fbooks%2F%7Bcustomer_id%7D/parameter/default-binding/customer_id/scalar/schema
name: schema
datatype: http://www.w3.org/2001/XMLSchema#string
path: /books/{customer_id}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
],
"http://a.ml/vocabularies/apiContract#parameter": [
{
"@id": "file://transform/src/test/resources/transformations/security/api.raml#/web-api/end-points/%2Fusers%2F%7Buserid%7D%2Fgists/parameter/userid",
"@id": "file://transform/src/test/resources/transformations/security/api.raml#/web-api/end-points/%2Fusers%2F%7Buserid%7D%2Fgists/parameter/path/userid",
"@type": [
"http://a.ml/vocabularies/apiContract#Parameter",
"file://vocabulary/src/main/resources/dialects/canonical_webapi_spec.yaml#/declarations/Parameter",
Expand Down Expand Up @@ -81,7 +81,7 @@
],
"http://a.ml/vocabularies/shapes#schema": [
{
"@id": "file://transform/src/test/resources/transformations/security/api.raml#/web-api/end-points/%2Fusers%2F%7Buserid%7D%2Fgists/parameter/userid/scalar/userid",
"@id": "file://transform/src/test/resources/transformations/security/api.raml#/web-api/end-points/%2Fusers%2F%7Buserid%7D%2Fgists/parameter/default-binding/userid/scalar/userid",
"@type": [
"http://a.ml/vocabularies/shapes#ScalarShape",
"file://vocabulary/src/main/resources/dialects/canonical_webapi_spec.yaml#/declarations/ScalarShape",
Expand Down Expand Up @@ -240,7 +240,7 @@
],
"http://a.ml/vocabularies/apiContract#header": [
{
"@id": "file://transform/src/test/resources/transformations/security/api.raml#/declarations/securitySchemes/oauth_2_0/parameter/Authorization",
"@id": "file://transform/src/test/resources/transformations/security/api.raml#/declarations/securitySchemes/oauth_2_0/parameter/header/Authorization",
"@type": [
"http://a.ml/vocabularies/apiContract#Parameter",
"file://vocabulary/src/main/resources/dialects/canonical_webapi_spec.yaml#/declarations/Parameter",
Expand Down Expand Up @@ -274,7 +274,7 @@
],
"http://a.ml/vocabularies/shapes#schema": [
{
"@id": "file://transform/src/test/resources/transformations/security/api.raml#/declarations/securitySchemes/oauth_2_0/parameter/Authorization/scalar/schema",
"@id": "file://transform/src/test/resources/transformations/security/api.raml#/declarations/securitySchemes/oauth_2_0/parameter/default-binding/Authorization/scalar/schema",
"@type": [
"http://a.ml/vocabularies/shapes#ScalarShape",
"file://vocabulary/src/main/resources/dialects/canonical_webapi_spec.yaml#/declarations/ScalarShape",
Expand Down Expand Up @@ -489,7 +489,7 @@
],
"http://a.ml/vocabularies/apiContract#header": [
{
"@id": "file://transform/src/test/resources/transformations/security/api.raml#/declarations/securitySchemes/oauth_2_0/parameter/Authorization",
"@id": "file://transform/src/test/resources/transformations/security/api.raml#/declarations/securitySchemes/oauth_2_0/parameter/header/Authorization",
"@type": [
"http://a.ml/vocabularies/apiContract#Parameter",
"file://vocabulary/src/main/resources/dialects/canonical_webapi_spec.yaml#/declarations/Parameter",
Expand Down Expand Up @@ -523,7 +523,7 @@
],
"http://a.ml/vocabularies/shapes#schema": [
{
"@id": "file://transform/src/test/resources/transformations/security/api.raml#/declarations/securitySchemes/oauth_2_0/parameter/Authorization/scalar/schema",
"@id": "file://transform/src/test/resources/transformations/security/api.raml#/declarations/securitySchemes/oauth_2_0/parameter/default-binding/Authorization/scalar/schema",
"@type": [
"http://a.ml/vocabularies/shapes#ScalarShape",
"file://vocabulary/src/main/resources/dialects/canonical_webapi_spec.yaml#/declarations/ScalarShape",
Expand Down
Loading

0 comments on commit 035dc00

Please sign in to comment.