Skip to content

Commit

Permalink
bugfix(ui): fix lookup for oneof nested schemas
Browse files Browse the repository at this point in the history
  • Loading branch information
timonback committed Dec 31, 2024
1 parent f90c6f1 commit ebf2cf6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export class AsyncApiMapperService {
item.channels,
item.operations,
item.components.messages,
item.components.schemas,
item.servers,
item.defaultContentType
);
Expand Down Expand Up @@ -110,6 +111,7 @@ export class AsyncApiMapperService {
channels: ServerChannels,
operations: ServerOperations,
messages: ServerComponents["messages"],
schemas: ServerComponents["schemas"],
servers: ServerServers,
defaultContentType: string
): Channel[] {
Expand Down Expand Up @@ -139,6 +141,7 @@ export class AsyncApiMapperService {
channelName,
channels[channelId],
messages,
schemas,
operation.messages,
defaultContentType
);
Expand Down Expand Up @@ -249,6 +252,7 @@ export class AsyncApiMapperService {
channelName: string,
channel: ServerChannel,
messages: ServerComponents["messages"],
schemas: ServerComponents["schemas"],
operationMessages: ServerOperationMessage[],
defaultContentType: string
): Message[] {
Expand All @@ -270,7 +274,7 @@ 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,
Expand All @@ -289,7 +293,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);
Expand All @@ -302,7 +307,7 @@ export class AsyncApiMapperService {
};
}

return this.mapSchemaObj(payloadName, schema, {});
return this.mapSchemaObj(payloadName, schema, schemas);
}

private mapServerAsyncApiMessageBindings(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export interface ServerAsyncApiSchema {
enum?: string[];
examples?: any[];

type: string;
type?: string;
format?: string;
// type == ref
not?: ServerAsyncApiSchemaOrRef;
Expand Down

0 comments on commit ebf2cf6

Please sign in to comment.