Internal comments not stripped from enum query parameter's description
kyle-mccarthy opened this issue Β· comments
Kyle McCarthy commented
π 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.)
Johan Brandhorst-Satzkorn commented
Thanks for the detailed bug report, this seems like an oversight in the initial implementation. Are you interested in submitting a fix for this?
Christopher Poenaru commented
Addressed in #3864