MCPcopy Create free account
hub / github.com/apache/dubbo-go / TestEncoder_toMap_FullOpenAPI

Function TestEncoder_toMap_FullOpenAPI

protocol/triple/openapi/encoder_test.go:143–168  ·  view source on GitHub ↗

--- toMap tests ---

(t *testing.T)

Source from the content-addressed store, hash-verified

141// --- toMap tests ---
142
143func 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
170func TestEncoder_toMap_NoPaths(t *testing.T) {
171 e := NewEncoder()

Callers

nothing calls this directly

Calls 14

AddPathMethod · 0.95
toMapMethod · 0.95
NewOpenAPIFunction · 0.92
NewPathItemFunction · 0.92
NewOperationFunction · 0.92
NewComponentsFunction · 0.92
NewSchemaFunction · 0.92
NewEncoderFunction · 0.85
SetOperationMethod · 0.80
SetOperationIdMethod · 0.80
AddSchemaMethod · 0.80
SetTypeMethod · 0.80

Tested by

no test coverage detected