Skip to content

Commit

Permalink
Merge pull request #86 from mtseluiko/HCK-2773--v6-7-3-alpha-1-5-infe…
Browse files Browse the repository at this point in the history
…rring-of-subject-name-str

Hck 2773  v6 7 3 alpha 1 5 inferring of subject name str
  • Loading branch information
Vitalii4as authored Dec 16, 2022
2 parents e5e2f96 + 6135751 commit 0613da4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
12 changes: 6 additions & 6 deletions forward_engineering/helpers/formatAvroSchemaByType.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,19 +76,19 @@ const getConfluentPostQuery = ({
return confluentSubjectName;
}

const typePostfix = schemaType ? `-${schemaType}` : '';
const containerPrefix = namespace ? `${namespace}.`:'';
const typePostfix = schemaType || '';
const containerPrefix = namespace || '';
const topicPrefix = schemaTopic || '';

switch(schemaNameStrategy){
case RECORD_NAME_STRATEGY:
return `${containerPrefix}${name}${typePostfix}`
return [containerPrefix, name, typePostfix].filter(Boolean).join('-');
case TOPIC_NAME_STRATEGY:
return `${topicPrefix || name}${typePostfix}`
return [topicPrefix || name, typePostfix].filter(Boolean).join('-');
case TOPIC_RECORD_NAME_STRATEGY:
return `${topicPrefix}-${containerPrefix}${name}${typePostfix}`
return [topicPrefix, containerPrefix, name, typePostfix].filter(Boolean).join('-');
default:
return `${name}${typePostfix}`;
return [name, typePostfix].filter(Boolean).join('-');
}
}

Expand Down
4 changes: 4 additions & 0 deletions reverse_engineering/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ const inferSchemaNameStrategy = ({ name, namespace, confluentSubjectName, schema
}

if (startsWithTopic && _.isEmpty(splittedSubjectName)) {
if (name === schemaTopic) {
return 'RecordNameStrategy';
}

return 'TopicNameStrategy';
}

Expand Down

0 comments on commit 0613da4

Please sign in to comment.