Skip to content

Commit 44d988c

Browse files
enums
1 parent 5d047da commit 44d988c

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

apps/portal/src/components/Document/APIEndpointMeta/OpenApiEndpoint.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ function generateExampleFromSchema(schema: any, visited = new Set()): any {
6464
switch (schema.type) {
6565
case "string":
6666
if (schema.enum && schema.enum.length > 0) {
67-
return schema.enum[0];
67+
// Join all enum values with | separator for display
68+
return schema.enum.join(" | ");
6869
}
6970
if (schema.format === "date-time") {
7071
return new Date().toISOString();
@@ -82,6 +83,10 @@ function generateExampleFromSchema(schema: any, visited = new Set()): any {
8283

8384
case "number":
8485
case "integer":
86+
if (schema.enum && schema.enum.length > 0) {
87+
// Join all enum values with | separator for display
88+
return schema.enum.join(" | ");
89+
}
8590
if (schema.minimum !== undefined) {
8691
return schema.minimum;
8792
}
@@ -386,7 +391,7 @@ function transformOpenApiToApiEndpointMeta(
386391
description: prop.description || "",
387392
type: prop.type,
388393
required: required.includes(propName),
389-
example: prop.example,
394+
example: prop.example || generateExampleFromSchema(prop),
390395
} as APIParameter;
391396

392397
bodyParameters.push(apiParam);

0 commit comments

Comments
 (0)