diff --git a/bun.lock b/bun.lock index 95ca0d9..5de2b21 100644 --- a/bun.lock +++ b/bun.lock @@ -4,8 +4,8 @@ "": { "name": "@elysiajs/swagger", "dependencies": { - "@scalar/themes": "^0.9.52", - "@scalar/types": "^0.0.12", + "@scalar/themes": "^0.9.81", + "@scalar/types": "^0.1.3", "openapi-types": "^12.1.3", "pathe": "^1.1.2", }, @@ -159,11 +159,11 @@ "@rollup/rollup-win32-x64-msvc": ["@rollup/rollup-win32-x64-msvc@4.40.1", "", { "os": "win32", "cpu": "x64" }, "sha512-ECyOuDeH3C1I8jH2MK1RtBJW+YPMvSfT0a5NN0nHfQYnDSJ6tUiZH3gzwVP5/Kfh/+Tt7tpWVF9LXNTnhTJ3kA=="], - "@scalar/openapi-types": ["@scalar/openapi-types@0.1.1", "", {}, "sha512-NMy3QNk6ytcCoPUGJH0t4NNr36OWXgZhA3ormr3TvhX1NDgoF95wFyodGVH8xiHeUyn2/FxtETm8UBLbB5xEmg=="], + "@scalar/openapi-types": ["@scalar/openapi-types@0.2.0", "", { "dependencies": { "zod": "^3.23.8" } }, "sha512-waiKk12cRCqyUCWTOX0K1WEVX46+hVUK+zRPzAahDJ7G0TApvbNkuy5wx7aoUyEk++HHde0XuQnshXnt8jsddA=="], "@scalar/themes": ["@scalar/themes@0.9.86", "", { "dependencies": { "@scalar/types": "0.1.7" } }, "sha512-QUHo9g5oSWi+0Lm1vJY9TaMZRau8LHg+vte7q5BVTBnu6NuQfigCaN+ouQ73FqIVd96TwMO6Db+dilK1B+9row=="], - "@scalar/types": ["@scalar/types@0.0.12", "", { "dependencies": { "@scalar/openapi-types": "0.1.1", "@unhead/schema": "^1.9.5" } }, "sha512-XYZ36lSEx87i4gDqopQlGCOkdIITHHEvgkuJFrXFATQs9zHARop0PN0g4RZYWj+ZpCUclOcaOjbCt8JGe22mnQ=="], + "@scalar/types": ["@scalar/types@0.1.7", "", { "dependencies": { "@scalar/openapi-types": "0.2.0", "@unhead/schema": "^1.11.11", "nanoid": "^5.1.5", "type-fest": "^4.20.0", "zod": "^3.23.8" } }, "sha512-irIDYzTQG2KLvFbuTI8k2Pz/R4JR+zUUSykVTbEMatkzMmVFnn1VzNSMlODbadycwZunbnL2tA27AXed9URVjw=="], "@sinclair/typebox": ["@sinclair/typebox@0.34.33", "", {}, "sha512-5HAV9exOMcXRUxo+9iYB5n09XxzCXnfy4VTNW4xnDv+FgjzAGY989C28BIdljKqmF+ZltUwujE3aossvcVtq6g=="], @@ -475,8 +475,6 @@ "@isaacs/cliui/strip-ansi": ["strip-ansi@7.1.0", "", { "dependencies": { "ansi-regex": "^6.0.1" } }, "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ=="], - "@scalar/themes/@scalar/types": ["@scalar/types@0.1.7", "", { "dependencies": { "@scalar/openapi-types": "0.2.0", "@unhead/schema": "^1.11.11", "nanoid": "^5.1.5", "type-fest": "^4.20.0", "zod": "^3.23.8" } }, "sha512-irIDYzTQG2KLvFbuTI8k2Pz/R4JR+zUUSykVTbEMatkzMmVFnn1VzNSMlODbadycwZunbnL2tA27AXed9URVjw=="], - "eslint/ajv": ["ajv@6.12.6", "", { "dependencies": { "fast-deep-equal": "^3.1.1", "fast-json-stable-stringify": "^2.0.0", "json-schema-traverse": "^0.4.1", "uri-js": "^4.2.2" } }, "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g=="], "glob/minimatch": ["minimatch@9.0.5", "", { "dependencies": { "brace-expansion": "^2.0.1" } }, "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow=="], @@ -497,8 +495,6 @@ "@isaacs/cliui/strip-ansi/ansi-regex": ["ansi-regex@6.1.0", "", {}, "sha512-7HSX4QQb4CspciLpVFwyRe79O3xsIZDDLER21kERQ71oaPodF8jL725AgJMFAYbooIqolJoRLuM81SpeUkpkvA=="], - "@scalar/themes/@scalar/types/@scalar/openapi-types": ["@scalar/openapi-types@0.2.0", "", { "dependencies": { "zod": "^3.23.8" } }, "sha512-waiKk12cRCqyUCWTOX0K1WEVX46+hVUK+zRPzAahDJ7G0TApvbNkuy5wx7aoUyEk++HHde0XuQnshXnt8jsddA=="], - "eslint/ajv/json-schema-traverse": ["json-schema-traverse@0.4.1", "", {}, "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg=="], "glob/minimatch/brace-expansion": ["brace-expansion@2.0.1", "", { "dependencies": { "balanced-match": "^1.0.0" } }, "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA=="], diff --git a/package.json b/package.json index de1a9ad..0979be6 100644 --- a/package.json +++ b/package.json @@ -68,8 +68,8 @@ "typescript": "^5.5.3" }, "dependencies": { - "@scalar/themes": "^0.9.52", - "@scalar/types": "^0.0.12", + "@scalar/themes": "^0.9.81", + "@scalar/types": "^0.1.3", "openapi-types": "^12.1.3", "pathe": "^1.1.2" } diff --git a/src/index.ts b/src/index.ts index 4fc45df..7a2c41f 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 { ApiReferenceConfigurationWithSources } from '@scalar/types/api-reference' with { "resolution-mode": "import" }; import type { ElysiaSwaggerConfig } from './types' /** @@ -45,8 +45,6 @@ export const swagger = ({ ...documentation.info } - const relativePath = path.startsWith('/') ? path.slice(1) : path - const app = new Elysia({ name: '@elysiajs/swagger' }) const page = new Response( @@ -70,15 +68,11 @@ export const swagger = ({ info, scalarVersion, { - spec: { - ...scalarConfig.spec, - url: specPath - }, + sources: [{url: specPath}], ...scalarConfig, // so we can showcase the elysia theme - // @ts-expect-error _integration: 'elysiajs' - } satisfies ReferenceConfiguration, + } satisfies Partial, scalarCDN ), { diff --git a/src/scalar/index.ts b/src/scalar/index.ts index 883ea66..3fa69d5 100644 --- a/src/scalar/index.ts +++ b/src/scalar/index.ts @@ -1,11 +1,11 @@ import { elysiajsTheme } from '@scalar/themes' import type { OpenAPIV3 } from 'openapi-types' -import type { ReferenceConfiguration } from '@scalar/types' +import type { ApiReferenceConfigurationWithSources } from '@scalar/types/api-reference' with { "resolution-mode": "import" }; export const ScalarRender = ( info: OpenAPIV3.InfoObject, version: string, - config: ReferenceConfiguration, + config: Partial, cdn: string ) => ` @@ -33,16 +33,16 @@ export const ScalarRender = ( - +
+ + + ` diff --git a/src/types.ts b/src/types.ts index ce16c26..a900070 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 { ApiReferenceConfigurationWithSources } from '@scalar/types/api-reference' with { "resolution-mode": "import" }; import type { SwaggerUIOptions } from './swagger/types' export interface ElysiaSwaggerConfig { @@ -46,7 +46,7 @@ export interface ElysiaSwaggerConfig { *' * @see https://github.com/scalar/scalar/blob/main/documentation/configuration.md */ - scalarConfig?: ReferenceConfiguration + scalarConfig?: Partial /** * Version to use for swagger cdn bundle *