Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ export const entries: EntryGenerator = () => {

export const load: PageServerLoad = async ({ params }) => {
const { platform, service } = params;
const version = params.version === 'cloud' ? '1.8.x' : params.version;

if (!versions.includes(version)) error(404, 'Invalid version');
if (params.version !== 'cloud' && !versions.includes(params.version)) error(404, 'Invalid version');
if (!platforms.includes(platform as Platform)) error(404, 'Invalid platform');
if (!services.includes(service as ServiceValue)) error(404, 'Invalid service');

// Convert cloud to latest after validation
const version = params.version === 'cloud' ? 'latest' : params.version;
return getService(version, platform, service);
};
25 changes: 20 additions & 5 deletions src/routes/docs/references/[version]/[platform]/[service]/specs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,21 @@ export async function getDescription(service: string) {
return descriptions[target]() as unknown as string;
}

function getContentTypeDescription(content: Record<string, any>): string {
const contentType = Object.keys(content)[0];

if (contentType === '*/*') {
const mediaTypeObject = content[contentType];
const schema = mediaTypeObject?.schema as OpenAPIV3.SchemaObject;

if (schema?.type === 'string' && schema?.format === 'binary') {
return 'application/gzip';
}
}

return contentType;
}

export async function getService(
version: string,
platform: string,
Expand Down Expand Up @@ -487,18 +502,18 @@ export async function getService(

return {
code: Number(code),
contentType: response?.content ? Object.keys(response.content)[0] : undefined,
contentType: response?.content ? getContentTypeDescription(response.content) : undefined,
models
};
}
);

const exampleVersion = version === 'latest' ? '1.7.x' : version;
const path = isAndroid
? `/node_modules/@appwrite.io/repo/docs/examples/${version}/${
? `/node_modules/@appwrite.io/repo/docs/examples/${exampleVersion}/${
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}`;

}/${isAndroidJava ? 'java' : 'kotlin'}/${operation['x-appwrite'].demo}`
: `/node_modules/@appwrite.io/repo/docs/examples/${exampleVersion}/${platform}/examples/${operation['x-appwrite'].demo}`;
if (!(path in examples)) {
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type Model = {
};

export const load: PageServerLoad = async ({ params }) => {
const version = params.version === 'cloud' ? '1.8.x' : params.version;
const version = params.version === 'cloud' ? 'latest' : params.version;
const api = await getApi(version, 'console-web');
const schema = getSchema(params.model, api);
const props = Object.entries(schema.properties ?? {});
Expand Down