Skip to content

Commit

Permalink
Merge pull request #1999 from aml-org/W-15845362
Browse files Browse the repository at this point in the history
W-15845362 - Fixed some missing matches with new Async 2.x Specs
  • Loading branch information
looseale authored May 24, 2024
2 parents ad62772 + 08ba696 commit 907d3dd
Show file tree
Hide file tree
Showing 26 changed files with 509 additions and 93 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,13 @@ class ResolvedModelDuplicateIdsTest extends AsyncFunSuite with DuplicateIdsTest
}

private def amfConfigFrom(spec: Spec): AMFConfiguration = spec match {
case Spec.OAS30 => OASConfiguration.OAS30()
case Spec.OAS20 => OASConfiguration.OAS20()
case Spec.RAML10 => RAMLConfiguration.RAML10()
case Spec.RAML08 => RAMLConfiguration.RAML08()
case Spec.ASYNC20 => AsyncAPIConfiguration.Async20()
case _ => throw new IllegalArgumentException
case Spec.OAS30 => OASConfiguration.OAS30()
case Spec.OAS20 => OASConfiguration.OAS20()
case Spec.RAML10 => RAMLConfiguration.RAML10()
case Spec.RAML08 => RAMLConfiguration.RAML08()
case Spec.ASYNC20 | Spec.ASYNC21 | Spec.ASYNC22 | Spec.ASYNC23 | Spec.ASYNC24 | Spec.ASYNC25 | Spec.ASYNC26 =>
AsyncAPIConfiguration.Async20()
case _ => throw new IllegalArgumentException
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,13 @@ trait CommandHelper {
}

private def configFor(spec: Spec): Option[AMFConfiguration] = spec match {
case Spec.RAML10 => Some(RAMLConfiguration.RAML10())
case Spec.RAML08 => Some(RAMLConfiguration.RAML08())
case Spec.OAS20 => Some(OASConfiguration.OAS20())
case Spec.OAS30 => Some(OASConfiguration.OAS30())
case Spec.ASYNC20 => Some(AsyncAPIConfiguration.Async20())
case _ => None
case Spec.RAML10 => Some(RAMLConfiguration.RAML10())
case Spec.RAML08 => Some(RAMLConfiguration.RAML08())
case Spec.OAS20 => Some(OASConfiguration.OAS20())
case Spec.OAS30 => Some(OASConfiguration.OAS30())
case Spec.ASYNC20 | Spec.ASYNC21 | Spec.ASYNC22 | Spec.ASYNC23 | Spec.ASYNC24 | Spec.ASYNC25 | Spec.ASYNC26 =>
Some(AsyncAPIConfiguration.Async20())
case _ => None
}

def effectiveVendor(spec: Option[String]): Spec = spec.flatMap(Spec.unapply).getOrElse(Spec("unknown"))
Expand Down
36 changes: 36 additions & 0 deletions amf-cli/shared/src/test/resources/references/async/async20.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
asyncapi: '2.0.0'
info:
title: Streetlights Kafka API
version: '1.0.0'

defaultContentType: application/json

channels:
smartylighting.streetlights.1.0.event.{streetlightId}.lighting.measured:
description: The topic on which measured values may be produced and consumed.
publish:
summary: Inform about environmental lighting conditions of a particular streetlight.
operationId: receiveLightMeasurement
message:
name: lightMeasured
title: Light measured
summary: Inform about environmental lighting conditions of a particular streetlight.
contentType: application/json
payload:
$ref: "#/components/schemas/lightMeasuredPayload"

components:
schemas:
sentAt:
type: string
format: date-time
description: Date and time when the message was sent.
lightMeasuredPayload:
type: object
properties:
lumens:
type: integer
minimum: 0
description: Light intensity measured in lumens.
sentAt:
$ref: "#/components/schemas/sentAt"
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
asyncapi: 2.0.0
info:
title: Streetlights Kafka API
version: 1.0.0
defaultContentType: application/json
components:
schemas:
sentAt:
type: string
format: date-time
description: Date and time when the message was sent.
lightMeasuredPayload:
type: object
properties:
lumens:
type: integer
minimum: 0
description: Light intensity measured in lumens.
sentAt:
type: string
format: date-time
description: Date and time when the message was sent.
channels:
smartylighting.streetlights.1.0.event.{streetlightId}.lighting.measured:
description: The topic on which measured values may be produced and consumed.
publish:
summary: Inform about environmental lighting conditions of a particular streetlight.
operationId: receiveLightMeasurement
message:
name: lightMeasured
title: Light measured
summary: Inform about environmental lighting conditions of a particular streetlight.
contentType: application/json
payload:
type: object
properties:
lumens:
type: integer
minimum: 0
description: Light intensity measured in lumens.
sentAt:
type: string
format: date-time
description: Date and time when the message was sent.
description: The topic on which measured values may be produced and consumed.
36 changes: 36 additions & 0 deletions amf-cli/shared/src/test/resources/references/async/async26.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
asyncapi: '2.6.0'
info:
title: Streetlights Kafka API
version: '1.0.0'

defaultContentType: application/json

channels:
smartylighting.streetlights.1.0.event.1.lighting.measured:
description: The topic on which measured values may be produced and consumed.
publish:
summary: Inform about environmental lighting conditions of a particular streetlight.
operationId: receiveLightMeasurement
message:
name: lightMeasured
title: Light measured
summary: Inform about environmental lighting conditions of a particular streetlight.
contentType: application/json
payload:
$ref: "#/components/schemas/lightMeasuredPayload"

components:
schemas:
sentAt:
type: string
format: date-time
description: Date and time when the message was sent.
lightMeasuredPayload:
type: object
properties:
lumens:
type: integer
minimum: 0
description: Light intensity measured in lumens.
sentAt:
$ref: "#/components/schemas/sentAt"
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
asyncapi: 2.6.0
info:
title: Streetlights Kafka API
version: 1.0.0
defaultContentType: application/json
components:
schemas:
sentAt:
type: string
format: date-time
description: Date and time when the message was sent.
lightMeasuredPayload:
type: object
properties:
lumens:
type: integer
minimum: 0
description: Light intensity measured in lumens.
sentAt:
type: string
format: date-time
description: Date and time when the message was sent.
channels:
smartylighting.streetlights.1.0.event.1.lighting.measured:
description: The topic on which measured values may be produced and consumed.
publish:
summary: Inform about environmental lighting conditions of a particular streetlight.
operationId: receiveLightMeasurement
message:
name: lightMeasured
title: Light measured
summary: Inform about environmental lighting conditions of a particular streetlight.
contentType: application/json
payload:
type: object
properties:
lumens:
type: integer
minimum: 0
description: Light intensity measured in lumens.
sentAt:
type: string
format: date-time
description: Date and time when the message was sent.
description: The topic on which measured values may be produced and consumed.
Original file line number Diff line number Diff line change
Expand Up @@ -3017,12 +3017,17 @@
],
"http://a.ml/vocabularies/document#link-target": [
{
"@id": "file://amf-cli/shared/src/test/resources/validations/async20/asyncApi-2.1-all.yaml#/declares/msg/marketData/payload/default/shape/schema/shape/schema"
"@id": "file://amf-cli/shared/src/test/resources/validations/async20/asyncApi-2.1-all.yaml#/declares/shape/market"
}
],
"http://a.ml/vocabularies/document#link-label": [
{
"@value": "#/components/schemas/market"
"@value": "market"
}
],
"http://a.ml/vocabularies/document#recursive": [
{
"@value": true
}
],
"http://www.w3.org/ns/shacl#name": [
Expand All @@ -3038,10 +3043,10 @@
],
"http://a.ml/vocabularies/document-source-maps#synthesized-field": [
{
"@id": "file://amf-cli/shared/src/test/resources/validations/async20/asyncApi-2.1-all.yaml#/declares/msg/marketData/payload/default/shape/schema/source-map/synthesized-field/element_1",
"@id": "file://amf-cli/shared/src/test/resources/validations/async20/asyncApi-2.1-all.yaml#/declares/msg/marketData/payload/default/shape/schema/source-map/synthesized-field/element_2",
"http://a.ml/vocabularies/document-source-maps#element": [
{
"@value": "http://a.ml/vocabularies/document#link-target"
"@value": "http://a.ml/vocabularies/document#link-label"
}
],
"http://a.ml/vocabularies/document-source-maps#value": [
Expand All @@ -3054,7 +3059,20 @@
"@id": "file://amf-cli/shared/src/test/resources/validations/async20/asyncApi-2.1-all.yaml#/declares/msg/marketData/payload/default/shape/schema/source-map/synthesized-field/element_0",
"http://a.ml/vocabularies/document-source-maps#element": [
{
"@value": "http://a.ml/vocabularies/document#link-label"
"@value": "http://a.ml/vocabularies/document#recursive"
}
],
"http://a.ml/vocabularies/document-source-maps#value": [
{
"@value": "true"
}
]
},
{
"@id": "file://amf-cli/shared/src/test/resources/validations/async20/asyncApi-2.1-all.yaml#/declares/msg/marketData/payload/default/shape/schema/source-map/synthesized-field/element_1",
"http://a.ml/vocabularies/document-source-maps#element": [
{
"@value": "http://a.ml/vocabularies/document#link-target"
}
],
"http://a.ml/vocabularies/document-source-maps#value": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2278,10 +2278,11 @@
],
"http://a.ml/vocabularies/document#link-target": [
{
"@id": "file://amf-cli/shared/src/test/resources/validations/async20/asyncApi-2.1-all.yaml#/declares/msg/marketData/payload/default/shape/schema/shape/schema"
"@id": "file://amf-cli/shared/src/test/resources/validations/async20/asyncApi-2.1-all.yaml#/declares/shape/market"
}
],
"http://a.ml/vocabularies/document#link-label": "#/components/schemas/market",
"http://a.ml/vocabularies/document#link-label": "market",
"http://a.ml/vocabularies/document#recursive": true,
"http://www.w3.org/ns/shacl#name": "schema",
"http://a.ml/vocabularies/document-source-maps#sources": [
{
Expand Down Expand Up @@ -2471,10 +2472,13 @@
],
"http://a.ml/vocabularies/document-source-maps#synthesized-field": [
{
"@id": "file://amf-cli/shared/src/test/resources/validations/async20/asyncApi-2.1-all.yaml#/declares/msg/marketData/payload/default/shape/schema/source-map/synthesized-field/element_1"
"@id": "file://amf-cli/shared/src/test/resources/validations/async20/asyncApi-2.1-all.yaml#/declares/msg/marketData/payload/default/shape/schema/source-map/synthesized-field/element_2"
},
{
"@id": "file://amf-cli/shared/src/test/resources/validations/async20/asyncApi-2.1-all.yaml#/declares/msg/marketData/payload/default/shape/schema/source-map/synthesized-field/element_0"
},
{
"@id": "file://amf-cli/shared/src/test/resources/validations/async20/asyncApi-2.1-all.yaml#/declares/msg/marketData/payload/default/shape/schema/source-map/synthesized-field/element_1"
}
],
"http://a.ml/vocabularies/document-source-maps#lexical": [
Expand Down Expand Up @@ -2670,13 +2674,18 @@
"http://a.ml/vocabularies/document-source-maps#value": "[(98,10)-(99,0)]"
},
{
"@id": "file://amf-cli/shared/src/test/resources/validations/async20/asyncApi-2.1-all.yaml#/declares/msg/marketData/payload/default/shape/schema/source-map/synthesized-field/element_1",
"http://a.ml/vocabularies/document-source-maps#element": "http://a.ml/vocabularies/document#link-target",
"@id": "file://amf-cli/shared/src/test/resources/validations/async20/asyncApi-2.1-all.yaml#/declares/msg/marketData/payload/default/shape/schema/source-map/synthesized-field/element_2",
"http://a.ml/vocabularies/document-source-maps#element": "http://a.ml/vocabularies/document#link-label",
"http://a.ml/vocabularies/document-source-maps#value": "true"
},
{
"@id": "file://amf-cli/shared/src/test/resources/validations/async20/asyncApi-2.1-all.yaml#/declares/msg/marketData/payload/default/shape/schema/source-map/synthesized-field/element_0",
"http://a.ml/vocabularies/document-source-maps#element": "http://a.ml/vocabularies/document#link-label",
"http://a.ml/vocabularies/document-source-maps#element": "http://a.ml/vocabularies/document#recursive",
"http://a.ml/vocabularies/document-source-maps#value": "true"
},
{
"@id": "file://amf-cli/shared/src/test/resources/validations/async20/asyncApi-2.1-all.yaml#/declares/msg/marketData/payload/default/shape/schema/source-map/synthesized-field/element_1",
"http://a.ml/vocabularies/document-source-maps#element": "http://a.ml/vocabularies/document#link-target",
"http://a.ml/vocabularies/document-source-maps#value": "true"
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3920,12 +3920,17 @@
],
"http://a.ml/vocabularies/document#link-target": [
{
"@id": "file://amf-cli/shared/src/test/resources/validations/async20/asyncApi-2.2-all.yaml#/declares/msg/marketData/payload/default/shape/schema/shape/schema"
"@id": "file://amf-cli/shared/src/test/resources/validations/async20/asyncApi-2.2-all.yaml#/declares/shape/market"
}
],
"http://a.ml/vocabularies/document#link-label": [
{
"@value": "#/components/schemas/market"
"@value": "market"
}
],
"http://a.ml/vocabularies/document#recursive": [
{
"@value": true
}
],
"http://www.w3.org/ns/shacl#name": [
Expand All @@ -3941,10 +3946,10 @@
],
"http://a.ml/vocabularies/document-source-maps#synthesized-field": [
{
"@id": "file://amf-cli/shared/src/test/resources/validations/async20/asyncApi-2.2-all.yaml#/declares/msg/marketData/payload/default/shape/schema/source-map/synthesized-field/element_1",
"@id": "file://amf-cli/shared/src/test/resources/validations/async20/asyncApi-2.2-all.yaml#/declares/msg/marketData/payload/default/shape/schema/source-map/synthesized-field/element_2",
"http://a.ml/vocabularies/document-source-maps#element": [
{
"@value": "http://a.ml/vocabularies/document#link-target"
"@value": "http://a.ml/vocabularies/document#link-label"
}
],
"http://a.ml/vocabularies/document-source-maps#value": [
Expand All @@ -3957,7 +3962,20 @@
"@id": "file://amf-cli/shared/src/test/resources/validations/async20/asyncApi-2.2-all.yaml#/declares/msg/marketData/payload/default/shape/schema/source-map/synthesized-field/element_0",
"http://a.ml/vocabularies/document-source-maps#element": [
{
"@value": "http://a.ml/vocabularies/document#link-label"
"@value": "http://a.ml/vocabularies/document#recursive"
}
],
"http://a.ml/vocabularies/document-source-maps#value": [
{
"@value": "true"
}
]
},
{
"@id": "file://amf-cli/shared/src/test/resources/validations/async20/asyncApi-2.2-all.yaml#/declares/msg/marketData/payload/default/shape/schema/source-map/synthesized-field/element_1",
"http://a.ml/vocabularies/document-source-maps#element": [
{
"@value": "http://a.ml/vocabularies/document#link-target"
}
],
"http://a.ml/vocabularies/document-source-maps#value": [
Expand Down
Loading

0 comments on commit 907d3dd

Please sign in to comment.