Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/maxmindlin/openfga-dsl-parser
Parsing and JSON transformer library for the OpenFGA authorization DSL
https://github.com/maxmindlin/openfga-dsl-parser
json library openfga parser transformer
Last synced: 4 months ago
JSON representation
Parsing and JSON transformer library for the OpenFGA authorization DSL
- Host: GitHub
- URL: https://github.com/maxmindlin/openfga-dsl-parser
- Owner: maxmindlin
- License: apache-2.0
- Created: 2022-07-25T17:21:02.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2022-10-17T22:14:13.000Z (over 2 years ago)
- Last Synced: 2024-10-11T20:18:53.560Z (4 months ago)
- Topics: json, library, openfga, parser, transformer
- Language: Rust
- Homepage: https://crates.io/crates/openfga-dsl-parser
- Size: 41 KB
- Stars: 7
- Watchers: 4
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# OpenFGA DSL Parser
[![Openfga-dsl-parser crate](https://img.shields.io/crates/v/openfga-dsl-parser.svg)](https://crates.io/crates/openfga-dsl-parser)
[![Openfga-dsl-parser documentation](https://docs.rs/openfga-dsl-parser/badge.svg)](https://docs.rs/openfga-dsl-parser)The OpenFGA DSL Parser provides utilities for parsing DSL file string inputs into an AST representation, as well as transforming them into a JSON representation.
This library is meant to be a utility for services using [OpenFGA](https://openfga.dev/) for their authorization solution, but need a way to translate from their DSL to the JSON format the HTTP API expects. A [Typescript library](https://github.com/openfga/syntax-transformer) is available that does something similar, however this library aims to target Rust as well as be a base for other potential languages to bind to.
# Usage
```rust
use openfga_dsl_parser::{json, Parser};let input = "type group
relations
define member as self
type resource
relations
define writer as self
define reader as self but not writer";let mut parser = Parser::new(input);
let doc = parser.parse_document()?;let json = json::JsonTransformer::new(&doc).serialize();
```