fix for empty default response
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
parent
e6b8324395
commit
41e32e36b3
83
openapiv3.go
83
openapiv3.go
@ -653,49 +653,54 @@ func (g *openapiv3Generator) buildOperationV3(
|
|||||||
opt := eopt.(*v3.Operation)
|
opt := eopt.(*v3.Operation)
|
||||||
if r := opt.Responses; r != nil {
|
if r := opt.Responses; r != nil {
|
||||||
responses = r
|
responses = r
|
||||||
}
|
|
||||||
|
|
||||||
if ref := responses.Default.GetReference(); ref != nil && ref.GetXRef() != "" {
|
rd := responses.Default
|
||||||
xref := strings.TrimPrefix(ref.GetXRef(), ".")
|
if rd != nil {
|
||||||
description := "Default"
|
if ref := rd.GetReference(); ref != nil && ref.GetXRef() != "" {
|
||||||
if strings.Contains(xref, "micro.errors.Error") {
|
xref := strings.TrimPrefix(ref.GetXRef(), ".")
|
||||||
description += " Error"
|
description := "Default"
|
||||||
}
|
if strings.Contains(xref, "micro.errors.Error") {
|
||||||
desc, err := protofiles.FindDescriptorByName(protoreflect.FullName(xref))
|
description += " Error"
|
||||||
if err != nil {
|
}
|
||||||
log.Printf("unknown ref type %s err %v", xref, err)
|
desc, err := protofiles.FindDescriptorByName(protoreflect.FullName(xref))
|
||||||
} else {
|
if err != nil {
|
||||||
responses.Default.Oneof = &v3.ResponseOrReference_Response{
|
log.Printf("unknown ref type %s err %v", xref, err)
|
||||||
Response: &v3.Response{
|
} else {
|
||||||
Description: description,
|
responses.Default.Oneof = &v3.ResponseOrReference_Response{
|
||||||
Content: g.responseContentForMessage(&protogen.Message{
|
Response: &v3.Response{
|
||||||
Desc: desc.(protoreflect.MessageDescriptor),
|
Description: description,
|
||||||
}),
|
Content: g.responseContentForMessage(&protogen.Message{
|
||||||
},
|
Desc: desc.(protoreflect.MessageDescriptor),
|
||||||
}
|
}),
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
for _, rref := range responses.GetResponseOrReference() {
|
|
||||||
if ref := rref.Value.GetReference(); ref != nil && ref.GetXRef() != "" {
|
|
||||||
xref := strings.TrimPrefix(ref.GetXRef(), ".")
|
|
||||||
description := "Default"
|
|
||||||
if strings.Contains(xref, "micro.errors.Error") {
|
|
||||||
description += " Error"
|
|
||||||
}
|
|
||||||
desc, err := protofiles.FindDescriptorByName(protoreflect.FullName(xref))
|
|
||||||
if err != nil {
|
|
||||||
log.Printf("unknown ref type %s err %v", xref, err)
|
|
||||||
} else {
|
|
||||||
responses.Default.Oneof = &v3.ResponseOrReference_Response{
|
|
||||||
Response: &v3.Response{
|
|
||||||
Description: description,
|
|
||||||
Content: g.responseContentForMessage(&protogen.Message{
|
|
||||||
Desc: desc.(protoreflect.MessageDescriptor),
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for _, rref := range responses.GetResponseOrReference() {
|
||||||
|
if ref := rref.Value.GetReference(); ref != nil && ref.GetXRef() != "" {
|
||||||
|
xref := strings.TrimPrefix(ref.GetXRef(), ".")
|
||||||
|
description := "Default"
|
||||||
|
if strings.Contains(xref, "micro.errors.Error") {
|
||||||
|
description += " Error"
|
||||||
|
}
|
||||||
|
desc, err := protofiles.FindDescriptorByName(protoreflect.FullName(xref))
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("unknown ref type %s err %v", xref, err)
|
||||||
|
} else {
|
||||||
|
responses.Default.Oneof = &v3.ResponseOrReference_Response{
|
||||||
|
Response: &v3.Response{
|
||||||
|
Description: description,
|
||||||
|
Content: g.responseContentForMessage(&protogen.Message{
|
||||||
|
Desc: desc.(protoreflect.MessageDescriptor),
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
responses = &v3.Responses{}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
responses = &v3.Responses{}
|
responses = &v3.Responses{}
|
||||||
|
@ -16,8 +16,8 @@ var (
|
|||||||
microServerPackage = protogen.GoImportPath("go.unistack.org/micro/v3/server")
|
microServerPackage = protogen.GoImportPath("go.unistack.org/micro/v3/server")
|
||||||
microClientHttpPackage = protogen.GoImportPath("go.unistack.org/micro-client-http/v3")
|
microClientHttpPackage = protogen.GoImportPath("go.unistack.org/micro-client-http/v3")
|
||||||
microServerHttpPackage = protogen.GoImportPath("go.unistack.org/micro-server-http/v3")
|
microServerHttpPackage = protogen.GoImportPath("go.unistack.org/micro-server-http/v3")
|
||||||
microCodecPackage = protogen.GoImportPath("go.unistack.org/micro-proto/v3/codec")
|
microCodecPackage = protogen.GoImportPath("go.unistack.org/micro/v3/codec")
|
||||||
microErrorsPackage = protogen.GoImportPath("go.unistack.org/micro-proto/v3/errors")
|
microErrorsPackage = protogen.GoImportPath("go.unistack.org/micro/v3/errors")
|
||||||
timePackage = protogen.GoImportPath("time")
|
timePackage = protogen.GoImportPath("time")
|
||||||
deprecationComment = "// Deprecated: Do not use."
|
deprecationComment = "// Deprecated: Do not use."
|
||||||
versionComment = "v3.5.3"
|
versionComment = "v3.5.3"
|
||||||
|
Loading…
Reference in New Issue
Block a user