diff --git a/adrs/0014-avro-parsing.md b/adrs/0014-avro-parsing.md new file mode 100644 index 0000000000..22393cdd0b --- /dev/null +++ b/adrs/0014-avro-parsing.md @@ -0,0 +1,59 @@ +# 13. AWS OAS parsing + +Date: 2024-07-02 + + +## Status + +Accepted + + +## Context + +Async 2.x supports AVRO Schemas and we currently don't. +We want to add support AVRO Schemas inside Async APIs and as a standalone documents. + +We need to decide: +- how are we going to map AVRO Schemas to the AMF Model +- how are we going to validate AVRO Schemas + +an AVRO Schema has the following properties: +- It's defined in plain JSON, they MAY be also be defined as a `.avsc` file +- It doesn't have a special key that indicates it's an AVRO Schema, nor it's version (like JSON Schema does with it's `$schema`) + + +## Decision + +Implement AVRO Schema parsing as a new specification, following the [AVRO Schema 1.9.0 specification](https://avro.apache.org/docs/1.9.0/spec.html#schemas). + +An AVRO Schema may be a: +- Map +- Array +- Record (with fields, each one being any of the possible types) +- Enum +- Fixed Type +- Primitive Type ("null", "boolean", "int", "long", "float", "double", "bytes", "string") + +We've parsed each AVRO Type to the following AMF Shape: +- Map --> NodeShape with `AdditionalProperties` field for the values shape +- Array --> ArrayShape with `Items` field for the items shape +- Record --> NodeShape with `Properties` with a PropertyShape that contains each field shape +- Enum --> ScalarShape with `Values` field for it's symbols +- Fixed Type --> ScalarShape with `Datatype` field for its type and `Size` for its size +- Primitive Type --> ScalarShape with `Datatype` field, or NilShape if its type 'null' + +Given that in this mapping, several AVRO Types correspond to a ScalarShape or a NodeShape, **we've added the `avro-schema` annotation** with an `avroType` that contains the avro type declared before parsing. +This way, we can know the exact type for rendering or other purposes, for example having a NodeShape and knowing if it's an avro record or a map (both are parsed as NodeShapes). + +We've also added 3 AVRO-specific fields to the `AnyShape` Model via the `AvroFields` trait, adding the following fields: +- AvroNamespace +- Aliases +- Size + + +For now only parsing is done + + +## Consequences + +None so far. \ No newline at end of file diff --git a/amf-cli/shared/src/test/resources/avro/tck/apis/valid/async-avro-component-ref.dumped.yaml b/amf-cli/shared/src/test/resources/avro/tck/apis/valid/async-avro-component-ref.dumped.yaml index d66f303f09..d9d4365847 100644 --- a/amf-cli/shared/src/test/resources/avro/tck/apis/valid/async-avro-component-ref.dumped.yaml +++ b/amf-cli/shared/src/test/resources/avro/tck/apis/valid/async-avro-component-ref.dumped.yaml @@ -10,6 +10,6 @@ channels: mychannel: publish: message: - schemaFormat: application/vnd.apache.avro;version=1.8.2 + schemaFormat: application/vnd.apache.avro;version=1.9.0 payload: $ref: "#/components/schemas/Person" diff --git a/amf-cli/shared/src/test/resources/avro/tck/apis/valid/async-avro-component-ref.jsonld b/amf-cli/shared/src/test/resources/avro/tck/apis/valid/async-avro-component-ref.jsonld index dadb042113..1be4f201a8 100644 --- a/amf-cli/shared/src/test/resources/avro/tck/apis/valid/async-avro-component-ref.jsonld +++ b/amf-cli/shared/src/test/resources/avro/tck/apis/valid/async-avro-component-ref.jsonld @@ -70,39 +70,7 @@ ], "http://a.ml/vocabularies/apiContract#schemaMediaType": [ { - "@value": "application/vnd.apache.avro;version=1.8.2" - } - ], - "http://a.ml/vocabularies/shapes#schema": [ - { - "@id": "file://amf-cli/shared/src/test/resources/avro/tck/apis/valid/async-avro-component-ref.yaml#/async-api/endpoint/mychannel/supportedOperation/publish/expects/request/payload/default/scalar/schema", - "@type": [ - "http://a.ml/vocabularies/shapes#ScalarShape", - "http://a.ml/vocabularies/shapes#AnyShape", - "http://www.w3.org/ns/shacl#Shape", - "http://a.ml/vocabularies/shapes#Shape", - "http://a.ml/vocabularies/document#DomainElement" - ], - "http://a.ml/vocabularies/document#link-target": [ - { - "@id": "file://amf-cli/shared/src/test/resources/avro/tck/apis/valid/async-avro-component-ref.yaml#/declares/scalar/Person" - } - ], - "http://a.ml/vocabularies/document#link-label": [ - { - "@value": "Person" - } - ], - "http://a.ml/vocabularies/document#recursive": [ - { - "@value": true - } - ], - "http://www.w3.org/ns/shacl#name": [ - { - "@value": "schema" - } - ] + "@value": "application/vnd.apache.avro;version=1.9.0" } ] } diff --git a/amf-cli/shared/src/test/resources/avro/tck/apis/valid/async-avro-component-ref.yaml b/amf-cli/shared/src/test/resources/avro/tck/apis/valid/async-avro-component-ref.yaml index 21530c517d..f65585cb55 100644 --- a/amf-cli/shared/src/test/resources/avro/tck/apis/valid/async-avro-component-ref.yaml +++ b/amf-cli/shared/src/test/resources/avro/tck/apis/valid/async-avro-component-ref.yaml @@ -31,6 +31,6 @@ channels: mychannel: publish: message: - schemaFormat: application/vnd.apache.avro;version=1.8.2 + schemaFormat: application/vnd.apache.avro;version=1.9.0 payload: $ref: '#/components/schemas/Person' diff --git a/amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-inline.dumped.yaml b/amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-inline.dumped.yaml index 95b6289005..4a562c1ebe 100644 --- a/amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-inline.dumped.yaml +++ b/amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-inline.dumped.yaml @@ -6,5 +6,5 @@ channels: mychannel: publish: message: - schemaFormat: application/vnd.apache.avro;version=1.8.2 + schemaFormat: application/vnd.apache.avro;version=1.9.0 payload: {} diff --git a/amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-inline.jsonld b/amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-inline.jsonld index 46ed1ac0d0..007a9e9c30 100644 --- a/amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-inline.jsonld +++ b/amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-inline.jsonld @@ -70,21 +70,511 @@ ], "http://a.ml/vocabularies/apiContract#schemaMediaType": [ { - "@value": "application/vnd.apache.avro;version=1.8.2" + "@value": "application/vnd.apache.avro;version=1.9.0" } ], "http://a.ml/vocabularies/shapes#schema": [ { - "@id": "file://amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-inline.yaml#/async-api/endpoint/mychannel/supportedOperation/publish/expects/request/payload/default/any/schema", + "@id": "file://amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-inline.yaml#/async-api/endpoint/mychannel/supportedOperation/publish/expects/request/payload/default/shape/Person", "@type": [ + "http://www.w3.org/ns/shacl#NodeShape", "http://a.ml/vocabularies/shapes#AnyShape", "http://www.w3.org/ns/shacl#Shape", "http://a.ml/vocabularies/shapes#Shape", "http://a.ml/vocabularies/document#DomainElement" ], + "http://www.w3.org/ns/shacl#property": [ + { + "@id": "file://amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-inline.yaml#/async-api/endpoint/mychannel/supportedOperation/publish/expects/request/payload/default/shape/Person/property/property/name", + "@type": [ + "http://www.w3.org/ns/shacl#PropertyShape", + "http://www.w3.org/ns/shacl#Shape", + "http://a.ml/vocabularies/shapes#Shape", + "http://a.ml/vocabularies/document#DomainElement" + ], + "http://a.ml/vocabularies/shapes#range": [ + { + "@id": "file://amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-inline.yaml#/async-api/endpoint/mychannel/supportedOperation/publish/expects/request/payload/default/shape/Person/property/property/name/scalar/default-scalar", + "@type": [ + "http://a.ml/vocabularies/shapes#ScalarShape", + "http://a.ml/vocabularies/shapes#AnyShape", + "http://www.w3.org/ns/shacl#Shape", + "http://a.ml/vocabularies/shapes#Shape", + "http://a.ml/vocabularies/document#DomainElement" + ], + "http://www.w3.org/ns/shacl#datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#string" + } + ], + "http://a.ml/vocabularies/document-source-maps#sources": [ + { + "@id": "file://amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-inline.yaml#/async-api/endpoint/mychannel/supportedOperation/publish/expects/request/payload/default/shape/Person/property/property/name/scalar/default-scalar/source-map", + "@type": [ + "http://a.ml/vocabularies/document-source-maps#SourceMap" + ], + "http://a.ml/vocabularies/document-source-maps#avro-schema": [ + { + "@id": "file://amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-inline.yaml#/async-api/endpoint/mychannel/supportedOperation/publish/expects/request/payload/default/shape/Person/property/property/name/scalar/default-scalar/source-map/avro-schema/element_0", + "http://a.ml/vocabularies/document-source-maps#element": [ + { + "@value": "file://amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-inline.yaml#/async-api/endpoint/mychannel/supportedOperation/publish/expects/request/payload/default/shape/Person/property/property/name/scalar/default-scalar" + } + ], + "http://a.ml/vocabularies/document-source-maps#value": [ + { + "@value": "string" + } + ] + } + ] + } + ] + } + ], + "http://www.w3.org/ns/shacl#name": [ + { + "@value": "name" + } + ] + }, + { + "@id": "file://amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-inline.yaml#/async-api/endpoint/mychannel/supportedOperation/publish/expects/request/payload/default/shape/Person/property/property/age", + "@type": [ + "http://www.w3.org/ns/shacl#PropertyShape", + "http://www.w3.org/ns/shacl#Shape", + "http://a.ml/vocabularies/shapes#Shape", + "http://a.ml/vocabularies/document#DomainElement" + ], + "http://a.ml/vocabularies/shapes#range": [ + { + "@id": "file://amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-inline.yaml#/async-api/endpoint/mychannel/supportedOperation/publish/expects/request/payload/default/shape/Person/property/property/age/union/age", + "@type": [ + "http://a.ml/vocabularies/shapes#UnionShape", + "http://a.ml/vocabularies/shapes#AnyShape", + "http://www.w3.org/ns/shacl#Shape", + "http://a.ml/vocabularies/shapes#Shape", + "http://a.ml/vocabularies/document#DomainElement" + ], + "http://a.ml/vocabularies/shapes#anyOf": [ + { + "@id": "file://amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-inline.yaml#/async-api/endpoint/mychannel/supportedOperation/publish/expects/request/payload/default/shape/Person/property/property/age/union/age/anyOf/nil/null", + "@type": [ + "http://a.ml/vocabularies/shapes#NilShape", + "http://www.w3.org/ns/shacl#Shape", + "http://a.ml/vocabularies/shapes#Shape", + "http://a.ml/vocabularies/document#DomainElement" + ], + "http://www.w3.org/ns/shacl#name": [ + { + "@value": "null" + } + ] + }, + { + "@id": "file://amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-inline.yaml#/async-api/endpoint/mychannel/supportedOperation/publish/expects/request/payload/default/shape/Person/property/property/age/union/age/anyOf/scalar/default-scalar", + "@type": [ + "http://a.ml/vocabularies/shapes#ScalarShape", + "http://a.ml/vocabularies/shapes#AnyShape", + "http://www.w3.org/ns/shacl#Shape", + "http://a.ml/vocabularies/shapes#Shape", + "http://a.ml/vocabularies/document#DomainElement" + ], + "http://www.w3.org/ns/shacl#datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#int" + } + ] + } + ], + "http://www.w3.org/ns/shacl#name": [ + { + "@value": "age" + } + ], + "http://www.w3.org/ns/shacl#defaultValue": [ + { + "@id": "file://amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-inline.yaml#/async-api/endpoint/mychannel/supportedOperation/publish/expects/request/payload/default/shape/Person/property/property/age/union/age/scalar_1", + "@type": [ + "http://a.ml/vocabularies/data#Scalar", + "http://a.ml/vocabularies/data#Node", + "http://a.ml/vocabularies/document#DomainElement" + ], + "http://a.ml/vocabularies/data#value": [ + { + "@value": "null" + } + ], + "http://www.w3.org/ns/shacl#datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#nil" + } + ], + "http://a.ml/vocabularies/core#name": [ + { + "@value": "scalar_1" + } + ] + } + ], + "http://a.ml/vocabularies/document-source-maps#sources": [ + { + "@id": "file://amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-inline.yaml#/async-api/endpoint/mychannel/supportedOperation/publish/expects/request/payload/default/shape/Person/property/property/age/union/age/source-map", + "@type": [ + "http://a.ml/vocabularies/document-source-maps#SourceMap" + ], + "http://a.ml/vocabularies/document-source-maps#avro-schema": [ + { + "@id": "file://amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-inline.yaml#/async-api/endpoint/mychannel/supportedOperation/publish/expects/request/payload/default/shape/Person/property/property/age/union/age/source-map/avro-schema/element_0", + "http://a.ml/vocabularies/document-source-maps#element": [ + { + "@value": "file://amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-inline.yaml#/async-api/endpoint/mychannel/supportedOperation/publish/expects/request/payload/default/shape/Person/property/property/age/union/age" + } + ], + "http://a.ml/vocabularies/document-source-maps#value": [ + { + "@value": "union" + } + ] + } + ] + } + ] + } + ], + "http://www.w3.org/ns/shacl#name": [ + { + "@value": "age" + } + ], + "http://www.w3.org/ns/shacl#defaultValue": [ + { + "@id": "file://amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-inline.yaml#/async-api/endpoint/mychannel/supportedOperation/publish/expects/request/payload/default/shape/Person/property/property/age/scalar_1", + "@type": [ + "http://a.ml/vocabularies/data#Scalar", + "http://a.ml/vocabularies/data#Node", + "http://a.ml/vocabularies/document#DomainElement" + ], + "http://a.ml/vocabularies/data#value": [ + { + "@value": "null" + } + ], + "http://www.w3.org/ns/shacl#datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#nil" + } + ], + "http://a.ml/vocabularies/core#name": [ + { + "@value": "scalar_1" + } + ] + } + ] + }, + { + "@id": "file://amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-inline.yaml#/async-api/endpoint/mychannel/supportedOperation/publish/expects/request/payload/default/shape/Person/property/property/favoriteProgrammingLanguage", + "@type": [ + "http://www.w3.org/ns/shacl#PropertyShape", + "http://www.w3.org/ns/shacl#Shape", + "http://a.ml/vocabularies/shapes#Shape", + "http://a.ml/vocabularies/document#DomainElement" + ], + "http://a.ml/vocabularies/shapes#range": [ + { + "@id": "file://amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-inline.yaml#/async-api/endpoint/mychannel/supportedOperation/publish/expects/request/payload/default/shape/Person/property/property/favoriteProgrammingLanguage/scalar/ProgrammingLanguage", + "@type": [ + "http://a.ml/vocabularies/shapes#ScalarShape", + "http://a.ml/vocabularies/shapes#AnyShape", + "http://www.w3.org/ns/shacl#Shape", + "http://a.ml/vocabularies/shapes#Shape", + "http://a.ml/vocabularies/document#DomainElement" + ], + "http://www.w3.org/ns/shacl#datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#string" + } + ], + "http://www.w3.org/ns/shacl#name": [ + { + "@value": "ProgrammingLanguage" + } + ], + "http://www.w3.org/ns/shacl#in": [ + { + "@id": "file://amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-inline.yaml#/async-api/endpoint/mychannel/supportedOperation/publish/expects/request/payload/default/shape/Person/property/property/favoriteProgrammingLanguage/scalar/ProgrammingLanguage/list", + "@type": "http://www.w3.org/2000/01/rdf-schema#Seq", + "http://www.w3.org/2000/01/rdf-schema#_1": [ + { + "@id": "file://amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-inline.yaml#/async-api/endpoint/mychannel/supportedOperation/publish/expects/request/payload/default/shape/Person/property/property/favoriteProgrammingLanguage/scalar/ProgrammingLanguage/in/data-node", + "@type": [ + "http://a.ml/vocabularies/data#Scalar", + "http://a.ml/vocabularies/data#Node", + "http://a.ml/vocabularies/document#DomainElement" + ], + "http://a.ml/vocabularies/data#value": [ + { + "@value": "JS" + } + ], + "http://www.w3.org/ns/shacl#datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + ], + "http://www.w3.org/2000/01/rdf-schema#_2": [ + { + "@id": "file://amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-inline.yaml#/async-api/endpoint/mychannel/supportedOperation/publish/expects/request/payload/default/shape/Person/property/property/favoriteProgrammingLanguage/scalar/ProgrammingLanguage/in/data-node_1", + "@type": [ + "http://a.ml/vocabularies/data#Scalar", + "http://a.ml/vocabularies/data#Node", + "http://a.ml/vocabularies/document#DomainElement" + ], + "http://a.ml/vocabularies/data#value": [ + { + "@value": "Java" + } + ], + "http://www.w3.org/ns/shacl#datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + ], + "http://www.w3.org/2000/01/rdf-schema#_3": [ + { + "@id": "file://amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-inline.yaml#/async-api/endpoint/mychannel/supportedOperation/publish/expects/request/payload/default/shape/Person/property/property/favoriteProgrammingLanguage/scalar/ProgrammingLanguage/in/data-node_2", + "@type": [ + "http://a.ml/vocabularies/data#Scalar", + "http://a.ml/vocabularies/data#Node", + "http://a.ml/vocabularies/document#DomainElement" + ], + "http://a.ml/vocabularies/data#value": [ + { + "@value": "Go" + } + ], + "http://www.w3.org/ns/shacl#datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + ], + "http://www.w3.org/2000/01/rdf-schema#_4": [ + { + "@id": "file://amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-inline.yaml#/async-api/endpoint/mychannel/supportedOperation/publish/expects/request/payload/default/shape/Person/property/property/favoriteProgrammingLanguage/scalar/ProgrammingLanguage/in/data-node_3", + "@type": [ + "http://a.ml/vocabularies/data#Scalar", + "http://a.ml/vocabularies/data#Node", + "http://a.ml/vocabularies/document#DomainElement" + ], + "http://a.ml/vocabularies/data#value": [ + { + "@value": "Rust" + } + ], + "http://www.w3.org/ns/shacl#datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + ], + "http://www.w3.org/2000/01/rdf-schema#_5": [ + { + "@id": "file://amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-inline.yaml#/async-api/endpoint/mychannel/supportedOperation/publish/expects/request/payload/default/shape/Person/property/property/favoriteProgrammingLanguage/scalar/ProgrammingLanguage/in/data-node_4", + "@type": [ + "http://a.ml/vocabularies/data#Scalar", + "http://a.ml/vocabularies/data#Node", + "http://a.ml/vocabularies/document#DomainElement" + ], + "http://a.ml/vocabularies/data#value": [ + { + "@value": "C" + } + ], + "http://www.w3.org/ns/shacl#datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + ] + } + ], + "http://a.ml/vocabularies/document-source-maps#sources": [ + { + "@id": "file://amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-inline.yaml#/async-api/endpoint/mychannel/supportedOperation/publish/expects/request/payload/default/shape/Person/property/property/favoriteProgrammingLanguage/scalar/ProgrammingLanguage/source-map", + "@type": [ + "http://a.ml/vocabularies/document-source-maps#SourceMap" + ], + "http://a.ml/vocabularies/document-source-maps#avro-schema": [ + { + "@id": "file://amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-inline.yaml#/async-api/endpoint/mychannel/supportedOperation/publish/expects/request/payload/default/shape/Person/property/property/favoriteProgrammingLanguage/scalar/ProgrammingLanguage/source-map/avro-schema/element_0", + "http://a.ml/vocabularies/document-source-maps#element": [ + { + "@value": "file://amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-inline.yaml#/async-api/endpoint/mychannel/supportedOperation/publish/expects/request/payload/default/shape/Person/property/property/favoriteProgrammingLanguage/scalar/ProgrammingLanguage" + } + ], + "http://a.ml/vocabularies/document-source-maps#value": [ + { + "@value": "enum" + } + ] + } + ] + } + ] + } + ], + "http://www.w3.org/ns/shacl#name": [ + { + "@value": "favoriteProgrammingLanguage" + } + ] + }, + { + "@id": "file://amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-inline.yaml#/async-api/endpoint/mychannel/supportedOperation/publish/expects/request/payload/default/shape/Person/property/property/address", + "@type": [ + "http://www.w3.org/ns/shacl#PropertyShape", + "http://www.w3.org/ns/shacl#Shape", + "http://a.ml/vocabularies/shapes#Shape", + "http://a.ml/vocabularies/document#DomainElement" + ], + "http://a.ml/vocabularies/shapes#range": [ + { + "@id": "file://amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-inline.yaml#/async-api/endpoint/mychannel/supportedOperation/publish/expects/request/payload/default/shape/Person/property/property/address/shape/Address", + "@type": [ + "http://www.w3.org/ns/shacl#NodeShape", + "http://a.ml/vocabularies/shapes#AnyShape", + "http://www.w3.org/ns/shacl#Shape", + "http://a.ml/vocabularies/shapes#Shape", + "http://a.ml/vocabularies/document#DomainElement" + ], + "http://www.w3.org/ns/shacl#property": [ + { + "@id": "file://amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-inline.yaml#/async-api/endpoint/mychannel/supportedOperation/publish/expects/request/payload/default/shape/Person/property/property/address/shape/Address/property/property/zipcode", + "@type": [ + "http://www.w3.org/ns/shacl#PropertyShape", + "http://www.w3.org/ns/shacl#Shape", + "http://a.ml/vocabularies/shapes#Shape", + "http://a.ml/vocabularies/document#DomainElement" + ], + "http://a.ml/vocabularies/shapes#range": [ + { + "@id": "file://amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-inline.yaml#/async-api/endpoint/mychannel/supportedOperation/publish/expects/request/payload/default/shape/Person/property/property/address/shape/Address/property/property/zipcode/scalar/default-scalar", + "@type": [ + "http://a.ml/vocabularies/shapes#ScalarShape", + "http://a.ml/vocabularies/shapes#AnyShape", + "http://www.w3.org/ns/shacl#Shape", + "http://a.ml/vocabularies/shapes#Shape", + "http://a.ml/vocabularies/document#DomainElement" + ], + "http://www.w3.org/ns/shacl#datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#int" + } + ], + "http://a.ml/vocabularies/document-source-maps#sources": [ + { + "@id": "file://amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-inline.yaml#/async-api/endpoint/mychannel/supportedOperation/publish/expects/request/payload/default/shape/Person/property/property/address/shape/Address/property/property/zipcode/scalar/default-scalar/source-map", + "@type": [ + "http://a.ml/vocabularies/document-source-maps#SourceMap" + ], + "http://a.ml/vocabularies/document-source-maps#avro-schema": [ + { + "@id": "file://amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-inline.yaml#/async-api/endpoint/mychannel/supportedOperation/publish/expects/request/payload/default/shape/Person/property/property/address/shape/Address/property/property/zipcode/scalar/default-scalar/source-map/avro-schema/element_0", + "http://a.ml/vocabularies/document-source-maps#element": [ + { + "@value": "file://amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-inline.yaml#/async-api/endpoint/mychannel/supportedOperation/publish/expects/request/payload/default/shape/Person/property/property/address/shape/Address/property/property/zipcode/scalar/default-scalar" + } + ], + "http://a.ml/vocabularies/document-source-maps#value": [ + { + "@value": "int" + } + ] + } + ] + } + ] + } + ], + "http://www.w3.org/ns/shacl#name": [ + { + "@value": "zipcode" + } + ] + } + ], + "http://www.w3.org/ns/shacl#name": [ + { + "@value": "Address" + } + ], + "http://a.ml/vocabularies/document-source-maps#sources": [ + { + "@id": "file://amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-inline.yaml#/async-api/endpoint/mychannel/supportedOperation/publish/expects/request/payload/default/shape/Person/property/property/address/shape/Address/source-map", + "@type": [ + "http://a.ml/vocabularies/document-source-maps#SourceMap" + ], + "http://a.ml/vocabularies/document-source-maps#avro-schema": [ + { + "@id": "file://amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-inline.yaml#/async-api/endpoint/mychannel/supportedOperation/publish/expects/request/payload/default/shape/Person/property/property/address/shape/Address/source-map/avro-schema/element_0", + "http://a.ml/vocabularies/document-source-maps#element": [ + { + "@value": "file://amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-inline.yaml#/async-api/endpoint/mychannel/supportedOperation/publish/expects/request/payload/default/shape/Person/property/property/address/shape/Address" + } + ], + "http://a.ml/vocabularies/document-source-maps#value": [ + { + "@value": "record" + } + ] + } + ] + } + ] + } + ], + "http://www.w3.org/ns/shacl#name": [ + { + "@value": "address" + } + ] + } + ], "http://www.w3.org/ns/shacl#name": [ { - "@value": "schema" + "@value": "Person" + } + ], + "http://a.ml/vocabularies/document-source-maps#sources": [ + { + "@id": "file://amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-inline.yaml#/async-api/endpoint/mychannel/supportedOperation/publish/expects/request/payload/default/shape/Person/source-map", + "@type": [ + "http://a.ml/vocabularies/document-source-maps#SourceMap" + ], + "http://a.ml/vocabularies/document-source-maps#avro-schema": [ + { + "@id": "file://amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-inline.yaml#/async-api/endpoint/mychannel/supportedOperation/publish/expects/request/payload/default/shape/Person/source-map/avro-schema/element_0", + "http://a.ml/vocabularies/document-source-maps#element": [ + { + "@value": "file://amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-inline.yaml#/async-api/endpoint/mychannel/supportedOperation/publish/expects/request/payload/default/shape/Person" + } + ], + "http://a.ml/vocabularies/document-source-maps#value": [ + { + "@value": "record" + } + ] + } + ] } ] } diff --git a/amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-inline.yaml b/amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-inline.yaml index 192a01998d..27f90fb851 100644 --- a/amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-inline.yaml +++ b/amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-inline.yaml @@ -6,7 +6,7 @@ channels: mychannel: publish: message: - schemaFormat: application/vnd.apache.avro;version=1.8.2 + schemaFormat: application/vnd.apache.avro;version=1.9.0 payload: type: record name: Person diff --git a/amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-ref-1.8.2.dumped.yaml b/amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-ref-1.9.0.dumped.yaml similarity index 55% rename from amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-ref-1.8.2.dumped.yaml rename to amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-ref-1.9.0.dumped.yaml index 3ab9cf7925..387832109f 100644 --- a/amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-ref-1.8.2.dumped.yaml +++ b/amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-ref-1.9.0.dumped.yaml @@ -6,6 +6,6 @@ channels: myChannel: publish: message: - schemaFormat: application/vnd.apache.avro;version=1.8.2 + schemaFormat: application/vnd.apache.avro;version=1.9.0 payload: - $ref: schema-1.8.2.avsc + $ref: schema-1.9.0.avsc diff --git a/amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-ref-1.8.2.jsonld b/amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-ref-1.9.0.jsonld similarity index 66% rename from amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-ref-1.8.2.jsonld rename to amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-ref-1.9.0.jsonld index ca972761f0..97e2d2bb2a 100644 --- a/amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-ref-1.8.2.jsonld +++ b/amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-ref-1.9.0.jsonld @@ -1,6 +1,6 @@ [ { - "@id": "file://amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-ref-1.8.2.yaml", + "@id": "file://amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-ref-1.9.0.yaml", "@type": [ "http://a.ml/vocabularies/document#Document", "http://a.ml/vocabularies/document#Fragment", @@ -9,7 +9,7 @@ ], "http://a.ml/vocabularies/document#encodes": [ { - "@id": "file://amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-ref-1.8.2.yaml#/async-api", + "@id": "file://amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-ref-1.9.0.yaml#/async-api", "@type": [ "http://a.ml/vocabularies/apiContract#AsyncAPI", "http://a.ml/vocabularies/apiContract#API", @@ -28,7 +28,7 @@ ], "http://a.ml/vocabularies/apiContract#endpoint": [ { - "@id": "file://amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-ref-1.8.2.yaml#/async-api/endpoint/myChannel", + "@id": "file://amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-ref-1.9.0.yaml#/async-api/endpoint/myChannel", "@type": [ "http://a.ml/vocabularies/apiContract#EndPoint", "http://a.ml/vocabularies/document#DomainElement" @@ -40,7 +40,7 @@ ], "http://a.ml/vocabularies/apiContract#supportedOperation": [ { - "@id": "file://amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-ref-1.8.2.yaml#/async-api/endpoint/myChannel/supportedOperation/publish", + "@id": "file://amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-ref-1.9.0.yaml#/async-api/endpoint/myChannel/supportedOperation/publish", "@type": [ "http://a.ml/vocabularies/apiContract#Operation", "http://a.ml/vocabularies/core#Operation", @@ -53,7 +53,7 @@ ], "http://a.ml/vocabularies/apiContract#expects": [ { - "@id": "file://amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-ref-1.8.2.yaml#/async-api/endpoint/myChannel/supportedOperation/publish/expects/request", + "@id": "file://amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-ref-1.9.0.yaml#/async-api/endpoint/myChannel/supportedOperation/publish/expects/request", "@type": [ "http://a.ml/vocabularies/apiContract#Request", "http://a.ml/vocabularies/core#Request", @@ -62,7 +62,7 @@ ], "http://a.ml/vocabularies/apiContract#payload": [ { - "@id": "file://amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-ref-1.8.2.yaml#/async-api/endpoint/myChannel/supportedOperation/publish/expects/request/payload/default", + "@id": "file://amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-ref-1.9.0.yaml#/async-api/endpoint/myChannel/supportedOperation/publish/expects/request/payload/default", "@type": [ "http://a.ml/vocabularies/apiContract#Payload", "http://a.ml/vocabularies/core#Payload", @@ -70,38 +70,7 @@ ], "http://a.ml/vocabularies/apiContract#schemaMediaType": [ { - "@value": "application/vnd.apache.avro;version=1.8.2" - } - ], - "http://a.ml/vocabularies/shapes#schema": [ - { - "@id": "file://amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-ref-1.8.2.yaml#/async-api/endpoint/myChannel/supportedOperation/publish/expects/request/payload/default/any/schema", - "@type": [ - "http://a.ml/vocabularies/shapes#AnyShape", - "http://www.w3.org/ns/shacl#Shape", - "http://a.ml/vocabularies/shapes#Shape", - "http://a.ml/vocabularies/document#DomainElement" - ], - "http://a.ml/vocabularies/document#link-target": [ - { - "@id": "file://amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-ref-1.8.2.yaml#/references/0/any/schema" - } - ], - "http://a.ml/vocabularies/document#link-label": [ - { - "@value": "schema-1.8.2.avsc" - } - ], - "http://a.ml/vocabularies/document#recursive": [ - { - "@value": true - } - ], - "http://www.w3.org/ns/shacl#name": [ - { - "@value": "schema" - } - ] + "@value": "application/vnd.apache.avro;version=1.9.0" } ] } @@ -121,7 +90,7 @@ ], "http://a.ml/vocabularies/document#processingData": [ { - "@id": "file://amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-ref-1.8.2.yaml#/BaseUnitProcessingData", + "@id": "file://amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-ref-1.9.0.yaml#/BaseUnitProcessingData", "@type": [ "http://a.ml/vocabularies/document#APIContractProcessingData" ], @@ -139,24 +108,27 @@ ], "http://a.ml/vocabularies/document#references": [ { - "@id": "file://amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-ref-1.8.2.yaml#/references/0", + "@id": "file://amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-ref-1.9.0.yaml#/references/0", "@type": [ - "http://a.ml/vocabularies/shapes#DataTypeFragment", + "http://a.ml/vocabularies/document#ExternalFragment", "http://a.ml/vocabularies/document#Fragment", "http://a.ml/vocabularies/document#Unit" ], "http://a.ml/vocabularies/document#encodes": [ { - "@id": "file://amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-ref-1.8.2.yaml#/references/0/any/schema", + "@id": "file://amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-ref-1.9.0.yaml#/references/0/external", "@type": [ - "http://a.ml/vocabularies/shapes#AnyShape", - "http://www.w3.org/ns/shacl#Shape", - "http://a.ml/vocabularies/shapes#Shape", + "http://a.ml/vocabularies/document#ExternalDomainElement", "http://a.ml/vocabularies/document#DomainElement" ], - "http://www.w3.org/ns/shacl#name": [ + "http://a.ml/vocabularies/document#raw": [ + { + "@value": "{\n \"type\": \"record\",\n \"name\": \"Person\",\n \"fields\": [\n {\"name\": \"name\", \"type\": \"string\", \"example\": \"Donkey\"},\n {\"name\": \"age\", \"type\": [\"null\", \"int\"], \"default\": null},\n {\n \"name\": \"favoriteProgrammingLanguage\",\n \"type\": {\"name\": \"ProgrammingLanguage\", \"type\": \"enum\", \"symbols\": [\"JS\", \"Java\", \"Go\", \"Rust\", \"C\"]}\n },\n {\n \"name\": \"address\",\n \"type\": {\n \"name\": \"Address\",\n \"type\": \"record\",\n \"fields\": [{\"name\": \"zipcode\", \"type\": \"int\"}]\n }\n }\n ],\n}\n" + } + ], + "http://a.ml/vocabularies/core#mediaType": [ { - "@value": "schema" + "@value": "application/json" } ] } @@ -168,7 +140,7 @@ ], "http://a.ml/vocabularies/document#processingData": [ { - "@id": "file://amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-ref-1.8.2.yaml#/references/0/BaseUnitProcessingData", + "@id": "file://amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-ref-1.9.0.yaml#/references/0/BaseUnitProcessingData", "@type": [ "http://a.ml/vocabularies/document#BaseUnitProcessingData" ], diff --git a/amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-ref-1.8.2.yaml b/amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-ref-1.9.0.yaml similarity index 73% rename from amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-ref-1.8.2.yaml rename to amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-ref-1.9.0.yaml index b274750f88..ae0321710e 100644 --- a/amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-ref-1.8.2.yaml +++ b/amf-cli/shared/src/test/resources/avro/tck/apis/valid/avro-ref-1.9.0.yaml @@ -6,9 +6,9 @@ channels: myChannel: publish: message: - schemaFormat: application/vnd.apache.avro;version=1.8.2 + schemaFormat: application/vnd.apache.avro;version=1.9.0 payload: - $ref: 'schema-1.8.2.avsc' + $ref: 'schema-1.9.0.avsc' # tratar de validar esta referencia. # Crear dump y jsold files. # Agregar json con schemas simples. Tratando de abarcar toda la spec de avro (fields, types) diff --git a/amf-cli/shared/src/test/resources/avro/tck/apis/valid/schema-1.8.2.avsc b/amf-cli/shared/src/test/resources/avro/tck/apis/valid/schema-1.9.0.avsc similarity index 100% rename from amf-cli/shared/src/test/resources/avro/tck/apis/valid/schema-1.8.2.avsc rename to amf-cli/shared/src/test/resources/avro/tck/apis/valid/schema-1.9.0.avsc diff --git a/amf-cli/shared/src/test/scala/amf/avro/AsyncAvroValidTCKParsingTest.scala b/amf-cli/shared/src/test/scala/amf/avro/AsyncAvroValidTCKParsingTest.scala index 60c4a8e5fe..85d84bbb54 100644 --- a/amf-cli/shared/src/test/scala/amf/avro/AsyncAvroValidTCKParsingTest.scala +++ b/amf-cli/shared/src/test/scala/amf/avro/AsyncAvroValidTCKParsingTest.scala @@ -2,7 +2,6 @@ package amf.avro import amf.core.internal.remote.{AmfJsonHint, Async20YamlHint, AvroHint} - class AsyncAvroValidTCKParsingTest extends AsyncAvroCycleTest { override def basePath: String = s"amf-cli/shared/src/test/resources/avro/tck/apis/valid/" @@ -13,6 +12,7 @@ class AsyncAvroValidTCKParsingTest extends AsyncAvroCycleTest { cycle(api, api.replace(".yaml", ".jsonld"), Async20YamlHint, AmfJsonHint) } + // todo: change ignore to test when emission is ready ignore(s"Avro TCK > Apis > Valid > $api: dumped YAML matches golden") { cycle(api, api.replace(".yaml", ".dumped.yaml"), Async20YamlHint, Async20YamlHint) }