Skip to content
This repository was archived by the owner on Jun 18, 2023. It is now read-only.

Commit 001175c

Browse files
timonbackstavshamir
authored andcommitted
GH-27: Add asyncApi json to info model
The mapped info model lose the original json structure, which is needed for the download.
1 parent f069d93 commit 001175c

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

src/app/info/info.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export class InfoComponent implements OnInit {
2323
}
2424

2525
download(): Boolean {
26-
var json = JSON.stringify(this.asyncApiData, null, 2);
26+
var json = JSON.stringify(this.asyncApiData.info.asyncApiJson, null, 2);
2727
var bytes = new TextEncoder().encode(json);
2828
var blob = new Blob([bytes], { type: 'application/json' });
2929
var url = window.URL.createObjectURL(blob);

src/app/shared/asyncapi-mapper.service.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {Channel, CHANNEL_ANCHOR_PREFIX, Message, Operation, OperationType} from
44
import { Schema } from './models/schema.model';
55
import { Injectable } from '@angular/core';
66
import {Example} from "./models/example.model";
7+
import {Info} from "./models/info.model";
78

89
interface ServerAsyncApiSchema {
910
description?: string;
@@ -69,7 +70,7 @@ export class AsyncApiMapperService {
6970

7071
public toAsyncApi(item: ServerAsyncApi): AsyncApi {
7172
return {
72-
info: item.info,
73+
info: this.mapInfo(item),
7374
servers: this.mapServers(item.servers),
7475
channels: this.mapChannels(item.channels),
7576
components: {
@@ -78,6 +79,15 @@ export class AsyncApiMapperService {
7879
};
7980
}
8081

82+
private mapInfo(item: ServerAsyncApi): Info {
83+
return {
84+
title: item.info.title,
85+
version: item.info.version,
86+
description: item.info.description,
87+
asyncApiJson: item,
88+
};
89+
}
90+
8191
private mapServers(servers: ServerAsyncApi["servers"]): Map<string, Server> {
8292
const s = new Map<string, Server>();
8393
Object.entries(servers).forEach(([k, v]) => s.set(k, v));

src/app/shared/models/info.model.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ export interface Info {
22
title: string;
33
version: string;
44
description?: string;
5+
asyncApiJson: object;
56
}

0 commit comments

Comments
 (0)