diff --git a/apps/miranum-config-editor/README.md b/apps/miranum-config-editor/README.md index 7fb350f4..2d09c9b7 100644 --- a/apps/miranum-config-editor/README.md +++ b/apps/miranum-config-editor/README.md @@ -78,7 +78,7 @@ If you don't have them yet, you can create them using the [Miranum JSON Forms Pl Once you have your `JSON Schema` and `UI-Schema` files, you need to set the path to those files in the settings. To do this, open the setting️s (Code > Preferences > Preferences) and search for `miranum-ide`. There should be an entry called `Miranum IDE > Config Editor: Base Path` with an empty text field. -You need to enter the path to your `JSON Schema` and `UI-Schema` files in this text field. +You need to enter the full path to your `JSON Schema` and `UI-Schema` files in this text field. ### Usage @@ -86,9 +86,9 @@ To use the editor, you have to open or create a `.config.json` file. The plugin will then search for the `JSON Schema` and `UI-Schema` files in the directory you specified in the settings. To find the right files, you have to stick to the following naming convention: -| Your Config File | Your JSON Schema | Your UI Schema | -|--------------------------|-----------------------|-------------------------| -| my-config.s3.config.json | schema.s3.config.json | uischema.s3.config.json | +| Your Config File | Your JSON Schema | Your UI Schema | +|--------------------------|------------------|------------------| +| my-config.s3.config.json | s3.schema.json | s3.uischema.json | The plugin will read these files and display your form in the editor. diff --git a/apps/miranum-config-editor/src/application/usecases.spec.ts b/apps/miranum-config-editor/src/application/usecases.spec.ts index 58947ed1..d15a4f30 100644 --- a/apps/miranum-config-editor/src/application/usecases.spec.ts +++ b/apps/miranum-config-editor/src/application/usecases.spec.ts @@ -5,8 +5,8 @@ import { ReadJsonFormUseCase } from "./usecases"; describe("Read Json Schema and UI Schema", () => { const directory = new Map([ - ["my/base/path/to/schema.s3.config.json", "JSON Schema was read!"], - ["my/base/path/to/uischema.s3.config.json", "UI Schema was read!"], + ["my/base/path/to/s3.schema.json", "JSON Schema was read!"], + ["my/base/path/to/s3.uischema.json", "UI Schema was read!"], ]); const reader: ReaderOutPort = { readFile(fileName: string): Promise { @@ -16,7 +16,7 @@ describe("Read Json Schema and UI Schema", () => { it("should work", async () => { const readJsonFormUseCase = new ReadJsonFormUseCase(reader); - const query = new ReadJsonFormQuery("schema.s3.config.json", "my/base/path/to"); + const query = new ReadJsonFormQuery("my-form.s3.config.json", "my/base/path/to"); const files = readJsonFormUseCase.readJsonForm(query); const schema = await files.get("schema"); diff --git a/apps/miranum-config-editor/src/application/usecases.ts b/apps/miranum-config-editor/src/application/usecases.ts index 0c9c9e88..242e539e 100644 --- a/apps/miranum-config-editor/src/application/usecases.ts +++ b/apps/miranum-config-editor/src/application/usecases.ts @@ -152,13 +152,18 @@ export class ReadJsonFormUseCase implements ReadJsonFormInPort { ) {} readJsonForm(readJsonFormQuery: ReadJsonFormQuery): Map> { + // The filename consists of the following parts. + // name | type | extension + // my-form.process.config.json const fileName = readJsonFormQuery.fileName; const basePath = readJsonFormQuery.basePath; - const extension = fileName.substring(fileName.indexOf("."), fileName.length); + const type = fileName.split(".").slice(-3, 2)[0]; - const schema = this.readerOutPort.readFile(`${basePath}/schema${extension}`); - const uischema = this.readerOutPort.readFile(`${basePath}/uischema${extension}`); + const schema = this.readerOutPort.readFile(`${basePath}/${type}.schema.json`); + const uischema = this.readerOutPort.readFile( + `${basePath}/${type}.uischema.json`, + ); return new Map([ ["schema", schema],