@art-ws/openapi 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es/index.d.ts +1 -0
- package/dist/es/index.js +1 -0
- package/dist/es/open-api.d.ts +11 -0
- package/dist/es/open-api.js +16 -0
- package/package.json +34 -0
@@ -0,0 +1 @@
|
|
1
|
+
export * from "./open-api.js";
|
package/dist/es/index.js
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
export * from "./open-api.js";
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import type { FastifyInstance } from "@art-ws/fastify-http-server";
|
2
|
+
import { type FastifyDynamicSwaggerOptions, type SwaggerTransform } from "@fastify/swagger";
|
3
|
+
export type OpenAPIRouteSchema = ReturnType<SwaggerTransform>["schema"];
|
4
|
+
export type OpenAPIOptions = FastifyDynamicSwaggerOptions;
|
5
|
+
export declare function configureOpenAPI({ fastify, options, }: {
|
6
|
+
fastify: FastifyInstance;
|
7
|
+
options?: Partial<OpenAPIOptions>;
|
8
|
+
}): Promise<void>;
|
9
|
+
export declare function initOpenAPI({ fastify }: {
|
10
|
+
fastify: FastifyInstance;
|
11
|
+
}): Promise<void>;
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import fastifySwagger, {} from "@fastify/swagger";
|
2
|
+
import fastifyApiReference from "@scalar/fastify-api-reference";
|
3
|
+
export async function configureOpenAPI({ fastify, options, }) {
|
4
|
+
await fastify.register(fastifySwagger, {
|
5
|
+
...options,
|
6
|
+
});
|
7
|
+
await fastify.register(fastifyApiReference, {
|
8
|
+
routePrefix: "/docs",
|
9
|
+
configuration: {
|
10
|
+
pageTitle: options?.openapi?.info?.title || "API Reference",
|
11
|
+
},
|
12
|
+
});
|
13
|
+
}
|
14
|
+
export async function initOpenAPI({ fastify }) {
|
15
|
+
fastify.swagger();
|
16
|
+
}
|
package/package.json
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
{
|
2
|
+
"name": "@art-ws/openapi",
|
3
|
+
"version": "0.1.1",
|
4
|
+
"description": "OpenAPI utilities",
|
5
|
+
"license": "UNLICENSED",
|
6
|
+
"author": "Alexander Shagin",
|
7
|
+
"type": "module",
|
8
|
+
"main": "./dist/es/index.js",
|
9
|
+
"types": "dist/es",
|
10
|
+
"files": [
|
11
|
+
"./dist/*"
|
12
|
+
],
|
13
|
+
"dependencies": {
|
14
|
+
"@fastify/swagger": "9.5.1",
|
15
|
+
"@scalar/fastify-api-reference": "^1.34.6",
|
16
|
+
"@art-ws/fastify-http-server": "2.0.15"
|
17
|
+
},
|
18
|
+
"devDependencies": {
|
19
|
+
"eslint": "^9.34.0",
|
20
|
+
"typescript": "^5.9.2",
|
21
|
+
"@art-ws/config-ts": "2.0.6",
|
22
|
+
"@art-ws/config-eslint": "2.0.3"
|
23
|
+
},
|
24
|
+
"scripts": {
|
25
|
+
"build": "tsc",
|
26
|
+
"check": "pnpm clean && pnpm build && pnpm lint && pnpm test",
|
27
|
+
"clean": "rm -rf dist",
|
28
|
+
"clean:nm": "rm -rf node_modules",
|
29
|
+
"lint": "eslint .",
|
30
|
+
"test": "exit 0",
|
31
|
+
"test:watch": "vitest",
|
32
|
+
"watch": "tsc --watch"
|
33
|
+
}
|
34
|
+
}
|