schema-display.tsx 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. "use client";
  2. import {
  3. SchemaDisplay,
  4. SchemaDisplayContent,
  5. SchemaDisplayDescription,
  6. SchemaDisplayHeader,
  7. SchemaDisplayMethod,
  8. SchemaDisplayParameters,
  9. SchemaDisplayPath,
  10. SchemaDisplayRequest,
  11. SchemaDisplayResponse,
  12. } from "@/components/ai-elements/schema-display";
  13. const Example = () => (
  14. <SchemaDisplay
  15. description="Create a new post for a specific user. Requires authentication."
  16. method="POST"
  17. parameters={[
  18. {
  19. description: "The unique identifier of the user",
  20. location: "path",
  21. name: "userId",
  22. required: true,
  23. type: "string",
  24. },
  25. {
  26. description: "Save as draft instead of publishing",
  27. location: "query",
  28. name: "draft",
  29. required: false,
  30. type: "boolean",
  31. },
  32. ]}
  33. path="/api/users/{userId}/posts"
  34. requestBody={[
  35. {
  36. description: "The post title",
  37. name: "title",
  38. required: true,
  39. type: "string",
  40. },
  41. {
  42. description: "The post content in markdown format",
  43. name: "content",
  44. required: true,
  45. type: "string",
  46. },
  47. {
  48. description: "Tags for categorization",
  49. items: { name: "tag", type: "string" },
  50. name: "tags",
  51. type: "array",
  52. },
  53. {
  54. description: "Additional metadata",
  55. name: "metadata",
  56. properties: [
  57. {
  58. description: "SEO optimized title",
  59. name: "seoTitle",
  60. type: "string",
  61. },
  62. {
  63. description: "Meta description",
  64. name: "seoDescription",
  65. type: "string",
  66. },
  67. ],
  68. type: "object",
  69. },
  70. ]}
  71. responseBody={[
  72. { description: "Post ID", name: "id", required: true, type: "string" },
  73. { name: "title", required: true, type: "string" },
  74. { name: "content", required: true, type: "string" },
  75. {
  76. description: "ISO 8601 timestamp",
  77. name: "createdAt",
  78. required: true,
  79. type: "string",
  80. },
  81. {
  82. name: "author",
  83. properties: [
  84. { name: "id", required: true, type: "string" },
  85. { name: "name", required: true, type: "string" },
  86. { name: "avatar", type: "string" },
  87. ],
  88. required: true,
  89. type: "object",
  90. },
  91. ]}
  92. >
  93. <SchemaDisplayHeader>
  94. <div className="flex items-center gap-3">
  95. <SchemaDisplayMethod />
  96. <SchemaDisplayPath />
  97. </div>
  98. </SchemaDisplayHeader>
  99. <SchemaDisplayDescription />
  100. <SchemaDisplayContent>
  101. <SchemaDisplayParameters />
  102. <SchemaDisplayRequest />
  103. <SchemaDisplayResponse />
  104. </SchemaDisplayContent>
  105. </SchemaDisplay>
  106. );
  107. export default Example;