Skip to content

Swagger document generated for JSON Transcoding enabled grpc server stream response, returns only single object #53431

@jetmansion

Description

@jetmansion

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Json Transcoding correctly supports the streaming of objects when calling a gRPC server streaming method. When testing an URL directly, multiple json objects are returned.

The generated swagger document however, describes the operation as only returning a single object instead of an array of objects. When generating client code from the swagger.json file, the code also will only return a single object.

Below snippet is from the swagger.json generated by the gRPC Transcoder sample application

       "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HelloReply"
                }
              }
            }
          }

Expected Behavior

Below response would generate correct client code:

       "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/HelloReply"
                  }
               }
            }
          }
        }

Steps To Reproduce

Can be reproduced using the Transcoder sample: https://github.com/grpc/grpc-dotnet/tree/master/examples/Transcoder

Exceptions (if any)

No response

.NET Version

7.0

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-grpcIncludes: GRPC wire-up, templates

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions