OpenAPI Generation Issue: Empty Specification for Protocol Buffer Service

Open
#412 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
go, openapi
Domain
api, tooling

Research direction

Start at the protoc-gen-openapi plugin entry point and reproduce the command with the supplied petstore.proto. Compare the generated openapi.yaml with the service, request, and response definitions; done means the output contains the expected paths and schemas instead of empty objects.

Written by the indexing model from the issue text.

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) {}
}
  1. 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

Dominant language
Go
Stars
2.3k
Forks
279
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from google/gnostic

All issues in google/gnostic

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.