mirror of
https://github.com/hanzo-docs/docs.git
synced 2026-10-25 04:20:02 +00:00
OpenAPI: Remove support for bin usages
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
---
|
||||
'fumadocs-openapi': major
|
||||
---
|
||||
|
||||
**Remove support for bin usages**
|
||||
|
||||
why: It is more flexible and faster to write a script directly.
|
||||
|
||||
migrate: Create a script named `scripts/generate-docs.mjs`:
|
||||
|
||||
```js
|
||||
import { generateFiles } from 'fumadocs-openapi';
|
||||
|
||||
void generateFiles({
|
||||
input: ['./petstore.yaml'],
|
||||
output: './content/docs',
|
||||
});
|
||||
```
|
||||
|
||||
Execute it with `node ./scripts/generate-docs.mjs`.
|
||||
@@ -11,28 +11,27 @@ Install the required packages.
|
||||
fumadocs-openapi
|
||||
```
|
||||
|
||||
Create configuration file:
|
||||
Create a script:
|
||||
|
||||
```js title="openapi.config.js"
|
||||
/**
|
||||
* @type {import("fumadocs-openapi").Config}
|
||||
*/
|
||||
module.exports = {
|
||||
```js title="scripts/generate-docs.mjs"
|
||||
import { generateFiles } from 'fumadocs-openapi';
|
||||
|
||||
void generateFiles({
|
||||
input: ['./petstore.yaml'],
|
||||
output: './content/docs',
|
||||
};
|
||||
});
|
||||
```
|
||||
|
||||
> Only OpenAPI 3.0 is supported.
|
||||
>
|
||||
> It doesn't allow JSON schema specific keywords like `const`, as [they are unsupported](https://swagger.io/docs/specification/data-models/keywords)
|
||||
|
||||
Generate docs with a command:
|
||||
Generate docs with the script:
|
||||
|
||||
```bash
|
||||
pnpm fumadocs-openapi
|
||||
node ./scripts/generate-docs.mjs
|
||||
```
|
||||
|
||||
### Demo
|
||||
|
||||
[View demo](/docs/ui/museum)
|
||||
[View demo](/docs/ui/museum).
|
||||
|
||||
@@ -13,9 +13,6 @@
|
||||
"type": "module",
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
"bin": {
|
||||
"fumadocs-openapi": "./dist/bin.js"
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
import { resolve } from 'node:path';
|
||||
import { pathToFileURL } from 'node:url';
|
||||
import { generateFiles, type Config } from './generate-file';
|
||||
|
||||
async function main(): Promise<void> {
|
||||
const configName = process.argv[2];
|
||||
const config = await readConfig(configName);
|
||||
|
||||
await generateFiles(config);
|
||||
}
|
||||
|
||||
async function readConfig(name = 'openapi.config.js'): Promise<Config> {
|
||||
const path = resolve(process.cwd(), name);
|
||||
const result = (await import(pathToFileURL(path).href)) as {
|
||||
default: Config;
|
||||
};
|
||||
|
||||
if (typeof result.default !== 'object')
|
||||
throw new Error('Invalid configuration');
|
||||
|
||||
return result.default;
|
||||
}
|
||||
|
||||
void main();
|
||||
@@ -1,7 +1,7 @@
|
||||
import { defineConfig } from 'tsup';
|
||||
|
||||
export default defineConfig({
|
||||
entry: ['./src/index.ts', './src/bin.ts'],
|
||||
entry: ['./src/index.ts'],
|
||||
format: 'esm',
|
||||
dts: true,
|
||||
target: 'node18',
|
||||
|
||||
Reference in New Issue
Block a user