Repository: getkin/kin-openapi (go)

Issue:
Crash on load
Loading this spec causes panic:

```
openapi: 3.0.1
info:
  title: Swagger API
  version: v1
paths:
  /test:
    post:
      requestBody:
        content:
          application/json:
```





Pull request:
fix crash on load
fix #794 

Patch:
diff --git a/openapi3/loader.go b/openapi3/loader.go
index 4a14f67..3b50a64 100644
--- a/openapi3/loader.go
+++ b/openapi3/loader.go
@@ -615,6 +615,9 @@ func (loader *Loader) resolveRequestBodyRef(doc *T, component *RequestBodyRef, d
 	}
 
 	for _, contentType := range value.Content {
+		if contentType == nil {
+			continue
+		}
 		examples := make([]string, 0, len(contentType.Examples))
 		for name := range contentType.Examples {
 			examples = append(examples, name)


Test patch:
diff --git a/openapi3/issue794_test.go b/openapi3/issue794_test.go
new file mode 100644
index 0000000..4958d29
--- /dev/null
+++ b/openapi3/issue794_test.go
@@ -0,0 +1,15 @@
+package openapi3
+
+import (
+	"testing"
+
+	"github.com/stretchr/testify/require"
+)
+
+func TestCrashOnLoad(t *testing.T) {
+	loader := NewLoader()
+	doc, err := loader.LoadFromFile("testdata/issue794.yml")
+	require.NoError(t, err)
+	err = doc.Validate(loader.Context)
+	require.NoError(t, err)
+}
diff --git a/openapi3/testdata/issue794.yml b/openapi3/testdata/issue794.yml
new file mode 100644
index 0000000..3cd4dc7
--- /dev/null
+++ b/openapi3/testdata/issue794.yml
@@ -0,0 +1,13 @@
+openapi: 3.0.1
+info:
+  title: Swagger API
+  version: v1
+paths:
+  /test:
+    post:
+      requestBody:
+        content:
+          application/json:
+      responses:
+        "200":
+          description: description