File tree Expand file tree Collapse file tree 5 files changed +16
-19
lines changed Expand file tree Collapse file tree 5 files changed +16
-19
lines changed Original file line number Diff line number Diff line change 6868 "typescript" : " ^5.5.3"
6969 },
7070 "dependencies" : {
71- "@scalar/themes" : " ^0.9.52 " ,
72- "@scalar/types" : " ^0.0.12 " ,
71+ "@scalar/themes" : " ^0.9.81 " ,
72+ "@scalar/types" : " ^0.1.3 " ,
7373 "openapi-types" : " ^12.1.3" ,
7474 "pathe" : " ^1.1.2"
7575 }
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ import { ScalarRender } from './scalar'
77import { filterPaths , registerSchemaPath } from './utils'
88
99import type { OpenAPIV3 } from 'openapi-types'
10- import type { ReferenceConfiguration } from '@scalar/types'
10+ import type { ApiReferenceConfigurationWithSources } from '@scalar/types/api-reference' with { "resolution-mode" : "import" } ;
1111import type { ElysiaSwaggerConfig } from './types'
1212
1313/**
@@ -82,14 +82,11 @@ export const swagger = async <Path extends string = '/swagger'>(
8282 }
8383 )
8484
85- const scalarConfiguration : ReferenceConfiguration = {
86- spec : {
87- ...scalarConfig . spec ,
88- url : `${ new URL ( request . url ) . pathname . replace ( / \/ $ / , "" ) } /json`
89- } ,
85+ const scalarConfiguration : Partial < ApiReferenceConfigurationWithSources > = {
86+ sources : [ { url : `${ new URL ( request . url ) . pathname . replace ( / \/ $ / , "" ) } /json` } ] ,
87+ // allow scalarConfig to override sources if they want to define more than one
9088 ...scalarConfig ,
9189 // so we can showcase the elysia theme
92- // @ts -expect-error
9390 _integration : 'elysiajs'
9491 }
9592
Original file line number Diff line number Diff line change 11import { elysiajsTheme } from '@scalar/themes'
22import type { OpenAPIV3 } from 'openapi-types'
3- import type { ReferenceConfiguration } from '@scalar/types'
3+ import type { ApiReferenceConfigurationWithSources } from '@scalar/types/api-reference' with { "resolution-mode" : "import" } ;
44
55export const ScalarRender = (
66 info : OpenAPIV3 . InfoObject ,
77 version : string ,
8- config : ReferenceConfiguration ,
8+ config : Partial < ApiReferenceConfigurationWithSources > ,
99 cdn : string
1010) => `<!doctype html>
1111<html>
@@ -33,16 +33,16 @@ export const ScalarRender = (
3333 </style>
3434 </head>
3535 <body>
36- <script
37- id="api-reference"
38- data-url="${ config . spec ?. url } "
39- data-configuration='${ JSON . stringify ( config ) } '
40- >
41- </script>
36+ <div id="app"></div>
37+
4238 <script src="${
4339 cdn
4440 ? cdn
4541 : `https://cdn.jsdelivr.net/npm/@scalar/api-reference@${ version } /dist/browser/standalone.min.js`
4642 } " crossorigin></script>
43+
44+ <script>
45+ Scalar.createApiReference('#app', ${ JSON . stringify ( config ) } )
46+ </script>
4747 </body>
4848</html>`
Original file line number Diff line number Diff line change 11import type { OpenAPIV3 } from 'openapi-types'
2- import type { ReferenceConfiguration } from '@scalar/types'
2+ import type { ApiReferenceConfigurationWithSources } from '@scalar/types/api-reference' with { "resolution-mode" : "import" } ;
33import type { SwaggerUIOptions } from './swagger/types'
44
55export interface ElysiaSwaggerConfig < Path extends string = '/swagger' > {
@@ -46,7 +46,7 @@ export interface ElysiaSwaggerConfig<Path extends string = '/swagger'> {
4646 *'
4747 * @see https://github.com/scalar/scalar/blob/main/documentation/configuration.md
4848 */
49- scalarConfig ?: ReferenceConfiguration
49+ scalarConfig ?: Partial < ApiReferenceConfigurationWithSources >
5050 /**
5151 * Version to use for swagger cdn bundle
5252 *
You can’t perform that action at this time.
0 commit comments