From 4f9a76147b49b35a2b580f23adf4f1ce69087fc1 Mon Sep 17 00:00:00 2001 From: Timon Back Date: Tue, 31 Dec 2024 17:01:36 +0100 Subject: [PATCH] bugfix(ui): fix lookup for oneof nested schemas --- .../service/asyncapi/asyncapi-mapper.service.ts | 15 ++++++++++++--- .../app/service/asyncapi/models/schema.model.ts | 2 +- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/springwolf-ui/src/app/service/asyncapi/asyncapi-mapper.service.ts b/springwolf-ui/src/app/service/asyncapi/asyncapi-mapper.service.ts index 7059ab779..33eee88f0 100644 --- a/springwolf-ui/src/app/service/asyncapi/asyncapi-mapper.service.ts +++ b/springwolf-ui/src/app/service/asyncapi/asyncapi-mapper.service.ts @@ -47,6 +47,7 @@ export class AsyncApiMapperService { item.channels, item.operations, item.components.messages, + item.components.schemas, item.servers, item.defaultContentType ); @@ -110,6 +111,7 @@ export class AsyncApiMapperService { channels: ServerChannels, operations: ServerOperations, messages: ServerComponents["messages"], + schemas: ServerComponents["schemas"], servers: ServerServers, defaultContentType: string ): Channel[] { @@ -139,6 +141,7 @@ export class AsyncApiMapperService { channelName, channels[channelId], messages, + schemas, operation.messages, defaultContentType ); @@ -249,6 +252,7 @@ export class AsyncApiMapperService { channelName: string, channel: ServerChannel, messages: ServerComponents["messages"], + schemas: ServerComponents["schemas"], operationMessages: ServerOperationMessage[], defaultContentType: string ): Message[] { @@ -270,7 +274,11 @@ export class AsyncApiMapperService { title: message.title, description: message.description, contentType: message.contentType || defaultContentType, - payload: this.mapPayload(message.name, message.payload.schema), + payload: this.mapPayload( + message.name, + message.payload.schema, + schemas + ), headers: { ts_type: "ref", name: headerName, @@ -289,7 +297,8 @@ export class AsyncApiMapperService { private mapPayload( payloadName: string, - schema: { $ref: string } | ServerAsyncApiSchema + schema: { $ref: string } | ServerAsyncApiSchema, + schemas: ServerComponents["schemas"] ): Message["payload"] { if ("$ref" in schema) { const payloadName = this.resolveRefId(schema.$ref); @@ -302,7 +311,7 @@ export class AsyncApiMapperService { }; } - return this.mapSchemaObj(payloadName, schema, {}); + return this.mapSchemaObj(payloadName, schema, schemas); } private mapServerAsyncApiMessageBindings( diff --git a/springwolf-ui/src/app/service/asyncapi/models/schema.model.ts b/springwolf-ui/src/app/service/asyncapi/models/schema.model.ts index e0ecbabf8..3f6b5e11e 100644 --- a/springwolf-ui/src/app/service/asyncapi/models/schema.model.ts +++ b/springwolf-ui/src/app/service/asyncapi/models/schema.model.ts @@ -9,7 +9,7 @@ export interface ServerAsyncApiSchema { enum?: string[]; examples?: any[]; - type: string; + type?: string; format?: string; // type == ref not?: ServerAsyncApiSchemaOrRef;