Update object definitions in list and map
This commit is contained in:
@@ -2,9 +2,7 @@ import { CommonModule } from '@angular/common';
|
||||
import {
|
||||
ChangeDetectionStrategy,
|
||||
Component,
|
||||
OnInit,
|
||||
computed,
|
||||
effect,
|
||||
forwardRef,
|
||||
input,
|
||||
model,
|
||||
|
||||
@@ -34,6 +34,7 @@ message Test {
|
||||
NestedMessage hello10 = 10;
|
||||
EnumTest enum_test = 11;
|
||||
myimportedpackage.ImportedMessage imported_message = 12;
|
||||
repeated ReferenceMessage obj_list = 13;
|
||||
}
|
||||
|
||||
message ReferenceMessage {
|
||||
@@ -68,7 +69,7 @@ describe('TestService', () => {
|
||||
|
||||
expect(converted.name).toBe('Test');
|
||||
|
||||
expect(converted.values.length).toBe(12);
|
||||
expect(converted.values.length).toBe(13);
|
||||
checkNameAndType(converted, 'hello', MessageTypeEnum.String);
|
||||
checkNameAndType(converted, 'hello2', MessageTypeEnum.Numeric);
|
||||
checkNameAndType(converted, 'hello3', MessageTypeEnum.Numeric);
|
||||
@@ -81,6 +82,7 @@ describe('TestService', () => {
|
||||
checkNameAndType(converted, 'hello10', MessageTypeEnum.Object);
|
||||
checkNameAndType(converted, 'enumTest', MessageTypeEnum.Enum);
|
||||
checkNameAndType(converted, 'importedMessage', MessageTypeEnum.Object);
|
||||
checkNameAndType(converted, 'objList', MessageTypeEnum.List);
|
||||
|
||||
const listMessage = converted.values[6].configuration as ListMessage;
|
||||
expect(listMessage.subConfiguration.type).toBe(MessageTypeEnum.String);
|
||||
@@ -126,6 +128,15 @@ describe('TestService', () => {
|
||||
const enumMessage = converted.values[10].configuration as EnumMessage;
|
||||
expect(enumMessage.options.length).toBe(1);
|
||||
expect(enumMessage.options[0]).toBe('Hello');
|
||||
|
||||
const objectListMessage = converted.values[12].configuration as ListMessage;
|
||||
expect(objectListMessage.type).toBe(MessageTypeEnum.List);
|
||||
expect(objectListMessage.subConfiguration.type).toBe(
|
||||
MessageTypeEnum.Object
|
||||
);
|
||||
const objectListNestedMessage =
|
||||
objectListMessage.subConfiguration as ObjectMessage;
|
||||
expect(objectListNestedMessage.messageDefinition.values.length).toBe(2);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -82,9 +82,27 @@ export class ProtoDefinitionService {
|
||||
.map((messageObject) => messageObject as ProtoMessage);
|
||||
for (const messageObject of standardMessages) {
|
||||
for (const value of messageObject.values) {
|
||||
let configuration: MessageConfiguration | null = null;
|
||||
if (value.configuration.type === MessageTypeEnum.Object) {
|
||||
configuration = value.configuration;
|
||||
} else if (value.configuration.type === MessageTypeEnum.List) {
|
||||
const listConfiguration = value.configuration as ListMessage;
|
||||
if (
|
||||
listConfiguration.subConfiguration.type === MessageTypeEnum.Object
|
||||
) {
|
||||
configuration = listConfiguration.subConfiguration;
|
||||
}
|
||||
} else if (value.configuration.type === MessageTypeEnum.Map) {
|
||||
const listConfiguration = value.configuration as MapMessage;
|
||||
if (
|
||||
listConfiguration.valueConfiguration.type === MessageTypeEnum.Object
|
||||
) {
|
||||
configuration = listConfiguration.valueConfiguration;
|
||||
}
|
||||
}
|
||||
if (configuration) {
|
||||
this.populateNestedObject(
|
||||
value.configuration as ObjectMessage,
|
||||
configuration as ObjectMessage,
|
||||
messageObject.packageName!,
|
||||
standardMessages
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user