Skip to content
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
3 changes: 3 additions & 0 deletions buf.yaml
Original file line number Diff line number Diff line change
@@ -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.

deps:
- buf.build/bufbuild/protovalidate
lint:
except:
- FIELD_NOT_REQUIRED
- PACKAGE_NO_IMPORT_CYCLE
- PACKAGE_VERSION_SUFFIX
ignore:
- internal/proto/bufext
disallow_comment_ignores: true
Expand Down
6 changes: 4 additions & 2 deletions internal/cmd/jsonschema-generate-testdata/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,10 @@ func run() error {
}
for _, testDesc := range testDescs {
// Generate the JSON schema
result := jsonschema.Generate(testDesc)

result, err := jsonschema.Generate(testDesc)
if err != nil {
return err
}
// Make sure the directory exists
if err := os.MkdirAll(outputDir, 0755); err != nil {
return err
Expand Down
213 changes: 148 additions & 65 deletions internal/gen/proto/buf/protoschema/test/v1/test_cases.pb.go

Large diffs are not rendered by default.

220 changes: 220 additions & 0 deletions internal/gen/proto/buf/schema/schema.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions internal/proto/buf/protoschema/test/v1/test_cases.proto
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ syntax = "proto3";

package buf.protoschema.test.v1;

import "buf/schema/schema.proto";
import "buf/validate/validate.proto";
import "bufext/cel/expr/conformance/proto3/test_all_types.proto";

Expand Down Expand Up @@ -59,3 +60,11 @@ message IgnoreField {
// jsonschema:hide
NestedReference nested_reference = 5;
}

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"
];
}
1 change: 1 addition & 0 deletions internal/protoschema/golden/golden.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ func GetTestDescriptors(testdataPath string) ([]protoreflect.MessageDescriptor,
"buf.protoschema.test.v1.NestedReference",
"buf.protoschema.test.v1.CustomOptions",
"buf.protoschema.test.v1.IgnoreField",
"buf.protoschema.test.v1.SchemaMessage",
}

msgs := make([]protoreflect.MessageDescriptor, len(fqns))
Expand Down
Loading