--- toMap tests ---
(t *testing.T)
| 141 | // --- toMap tests --- |
| 142 | |
| 143 | func TestEncoder_toMap_FullOpenAPI(t *testing.T) { |
| 144 | e := NewEncoder() |
| 145 | openAPI := model.NewOpenAPI() |
| 146 | openAPI.Info.Title = "Test API" |
| 147 | openAPI.Info.Version = "1.0.0" |
| 148 | openAPI.Info.Description = "A test API" |
| 149 | openAPI.AddPath("/test", model.NewPathItem().SetOperation("POST", |
| 150 | model.NewOperation().SetOperationId("testOp"))) |
| 151 | openAPI.Components = model.NewComponents() |
| 152 | openAPI.Components.AddSchema("TestSchema", model.NewSchema().SetType(model.SchemaTypeObject)) |
| 153 | |
| 154 | m := e.toMap(openAPI) |
| 155 | |
| 156 | if m["openapi"] != model.OpenAPIVersion30 { |
| 157 | t.Errorf("openapi = %v, want %s", m["openapi"], model.OpenAPIVersion30) |
| 158 | } |
| 159 | if _, ok := m["info"]; !ok { |
| 160 | t.Error("info should be present") |
| 161 | } |
| 162 | if _, ok := m["paths"]; !ok { |
| 163 | t.Error("paths should be present") |
| 164 | } |
| 165 | if _, ok := m["components"]; !ok { |
| 166 | t.Error("components should be present") |
| 167 | } |
| 168 | } |
| 169 | |
| 170 | func TestEncoder_toMap_NoPaths(t *testing.T) { |
| 171 | e := NewEncoder() |
nothing calls this directly
no test coverage detected