Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Internal comments not stripped from enum query parameter's description #3778

Closed
kyle-mccarthy opened this issue Dec 1, 2023 · 2 comments · Fixed by #3864
Closed

Internal comments not stripped from enum query parameter's description #3778

kyle-mccarthy opened this issue Dec 1, 2023 · 2 comments · Fixed by #3864

Comments

@kyle-mccarthy
Copy link

🐛 Bug Report

When an enum is located in the query, the description of the query parameter includes internal comments. Note that the internal comments are correctly stripped from the enum's description in definitions.

To Reproduce

example/v1/example.proto

syntax = "proto3";

package example.v1;

import "google/api/annotations.proto";

option go_package = "./";

service ExampleService {
  rpc Example(ExampleRequest) returns (ExampleResponse) {
    option (google.api.http) = {
      post: "/example"
      body: "example"
    };
  }
}

enum ExampleKind {
  // (-- aip.dev/not-precedent: This preceded the AIP standards
  // buf:lint:ignore ENUM_ZERO_VALUE_SUFFIX --)
  FIRST = 0;
  SECOND = 1;
}

message Example {}

message ExampleRequest {
  Example example = 1;
  ExampleKind kind = 2;
}

message ExampleResponse {}

buf.yaml

version: v1
breaking:
  use:
    - FILE
lint:
  use:
    - DEFAULT
deps:
  - buf.build/googleapis/googleapis

buf.gen.yaml

version: v1
plugins:
  - plugin: buf.build/grpc-ecosystem/openapiv2:v2.18.1
    out: gen/openapiv2
    opt:
      - remove_internal_comments=true

Expected behavior

{
  "name": "kind",
  "in": "query",
  "required": false,
  "type": "string",
  "enum": [
    "FIRST",
    "SECOND"
  ],
  "default": "FIRST"
}

Actual Behavior

{
  "name": "kind",
  "description": " - FIRST: (-- aip.dev/not-precedent: This preceded the AIP standards\nbuf:lint:ignore ENUM_ZERO_VALUE_SUFFIX --)",
  "in": "query",
  "required": false,
  "type": "string",
  "enum": [
    "FIRST",
    "SECOND"
  ],
  "default": "FIRST"
}

The full output:

{
  "swagger": "2.0",
  "info": {
    "title": "example/v1/example.proto",
    "version": "version not set"
  },
  "tags": [
    {
      "name": "ExampleService"
    }
  ],
  "consumes": [
    "application/json"
  ],
  "produces": [
    "application/json"
  ],
  "paths": {
    "/example": {
      "post": {
        "operationId": "ExampleService_Example",
        "responses": {
          "200": {
            "description": "A successful response.",
            "schema": {
              "$ref": "#/definitions/v1ExampleResponse"
            }
          },
          "default": {
            "description": "An unexpected error response.",
            "schema": {
              "$ref": "#/definitions/rpcStatus"
            }
          }
        },
        "parameters": [
          {
            "name": "example",
            "in": "body",
            "required": true,
            "schema": {
              "$ref": "#/definitions/v1Example"
            }
          },
          {
            "name": "kind",
            "description": " - FIRST: (-- aip.dev/not-precedent: This preceded the AIP standards\nbuf:lint:ignore ENUM_ZERO_VALUE_SUFFIX --)",
            "in": "query",
            "required": false,
            "type": "string",
            "enum": [
              "FIRST",
              "SECOND"
            ],
            "default": "FIRST"
          }
        ],
        "tags": [
          "ExampleService"
        ]
      }
    }
  },
  "definitions": {
    "protobufAny": {
      "type": "object",
      "properties": {
        "@type": {
          "type": "string"
        }
      },
      "additionalProperties": {}
    },
    "rpcStatus": {
      "type": "object",
      "properties": {
        "code": {
          "type": "integer",
          "format": "int32"
        },
        "message": {
          "type": "string"
        },
        "details": {
          "type": "array",
          "items": {
            "type": "object",
            "$ref": "#/definitions/protobufAny"
          }
        }
      }
    },
    "v1Example": {
      "type": "object"
    },
    "v1ExampleKind": {
      "type": "string",
      "enum": [
        "FIRST",
        "SECOND"
      ],
      "default": "FIRST",
      "title": "- FIRST:"
    },
    "v1ExampleResponse": {
      "type": "object"
    }
  }
}

Your Environment

(Environment name, version and operating system.)

@johanbrandhorst
Copy link
Collaborator

Thanks for the detailed bug report, this seems like an oversight in the initial implementation. Are you interested in submitting a fix for this?

@kiambogo
Copy link
Contributor

kiambogo commented Jan 6, 2024

Addressed in #3864

bobcallaway added a commit to sigstore/fulcio that referenced this issue Feb 5, 2024
haydentherapper pushed a commit to sigstore/fulcio that referenced this issue Feb 6, 2024
…in /hack/tools (#1550)

* Bump github.com/grpc-ecosystem/grpc-gateway/v2 in /hack/tools

Bumps [github.com/grpc-ecosystem/grpc-gateway/v2](https://github.com/grpc-ecosystem/grpc-gateway) from 2.19.0 to 2.19.1.
- [Release notes](https://github.com/grpc-ecosystem/grpc-gateway/releases)
- [Changelog](https://github.com/grpc-ecosystem/grpc-gateway/blob/main/.goreleaser.yml)
- [Commits](grpc-ecosystem/grpc-gateway@v2.19.0...v2.19.1)

---
updated-dependencies:
- dependency-name: github.com/grpc-ecosystem/grpc-gateway/v2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* add updated json file; this change is expected

grpc-ecosystem/grpc-gateway#3778 (comment)

Signed-off-by: Bob Callaway <bcallaway@google.com>

---------

Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: Bob Callaway <bcallaway@google.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Bob Callaway <bcallaway@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants