Skip to content

Commit

Permalink
finos#486 always instantiate 'interfaces' block
Browse files Browse the repository at this point in the history
  • Loading branch information
willosborne committed Nov 18, 2024
1 parent 32e3dc5 commit 107406c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
5 changes: 1 addition & 4 deletions shared/src/commands/generate/components/instantiate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@ export function instantiateGenericObject(definition: object, schemaDirectory: Sc
const currentPath = appendPath(path, key);
const renderedPath = renderPath(currentPath);

if (!instantiateAll && required && !required.includes(key)) { // TODO should we always do interfaces even if not required?
if (key === 'interfaces') {
logger.warn(`${renderedPath}: 'interfaces' property was not marked as required. You might be missing some values if this object has interfaces defined.`);
}
if (!instantiateAll && required && !required.includes(key) && key !== 'interfaces') { // TODO should we always do interfaces even if not required?
logger.debug(`${renderedPath}: Skipping property ${key} as it is not marked as required.`);
continue;
}
Expand Down
3 changes: 2 additions & 1 deletion shared/src/commands/generate/components/node.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ describe('instantiateNodes', () => {
expect(spy).toHaveBeenCalledWith(reference);
});

it('return instantiated node with interface', () => {
it('return instantiated node with interfaces, even when not marked as required', () => {
const pattern = {
properties: {
nodes: {
Expand All @@ -165,6 +165,7 @@ describe('instantiateNodes', () => {
},
// interfaces should be inserted
'interfaces': {
'type': 'array',
'prefixItems': [
{
properties: {
Expand Down
4 changes: 4 additions & 0 deletions shared/src/commands/generate/components/property.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ export function getPropertyValue(keyName: string, detail: Detail): string | stri
return -1;
}
if (propertyType === 'array') {
// special case: we always want to instantiate interfaces, even if not required, but not to output [ {{ INTERFACES }} ] in this case.
if (keyName === 'interfaces') {
return [];
}
return [
getStringPlaceholder(keyName)
];
Expand Down

0 comments on commit 107406c

Please sign in to comment.