diff --git a/src/lib/utils/specs.ts b/src/lib/utils/specs.ts index b49d7a1b15..d2d5da0a14 100644 --- a/src/lib/utils/specs.ts +++ b/src/lib/utils/specs.ts @@ -2,310 +2,319 @@ import { OpenAPIV3 } from 'openapi-types'; import { Platform, type Service } from './references'; type SDKMethod = { - id: string; - title: string; - description: string; - demo: string; - parameters: Array<{ - name: string; - description: string; - required: boolean; - type: string; - example: string; - }>; - responses: Array<{ - code: number; - contentType?: string; - models?: SDKMethodModel[]; - }>; + id: string; + title: string; + description: string; + demo: string; + parameters: Array<{ + name: string; + description: string; + required: boolean; + type: string; + example: string; + }>; + responses: Array<{ + code: number; + contentType?: string; + models?: SDKMethodModel[]; + }>; + method: OpenAPIV3.HttpMethods; + url: string; }; type SDKMethodModel = { - id: string; - name: string; + id: string; + name: string; }; type AppwriteOperationObject = OpenAPIV3.OperationObject & { - 'x-appwrite': { - method: string; - weight: number; - cookies: boolean; - type: string; - demo: string; - edit: string; - 'rate-limit': number; - 'rate-time': number; - 'rate-key': string; - scope: string; - platforms: string[]; - packaging: boolean; - }; + 'x-appwrite': { + method: string; + weight: number; + cookies: boolean; + type: string; + demo: string; + edit: string; + 'rate-limit': number; + 'rate-time': number; + 'rate-key': string; + scope: string; + platforms: string[]; + packaging: boolean; + }; }; export type AppwriteSchemaObject = OpenAPIV3.SchemaObject & { - 'x-example': string; + 'x-example': string; }; function getExamples(version: string) { - switch (version) { - case '0.15.x': - return import.meta.glob('$appwrite/docs/examples/0.15.x/**/*.md', { - as: 'raw' - }); - case '1.0.x': - return import.meta.glob('$appwrite/docs/examples/1.0.x/**/*.md', { - as: 'raw' - }); - case '1.1.x': - return import.meta.glob('$appwrite/docs/examples/1.1.x/**/*.md', { - as: 'raw' - }); - case '1.2.x': - return import.meta.glob('$appwrite/docs/examples/1.2.x/**/*.md', { - as: 'raw' - }); - case '1.3.x': - return import.meta.glob('$appwrite/docs/examples/1.3.x/**/*.md', { - as: 'raw' - }); - case '1.4.x': - return import.meta.glob('$appwrite/docs/examples/1.4.x/**/*.md', { - as: 'raw' - }); - } + switch (version) { + case '0.15.x': + return import.meta.glob('$appwrite/docs/examples/0.15.x/**/*.md', { + as: 'raw' + }); + case '1.0.x': + return import.meta.glob('$appwrite/docs/examples/1.0.x/**/*.md', { + as: 'raw' + }); + case '1.1.x': + return import.meta.glob('$appwrite/docs/examples/1.1.x/**/*.md', { + as: 'raw' + }); + case '1.2.x': + return import.meta.glob('$appwrite/docs/examples/1.2.x/**/*.md', { + as: 'raw' + }); + case '1.3.x': + return import.meta.glob('$appwrite/docs/examples/1.3.x/**/*.md', { + as: 'raw' + }); + case '1.4.x': + return import.meta.glob('$appwrite/docs/examples/1.4.x/**/*.md', { + as: 'raw' + }); + } } function* iterateAllMethods( - api: OpenAPIV3.Document, - service: string -): Generator<[OpenAPIV3.HttpMethods, OpenAPIV3.OperationObject]> { - for (const url in api.paths) { - const methods = api.paths[url]; - if (methods?.get?.tags?.includes(service)) { - yield [OpenAPIV3.HttpMethods.GET, methods.get]; - } - if (methods?.post?.tags?.includes(service)) { - yield [OpenAPIV3.HttpMethods.POST, methods.post]; - } - if (methods?.put?.tags?.includes(service)) { - yield [OpenAPIV3.HttpMethods.PUT, methods.put]; - } - if (methods?.patch?.tags?.includes(service)) { - yield [OpenAPIV3.HttpMethods.PATCH, methods.patch]; - } - if (methods?.delete?.tags?.includes(service)) { - yield [OpenAPIV3.HttpMethods.DELETE, methods.delete]; - } - } + api: OpenAPIV3.Document, + service: string +): Generator<{ method: OpenAPIV3.HttpMethods; value: OpenAPIV3.OperationObject; url: string }> { + for (const url in api.paths) { + const methods = api.paths[url]; + if (methods?.get?.tags?.includes(service)) { + yield { method: OpenAPIV3.HttpMethods.GET, value: methods.get, url }; + } + if (methods?.post?.tags?.includes(service)) { + yield { method: OpenAPIV3.HttpMethods.POST, value: methods.post, url }; + } + if (methods?.put?.tags?.includes(service)) { + yield { method: OpenAPIV3.HttpMethods.PUT, value: methods.put, url }; + } + if (methods?.patch?.tags?.includes(service)) { + yield { method: OpenAPIV3.HttpMethods.PATCH, value: methods.patch, url }; + } + if (methods?.delete?.tags?.includes(service)) { + yield { method: OpenAPIV3.HttpMethods.DELETE, value: methods.delete, url }; + } + } } -function getParameters( - operation: AppwriteOperationObject -): SDKMethod['parameters'] { - const parameters: ReturnType = []; - const requestBody = operation?.requestBody as OpenAPIV3.RequestBodyObject; - const schemaJson = requestBody?.content['application/json']?.schema as OpenAPIV3.SchemaObject; - const schemaMultipart = requestBody?.content['multipart/form-data']?.schema as OpenAPIV3.SchemaObject; - if (operation?.parameters) { - for (const parameter of (operation?.parameters as OpenAPIV3.ParameterObject[])) { - const schema = parameter.schema as OpenAPIV3.SchemaObject; +function getParameters(operation: AppwriteOperationObject): SDKMethod['parameters'] { + const parameters: ReturnType = []; + const requestBody = operation?.requestBody as OpenAPIV3.RequestBodyObject; + const schemaJson = requestBody?.content['application/json']?.schema as OpenAPIV3.SchemaObject; + const schemaMultipart = requestBody?.content['multipart/form-data'] + ?.schema as OpenAPIV3.SchemaObject; + if (operation?.parameters) { + for (const parameter of operation?.parameters as OpenAPIV3.ParameterObject[]) { + const schema = parameter.schema as OpenAPIV3.SchemaObject; - parameters.push({ - name: parameter.name, - description: parameter.description ?? '', - required: parameter.required ?? false, - type: schema?.type ?? '', - example: schema?.example - }); - } - } - if (schemaJson?.properties) { - for (const [key, value] of Object.entries(schemaJson.properties)) { - const property = value as AppwriteSchemaObject; - parameters.push({ - name: key, - description: property.description ?? '', - required: schemaJson?.required?.includes(key) ?? false, - type: property.type ?? '', - example: property['x-example'] ?? '' - }); - } - } - if (schemaMultipart?.properties) { - for (const [key, value] of Object.entries(schemaMultipart.properties)) { - const property = value as AppwriteSchemaObject; - parameters.push({ - name: key, - description: property.description ?? '', - required: schemaMultipart?.required?.includes(key) ?? false, - type: property.type ?? '', - example: property['x-example'] ?? '' - }); - } - } + parameters.push({ + name: parameter.name, + description: parameter.description ?? '', + required: parameter.required ?? false, + type: schema?.type ?? '', + example: schema?.example + }); + } + } + if (schemaJson?.properties) { + for (const [key, value] of Object.entries(schemaJson.properties)) { + const property = value as AppwriteSchemaObject; + parameters.push({ + name: key, + description: property.description ?? '', + required: schemaJson?.required?.includes(key) ?? false, + type: property.type ?? '', + example: property['x-example'] ?? '' + }); + } + } + if (schemaMultipart?.properties) { + for (const [key, value] of Object.entries(schemaMultipart.properties)) { + const property = value as AppwriteSchemaObject; + parameters.push({ + name: key, + description: property.description ?? '', + required: schemaMultipart?.required?.includes(key) ?? false, + type: property.type ?? '', + example: property['x-example'] ?? '' + }); + } + } return parameters.sort((a, b) => { - return (a.required === b.required) ? 0 : a.required ? -1 : 1; + return a.required === b.required ? 0 : a.required ? -1 : 1; }); } export function getSchema(id: string, api: OpenAPIV3.Document): OpenAPIV3.SchemaObject { - const schema = api.components?.schemas?.[id] as OpenAPIV3.SchemaObject; - if (schema) { - return schema; - } - throw new Error("Schema doesn't exist"); + const schema = api.components?.schemas?.[id] as OpenAPIV3.SchemaObject; + if (schema) { + return schema; + } + throw new Error("Schema doesn't exist"); } const specs = import.meta.glob( - '$appwrite/app/config/specs/open-api3*-(client|server|console).json', - { - as: 'raw' - } + '$appwrite/app/config/specs/open-api3*-(client|server|console).json', + { + as: 'raw' + } ); async function getSpec(version: string, platform: string) { - const isClient = platform.startsWith('client-'); - const isServer = platform.startsWith('server-'); - const target = `/node_modules/@appwrite.io/repo/app/config/specs/open-api3-${version}-${ - isServer ? 'server' : isClient ? 'client' : 'console' - }.json`; - return specs[target](); + const isClient = platform.startsWith('client-'); + const isServer = platform.startsWith('server-'); + const target = `/node_modules/@appwrite.io/repo/app/config/specs/open-api3-${version}-${ + isServer ? 'server' : isClient ? 'client' : 'console' + }.json`; + return specs[target](); } export async function getApi(version: string, platform: string): Promise { - const raw = await getSpec(version, platform); - const api = JSON.parse(raw); - return api; + const raw = await getSpec(version, platform); + const api = JSON.parse(raw); + return api; } const descriptions = import.meta.glob( - '/src/routes/docs/references/[version]/[platform]/[service]/descriptions/*.md', - { - as: 'raw' - } + '/src/routes/docs/references/[version]/[platform]/[service]/descriptions/*.md', + { + as: 'raw' + } ); export async function getDescription(service: string): Promise { - const target = `/src/routes/docs/references/[version]/[platform]/[service]/descriptions/${service}.md`; + const target = `/src/routes/docs/references/[version]/[platform]/[service]/descriptions/${service}.md`; - if (!(target in descriptions)) { - throw new Error('Missing service description'); - } - return descriptions[target](); + if (!(target in descriptions)) { + throw new Error('Missing service description'); + } + return descriptions[target](); } export async function getService( - version: string, - platform: string, - service: string + version: string, + platform: string, + service: string ): Promise<{ - service: { - name: Service; - description: string; - }; - methods: SDKMethod[]; + service: { + name: Service; + description: string; + }; + methods: SDKMethod[]; }> { - /** - * Exceptions for Android SDK. - */ - const isAndroidJava = platform === Platform.ClientAndroidJava || platform === Platform.ServerJava; - const isAndroidKotlin = platform === Platform.ClientAndroidKotlin || platform === Platform.ServerKotlin; - const isAndroid = isAndroidJava || isAndroidKotlin; - const isAndroidServer = platform === Platform.ServerJava || platform === Platform.ServerKotlin; - const api = await getApi(version, platform); - const tag = api.tags?.find((n) => n.name === service); + /** + * Exceptions for Android SDK. + */ + const isAndroidJava = + platform === Platform.ClientAndroidJava || platform === Platform.ServerJava; + const isAndroidKotlin = + platform === Platform.ClientAndroidKotlin || platform === Platform.ServerKotlin; + const isAndroid = isAndroidJava || isAndroidKotlin; + const isAndroidServer = platform === Platform.ServerJava || platform === Platform.ServerKotlin; + const api = await getApi(version, platform); + const tag = api.tags?.find((n) => n.name === service); - const data: Awaited> = { - service: { - name: tag?.name as Service, - description: await getDescription(service) - }, - methods: [] - }; + const data: Awaited> = { + service: { + name: tag?.name as Service, + description: await getDescription(service) + }, + methods: [] + }; - const examples = getExamples(version); + const examples = getExamples(version); - if (!examples) { - return data; - } + if (!examples) { + return data; + } - for (const [method, value] of iterateAllMethods(api, service)) { - const operation = value as AppwriteOperationObject; - const parameters = getParameters(operation); - const responses: SDKMethod['responses'] = Object.entries(operation.responses ?? {}).map( - (tuple) => { - const [code, response] = tuple as [string, OpenAPIV3.ResponseObject]; - const models: SDKMethodModel[] = []; - const schemas = response?.content?.['application/json']?.schema as OpenAPIV3.SchemaObject; - if (code !== '204') { - if (schemas?.oneOf) { - schemas.oneOf.forEach((ref) => { - const schema = resolveReference(ref as OpenAPIV3.ReferenceObject, api); - models.push({ - id: getIdFromReference(ref as OpenAPIV3.ReferenceObject), - name: schema.description ?? '' - }); - }); - } else { - if (schemas) { - const id = getIdFromReference(schemas as OpenAPIV3.ReferenceObject); - const schema = resolveReference(schemas as OpenAPIV3.ReferenceObject, api); - models.push({ - id, - name: schema?.description ?? '' - }); - } - } - } + for (const { method, value, url } of iterateAllMethods(api, service)) { + const operation = value as AppwriteOperationObject; + const parameters = getParameters(operation); + const responses: SDKMethod['responses'] = Object.entries(operation.responses ?? {}).map( + (tuple) => { + const [code, response] = tuple as [string, OpenAPIV3.ResponseObject]; + const models: SDKMethodModel[] = []; + const schemas = response?.content?.['application/json'] + ?.schema as OpenAPIV3.SchemaObject; + if (code !== '204') { + if (schemas?.oneOf) { + schemas.oneOf.forEach((ref) => { + const schema = resolveReference(ref as OpenAPIV3.ReferenceObject, api); + models.push({ + id: getIdFromReference(ref as OpenAPIV3.ReferenceObject), + name: schema.description ?? '' + }); + }); + } else { + if (schemas) { + const id = getIdFromReference(schemas as OpenAPIV3.ReferenceObject); + const schema = resolveReference( + schemas as OpenAPIV3.ReferenceObject, + api + ); + models.push({ + id, + name: schema?.description ?? '' + }); + } + } + } - return { - code: Number(code), - contentType: response?.content ? Object.keys(response.content)[0] : undefined, - models - }; - } - ); + return { + code: Number(code), + contentType: response?.content ? Object.keys(response.content)[0] : undefined, + models + }; + } + ); - const path = isAndroid - ? `/node_modules/@appwrite.io/repo/docs/examples/${version}/${isAndroidServer ? 'server-kotlin' : 'client-android'}/${ - isAndroidJava ? 'java' : 'kotlin' - }/${operation['x-appwrite'].demo}` - : `/node_modules/@appwrite.io/repo/docs/examples/${version}/${platform}/examples/${operation['x-appwrite'].demo}`; - if (!(path in examples)) { - continue; - } - data.methods.push({ - id: operation['x-appwrite'].method, - demo: await examples[path](), - title: operation.summary ?? '', - description: operation.description ?? '', - parameters: parameters ?? [], - responses: responses ?? [] - }); - } + const path = isAndroid + ? `/node_modules/@appwrite.io/repo/docs/examples/${version}/${ + isAndroidServer ? 'server-kotlin' : 'client-android' + }/${isAndroidJava ? 'java' : 'kotlin'}/${operation['x-appwrite'].demo}` + : `/node_modules/@appwrite.io/repo/docs/examples/${version}/${platform}/examples/${operation['x-appwrite'].demo}`; + if (!(path in examples)) { + continue; + } + data.methods.push({ + id: operation['x-appwrite'].method, + demo: await examples[path](), + title: operation.summary ?? '', + description: operation.description ?? '', + parameters: parameters ?? [], + responses: responses ?? [], + method, + url + }); + } - return data; + return data; } export function getIdFromReference(reference: OpenAPIV3.ReferenceObject) { - const id = reference?.$ref?.split('/')?.pop(); - if (!id) { - throw new Error('Invalid reference'); - } - return id; + const id = reference?.$ref?.split('/')?.pop(); + if (!id) { + throw new Error('Invalid reference'); + } + return id; } export function resolveReference( - reference: OpenAPIV3.ReferenceObject, - api: OpenAPIV3.Document + reference: OpenAPIV3.ReferenceObject, + api: OpenAPIV3.Document ): AppwriteSchemaObject { - const id = reference.$ref.split('/').pop(); - if (!id) { - throw new Error('Invalid reference'); - } - const schema = api.components?.schemas?.[id] as AppwriteSchemaObject; - if (schema) { - return schema; - } - throw new Error("Schema doesn't exist"); + const id = reference.$ref.split('/').pop(); + if (!id) { + throw new Error('Invalid reference'); + } + const schema = api.components?.schemas?.[id] as AppwriteSchemaObject; + if (schema) { + return schema; + } + throw new Error("Schema doesn't exist"); } diff --git a/src/markdoc/nodes/Fence.svelte b/src/markdoc/nodes/Fence.svelte index d92b26129d..550f2d4b13 100644 --- a/src/markdoc/nodes/Fence.svelte +++ b/src/markdoc/nodes/Fence.svelte @@ -9,9 +9,11 @@ import { melt } from '@melt-ui/svelte'; export let content: string; + export let toCopy: string | undefined = undefined; export let language: Language; export let process: boolean; export let withLineNumbers = true; + export let badge: string | null = null; const insideMultiCode = hasContext('multi-code'); const selected = insideMultiCode ? getContext('multi-code').selected : null; @@ -22,7 +24,7 @@ } let copyText = CopyStatus.Copy; async function handleCopy() { - await copy(content); + await copy(toCopy ?? content); copyText = CopyStatus.Copied; setTimeout(() => { @@ -49,6 +51,8 @@ $: result = process ? getCodeHtml({ content, language: language ?? 'sh', withLineNumbers }) : content; + + $: badgeValue = badge ?? platformMap[language]; {#if insideMultiCode} @@ -60,9 +64,9 @@
- {#if platformMap[language]} + {#if badgeValue}
-
{platformMap[language]}
+
{badgeValue}
{/if}
diff --git a/src/routes/docs/+page.svelte b/src/routes/docs/+page.svelte index bbd96c6a4b..1be7c2b703 100644 --- a/src/routes/docs/+page.svelte +++ b/src/routes/docs/+page.svelte @@ -69,22 +69,6 @@ -
- -
-
@@ -121,18 +105,27 @@ Explore all technologies -
+
+
-
+

Show me some code

@@ -429,11 +422,6 @@ .tech-hero { @include border-block-gradient; - background: linear-gradient(to right, #19191c80, #19191c00); - // background-color: #19191c80; - backdrop-filter: blur(1rem); - -webkit-backdrop-filter: blur(1rem); - --m-border-size: 1px; --m-border-gradient-before: linear-gradient( to right, @@ -460,9 +448,10 @@ left: calc(50% - 384px + 600px); } - .bg-boi { + .bg-overlay { position: absolute; - background: linear-gradient(to right, #19191c00 0%, #19191c00 10%, #19191c); + + background: linear-gradient(to right, #ffffff00 0%, #ffffff00 10%, #ffffff); top: 0; right: 10rem; @@ -473,4 +462,14 @@ z-index: 9999; } } + + :global(.theme-dark) .tech-hero { + background: linear-gradient(to right, #19191c80, #19191c00); + backdrop-filter: blur(1rem); + -webkit-backdrop-filter: blur(1rem); + } + + :global(.theme-dark) .bg-overlay { + background: linear-gradient(to right, #19191c00 0%, #19191c00 10%, #19191c); + } diff --git a/src/routes/docs/references/[version]/[platform]/[service]/+page.svelte b/src/routes/docs/references/[version]/[platform]/[service]/+page.svelte index 64508c676b..aa020f094f 100644 --- a/src/routes/docs/references/[version]/[platform]/[service]/+page.svelte +++ b/src/routes/docs/references/[version]/[platform]/[service]/+page.svelte @@ -145,12 +145,24 @@ -
+
{@html parse(data.service?.description)}
+
+ +
+ {#if data.methods.length === 0}
@@ -190,23 +202,17 @@
-
+
    {#each method.parameters as parameter, i} {@const first = i === 0} -
  • +
  • {parameter.name} @@ -245,9 +251,7 @@
-
+
    {#each method.responses as response} {#if response.models} @@ -299,11 +303,21 @@ style="--inset-block-start:var(--p-grid-huge-navs-secondary-sticky-position);" > +
    + +
@@ -359,4 +373,29 @@ .aw-inline-code { translate: 0 0.125rem; } + + .collapsible-item { + border-block-end: 0.0625rem solid hsl(var(--aw-color-offset)); + } + + .collapsible-button { + padding-block: 1rem; + } + + .collapsible-content { + margin-block-start: 0; + padding-block-end: 1rem; + + article :last-child { + margin-block-end: 0; + } + + ul { + gap: 1rem; + + li:not(:first-child) { + border-block-start: solid 0.0625rem hsl(var(--aw-color-offset)); + } + } + } diff --git a/src/routes/docs/references/[version]/models/[model]/+page.server.ts b/src/routes/docs/references/[version]/models/[model]/+page.server.ts index a85a55f2ea..2227c15290 100644 --- a/src/routes/docs/references/[version]/models/[model]/+page.server.ts +++ b/src/routes/docs/references/[version]/models/[model]/+page.server.ts @@ -1,15 +1,6 @@ -import type { EntryGenerator, PageServerLoad } from './$types'; -import { - getApi, - getSchema, - getService, - type AppwriteSchemaObject, - getIdFromReference, - resolveReference -} from '$lib/utils/specs'; -import { Platform, Service, versions } from '$lib/utils/references'; -import { error } from '@sveltejs/kit'; +import { getApi, getIdFromReference, getSchema, type AppwriteSchemaObject } from '$lib/utils/specs'; import type { OpenAPIV3 } from 'openapi-types'; +import type { PageServerLoad } from './$types'; // export const entries: EntryGenerator = () => { // return ['cloud', ...(versions as string[])].flatMap((version) => { @@ -22,67 +13,69 @@ import type { OpenAPIV3 } from 'openapi-types'; // }; type Model = { - title: string; - properties: Array<{ - name: string; - type: string; - description: string; - example: string | boolean | number | object | Array; - items?: Array; - }>; + title: string; + properties: Array<{ + name: string; + type: string; + description: string; + example: string | boolean | number | object | Array; + items?: Array; + }>; }; export const load: PageServerLoad = async ({ params }) => { - const version = params.version === 'cloud' ? '1.4.x' : params.version; - const api = await getApi(version, 'console-web'); - const schema = getSchema(params.model, api); - const props = Object.entries(schema.properties ?? {}); - const model: Model = { - title: schema.description as string, - properties: props.map(([name, data]) => { - const property = data as AppwriteSchemaObject; - switch (property.type) { - case 'array': { - const items = []; - const propItems = property.items as AppwriteSchemaObject; - if (Array.isArray(propItems.anyOf)) { - items.push( - ...propItems.anyOf.map((ref) => getIdFromReference(ref as OpenAPIV3.ReferenceObject)) - ); - } else { - // items.push(getIdFromReference(propItems as unknown as OpenAPIV3.ReferenceObject)); - } - return { - name, - type: property.type as string, - description: property.description as string, - example: '', - items: - (property.items as AppwriteSchemaObject)?.anyOf?.map((ref) => { - const item = getIdFromReference(ref as OpenAPIV3.ReferenceObject); - return item; - }) ?? [] - }; - } + const version = params.version === 'cloud' ? '1.4.x' : params.version; + const api = await getApi(version, 'console-web'); + const schema = getSchema(params.model, api); + const props = Object.entries(schema.properties ?? {}); + const model: Model = { + title: schema.description as string, + properties: props.map(([name, data]) => { + const property = data as AppwriteSchemaObject; + switch (property.type) { + case 'array': { + const items = []; + const propItems = property.items as AppwriteSchemaObject; + if (Array.isArray(propItems.anyOf)) { + items.push( + ...propItems.anyOf.map((ref) => + getIdFromReference(ref as OpenAPIV3.ReferenceObject) + ) + ); + } else { + // items.push(getIdFromReference(propItems as unknown as OpenAPIV3.ReferenceObject)); + } + return { + name, + type: property.type as string, + description: property.description as string, + example: '', + items: + (property.items as AppwriteSchemaObject)?.anyOf?.map((ref) => { + const item = getIdFromReference(ref as OpenAPIV3.ReferenceObject); + return item; + }) ?? [] + }; + } - default: - return { - name, - type: property.type as string, - description: property.description as string, - example: property['x-example'] - }; - } - }) - }; + default: + return { + name, + type: property.type as string, + description: property.description as string, + example: property['x-example'] + }; + } + }) + }; - const example = model.properties.reduce>((carry, property) => { - carry[property.name] = property.example; + const example = model.properties.reduce>((carry, property) => { + carry[property.name] = property.example; - return carry; - }, {}); - return { - model, - example - }; + return carry; + }, {}); + return { + model, + example + }; };