Skip to content

Commit a837698

Browse files
committed
feat: supports enum schema
1 parent 117692a commit a837698

File tree

2 files changed

+47
-1
lines changed

2 files changed

+47
-1
lines changed

third_party/protoc-gen-openapiv2/options/annotations.proto

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ extend google.protobuf.MessageOptions {
2828
// different descriptor messages.
2929
Schema openapiv2_schema = 1042;
3030
}
31+
extend google.protobuf.EnumOptions {
32+
// ID assigned by protobuf-global-extension-registry@google.com for gRPC-Gateway project.
33+
//
34+
// All IDs are the same, as assigned. It is okay that they are the same, as they extend
35+
// different descriptor messages.
36+
EnumSchema openapiv2_enum = 1042;
37+
}
3138
extend google.protobuf.ServiceOptions {
3239
// ID assigned by protobuf-global-extension-registry@google.com for gRPC-Gateway project.
3340
//

third_party/protoc-gen-openapiv2/options/openapiv2.proto

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ message Parameters {
195195
// `HeaderParameter` a HTTP header parameter.
196196
// See: https://swagger.io/specification/v2/#parameter-object
197197
message HeaderParameter {
198-
// `Type` is a a supported HTTP header type.
198+
// `Type` is a supported HTTP header type.
199199
// See https://swagger.io/specification/v2/#parameterType.
200200
enum Type {
201201
UNKNOWN = 0;
@@ -443,6 +443,45 @@ message Schema {
443443
string example = 6;
444444
}
445445

446+
// `EnumSchema` is subset of fields from the OpenAPI v2 specification's Schema object.
447+
// Only fields that are applicable to Enums are included
448+
// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#schemaObject
449+
//
450+
// Example:
451+
//
452+
// option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_enum) = {
453+
// ...
454+
// title: "MyEnum";
455+
// description:"This is my nice enum";
456+
// example: "ZERO";
457+
// required: true;
458+
// ...
459+
// };
460+
//
461+
message EnumSchema {
462+
// A short description of the schema.
463+
string description = 1;
464+
string default = 2;
465+
// The title of the schema.
466+
string title = 3;
467+
bool required = 4;
468+
bool read_only = 5;
469+
// Additional external documentation for this schema.
470+
ExternalDocumentation external_docs = 6;
471+
string example = 7;
472+
// Ref is used to define an external reference to include in the message.
473+
// This could be a fully qualified proto message reference, and that type must
474+
// be imported into the protofile. If no message is identified, the Ref will
475+
// be used verbatim in the output.
476+
// For example:
477+
// `ref: ".google.protobuf.Timestamp"`.
478+
string ref = 8;
479+
// Custom properties that start with "x-" such as "x-foo" used to describe
480+
// extra functionality that is not covered by the standard OpenAPI Specification.
481+
// See: https://swagger.io/docs/specification/2-0/swagger-extensions/
482+
map<string, google.protobuf.Value> extensions = 9;
483+
}
484+
446485
// `JSONSchema` represents properties from JSON Schema taken, and as used, in
447486
// the OpenAPI v2 spec.
448487
//

0 commit comments

Comments
 (0)