/
comp_options.js
54 lines (46 loc) · 1.1 KB
/
comp_options.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
var tape = require("tape");
var protobuf = require("..");
var proto = `
syntax = "proto3";
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = {
info: {
title: "Some info";
version: "0";
};
host: "some.host";
};
message Message {
int32 regular_int32 = 1;
optional int32 optional_int32 = 2;
oneof _oneof_int32 {
int32 oneof_int32 = 3;
}
actionType action = 4 [ (validate.rules).enum = {
defined_only: true,
not_in: [ 0 ],
in: ["google","github","azuread"]
} ];
}
`;
tape.test("complex options", function (test) {
var root = protobuf.parse(proto).root;
test.deepEqual(root.parsedOptions[0], {
"(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger)": {
info: {
title: "Some info",
version: "0",
},
host: "some.host",
},
});
test.deepEqual(root.Message.fields.action.parsedOptions[0], {
"(validate.rules)": {
enum: {
defined_only: true,
not_in: [0],
in: ["google", "github", "azuread"],
},
},
});
test.end();
});