update
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
parent
2ec1af2884
commit
f814b489db
16
openapiv3.go
16
openapiv3.go
@ -222,6 +222,15 @@ func (g *openapiv3Generator) buildOperationV3(
|
|||||||
parameters = append(parameters, opt.Parameters...)
|
parameters = append(parameters, opt.Parameters...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sparameters := make(map[string]struct{})
|
||||||
|
for _, paramOrRef := range parameters {
|
||||||
|
parameter := paramOrRef.GetParameter()
|
||||||
|
if parameter == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
sparameters[parameter.Name] = struct{}{}
|
||||||
|
}
|
||||||
|
|
||||||
// Build a list of path parameters.
|
// Build a list of path parameters.
|
||||||
pathParameters := make([]string, 0)
|
pathParameters := make([]string, 0)
|
||||||
if matches := g.namePattern.FindStringSubmatch(path); matches != nil {
|
if matches := g.namePattern.FindStringSubmatch(path); matches != nil {
|
||||||
@ -244,6 +253,10 @@ func (g *openapiv3Generator) buildOperationV3(
|
|||||||
}
|
}
|
||||||
// Add the path parameters to the operation parameters.
|
// Add the path parameters to the operation parameters.
|
||||||
for _, pathParameter := range pathParameters {
|
for _, pathParameter := range pathParameters {
|
||||||
|
if _, ok := sparameters[pathParameter]; ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
parameters = append(parameters,
|
parameters = append(parameters,
|
||||||
&v3.ParameterOrReference{
|
&v3.ParameterOrReference{
|
||||||
Oneof: &v3.ParameterOrReference_Parameter{
|
Oneof: &v3.ParameterOrReference_Parameter{
|
||||||
@ -268,6 +281,9 @@ func (g *openapiv3Generator) buildOperationV3(
|
|||||||
for _, field := range inputMessage.Fields {
|
for _, field := range inputMessage.Fields {
|
||||||
fieldName := string(field.Desc.Name())
|
fieldName := string(field.Desc.Name())
|
||||||
if !contains(coveredParameters, fieldName) {
|
if !contains(coveredParameters, fieldName) {
|
||||||
|
if _, ok := sparameters[fieldName]; ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
// Get the field description from the comments.
|
// Get the field description from the comments.
|
||||||
fieldDescription := g.filterCommentString(field.Comments.Leading)
|
fieldDescription := g.filterCommentString(field.Comments.Leading)
|
||||||
parameters = append(parameters,
|
parameters = append(parameters,
|
||||||
|
2
util.go
2
util.go
@ -269,7 +269,7 @@ func generateServiceServerMethods(gfile *protogen.GeneratedFile, service *protog
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(parameters) > 0 {
|
if len(parameters) > 0 {
|
||||||
gfile.P(microServerHttpPackage.Ident("FillRequest"), `(req, `)
|
gfile.P(microServerHttpPackage.Ident("FillRequest"), `(ctx, req, `)
|
||||||
for pk, pv := range parameters {
|
for pk, pv := range parameters {
|
||||||
params := make([]string, 0, len(pv)/2)
|
params := make([]string, 0, len(pv)/2)
|
||||||
for k, v := range pv {
|
for k, v := range pv {
|
||||||
|
Loading…
Reference in New Issue
Block a user