Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix(ui): fix lookup for oneof nested schemas #1141

Merged
merged 1 commit into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions springwolf-ui/src/app/service/asyncapi/asyncapi-mapper.service.ts
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,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,
Expand All @@ -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);
Expand All @@ -302,7 +311,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
Loading