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

Enable schema validation for catalog editor #69

Open
travjenkins opened this issue Apr 6, 2022 · 3 comments
Open

Enable schema validation for catalog editor #69

travjenkins opened this issue Apr 6, 2022 · 3 comments
Labels
enhancement New feature or request

Comments

@travjenkins
Copy link
Member

The user can edit the catalog manually in the create flow. However, they are unable to know if their edits are valid. We need to load the Flow schema into the Monaco editor and have it validate it.

@travjenkins travjenkins added the enhancement New feature or request label Apr 6, 2022
@travjenkins travjenkins added this to the Control Plane UI - Alpha milestone Apr 6, 2022
@travjenkins
Copy link
Member Author

Moving to next. We did not implement this with the mvp

@travjenkins
Copy link
Member Author

Looked into this and going to take a bit of work.

Got the Schema loading by hardcoding it into the application as flowSchema.json file and including it in the src/types dir. This allowed me to load it into the editor using the prop onBeforeMount [^1]

This renders fine and does something where it is clearly picking up the description for the schema.
image

There is a warning stating that Draft 2019-09 is not supported. This warning is displayed when the schema uses a feature that is not yet supported by Monaco editor [issue]. There is on going work to fully implement this draft.(microsoft/vscode-json-languageservice#122 (comment))

Side note
If we want to ever use markdown in our description (not sure yet if we do) then that might be an issue and we'd have to use a different property: microsoft/monaco-editor#1816 (comment)

[^1] Handler used

        beforeMount: (monaco: Monaco) => {
            console.log('handlers:beforeMount', monaco);
            monaco.languages.json.jsonDefaults.setDiagnosticsOptions({
                validate: true,
                schemaValidation: 'error',
                schemas: [
                    {
                        uri: 'https://server/schema.json',
                        fileMatch: ['*'],
                        schema: flowSchema,
                    },
                ],
            });
        },

@travjenkins
Copy link
Member Author

travjenkins commented Feb 3, 2023

Luckily - we can still get some features like descriptions displaying:
image

However, with how the current flow schema is being brought into the UI the editor is getting confused. It does not understand our schema and does not connect that 1 is the same as 2
image

I think we need to get the flow schema broken up in the UI so that we can load it into the editor based on the entity being displayed.

@travjenkins travjenkins removed this from the Control Plane UI - Next milestone Feb 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant