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 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
|
syntax = "proto3";
// Visibility Rule Echo Service
// Similar to echo_service.proto but with annotations to change visibility
// of services, methods, fields and enum values.
//
// `google.api.VisibilityRule` annotations are added to customize where they are generated.
// Combined with the option `visibility_restriction_selectors` overlapping rules will appear in the OpenAPI output.
// Elements without `google.api.VisibilityRule` annotations will appear as usual in the generated output.
//
// These restrictions and selectors are completely arbitrary and you can define whatever values or hierarchies you want.
// In this example `INTERNAL`, `PREVIEW` are used, but `INTERNAL`, `ALPHA`, `BETA`, `RELEASED`, or anything else could be used if you wish.
package grpc.gateway.examples.internal.proto.examplepb;
import "google/api/annotations.proto";
import "google/api/visibility.proto";
option go_package = "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb;examplepb";
// Embedded represents a message embedded in SimpleMessage.
message VisibilityRuleEmbedded {
oneof mark {
int64 progress = 1;
string note = 2;
string internal_field = 3 [(google.api.field_visibility).restriction = "INTERNAL"];
string preview_field = 4 [(google.api.field_visibility).restriction = "INTERNAL,PREVIEW"];
}
}
// SimpleMessage represents a simple message sent to the Echo service.
message VisibilityRuleSimpleMessage {
enum VisibilityEnum {
VISIBILITY_ENUM_UNSPECIFIED = 0;
VISIBILITY_ENUM_VISIBLE = 1;
VISIBILITY_ENUM_INTERNAL = 2 [(google.api.value_visibility).restriction = "INTERNAL"];
VISIBILITY_ENUM_PREVIEW = 3 [(google.api.value_visibility).restriction = "INTERNAL,PREVIEW"];
}
// Id represents the message identifier.
string id = 1;
int64 num = 2;
oneof code {
int64 line_num = 3;
string lang = 4;
}
VisibilityRuleEmbedded status = 5;
oneof ext {
int64 en = 6;
VisibilityRuleEmbedded no = 7;
}
string internal_field = 8 [(google.api.field_visibility).restriction = "INTERNAL"];
string preview_field = 9 [(google.api.field_visibility).restriction = "INTERNAL,PREVIEW"];
VisibilityEnum an_enum = 10;
}
// VisibilityRuleEchoService service responds to incoming echo requests.
// Different services will be available in the swagger documentation depending
// based on `google.api.VisibilityRule`s and the set `visibility_restriction_selectors`
// flag when calling protoc-gen-openapiv2.
service VisibilityRuleEchoService {
// Echo method receives a simple message and returns it.
// It should always be visible in the open API output.
rpc Echo(VisibilityRuleSimpleMessage) returns (VisibilityRuleSimpleMessage) {
option (google.api.http) = {
post: "/v1/example/echo/{id}"
};
}
// EchoInternal is an internal API that should only be visible in the OpenAPI spec
// if `visibility_restriction_selectors` includes "INTERNAL".
rpc EchoInternal(VisibilityRuleSimpleMessage) returns (VisibilityRuleSimpleMessage) {
option (google.api.method_visibility).restriction = "INTERNAL";
option (google.api.http) = {
get: "/v1/example/echo_internal"
};
}
// EchoPreview is a preview API that should only be visible in the OpenAPI spec
// if `visibility_restriction_selectors` includes "PREVIEW".
rpc EchoPreview(VisibilityRuleSimpleMessage) returns (VisibilityRuleSimpleMessage) {
option (google.api.method_visibility).restriction = "PREVIEW";
option (google.api.http) = {
get: "/v1/example/echo_preview"
};
}
// EchoInternalAndPreview is a internal and preview API that should only be visible in the OpenAPI spec
// if `visibility_restriction_selectors` includes "PREVIEW" or "INTERNAL".
rpc EchoInternalAndPreview(VisibilityRuleSimpleMessage) returns (VisibilityRuleSimpleMessage) {
option (google.api.method_visibility).restriction = "INTERNAL,PREVIEW";
option (google.api.http) = {
get: "/v1/example/echo_internal_and_preview"
};
}
}
// VisibilityRuleInternalEchoService service responds to incoming echo requests.
// It should only be visible in the OpenAPI spec if `visibility_restriction_selectors` includes "INTERNAL".
service VisibilityRuleInternalEchoService {
option (google.api.api_visibility).restriction = "INTERNAL";
// Echo method receives a simple message and returns it.
// It should not be visible in the open API output.
rpc Echo(VisibilityRuleSimpleMessage) returns (VisibilityRuleSimpleMessage) {
option (google.api.http) = {
post: "/v1/example/internal/echo/{id}"
};
}
}
|