alibaba/spring-ai-alibaba · error · YAMLException

Parameter Not Allow Object Type

Error message

Parameter Not Allow Object Type

What it means

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.

Source

Thrown at spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-core/src/main/java/com/alibaba/cloud/ai/studio/core/utils/api/OpenApiUtils.java:984

		boolean needAdd = true;
		if (extensions != null && !extensions.isEmpty()) {
			Object paramSource = parameter.getExtensions().get(DEFINED_EXTENSION);
			if (String.valueOf(paramSource).equals(EXTENSION_USER_SOURCE)) {
				needAdd = false;
			}
		}

		if (!needAdd) {
			return;
		}

		String type = parameter.getSchema().getType();
		// token is not allowed
		if (StringUtils.isNotBlank(type) && TOKEN_TYPE.equals(type)) {
			throw new YAMLException("Type \"token\" is not allowed.");
		}
		if (StringUtils.isNotBlank(type) && "object".equals(type)) {
			throw new YAMLException("Parameter Not Allow Object Type");
		}

		ApiParameter param = new ApiParameter();
		param.setKey(parameter.getName());
		param.setType(type);
		param.setRequired(parameter.getRequired() != null && parameter.getRequired());
		param.setDescription(parameter.getDescription());
		resultList.add(param);
	}

	/**
	 * Exchanges schema between API parameters and OpenAPI schema
	 * @param allParams List of API parameters
	 * @param propertiesMap Properties map
	 * @param requiredList List of required parameters
	 */
	private static void exchangeSchema(List<ApiParameter> allParams, Map<String, Schema> propertiesMap,
			List<String> requiredList) {

View on GitHub (pinned to f82da0b50f)

Solutions

  1. Move the object payload into the request body (requestBody) instead of a parameter
  2. Flatten the object into individual primitive-typed parameters
  3. Use a JSON string parameter plus server-side deserialization if a single field is required
  4. Fix the code-generation annotation so DTOs map to body, not parameters

Example fix

// before
- name: filter
  in: query
  schema:
    type: object
    properties: { status: { type: string } }
// after
- name: status
  in: query
  schema:
    type: string
Defensive patterns

Strategy: validation

Validate before calling

boolean isObjectTypedParam(Parameter p) {
    return p != null && p.getSchema() != null && "object".equals(p.getSchema().getType());
}
// move such params to requestBody before import

Try / catch

try {
    OpenApiUtils.parseRestfulMethod(...);
} catch (YAMLException e) {
    if (e.getMessage().contains("Object Type")) {
        // convert object parameters to request body in the spec
    }
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of alibaba/spring-ai-alibaba@f82da0b50f (2026-09-09). Data as JSON: /api/errors/5ea29ae1a40ae6dc. Report an issue: GitHub.