ondc-code-generator 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -19,5 +19,6 @@ export declare class ConfigCompiler {
|
|
|
19
19
|
performValidations: (valConfig: ValidationConfig) => Promise<void>;
|
|
20
20
|
generateCode: (valConfig: ValidationConfig, codeName?: string) => Promise<void>;
|
|
21
21
|
generateL0Schema: () => Promise<void>;
|
|
22
|
+
generateValidPaths: () => Promise<void>;
|
|
22
23
|
}
|
|
23
24
|
export {};
|
|
@@ -5,7 +5,7 @@ import { SupportedLanguages } from "../types/compiler-types.js";
|
|
|
5
5
|
import { TypescriptGenerator } from "./generators/typescript/ts-generator.js";
|
|
6
6
|
import { ConfigValidator } from "./validators/config-validator.js";
|
|
7
7
|
import { writeAndFormatCode } from "../utils/fs-utils.js";
|
|
8
|
-
import { readFileSync } from "fs";
|
|
8
|
+
import { readFileSync, writeFileSync } from "fs";
|
|
9
9
|
import Mustache from "mustache";
|
|
10
10
|
import { fileURLToPath } from "url";
|
|
11
11
|
import path from "path";
|
|
@@ -74,6 +74,11 @@ export class ConfigCompiler {
|
|
|
74
74
|
const l0 = Mustache.render(template, { actions });
|
|
75
75
|
await writeAndFormatCode(`./generated/L0-schemas`, `index.ts`, l0, "typescript");
|
|
76
76
|
};
|
|
77
|
+
this.generateValidPaths = async () => {
|
|
78
|
+
if (!this.possibleJsonPaths)
|
|
79
|
+
throw new Error("Possible paths not initialized");
|
|
80
|
+
writeFileSync("./validPaths.json", JSON.stringify(this.possibleJsonPaths, null, 2));
|
|
81
|
+
};
|
|
77
82
|
this.language = language;
|
|
78
83
|
this.SchemaExtactionService = new SchemaExtactionService();
|
|
79
84
|
}
|
|
@@ -11,8 +11,10 @@ export class SchemaExtactionService {
|
|
|
11
11
|
for (const targetApi of apis) {
|
|
12
12
|
const existingSchema = paths[`/${targetApi}`].post.requestBody.content["application/json"]
|
|
13
13
|
.schema;
|
|
14
|
-
output["response"] =
|
|
15
|
-
|
|
14
|
+
// output["response"] =
|
|
15
|
+
// paths[`/${targetApi}`].post.responses.default.content[
|
|
16
|
+
// "application/json"
|
|
17
|
+
// ].schema;
|
|
16
18
|
const filtteredSchema = removeRequiredAndEnum(existingSchema, removeEnums, removeRequired);
|
|
17
19
|
output[targetApi] = filtteredSchema;
|
|
18
20
|
}
|