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

Add optional support for serde with a feature flag #590

Open
firstdorsal opened this issue Jan 26, 2025 · 0 comments
Open

Add optional support for serde with a feature flag #590

firstdorsal opened this issue Jan 26, 2025 · 0 comments

Comments

@firstdorsal
Copy link

firstdorsal commented Jan 26, 2025

I would like to parse a JSON/YAML document with serde into the required enums for the management API.

For example:
OidcAppType as one of Web, UserAgent or Native

{
    "appType": "Web"
}

This maybe could be done like mentioned here: https://github.com/neoeinstein/protoc-gen-prost/blob/main/protoc-gen-prost-serde/README.md

cargo install protoc-gen-prost-serde

# buf.gen.yaml
version: v1
managed:
  enabled: true
plugins:
  - plugin: prost
    out: src/api/generated
    opt:
      - compile_well_known_types
      - extern_path=.google.protobuf=::pbjson_types
  - plugin: prost-serde
    out: src/api/generated
  - plugin: tonic
    out: src/api/generated
    opt:
      - compile_well_known_types
      - extern_path=.google.protobuf=::pbjson_types
      - no_server
  - name: prost-crate
    out: .
    strategy: all
    opt:
      - gen_crate
      - include_file=src/api/generated/mod.rs

and adding pbjson = { version = "0.7.0", optional = true } as dependency

Support for schemars::JsonSchema would also be great although I didn't find a simple way to do this like for serde.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant