diff --git a/openapiv3.go b/openapiv3.go index 00a3ed8..7723d5a 100644 --- a/openapiv3.go +++ b/openapiv3.go @@ -653,49 +653,54 @@ func (g *openapiv3Generator) buildOperationV3( opt := eopt.(*v3.Operation) if r := opt.Responses; r != nil { responses = r - } - if ref := responses.Default.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), - }), - }, + rd := responses.Default + if rd != nil { + if ref := rd.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 { responses = &v3.Responses{} diff --git a/variables.go b/variables.go index 05d4a01..0cf425b 100644 --- a/variables.go +++ b/variables.go @@ -16,8 +16,8 @@ var ( microServerPackage = protogen.GoImportPath("go.unistack.org/micro/v3/server") microClientHttpPackage = protogen.GoImportPath("go.unistack.org/micro-client-http/v3") microServerHttpPackage = protogen.GoImportPath("go.unistack.org/micro-server-http/v3") - microCodecPackage = protogen.GoImportPath("go.unistack.org/micro-proto/v3/codec") - microErrorsPackage = protogen.GoImportPath("go.unistack.org/micro-proto/v3/errors") + microCodecPackage = protogen.GoImportPath("go.unistack.org/micro/v3/codec") + microErrorsPackage = protogen.GoImportPath("go.unistack.org/micro/v3/errors") timePackage = protogen.GoImportPath("time") deprecationComment = "// Deprecated: Do not use." versionComment = "v3.5.3"