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

Fix 2494 #3646

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 0 additions & 80 deletions examples/internal/clients/echo/api/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -411,46 +411,13 @@ paths:
required: true
type: "string"
x-exportParamName: "Lang"
- name: "lineNum"
in: "query"
required: false
type: "string"
format: "int64"
x-exportParamName: "LineNum"
x-optionalDataType: "String"
- name: "status.progress"
in: "query"
required: false
type: "string"
format: "int64"
x-exportParamName: "StatusProgress"
x-optionalDataType: "String"
- name: "status.note"
in: "query"
required: false
type: "string"
x-exportParamName: "StatusNote"
x-optionalDataType: "String"
- name: "en"
in: "query"
required: false
type: "string"
format: "int64"
x-exportParamName: "En"
x-optionalDataType: "String"
- name: "no.progress"
in: "query"
required: false
type: "string"
format: "int64"
x-exportParamName: "NoProgress"
x-optionalDataType: "String"
- name: "no.note"
in: "query"
required: false
type: "string"
x-exportParamName: "NoNote"
x-optionalDataType: "String"
- name: "resourceId"
in: "query"
required: false
Expand Down Expand Up @@ -510,33 +477,13 @@ paths:
format: "int64"
x-exportParamName: "Num"
x-optionalDataType: "String"
- name: "lang"
in: "query"
required: false
type: "string"
x-exportParamName: "Lang"
x-optionalDataType: "String"
- name: "status.progress"
in: "query"
required: false
type: "string"
format: "int64"
x-exportParamName: "StatusProgress"
x-optionalDataType: "String"
- name: "en"
in: "query"
required: false
type: "string"
format: "int64"
x-exportParamName: "En"
x-optionalDataType: "String"
- name: "no.progress"
in: "query"
required: false
type: "string"
format: "int64"
x-exportParamName: "NoProgress"
x-optionalDataType: "String"
- name: "resourceId"
in: "query"
required: false
Expand Down Expand Up @@ -591,40 +538,13 @@ paths:
format: "int64"
x-exportParamName: "Num"
x-optionalDataType: "String"
- name: "lineNum"
in: "query"
required: false
type: "string"
format: "int64"
x-exportParamName: "LineNum"
x-optionalDataType: "String"
- name: "lang"
in: "query"
required: false
type: "string"
x-exportParamName: "Lang"
x-optionalDataType: "String"
- name: "status.progress"
in: "query"
required: false
type: "string"
format: "int64"
x-exportParamName: "StatusProgress"
x-optionalDataType: "String"
- name: "en"
in: "query"
required: false
type: "string"
format: "int64"
x-exportParamName: "En"
x-optionalDataType: "String"
- name: "no.progress"
in: "query"
required: false
type: "string"
format: "int64"
x-exportParamName: "NoProgress"
x-optionalDataType: "String"
- name: "resourceId"
in: "query"
required: false
Expand Down
60 changes: 0 additions & 60 deletions examples/internal/clients/echo/api_echo_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,12 +351,7 @@ The message posted as the id parameter will also be returned.
* @param num
* @param lang
* @param optional nil or *EchoServiceEcho3Opts - Optional Parameters:
* @param "LineNum" (optional.String) -
* @param "StatusProgress" (optional.String) -
* @param "StatusNote" (optional.String) -
* @param "En" (optional.String) -
* @param "NoProgress" (optional.String) -
* @param "NoNote" (optional.String) -
* @param "ResourceId" (optional.String) -
* @param "NIdNId" (optional.String) -
* @param "NIdVal" (optional.String) -
Expand All @@ -365,12 +360,7 @@ The message posted as the id parameter will also be returned.
*/

type EchoServiceEcho3Opts struct {
LineNum optional.String
StatusProgress optional.String
StatusNote optional.String
En optional.String
NoProgress optional.String
NoNote optional.String
ResourceId optional.String
NIdNId optional.String
NIdVal optional.String
Expand All @@ -395,24 +385,9 @@ func (a *EchoServiceApiService) EchoServiceEcho3(ctx context.Context, id string,
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}

if localVarOptionals != nil && localVarOptionals.LineNum.IsSet() {
localVarQueryParams.Add("lineNum", parameterToString(localVarOptionals.LineNum.Value(), ""))
}
if localVarOptionals != nil && localVarOptionals.StatusProgress.IsSet() {
localVarQueryParams.Add("status.progress", parameterToString(localVarOptionals.StatusProgress.Value(), ""))
}
if localVarOptionals != nil && localVarOptionals.StatusNote.IsSet() {
localVarQueryParams.Add("status.note", parameterToString(localVarOptionals.StatusNote.Value(), ""))
}
if localVarOptionals != nil && localVarOptionals.En.IsSet() {
localVarQueryParams.Add("en", parameterToString(localVarOptionals.En.Value(), ""))
}
if localVarOptionals != nil && localVarOptionals.NoProgress.IsSet() {
localVarQueryParams.Add("no.progress", parameterToString(localVarOptionals.NoProgress.Value(), ""))
}
if localVarOptionals != nil && localVarOptionals.NoNote.IsSet() {
localVarQueryParams.Add("no.note", parameterToString(localVarOptionals.NoNote.Value(), ""))
}
if localVarOptionals != nil && localVarOptionals.ResourceId.IsSet() {
localVarQueryParams.Add("resourceId", parameterToString(localVarOptionals.ResourceId.Value(), ""))
}
Expand Down Expand Up @@ -506,10 +481,7 @@ The message posted as the id parameter will also be returned.
* @param statusNote
* @param optional nil or *EchoServiceEcho4Opts - Optional Parameters:
* @param "Num" (optional.String) -
* @param "Lang" (optional.String) -
* @param "StatusProgress" (optional.String) -
* @param "En" (optional.String) -
* @param "NoProgress" (optional.String) -
* @param "ResourceId" (optional.String) -
* @param "NIdNId" (optional.String) -
* @param "NIdVal" (optional.String) -
Expand All @@ -519,10 +491,7 @@ The message posted as the id parameter will also be returned.

type EchoServiceEcho4Opts struct {
Num optional.String
Lang optional.String
StatusProgress optional.String
En optional.String
NoProgress optional.String
ResourceId optional.String
NIdNId optional.String
NIdVal optional.String
Expand Down Expand Up @@ -550,18 +519,9 @@ func (a *EchoServiceApiService) EchoServiceEcho4(ctx context.Context, id string,
if localVarOptionals != nil && localVarOptionals.Num.IsSet() {
localVarQueryParams.Add("num", parameterToString(localVarOptionals.Num.Value(), ""))
}
if localVarOptionals != nil && localVarOptionals.Lang.IsSet() {
localVarQueryParams.Add("lang", parameterToString(localVarOptionals.Lang.Value(), ""))
}
if localVarOptionals != nil && localVarOptionals.StatusProgress.IsSet() {
localVarQueryParams.Add("status.progress", parameterToString(localVarOptionals.StatusProgress.Value(), ""))
}
if localVarOptionals != nil && localVarOptionals.En.IsSet() {
localVarQueryParams.Add("en", parameterToString(localVarOptionals.En.Value(), ""))
}
if localVarOptionals != nil && localVarOptionals.NoProgress.IsSet() {
localVarQueryParams.Add("no.progress", parameterToString(localVarOptionals.NoProgress.Value(), ""))
}
if localVarOptionals != nil && localVarOptionals.ResourceId.IsSet() {
localVarQueryParams.Add("resourceId", parameterToString(localVarOptionals.ResourceId.Value(), ""))
}
Expand Down Expand Up @@ -654,11 +614,7 @@ The message posted as the id parameter will also be returned.
* @param optional nil or *EchoServiceEcho5Opts - Optional Parameters:
* @param "Id" (optional.String) - Id represents the message identifier.
* @param "Num" (optional.String) -
* @param "LineNum" (optional.String) -
* @param "Lang" (optional.String) -
* @param "StatusProgress" (optional.String) -
* @param "En" (optional.String) -
* @param "NoProgress" (optional.String) -
* @param "ResourceId" (optional.String) -
* @param "NIdNId" (optional.String) -
* @param "NIdVal" (optional.String) -
Expand All @@ -669,11 +625,7 @@ The message posted as the id parameter will also be returned.
type EchoServiceEcho5Opts struct {
Id optional.String
Num optional.String
LineNum optional.String
Lang optional.String
StatusProgress optional.String
En optional.String
NoProgress optional.String
ResourceId optional.String
NIdNId optional.String
NIdVal optional.String
Expand Down Expand Up @@ -702,21 +654,9 @@ func (a *EchoServiceApiService) EchoServiceEcho5(ctx context.Context, noNote str
if localVarOptionals != nil && localVarOptionals.Num.IsSet() {
localVarQueryParams.Add("num", parameterToString(localVarOptionals.Num.Value(), ""))
}
if localVarOptionals != nil && localVarOptionals.LineNum.IsSet() {
localVarQueryParams.Add("lineNum", parameterToString(localVarOptionals.LineNum.Value(), ""))
}
if localVarOptionals != nil && localVarOptionals.Lang.IsSet() {
localVarQueryParams.Add("lang", parameterToString(localVarOptionals.Lang.Value(), ""))
}
if localVarOptionals != nil && localVarOptionals.StatusProgress.IsSet() {
localVarQueryParams.Add("status.progress", parameterToString(localVarOptionals.StatusProgress.Value(), ""))
}
if localVarOptionals != nil && localVarOptionals.En.IsSet() {
localVarQueryParams.Add("en", parameterToString(localVarOptionals.En.Value(), ""))
}
if localVarOptionals != nil && localVarOptionals.NoProgress.IsSet() {
localVarQueryParams.Add("no.progress", parameterToString(localVarOptionals.NoProgress.Value(), ""))
}
if localVarOptionals != nil && localVarOptionals.ResourceId.IsSet() {
localVarQueryParams.Add("resourceId", parameterToString(localVarOptionals.ResourceId.Value(), ""))
}
Expand Down
80 changes: 0 additions & 80 deletions examples/internal/proto/examplepb/echo_service.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -473,46 +473,13 @@
"required": true,
"type": "string"
},
{
"name": "lineNum",
"in": "query",
"required": false,
"type": "string",
"format": "int64"
},
{
"name": "status.progress",
"in": "query",
"required": false,
"type": "string",
"format": "int64"
},
{
"name": "status.note",
"in": "query",
"required": false,
"type": "string"
},
Comment on lines -483 to -495
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these were removed incorrectly, no? There's nothing in this RPC definition that means the status query parameters shouldn't show up, I think? Here's the definition:

additional_bindings: {get: "/v1/example/echo/{id}/{num}/{lang}"}
. I think it's removing all oneofs instead of just the lineNum oneof.

{
"name": "en",
"in": "query",
"required": false,
"type": "string",
"format": "int64"
},
{
"name": "no.progress",
"in": "query",
"required": false,
"type": "string",
"format": "int64"
},
{
"name": "no.note",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "resourceId",
"in": "query",
Expand Down Expand Up @@ -584,33 +551,13 @@
"type": "string",
"format": "int64"
},
{
"name": "lang",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "status.progress",
"in": "query",
"required": false,
"type": "string",
"format": "int64"
},
{
"name": "en",
"in": "query",
"required": false,
"type": "string",
"format": "int64"
},
{
"name": "no.progress",
"in": "query",
"required": false,
"type": "string",
"format": "int64"
},
{
"name": "resourceId",
"in": "query",
Expand Down Expand Up @@ -675,40 +622,13 @@
"type": "string",
"format": "int64"
},
{
"name": "lineNum",
"in": "query",
"required": false,
"type": "string",
"format": "int64"
},
{
"name": "lang",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "status.progress",
"in": "query",
"required": false,
"type": "string",
"format": "int64"
},
{
"name": "en",
"in": "query",
"required": false,
"type": "string",
"format": "int64"
},
{
"name": "no.progress",
"in": "query",
"required": false,
"type": "string",
"format": "int64"
},
{
"name": "resourceId",
"in": "query",
Expand Down
4 changes: 4 additions & 0 deletions protoc-gen-openapiv2/internal/genopenapi/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,10 @@ func nestedQueryParams(message *descriptor.Message, field *descriptor.Field, pre
if pathParam.Target == field {
return nil, nil
}
// make sure if path parameter is of type one_of then other field should not be present as query parameters
if pathParam.Target.OneofIndex != nil && field.OneofIndex != nil && pathParam.Target.GetOneofIndex() == field.GetOneofIndex() {
return nil, nil
}
}
// make sure the parameter is not already listed as a body parameter
if body != nil {
Expand Down
Loading
Loading