google / google/gnostic

OpenAPI Generation Issue: Empty Specification for Protocol Buffer Service

Open
#412 6 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
2.3k
Forks
279
PR merge metrics
No merged PRs in 30d

Description

**Issue Summary:**
I am experiencing a problem with the Gnostic library and the protoc-gen-openapi plugin when generating an OpenAPI specification from a Protocol Buffer service. The generated OpenAPI specification is empty and does not reflect the contents of the Protocol Buffer service definition.

**Steps to Reproduce:**

1. Create a Protocol Buffer service definition, like the one in Attachment 1.
2. Use the following command to generate the OpenAPI specification:
`protoc petstore.proto -I=. --openapi_out=.`
3. Examine the generated OpenAPI YAML specification (Attachment 2), which is expected to describe the Protocol Buffer service.

**Expected Behavior:**
The generated OpenAPI specification should accurately represent the Protocol Buffer service and its endpoints, including any request and response message types.

**Actual Behavior:**
The generated OpenAPI specification is empty, with no paths, components, or schemas, and it does not reflect the structure of the Protocol Buffer service.

**Attachments:**

1. Input Protobuf service (petstore.proto)
```
syntax = "proto3";

package swaggerpetstore_openapi3_1;

option go_package = "swaggerpetstore/openapi3_1";

message GetPetByIdRequest {
// ID of pet to return
int64 petId = 1;
}

message Pet {
int64 id = 1;
string name = 2;
Category category = 3;
repeated string photoUrls = 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 {
// Find pet by ID
//
// Returns a single pet
rpc GetPetById(GetPetByIdRequest) returns (Pet) {}
}
```
2. Output OpenAPI definition (openapi.yaml)

```
# Generated with protoc-gen-openapi
# https://github.com/google/gnostic/tree/master/cmd/protoc-gen-openapi

openapi: 3.0.3
info:
title: ""
version: 0.0.1
paths: {}
components:
schemas: {}
```

**Additional Information:**
Go Version: go1.21.4 windows/amd64
Gnostic Library Version: installed with `go install github.com/google/gnostic@latest` so I guess v0.7.0 (?)
Protocol Buffer Compiler Version: libprotoc 25.0 (protoc-25.0-win64)
Operating System: Windows 11 Enterprise build 22631

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.