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

python protobuf validation #41

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions protobuf/python/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@

## Usage

```shell
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
protoc -I=schema --python_out=. schema/sdk.proto
python validate.py
```

## Observations

- Maps cannot have mixed/variant data types, e.g.

When defined as
```protobuf
message {
map<string, string> headers = 1;
}
```

All values must be string, so timeout value has to be quoted:
```yaml
headers:
api_key: abcd
timeout: "1000"
```

- Maps do not support `oneof`, so something like this cannot be expressed as map of different types of messages.

```yaml
exporters:
otlp:
endpoint: http://some_url
protocol: http/protobuf
zipkin:
endpoint: http://another_url
timeout: 1000
```
Instead, each exporter type will have to be defined as a separate field of the Exporters message:

```protobuf
message Exporters {
OtlpExporter otlp = 1;
ZipkinExporter zipkin = 2;
}
```

- There is no way to define required fields.
Loading