diff --git a/bun.lockb b/bun.lockb index 833d9fe..0d80859 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index 9031870..79f024f 100644 --- a/package.json +++ b/package.json @@ -1,81 +1,81 @@ { - "name": "@elysiajs/swagger", - "version": "1.1.0", - "description": "Plugin for Elysia to auto-generate Swagger page", - "author": { - "name": "saltyAom", - "url": "https://github.com/SaltyAom", - "email": "saltyaom@gmail.com" + "name": "@elysiajs/swagger", + "version": "1.1.0", + "description": "Plugin for Elysia to auto-generate Swagger page", + "author": { + "name": "saltyAom", + "url": "https://github.com/SaltyAom", + "email": "saltyaom@gmail.com" + }, + "main": "./dist/cjs/index.js", + "module": "./dist/index.mjs", + "types": "./dist/index.d.ts", + "exports": { + "./package.json": "./package.json", + ".": { + "types": "./dist/index.d.ts", + "import": "./dist/index.mjs", + "require": "./dist/cjs/index.js" }, - "main": "./dist/cjs/index.js", - "module": "./dist/index.mjs", - "types": "./dist/index.d.ts", - "exports": { - "./package.json": "./package.json", - ".": { - "types": "./dist/index.d.ts", - "import": "./dist/index.mjs", - "require": "./dist/cjs/index.js" - }, - "./types": { - "types": "./dist/types.d.ts", - "import": "./dist/types.mjs", - "require": "./dist/cjs/types.js" - }, - "./utils": { - "types": "./dist/utils.d.ts", - "import": "./dist/utils.mjs", - "require": "./dist/cjs/utils.js" - }, - "./scalar": { - "types": "./dist/scalar/index.d.ts", - "import": "./dist/scalar/index.mjs", - "require": "./dist/cjs/scalar/index.js" - }, - "./scalar/theme": { - "types": "./dist/scalar/theme.d.ts", - "import": "./dist/scalar/theme.mjs", - "require": "./dist/cjs/scalar/theme.js" - }, - "./scalar/types": { - "types": "./dist/scalar/types/index.d.ts", - "import": "./dist/scalar/types/index.mjs", - "require": "./dist/cjs/scalar/types/index.js" - } + "./types": { + "types": "./dist/types.d.ts", + "import": "./dist/types.mjs", + "require": "./dist/cjs/types.js" }, - "keywords": [ - "elysia", - "swagger" - ], - "homepage": "https://github.com/elysiajs/elysia-swagger", - "repository": { - "type": "git", - "url": "https://github.com/elysiajs/elysia-swagger" + "./utils": { + "types": "./dist/utils.d.ts", + "import": "./dist/utils.mjs", + "require": "./dist/cjs/utils.js" }, - "bugs": "https://github.com/elysiajs/elysia-swagger/issues", - "license": "MIT", - "scripts": { - "dev": "bun run --watch example/index.ts", - "test": "bun test && npm run test:node", - "test:node": "npm install --prefix ./test/node/cjs/ && npm install --prefix ./test/node/esm/ && node ./test/node/cjs/index.js && node ./test/node/esm/index.js", - "build": "bun build.ts", - "release": "npm run build && npm run test && npm publish --access public" + "./scalar": { + "types": "./dist/scalar/index.d.ts", + "import": "./dist/scalar/index.mjs", + "require": "./dist/cjs/scalar/index.js" }, - "peerDependencies": { - "elysia": ">= 1.1.0" + "./scalar/theme": { + "types": "./dist/scalar/theme.d.ts", + "import": "./dist/scalar/theme.mjs", + "require": "./dist/cjs/scalar/theme.js" }, - "devDependencies": { - "@apidevtools/swagger-parser": "^10.1.0", - "@scalar/api-reference": "^1.12.5", - "@types/bun": "1.1.6", - "@types/lodash.clonedeep": "^4.5.9", - "elysia": ">= 1.1.0-rc.2", - "eslint": "9.6.0", - "tsup": "^8.1.0", - "typescript": "^5.5.3" - }, - "dependencies": { - "lodash.clonedeep": "^4.5.0", - "openapi-types": "^12.1.3" + "./scalar/types": { + "types": "./dist/scalar/types/index.d.ts", + "import": "./dist/scalar/types/index.mjs", + "require": "./dist/cjs/scalar/types/index.js" } + }, + "keywords": [ + "elysia", + "swagger" + ], + "homepage": "https://github.com/elysiajs/elysia-swagger", + "repository": { + "type": "git", + "url": "https://github.com/elysiajs/elysia-swagger" + }, + "bugs": "https://github.com/elysiajs/elysia-swagger/issues", + "license": "MIT", + "scripts": { + "dev": "bun run --watch example/index.ts", + "test": "bun test && npm run test:node", + "test:node": "npm install --prefix ./test/node/cjs/ && npm install --prefix ./test/node/esm/ && node ./test/node/cjs/index.js && node ./test/node/esm/index.js", + "build": "bun build.ts", + "release": "npm run build && npm run test && npm publish --access public" + }, + "peerDependencies": { + "elysia": ">= 1.1.0" + }, + "devDependencies": { + "@apidevtools/swagger-parser": "^10.1.0", + "@scalar/api-reference": "^1.24.68", + "@types/bun": "1.1.6", + "@types/lodash.clonedeep": "^4.5.9", + "elysia": ">= 1.1.0-rc.2", + "eslint": "9.6.0", + "tsup": "^8.1.0", + "typescript": "^5.5.3" + }, + "dependencies": { + "lodash.clonedeep": "^4.5.0", + "openapi-types": "^12.1.3" + } } \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index 7fdb2c9..d047645 100644 --- a/src/index.ts +++ b/src/index.ts @@ -7,7 +7,7 @@ import { ScalarRender } from './scalar' import { filterPaths, registerSchemaPath } from './utils' import type { OpenAPIV3 } from 'openapi-types' -import type { ReferenceConfiguration } from './scalar/types' +import type { ReferenceConfiguration } from '@scalar/api-reference' import type { ElysiaSwaggerConfig } from './types' /** @@ -97,7 +97,7 @@ export const swagger = async ( stringifiedSwaggerOptions, autoDarkMode ) - : ScalarRender(scalarVersion, scalarConfiguration, scalarCDN), + : ScalarRender(info, scalarVersion, scalarConfiguration, scalarCDN), { headers: { 'content-type': 'text/html; charset=utf8' diff --git a/src/scalar/index.ts b/src/scalar/index.ts index c9e02d0..fbe8558 100644 --- a/src/scalar/index.ts +++ b/src/scalar/index.ts @@ -1,14 +1,24 @@ import scalarElysiaTheme from './theme' -import type { ReferenceConfiguration } from './types' +import type { OpenAPIV3 } from 'openapi-types' +import type { ReferenceConfiguration } from '@scalar/api-reference' export const ScalarRender = ( + info: OpenAPIV3.InfoObject, version: string, config: ReferenceConfiguration, cdn: string ) => ` - API Reference + ${info.title} + + void; -}; - export type SpecConfiguration = { /** URL to a Swagger/OpenAPI file */ url?: string; diff --git a/src/types.ts b/src/types.ts index 1c41e04..7f21ecd 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,5 +1,5 @@ import type { OpenAPIV3 } from 'openapi-types' -import type { ReferenceConfiguration } from './scalar/types' +import type { ReferenceConfiguration } from '@scalar/api-reference' import type { SwaggerUIOptions } from './swagger/types' export interface ElysiaSwaggerConfig {