mirror of
https://github.com/jakejarvis/sofa.git
synced 2026-07-14 18:15:56 -04:00
feat(docs): use parameterized OpenAPI server URL
Replace the static `https://sofa.example.com/api/v1` server entry with a variable-based URL (`{protocol}://{host}:{port}/api/v1`) so the spec works against any instance out of the box. Also move the output path from `docs/openapi.json` to `docs/public/openapi.json` so the file is served as a static asset by the docs site.
This commit is contained in:
@@ -7,7 +7,23 @@ import {
|
||||
const spec = await generateOpenApiSpec({
|
||||
title: "Sofa API",
|
||||
version: packageJson.version || "1.0.0",
|
||||
servers: [{ url: "https://sofa.example.com/api/v1" }],
|
||||
servers: [
|
||||
{
|
||||
url: "{protocol}://{host}:{port}/api/v1",
|
||||
variables: {
|
||||
protocol: {
|
||||
default: "http",
|
||||
enum: ["http", "https"],
|
||||
},
|
||||
host: {
|
||||
default: "localhost",
|
||||
},
|
||||
port: {
|
||||
default: "3000",
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
sessionCookieName: "better-auth.session_token",
|
||||
tags: [...openApiTags],
|
||||
});
|
||||
@@ -55,5 +71,5 @@ for (const pathItem of Object.values(spec.paths ?? {})) {
|
||||
}
|
||||
}
|
||||
|
||||
await Bun.write("docs/openapi.json", JSON.stringify(spec, null, 2));
|
||||
await Bun.write("docs/public/openapi.json", JSON.stringify(spec, null, 2));
|
||||
console.log("OpenAPI spec written to docs/openapi.json");
|
||||
|
||||
Reference in New Issue
Block a user