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 68
68
"typescript" : " ^5.5.3"
69
69
},
70
70
"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 " ,
73
73
"openapi-types" : " ^12.1.3" ,
74
74
"pathe" : " ^1.1.2"
75
75
}
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ import { ScalarRender } from './scalar'
7
7
import { filterPaths , registerSchemaPath } from './utils'
8
8
9
9
import 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" } ;
11
11
import type { ElysiaSwaggerConfig } from './types'
12
12
13
13
/**
@@ -82,14 +82,11 @@ export const swagger = async <Path extends string = '/swagger'>(
82
82
}
83
83
)
84
84
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
90
88
...scalarConfig ,
91
89
// so we can showcase the elysia theme
92
- // @ts -expect-error
93
90
_integration : 'elysiajs'
94
91
}
95
92
Original file line number Diff line number Diff line change 1
1
import { elysiajsTheme } from '@scalar/themes'
2
2
import 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" } ;
4
4
5
5
export const ScalarRender = (
6
6
info : OpenAPIV3 . InfoObject ,
7
7
version : string ,
8
- config : ReferenceConfiguration ,
8
+ config : Partial < ApiReferenceConfigurationWithSources > ,
9
9
cdn : string
10
10
) => `<!doctype html>
11
11
<html>
@@ -33,16 +33,16 @@ export const ScalarRender = (
33
33
</style>
34
34
</head>
35
35
<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
+
42
38
<script src="${
43
39
cdn
44
40
? cdn
45
41
: `https://cdn.jsdelivr.net/npm/@scalar/api-reference@${ version } /dist/browser/standalone.min.js`
46
42
} " crossorigin></script>
43
+
44
+ <script>
45
+ Scalar.createApiReference('#app', ${ JSON . stringify ( config ) } )
46
+ </script>
47
47
</body>
48
48
</html>`
Original file line number Diff line number Diff line change 1
1
import 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" } ;
3
3
import type { SwaggerUIOptions } from './swagger/types'
4
4
5
5
export interface ElysiaSwaggerConfig < Path extends string = '/swagger' > {
@@ -46,7 +46,7 @@ export interface ElysiaSwaggerConfig<Path extends string = '/swagger'> {
46
46
*'
47
47
* @see https://github.com/scalar/scalar/blob/main/documentation/configuration.md
48
48
*/
49
- scalarConfig ?: ReferenceConfiguration
49
+ scalarConfig ?: Partial < ApiReferenceConfigurationWithSources >
50
50
/**
51
51
* Version to use for swagger cdn bundle
52
52
*
You can’t perform that action at this time.
0 commit comments