Skip to content

Commit 103df5d

Browse files
committed
Add type to define the contents of exchange.json
1 parent 4c040f3 commit 103df5d

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

src/download/exchangeTypes.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,22 @@ export type RawRestApi = Omit<RestApi, "categories" | "fatRaml"> & {
4545
version: string;
4646
}[];
4747
};
48+
49+
export type ExchangeConfig = {
50+
dependencies?: {
51+
version: string;
52+
assetId: string;
53+
groupId: string;
54+
}[];
55+
version: string;
56+
originalFormatVersion: string;
57+
apiVersion: string;
58+
descriptorVersion: string;
59+
classifier: string;
60+
main: string;
61+
assetId: string;
62+
groupId: string;
63+
organizationId: string;
64+
name: string;
65+
tags: string[];
66+
};

src/download/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ export { extractFiles } from "./exchangeDirectoryParser";
99
export { groupByCategory, removeRamlLinks } from "./exchangeTools";
1010
export { DownloadCommand } from "./downloadCommand";
1111
export { getBearer } from "./bearerToken";
12-
export { RestApi } from "./exchangeTypes";
12+
export { RestApi, ExchangeConfig } from "./exchangeTypes";

src/generate/apiModel.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
} from "../common/amfParser";
1414

1515
import { Name } from "../common/structures/name";
16-
import { RestApi } from "../download/exchangeTypes";
16+
import { ExchangeConfig, RestApi } from "../download/exchangeTypes";
1717
import path from "path";
1818
import fs from "fs-extra";
1919
import { ramlToolLogger } from "../common/logger";
@@ -56,7 +56,7 @@ export class ApiModel extends ApiMetadata {
5656
fs.lstatSync(filepath).isDirectory() &&
5757
fs.existsSync(path.join(filepath, "exchange.json"))
5858
) {
59-
const exchangeConfig = fs.readJSONSync(
59+
const exchangeConfig: ExchangeConfig = fs.readJSONSync(
6060
path.join(filepath, "exchange.json")
6161
);
6262

0 commit comments

Comments
 (0)