Comments (6)
You may read these guidance to know how to define http service (by proto option, etc.) for grpc service:
https://google.aip.dev/127
https://github.com/googleapis/googleapis/blob/master/google/api/http.proto
from gnostic.
You may read these guidance to know how to define http service (by proto option, etc.) for grpc service: https://google.aip.dev/127 https://github.com/googleapis/googleapis/blob/master/google/api/http.proto
Hi there! I followed the steps outlined in point 2 of the Steps to Reproduce section, using the Protocol Buffer service definition provided in the second link you posted. Unfortunately, the result remains consistent with what was described in point 2 of the Attachments section—an empty OpenAPI definition.
This outcome leads me to believe that the issue may not be rooted in the Protocol Buffer service definition itself. I'd like to emphasize that I'm not attempting to execute this command against a sample petstore service but rather against a service from Google, specifically the Maps Booking API. Therefore, it seems the problem might be originating elsewhere in the process.
If you have any insights or suggestions on how to troubleshoot this further, I'd greatly appreciate your guidance.
from gnostic.
- Make a copy for
google/api
directory into your "include" path (e.g./usr/local/include/
on Linux) to ready for being imported.
Copy from google/api and keepgoogle
directory structure. See also theUsing these protos
paragraph in README.md, which points out several usual files. - Define http option.
- Do it,
protoc -I . -I ./include --openapi_out . ./petstore.proto
.
files structrure:
.
├── include
│ └── google
│ └── api
│ ├── annotations.proto
│ └── http.proto
└── petstore.proto
petstore.proto
:
syntax = "proto3";
package swaggerpetstore_openapi3_1;
option go_package = "swaggerpetstore/openapi3_1";
import "google/api/annotations.proto";
message GetPetByIdRequest {
int64 pet_id = 1;
}
message Pet {
int64 id = 1;
string name = 2;
Category category = 3;
repeated string photo_urls = 4;
repeated Tag tags = 5;
string status = 6;
message Category {
int64 id = 1;
string name = 2;
}
message Tag {
int64 id = 1;
string name = 2;
}
}
service SwaggerPetstoreOpenAPI31Service {
rpc GetPetById(GetPetByIdRequest) returns(Pet) {
option(google.api.http) = {
get: "/pets"
};
}
}
from gnostic.
Thank you for your guidance! I successfully followed the steps you provided and was able to generate the OpenAPI description for your version of the petstore.proto service (mine is still empty).
Here's the command I used:
protoc -I . -I "%userprofile%\Downloads\protoc-25.0-win64\include" --openapi_out . petstore2.proto
Encouraged by this success, I attempted to replicate the process with the actual Protocol Buffer service I need to convert to OpenAPI. However, I encountered an issue as the command failed to produce the expected result. I find this puzzling since the Protocol Buffer definition is sourced from Google and is unlikely to be malformed.
Any insights or suggestions on why this might be happening would be greatly appreciated.
from gnostic.
Upon annotating the various rpcs of the service with HTTP methods and endpoint names, I observed that the OpenAPI definition was generated correctly. Is there any documentation or specification indicating that this annotation step is a prerequisite for correct OpenAPI generation?
from gnostic.
Related Issues (20)
- Tag release with #359? HOT 2
- path parameters that refer to request message subfields are not mapped
- Request to remove reference to deprecated module 'github.com/golang/protobuf'
- [proto-gen-openapi] Wrong message included when message with same name exists in imported proto HOT 1
- go get upgrade broke compilation HOT 1
- Import of gnostic-models and gnostic generated code leads to panic HOT 8
- We are unable to detect the CVE-2022-28948 vulnerability through our vulnerability scanning.
- protoc-gen-openapi: Enum types that use stringified boolean values like `"TRUE"` are treated as the real boolean values HOT 2
- Openapiv3 doesn't able to generate of type map<string, bool> in protobuf
- panic: proto: message openapi.v2.AdditionalPropertiesItem is already registered
- protoc-gen-openapi BUG HOT 3
- How to set example for the field which defined in protobuf file by openapi v3 property
- Util package jsonwriter do not handle escape and null value
- The query FieldOptions custom example parameter does not work, the body succeeds, why?
- Cannot build due to deprecated go module github.com/golang/protobuf
- v0.7.0 isn't available on pkg.go.dev and the latest install fails HOT 1
- Proto to OpenAPIv3 - How to annotate Query Parameters as "required"? HOT 1
- Can protoc-gen-openapi generate v3.1.0 openapi file
- Default to gRPC path if no mapping is provided
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gnostic.