diff --git a/pkg/codegen/operations.go b/pkg/codegen/operations.go index 01666ff38f..ab09547d5a 100644 --- a/pkg/codegen/operations.go +++ b/pkg/codegen/operations.go @@ -661,7 +661,7 @@ func GenerateBodyDefinitions(operationID string, bodyOrRef *openapi3.RequestBody } // If the body is a pre-defined type - if IsGoTypeReference(content.Schema.Ref) { + if content.Schema != nil && IsGoTypeReference(content.Schema.Ref) { // Convert the reference path to Go type refType, err := RefPathToGoType(content.Schema.Ref) if err != nil {