Skip to content

Commit

Permalink
fix: outputSchema=true when onlyTypes=true (#1039)
Browse files Browse the repository at this point in the history
This PR aims to fix a conflict that is created between two options that
results in code that fails to compile. Please note that this is not an
attempt to fix the underlying problem, which I have explained in a TODO
comment in the code for posterity. I also created new tests to capture
any regressions.

---------

Co-authored-by: semantic-release-bot <semantic-release-bot@martynus.net>
  • Loading branch information
lukealvoeiro and semantic-release-bot authored May 15, 2024
1 parent 23bb2f8 commit 064665f
Show file tree
Hide file tree
Showing 10 changed files with 4,311 additions and 1 deletion.
3,758 changes: 3,758 additions & 0 deletions integration/options-types-only/google/protobuf/descriptor.ts

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions integration/options-types-only/options-test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { protoMetadata } from "./options";

describe("options", () => {
it("compiles", () => {
expect(protoMetadata).not.toBeUndefined();
});

it("has the right options", () => {
expect(protoMetadata.options?.messages?.["MyMessage"]?.options?.["my_message_option"]).toBe(1234);
});
});
Binary file added integration/options-types-only/options.bin
Binary file not shown.
75 changes: 75 additions & 0 deletions integration/options-types-only/options.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
syntax = "proto3";

import "google/protobuf/descriptor.proto";
import "something/something.proto";

extend google.protobuf.FileOptions {
optional string my_file_option = 50000;
}

extend google.protobuf.MessageOptions {
optional int32 my_message_option = 50001;
}

extend google.protobuf.FieldOptions {
optional float my_field_option = 50002;
}

extend google.protobuf.OneofOptions {
optional int64 my_oneof_option = 50003;
}

extend google.protobuf.EnumOptions {
optional bool my_enum_option = 50004;
}

extend google.protobuf.EnumValueOptions {
optional uint32 my_enum_value_option = 50005;
}

extend google.protobuf.ServiceOptions {
optional MyEnum my_service_option = 50006;
}

extend google.protobuf.MethodOptions {
optional MyMessage my_method_option = 50007;
}

option (my_file_option) = "Hello world!";

message MyMessage {
option (my_message_option) = 1234;

optional int32 foo = 1 [(my_field_option) = 4.5];
optional int32 foo_2 = 2 [(something.something) = {
hello: "world";
foo: [123, 345];
}];
optional string bar = 3;
oneof qux {
option (my_oneof_option) = 42;

string quux = 4;
}
}

enum MyEnum {
option (my_enum_option) = true;

FOO = 0 [(my_enum_value_option) = 321];
BAR = 1;
}

message RequestType {}
message ResponseType {}

service MyService {
option (my_service_option) = FOO;

rpc MyMethod(RequestType) returns(ResponseType) {
option (my_method_option).foo = 150;
option (my_method_option).foo_2 = 150;
option (my_method_option).bar = "Some string";
option (my_method_option).quux = "Some string";
}
}
Loading

0 comments on commit 064665f

Please sign in to comment.