Code Monkey home page Code Monkey logo

Comments (6)

zaakn avatar zaakn commented on June 7, 2024

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.

yankarinRG avatar yankarinRG commented on June 7, 2024

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.

zaakn avatar zaakn commented on June 7, 2024
  1. 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 keep google directory structure. See also the Using these protos paragraph in README.md, which points out several usual files.
  2. Define http option.
  3. 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.

yankarinRG avatar yankarinRG commented on June 7, 2024

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.

yankarinRG avatar yankarinRG commented on June 7, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.