stack/packages/stack-server/scripts/generate-docs.ts
Zai Shi 019738aa64
Added fern docs (#76)
* adding openapi generation

* added optional responses

* added path params

* added request body

* added full openapi file

* fixed crud bug

* fixed small bugs

* added generate-docs script

* added parameter example

* create docs from handler

* improved parse openapi interface

* removed unused

* added endpoint metadata

* added current user handler

* migrated old docs to fern

* 🌿 api set-up (#75)

Co-authored-by: Catherine Deskur <chdeskur@gmail.com>

* added sdk docs

* updated tabs

* improved styling

* added header links

* added tags to docs

* added focus to docs

* added focus to team docs

* improved docs wording

* added discord link

* updated generate-keys docs

* fixed merge error

* added yaml package

* added github actions

* fixed doc gen bug

* added docs lint check

* added doc watch changes

* updated github actions

* fixed action file

* updated publish docs workflow

* added overview page

* fixed action bug

---------

Co-authored-by: fern <126544928+fern-bot@users.noreply.github.com>
Co-authored-by: Catherine Deskur <chdeskur@gmail.com>
2024-06-15 14:04:00 +02:00

30 lines
809 B
TypeScript

import { currentUserCrudHandlers } from '@/app/api/v1/current-user/crud';
import { usersCrudHandlers } from '@/app/api/v1/users/crud';
import { parseOpenAPI } from '@/lib/openapi';
import yaml from 'yaml';
import fs from 'fs';
for (const audience of ['client', 'server'] as const) {
const openAPISchema = yaml.stringify(parseOpenAPI({
endpointOptions: [
{
handler: usersCrudHandlers.listHandler,
path: '/users',
tags: ['Users'],
},
{
handler: usersCrudHandlers,
path: '/users/{userId}',
tags: ['Users'],
},
{
handler: currentUserCrudHandlers,
path: '/current-user',
tags: ['Users'],
}
],
audience,
}));
fs.writeFileSync(`../../docs/fern/openapi/${audience}.yaml`, openAPISchema);
}