@@ -4591,13 +4591,19 @@ function generateValidExampleFromSchema(
45914591 if (resolvedSchema.example !== undefined) {
45924592 return resolvedSchema.example;
45934593 }
4594-
45954594 // Use default value if available
45964595 if (resolvedSchema.default !== undefined) {
45974596 return resolvedSchema.default;
45984597 }
45994598
4600- if (resolvedSchema.type === "object" && resolvedSchema.properties) {
4599+ // Handle type as array (OpenAPI 3.1 JSON Schema compatibility)
4600+ let schemaType = resolvedSchema.type;
4601+ if (Array.isArray(resolvedSchema.type) && resolvedSchema.type.length > 0) {
4602+ // Use first non-null type
4603+ schemaType = resolvedSchema.type.find(type => type !== "null") || resolvedSchema.type[0];
4604+ }
4605+
4606+ if (schemaType === "object" && resolvedSchema.properties) {
46014607 const example = {};
46024608 const required = resolvedSchema.required || [];
46034609
@@ -4631,10 +4637,8 @@ function generateValidExampleFromSchema(
46314637 example[propName] = value;
46324638 }
46334639 }
4634- }
4635-
4636- return example;
4637- } else if (resolvedSchema.type === "array" && resolvedSchema.items) {
4640+ } return example;
4641+ } else if (schemaType === "array" && resolvedSchema.items) {
46384642 if (indent < 5) {
46394643 const itemExample = generateValidExampleFromSchema(
46404644 resolvedSchema.items,
@@ -4662,13 +4666,19 @@ function generateValidPrimitiveExample(schema) {
46624666
46634667 // Use default value if available
46644668 if (schema.default !== undefined) return schema.default;
4665-
46664669 // Handle enums first
46674670 if (schema.enum && schema.enum.length > 0) {
46684671 return schema.enum[0];
46694672 }
46704673
4671- switch (schema.type) {
4674+ // Handle type as array (OpenAPI 3.1 JSON Schema compatibility)
4675+ let schemaType = schema.type;
4676+ if (Array.isArray(schema.type) && schema.type.length > 0) {
4677+ // Use first non-null type
4678+ schemaType = schema.type.find(type => type !== "null") || schema.type[0];
4679+ }
4680+
4681+ switch (schemaType) {
46724682 case "string":
46734683 return generateValidStringExample(schema);
46744684 case "integer":
0 commit comments