Skip to content

Add optional support for serde with a feature flag #590

Open
@firstdorsal

Description

@firstdorsal

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions