Closed advdv closed 2 months ago
I'm working on this now as part of #10. Would you expect a feature to auto translate to JSON (for use in pre 3.1 versions)?
As a temporary solution, I have defined a .vscode\tasks.json
using the Cedar CLI that can be manual run from inside VSCode. I haven't figured on how to trigger a task "on save" for a specific file extension (but also am spending my time on the built-in extension code). This does require cedar
to be on your path.
{
"version": "2.0.0",
"tasks": [
{
"label": "Cedar CLI translate-schema human-to-json",
"type": "shell",
"command": "cedar",
"args": [
"translate-schema",
"--schema",
"${file}",
"--direction",
"human-to-json",
"|",
"jq",
">",
"${file}.json"
]
}
]
}
Thank you for the task idea, that is nice.
I have two thoughts, not sure how related they are to what you're asking:
pre-release v0.7.2 added support to translate between JSON and human-readable schemas. along with some basic syntax highlighting and navigation. Either name the file cedarschema
or *.cedarschema
or Set Language Mode to Cedar Schema
However, IntelliSense (auto-complete) requires the JSON-based schema (for now). At the top of the Cedar Schema file is a clickable Code Lens line that will run translation (also available in context menu and as Cedar: Translate Cedar schema
in command palette.
I assume this can be closed based on #21?
Closing this since pre-release v0.7.3 supports this. Cedar 2.x vs Cedar 3.x is part of #10
Category
Cedar editing features
Describe the feature you'd like to request
The human-readable schema format is recommend according to the official documentation: https://docs.cedarpolicy.com/schema/schema.html#schema.
But I don't see a way for this extension to use it directly.
Describe alternatives you've considered
Manually converting the human readable format to the json format. But doing this on every change is painful when designing and iterating on the policies.
I could write the schema in json, but it doesn't support comments. Which makes it hard to reason about in a team
Additional context
No response
Is this something that you'd be interested in working on?