From 4f5cd8154a6519f08a42564af6c9599ae3c2cfad Mon Sep 17 00:00:00 2001 From: Toan Nguyen Date: Sat, 28 Dec 2024 18:31:59 +0700 Subject: [PATCH] refactor the oas parser v2 --- ndc-http-schema/openapi/internal/oas2.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ndc-http-schema/openapi/internal/oas2.go b/ndc-http-schema/openapi/internal/oas2.go index 0d73a60..cf132af 100644 --- a/ndc-http-schema/openapi/internal/oas2.go +++ b/ndc-http-schema/openapi/internal/oas2.go @@ -251,7 +251,13 @@ func (oc *OAS2Builder) getSchemaTypeFromParameter(param *v2.Parameter, fieldPath var typeEncoder schema.TypeEncoder nullable := param.Required == nil || !*param.Required - switch param.Type { + paramType := param.Type + hasArrayItem := param.Items != nil && param.Items.Type != "" + if param.Type == "" && hasArrayItem { + paramType = "array" + } + + switch paramType { case "object": return nil, fmt.Errorf("%s: unsupported object parameter", strings.Join(fieldPaths, ".")) case "array":