{"record":{"id":"5ea29ae1a40ae6dc","repo":"alibaba/spring-ai-alibaba","slug":"parameter-not-allow-object-type","errorCode":null,"errorMessage":"Parameter Not Allow Object Type","messagePattern":"Parameter Not Allow Object Type","errorType":"validation","errorClass":"YAMLException","httpStatus":null,"severity":"error","filePath":"spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-core/src/main/java/com/alibaba/cloud/ai/studio/core/utils/api/OpenApiUtils.java","lineNumber":984,"sourceCode":"\t\tboolean needAdd = true;\n\t\tif (extensions != null && !extensions.isEmpty()) {\n\t\t\tObject paramSource = parameter.getExtensions().get(DEFINED_EXTENSION);\n\t\t\tif (String.valueOf(paramSource).equals(EXTENSION_USER_SOURCE)) {\n\t\t\t\tneedAdd = false;\n\t\t\t}\n\t\t}\n\n\t\tif (!needAdd) {\n\t\t\treturn;\n\t\t}\n\n\t\tString type = parameter.getSchema().getType();\n\t\t// token is not allowed\n\t\tif (StringUtils.isNotBlank(type) && TOKEN_TYPE.equals(type)) {\n\t\t\tthrow new YAMLException(\"Type \\\"token\\\" is not allowed.\");\n\t\t}\n\t\tif (StringUtils.isNotBlank(type) && \"object\".equals(type)) {\n\t\t\tthrow new YAMLException(\"Parameter Not Allow Object Type\");\n\t\t}\n\n\t\tApiParameter param = new ApiParameter();\n\t\tparam.setKey(parameter.getName());\n\t\tparam.setType(type);\n\t\tparam.setRequired(parameter.getRequired() != null && parameter.getRequired());\n\t\tparam.setDescription(parameter.getDescription());\n\t\tresultList.add(param);\n\t}\n\n\t/**\n\t * Exchanges schema between API parameters and OpenAPI schema\n\t * @param allParams List of API parameters\n\t * @param propertiesMap Properties map\n\t * @param requiredList List of required parameters\n\t */\n\tprivate static void exchangeSchema(List<ApiParameter> allParams, Map<String, Schema> propertiesMap,\n\t\t\tList<String> requiredList) {","sourceCodeStart":966,"sourceCodeEnd":1002,"githubUrl":"https://github.com/alibaba/spring-ai-alibaba/blob/f82da0b50f35744c13968191be2b1cd2452ef550/spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-core/src/main/java/com/alibaba/cloud/ai/studio/core/utils/api/OpenApiUtils.java#L966-L1002","documentation":"OpenAPI parameters at the top level may not be of type \"object\". Because top-level parameters (header/query/path/cookie) are serialized flat, an object type cannot be mapped to a single ApiParameter, so a YAMLException(\"Parameter Not Allow Object Type\") is thrown. Use request bodies or individual primitive parameters instead.","triggerScenarios":"Parsing an OpenAPI operation whose parameter (after passing the token check) has parameter.getSchema().getType() equal to \"object\" — e.g. an object-typed query or header parameter.","commonSituations":"Generating specs from code where a complex DTO was annotated as a @Parameter instead of a request body; JSON-schema habits applied to OpenAPI; exporting from tools that permit object-typed query params.","solutions":["Move the object payload into the request body (requestBody) instead of a parameter","Flatten the object into individual primitive-typed parameters","Use a JSON string parameter plus server-side deserialization if a single field is required","Fix the code-generation annotation so DTOs map to body, not parameters"],"exampleFix":"// before\n- name: filter\n  in: query\n  schema:\n    type: object\n    properties: { status: { type: string } }\n// after\n- name: status\n  in: query\n  schema:\n    type: string","handlingStrategy":"validation","validationCode":"boolean isObjectTypedParam(Parameter p) {\n    return p != null && p.getSchema() != null && \"object\".equals(p.getSchema().getType());\n}\n// move such params to requestBody before import","typeGuard":null,"tryCatchPattern":"try {\n    OpenApiUtils.parseRestfulMethod(...);\n} catch (YAMLException e) {\n    if (e.getMessage().contains(\"Object Type\")) {\n        // convert object parameters to request body in the spec\n    }\n}","preventionTips":["Use requestBody for structured payloads, parameters only for primitives","Check codegen annotations so DTOs map to body, not @Parameter","Flatten object query params into individual fields"],"tags":["openapi","schema-validation","parameters"],"backgroundTag":"schema-validation-failed","analyzedSha":"f82da0b50f35744c13968191be2b1cd2452ef550","analyzedAt":"2026-09-09T15:32:42.421Z","contentChangedAt":"2026-09-09T15:32:42.421Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}