Skip to content

Commit

Permalink
update readme and openapi protobuf (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
kooksee authored May 24, 2024
2 parents 86ef69c + c7716c7 commit 572be9f
Show file tree
Hide file tree
Showing 9 changed files with 767 additions and 36 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# protoc-gen-openapi

This directory contains a protoc plugin that generates an
> This directory contains a protoc plugin that generates an
OpenAPI description for a REST API that corresponds to a
Protocol Buffer service.

> This project is a simplification of the [google/gnostic](https://github.com/google/gnostic/tree/main/openapiv3) project, dedicated to providing a simple version of the protoc-gen-openapi
Installation:

go install github.com/google/gnostic/cmd/protoc-gen-openapi
go install github.com/pubgo/protoc-gen-openapi@latest

Usage:

Expand Down
23 changes: 10 additions & 13 deletions examples/tests/enumoptions/message.openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,23 @@ info:
description: Messaging service
version: 0.0.1
paths:
/v1/messages/{message_id}:
/v1/messages/{messageId}:
post:
tags:
- Messaging
operationId: Messaging_CreateMessage
parameters:
- name: message_id
- name: messageId
in: path
required: true
schema:
type: string
- name: kind
in: query
schema:
enum:
- UNKNOWN_KIND
- KIND_1
- KIND_2
type: string
format: enum
type: integer
format: int32
requestBody:
content:
application/json: {}
application/json:
schema:
$ref: '#/components/schemas/Message'
required: true
responses:
"200":
Expand All @@ -50,5 +44,8 @@ components:
- KIND_2
type: string
format: enum
messageId:
type: integer
format: int32
tags:
- name: Messaging
21 changes: 11 additions & 10 deletions examples/tests/enumoptions/message.proto
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,19 @@ option go_package = "github.com/google/gnostic/apps/protoc-gen-openapi/examples/

// Messaging service
service Messaging {
rpc CreateMessage(Message) returns (Message) {
option (google.api.http) = {
post : "/v1/messages/{message_id}"
body : "body_text"
};
}
rpc CreateMessage (Message) returns (Message) {
option (google.api.http) = {
post: "/v1/messages/{message_id}"
body: "*"
};
}
}
message Message {
Kind kind = 1;
Kind kind = 1;
int32 message_id = 2;
}
enum Kind {
UNKNOWN_KIND = 0;
KIND_1 = 1;
KIND_2 = 2;
UNKNOWN_KIND = 0;
KIND_1 = 1;
KIND_2 = 2;
}
1 change: 0 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2719,7 +2719,6 @@ google.golang.org/genproto/googleapis/api v0.0.0-20240415180920-8c6c420018be/go.
google.golang.org/genproto/googleapis/api v0.0.0-20240429193739-8cf5692501f6/go.mod h1:10yRODfgim2/T8csjQsMPgZOMvtytXKTDRzH6HRGzRw=
google.golang.org/genproto/googleapis/api v0.0.0-20240506185236-b8a5c65736ae/go.mod h1:FfiGhwUm6CJviekPrc0oJ+7h29e+DmWU6UtjX0ZvI7Y=
google.golang.org/genproto/googleapis/api v0.0.0-20240513163218-0867130af1f8/go.mod h1:vPrPUTsDCYxXWjP7clS81mZ6/803D8K4iM9Ma27VKas=
google.golang.org/genproto/googleapis/api v0.0.0-20240515191416-fc5f0ca64291 h1:4HZJ3Xv1cmrJ+0aFo304Zn79ur1HMxptAE7aCPNLSqc=
google.golang.org/genproto/googleapis/api v0.0.0-20240515191416-fc5f0ca64291/go.mod h1:RGnPtTG7r4i8sPlNyDeikXF99hMM+hN6QMm4ooG9g2g=
google.golang.org/genproto/googleapis/api v0.0.0-20240521202816-d264139d666e h1:SkdGTrROJl2jRGT/Fxv5QUf9jtdKCQh4KQJXbXVLAi0=
google.golang.org/genproto/googleapis/api v0.0.0-20240521202816-d264139d666e/go.mod h1:LweJcLbyVij6rCex8YunD8DYR5VDonap/jYl3ZRxcIU=
Expand Down
Loading

0 comments on commit 572be9f

Please sign in to comment.