mirror of
https://github.com/protobufjs/protobuf.js.git
synced 2025-12-08 20:58:55 +00:00
* feat: proto3 optional support * chore: pre-release v6.11.0-pre * fix: rebuild * fix: fromObject should not initialize oneof members (#1597) * test: adding test for pbjs static code generation * fix: fromObject should not initialize oneof members * chore: release v6.11.0 * chore: rebuild * feat: add --no-service option for pbjs static target (#1577) This option skips generation of service clients. Co-authored-by: Alexander Fenster <fenster@google.com> * deps: set @types/node to >= (#1575) * deps: set @types/node to star version When using `protobuf.js` as a dependency in a project it is important that `@types/node` package gets de-duped and has the same version as for the rest of the modules in the project. Otherwise, typing conflicts could happen as they do between v13 and v14 node types. * fix: use @types/node >=13.7.0 * fix: use @types/node >=13.7.0 Co-authored-by: Alexander Fenster <fenster@google.com> Co-authored-by: Alexander Fenster <github@fenster.name> * chore: rebuild * docs: update changelog * fix: parse.js "parent.add(oneof)“ error (#1602) Co-authored-by: xiaoweili <xiaoweili@tencent.com> * chore: release v6.11.1 * fix(types): bring back Field.rule to .d.ts * fix: rebuild type, release v6.11.2 * build: configure backports * build: configure 6.x as default branch * fix: do not let setProperty change the prototype (#1731) * fix(deps): use eslint 8.x (#1728) * build: run tests if ci label added (#1734) * build: publish to main * chore(6.x): release 6.11.3 (#1737) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Support parsing of complex options * Use readValue to read the proto value and add better example * Fix lint issues * fix: rollback files * Re-do parse logic to take arrays into account and make it simpler Co-authored-by: Alexander Fenster <fenster@google.com> Co-authored-by: Matthew Douglass <5410142+mdouglass@users.noreply.github.com> Co-authored-by: Fedor Indutny <fedor.indutny@gmail.com> Co-authored-by: Alexander Fenster <github@fenster.name> Co-authored-by: leon <leon776@users.noreply.github.com> Co-authored-by: xiaoweili <xiaoweili@tencent.com> Co-authored-by: Benjamin Coe <bencoe@google.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
55 lines
1.1 KiB
JavaScript
55 lines
1.1 KiB
JavaScript
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();
|
|
});
|