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 support for specifying field name aliases #18

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open

Conversation

Alfus
Copy link
Contributor

@Alfus Alfus commented Jul 3, 2024

Using a new custom option:

message SchemaMessage {
  string string_schema_field = 1 [(buf.schema.field).alias = "string_schema_field_alias"];
  int32 int32_schema_field = 2 [
    (buf.schema.field).alias = "int32_schema_field_alias",
    (buf.schema.field).alias_json = "int32 schema field alias json"
  ];
}

@Alfus Alfus requested a review from rodaine July 3, 2024 23:39
@@ -1,12 +1,15 @@
version: v2
modules:
- path: internal/proto
- path: proto
name: buf.build/bufbuild/protoschema
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need more explanation here before we add a public repo to the bufbuild org. What is this for?

Copy link
Contributor Author

@Alfus Alfus Jul 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main use for this is protoyaml. It allows a field to be renamed without atomically updating all yaml files. Beyoned that, its a key missing feature for any usage of names in a serialization formats (e.g. json, yaml, flags, protobuf with optional ids, etc). For these formats, the main field name is preferred, and aliases support backwards compatibility for reads.

internal/protoschema/protoschema.go Show resolved Hide resolved
internal/protoschema/protoschema.go Show resolved Hide resolved
proto/buf/schema/schema.proto Show resolved Hide resolved
proto/buf/schema/schema.proto Show resolved Hide resolved
@Alfus Alfus requested a review from akshayjshah July 16, 2024 17:20
@Alfus Alfus requested a review from jhump August 7, 2024 13:51
@akshayjshah akshayjshah removed their request for review November 29, 2024 23:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants