Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/codegen/fromcto/avro/avrovisitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class AvroVisitor {

parameters.fileWriter.writeLine(
0,
`@namespace("${modelFile.getNamespace()}")`
`@namespace("${ModelUtil.parseNamespace(modelFile.getNamespace()).name}")`
);
const protocolName = parameters?.avroProtocolName ?? 'MyProtocol';
parameters.fileWriter.writeLine(0, `protocol ${protocolName} {\n`);
Expand Down
8 changes: 4 additions & 4 deletions test/codegen/__snapshots__/codegen.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ org.acme.hr_1_0_0.ChangeOfAddress "1" *-- "1" org.acme.hr.base_1_0_0.Address : n
exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'avro' 1`] = `
{
"key": "concerto.decorator@1.0.0.avdl",
"value": "@namespace("concerto.decorator@1.0.0")
"value": "@namespace("concerto.decorator")
protocol MyProtocol {

import idl "concerto@1.0.0.avdl";
Expand All @@ -387,7 +387,7 @@ protocol MyProtocol {
exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'avro' 2`] = `
{
"key": "concerto@1.0.0.avdl",
"value": "@namespace("concerto@1.0.0")
"value": "@namespace("concerto")
protocol MyProtocol {

import idl "concerto.decorator@1.0.0.avdl";
Expand Down Expand Up @@ -421,7 +421,7 @@ protocol MyProtocol {
exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'avro' 3`] = `
{
"key": "org.acme.hr.base@1.0.0.avdl",
"value": "@namespace("org.acme.hr.base@1.0.0")
"value": "@namespace("org.acme.hr.base")
protocol MyProtocol {

import idl "concerto@1.0.0.avdl";
Expand Down Expand Up @@ -466,7 +466,7 @@ protocol MyProtocol {
exports[`codegen #formats check we can convert all formats from namespace versioned CTO, format 'avro' 4`] = `
{
"key": "org.acme.hr@1.0.0.avdl",
"value": "@namespace("org.acme.hr@1.0.0")
"value": "@namespace("org.acme.hr")
protocol MyProtocol {

import idl "org.acme.hr.base@1.0.0.avdl";
Expand Down
11 changes: 11 additions & 0 deletions test/codegen/fromcto/avro/avrovisitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,17 @@ describe('Avro', function () {
file.should.match(/protocol FancyProtocol/);
});

it('should drop the version from the namespace', () => {
const modelManager = new ModelManager();
modelManager.addCTOModel( MODEL_SIMPLE );
const visitor = new AvroVisitor();
const fileWriter = new InMemoryWriter();
modelManager.accept(visitor, { fileWriter });
const files = fileWriter.getFilesInMemory();
const file = files.get('test@1.0.0.avdl');
file.should.match(/^@namespace\("test"\)$/m);
});

it('should throw an error when an unrecognised type is supplied', () => {
let thing = 'Something of unrecognised type';
const visitor = new AvroVisitor();
Expand Down
9 changes: 1 addition & 8 deletions test/verification/cases.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ const CASES = [
modelManager.addCTOModel(MetaModelUtil.metaModelCto);
},
skip: {
avro: 'versioned namespaces (e.g. concerto.decorator@1.0.0) are illegal Avro identifiers (segment "0")',
golang: 'GoLangVisitor emits bare package-name imports (e.g. import "concerto_decorator_1_0_0") instead of Go module-relative import paths, so any cross-namespace model fails go build',
},
},
Expand All @@ -48,7 +47,6 @@ const CASES = [
protobuf:'Empty enum produces invalid Protobuf (enum must have >= 1 item)',
graphql: 'map types emit invalid GraphQL SDL (key/value field syntax)',
rust: 'map declarations reference scalar key/value types (e.g. SSN) that the Rust visitor does not emit, so cargo check fails',
avro: 'versioned namespaces (e.g. concerto.decorator@1.0.0) are illegal Avro identifiers (segment "0")',
golang: 'GoLangVisitor emits bare package-name imports (e.g. import "concerto_decorator_1_0_0") instead of Go module-relative import paths, so any cross-namespace model fails go build',
},
},
Expand All @@ -62,7 +60,7 @@ const CASES = [
protobuf: 'Empty enum produces invalid Protobuf (enum must have >= 1 item) and scalar map keys (e.g. SSN) are not valid Proto3 map key types',
graphql: 'map types emit invalid GraphQL SDL (key/value field syntax)',
rust: 'map declarations reference scalar key/value types (e.g. SSN, Time) that the Rust visitor does not emit, so cargo check fails',
avro: 'versioned namespaces (e.g. concerto.decorator@1.0.0) are illegal Avro identifiers (segment "0")',
avro: 'imported types are referenced by short name (e.g. Category from org.acme.hr.base), so avro-tools cannot resolve them',
openapi: 'JSON Schema $decorators and invalid schema nesting fail OpenAPI struct validation',
golang: 'GoLangVisitor emits bare package-name imports (e.g. import "concerto_decorator_1_0_0") instead of Go module-relative import paths, so any cross-namespace model fails go build',
},
Expand All @@ -71,15 +69,13 @@ const CASES = [
name: 'stringlength',
files: ['stringlength.cto'],
skip: {
avro: 'versioned namespaces (e.g. concerto.decorator@1.0.0) are illegal Avro identifiers (segment "0")',
golang: 'GoLangVisitor emits bare package-name imports (e.g. import "concerto_decorator_1_0_0") instead of Go module-relative import paths, so any cross-namespace model fails go build',
},
},
{
name: 'collectionsize',
files: ['collectionsize.cto'],
skip: {
avro: 'versioned namespaces (e.g. concerto.decorator@1.0.0) are illegal Avro identifiers (segment "0")',
golang: 'GoLangVisitor emits bare package-name imports (e.g. import "concerto_decorator_1_0_0") instead of Go module-relative import paths, so any cross-namespace model fails go build',
protobuf: 'Relationships are not supported in protobuf',
graphql: 'Relationships are not supported in graphql visitor',
Expand All @@ -90,7 +86,6 @@ const CASES = [
name: 'model-base',
files: ['model-base.cto'],
skip: {
avro: 'versioned namespaces (e.g. concerto.decorator@1.0.0) are illegal Avro identifiers (segment "0")',
openapi: 'JSON Schema $decorators fail OpenAPI struct validation',
golang: 'GoLangVisitor emits bare package-name imports (e.g. import "concerto_decorator_1_0_0") instead of Go module-relative import paths, so any cross-namespace model fails go build',
},
Expand All @@ -99,7 +94,6 @@ const CASES = [
name: 'agreement',
files: ['agreement.cto'],
skip: {
avro: 'versioned namespaces (e.g. concerto.decorator@1.0.0) are illegal Avro identifiers (segment "0")',
openapi: 'JSON Schema $decorators fail OpenAPI struct validation',
golang: 'GoLangVisitor emits bare package-name imports (e.g. import "concerto_decorator_1_0_0") instead of Go module-relative import paths, so any cross-namespace model fails go build',
},
Expand All @@ -108,7 +102,6 @@ const CASES = [
name: 'circular',
files: ['circular.cto'],
skip: {
avro: 'versioned namespaces (e.g. concerto.decorator@1.0.0) are illegal Avro identifiers (segment "0")',
golang: 'GoLangVisitor emits bare package-name imports (e.g. import "concerto_decorator_1_0_0") instead of Go module-relative import paths, so any cross-namespace model fails go build',
},
},
Expand Down
1 change: 0 additions & 1 deletion verification/corpus/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
},
"skip": {
"csharp": "generated C# references AccordProject.Concerto runtime types (e.g. ConcertoConverterFactorySystem) that are not available for a standalone dotnet build",
"avro": "versioned namespaces (e.g. concerto.decorator@1.0.0) are illegal Avro identifiers (segment \"0\")",
"golang": "GoLangVisitor emits bare package-name imports (e.g. import \"concerto_decorator_1_0_0\") instead of Go module-relative import paths, so any cross-namespace model fails go build"
}
}
Expand Down
Loading