Skip to content

Commit

Permalink
Handle google/protobuf/wrappers.proto types on protoc-gen-openapi (#366)
Browse files Browse the repository at this point in the history
* handle wrappers type on protoc-gen-openapi
* handle timestamp type in protoc-gen-openapi URL query parameters
* add more comment
---------
Co-authored-by: Muhammad Idham Ramadhan <idham.ramadhan@bukalapak.com>
  • Loading branch information
galihputera committed Mar 24, 2023
1 parent 8c84f3c commit 0835de8
Show file tree
Hide file tree
Showing 9 changed files with 673 additions and 2 deletions.
12 changes: 12 additions & 0 deletions cmd/protoc-gen-openapi/examples/tests/protobuftypes/message.proto
Expand Up @@ -22,6 +22,8 @@ import "google/api/annotations.proto";
import "google/api/httpbody.proto";
import "google/protobuf/struct.proto";
import "google/protobuf/empty.proto";
import "google/protobuf/wrappers.proto";
import "google/protobuf/timestamp.proto";

option go_package = "github.com/google/gnostic/apps/protoc-gen-openapi/examples/tests/protobuftypes/message/v1;message";

Expand Down Expand Up @@ -101,4 +103,14 @@ message Message {
google.protobuf.Value value_type = 13;
// Description of repeated value
repeated google.protobuf.Value repeated_value_type = 14;
google.protobuf.BoolValue bool_value_type = 15;
google.protobuf.BytesValue bytes_value_type = 16;
google.protobuf.Int32Value int32_value_type = 17;
google.protobuf.UInt32Value uint32_value_type = 18;
google.protobuf.StringValue string_value_type = 19;
google.protobuf.Int64Value int64_value_type = 20;
google.protobuf.UInt64Value uint64_value_type = 21;
google.protobuf.FloatValue float_value_type = 22;
google.protobuf.DoubleValue double_value_type = 23;
google.protobuf.Timestamp timestamp_type = 24;
}
118 changes: 118 additions & 0 deletions cmd/protoc-gen-openapi/examples/tests/protobuftypes/openapi.yaml
Expand Up @@ -98,6 +98,52 @@ paths:
type: array
items:
$ref: '#/components/schemas/GoogleProtobufValue'
- name: bool_value_type
in: query
schema:
type: boolean
- name: bytes_value_type
in: query
schema:
type: string
format: bytes
- name: int32_value_type
in: query
schema:
type: integer
format: int32
- name: uint32_value_type
in: query
schema:
type: integer
format: uint32
- name: string_value_type
in: query
schema:
type: string
- name: int64_value_type
in: query
schema:
type: string
- name: uint64_value_type
in: query
schema:
type: string
- name: float_value_type
in: query
schema:
type: number
format: float
- name: double_value_type
in: query
schema:
type: number
format: double
- name: timestamp_type
in: query
schema:
type: string
format: date-time
responses:
"200":
description: OK
Expand Down Expand Up @@ -211,6 +257,52 @@ paths:
type: array
items:
$ref: '#/components/schemas/GoogleProtobufValue'
- name: bool_value_type
in: query
schema:
type: boolean
- name: bytes_value_type
in: query
schema:
type: string
format: bytes
- name: int32_value_type
in: query
schema:
type: integer
format: int32
- name: uint32_value_type
in: query
schema:
type: integer
format: uint32
- name: string_value_type
in: query
schema:
type: string
- name: int64_value_type
in: query
schema:
type: string
- name: uint64_value_type
in: query
schema:
type: string
- name: float_value_type
in: query
schema:
type: number
format: float
- name: double_value_type
in: query
schema:
type: number
format: double
- name: timestamp_type
in: query
schema:
type: string
format: date-time
requestBody:
content:
application/json:
Expand Down Expand Up @@ -326,6 +418,32 @@ components:
items:
$ref: '#/components/schemas/GoogleProtobufValue'
description: Description of repeated value
bool_value_type:
type: boolean
bytes_value_type:
type: string
format: bytes
int32_value_type:
type: integer
format: int32
uint32_value_type:
type: integer
format: uint32
string_value_type:
type: string
int64_value_type:
type: string
uint64_value_type:
type: string
float_value_type:
type: number
format: float
double_value_type:
type: number
format: double
timestamp_type:
type: string
format: date-time
Message_EmbMessage:
type: object
properties:
Expand Down
Expand Up @@ -98,6 +98,52 @@ paths:
type: array
items:
$ref: '#/components/schemas/GoogleProtobufValue'
- name: boolValueType
in: query
schema:
type: boolean
- name: bytesValueType
in: query
schema:
type: string
format: bytes
- name: int32ValueType
in: query
schema:
type: integer
format: int32
- name: uint32ValueType
in: query
schema:
type: integer
format: uint32
- name: stringValueType
in: query
schema:
type: string
- name: int64ValueType
in: query
schema:
type: string
- name: uint64ValueType
in: query
schema:
type: string
- name: floatValueType
in: query
schema:
type: number
format: float
- name: doubleValueType
in: query
schema:
type: number
format: double
- name: timestampType
in: query
schema:
type: string
format: date-time
responses:
"200":
description: OK
Expand Down Expand Up @@ -211,6 +257,52 @@ paths:
type: array
items:
$ref: '#/components/schemas/GoogleProtobufValue'
- name: boolValueType
in: query
schema:
type: boolean
- name: bytesValueType
in: query
schema:
type: string
format: bytes
- name: int32ValueType
in: query
schema:
type: integer
format: int32
- name: uint32ValueType
in: query
schema:
type: integer
format: uint32
- name: stringValueType
in: query
schema:
type: string
- name: int64ValueType
in: query
schema:
type: string
- name: uint64ValueType
in: query
schema:
type: string
- name: floatValueType
in: query
schema:
type: number
format: float
- name: doubleValueType
in: query
schema:
type: number
format: double
- name: timestampType
in: query
schema:
type: string
format: date-time
requestBody:
content:
application/json:
Expand Down Expand Up @@ -326,6 +418,32 @@ components:
items:
$ref: '#/components/schemas/GoogleProtobufValue'
description: Description of repeated value
boolValueType:
type: boolean
bytesValueType:
type: string
format: bytes
int32ValueType:
type: integer
format: int32
uint32ValueType:
type: integer
format: uint32
stringValueType:
type: string
int64ValueType:
type: string
uint64ValueType:
type: string
floatValueType:
type: number
format: float
doubleValueType:
type: number
format: double
timestampType:
type: string
format: date-time
Message_EmbMessage:
type: object
properties:
Expand Down

0 comments on commit 0835de8

Please sign in to comment.