Skip to content

Commit cdb1522

Browse files
authored
Merge pull request #131 from zAlweNy26/scalar_config
Update scalar configuration
2 parents cf53c6e + 608ea8a commit cdb1522

File tree

6 files changed

+16
-32
lines changed

6 files changed

+16
-32
lines changed

bun.lockb

-159 KB
Binary file not shown.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
},
6767
"devDependencies": {
6868
"@apidevtools/swagger-parser": "^10.1.0",
69-
"@scalar/api-reference": "^1.12.5",
69+
"@scalar/api-reference": "^1.25.21",
7070
"@types/bun": "1.1.6",
7171
"elysia": ">= 1.1.0-rc.2",
7272
"eslint": "9.6.0",

src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { ScalarRender } from './scalar'
77
import { filterPaths, registerSchemaPath } from './utils'
88

99
import type { OpenAPIV3 } from 'openapi-types'
10-
import type { ReferenceConfiguration } from './scalar/types'
10+
import type { ReferenceConfiguration } from '@scalar/api-reference'
1111
import type { ElysiaSwaggerConfig } from './types'
1212

1313
/**
@@ -97,7 +97,7 @@ export const swagger = async <Path extends string = '/swagger'>(
9797
stringifiedSwaggerOptions,
9898
autoDarkMode
9999
)
100-
: ScalarRender(scalarVersion, scalarConfiguration, scalarCDN),
100+
: ScalarRender(info, scalarVersion, scalarConfiguration, scalarCDN),
101101
{
102102
headers: {
103103
'content-type': 'text/html; charset=utf8'

src/scalar/index.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,24 @@
11
import scalarElysiaTheme from './theme'
2-
import type { ReferenceConfiguration } from './types'
2+
import type { OpenAPIV3 } from 'openapi-types'
3+
import type { ReferenceConfiguration } from '@scalar/api-reference'
34

45
export const ScalarRender = (
6+
info: OpenAPIV3.InfoObject,
57
version: string,
68
config: ReferenceConfiguration,
79
cdn: string
810
) => `<!doctype html>
911
<html>
1012
<head>
11-
<title>API Reference</title>
13+
<title>${info.title}</title>
14+
<meta
15+
name="description"
16+
content="${info.description}"
17+
/>
18+
<meta
19+
name="og:description"
20+
content="${info.description}"
21+
/>
1222
<meta charset="utf-8" />
1323
<meta
1424
name="viewport"

src/scalar/types/index.ts

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,3 @@
1-
import type { MetaFlatInput } from "./unjead";
2-
3-
export type ReferenceConfiguration = {
4-
/** A string to use one of the color presets */
5-
theme?: ThemeId;
6-
/** The layout to use for the references */
7-
layout?: ReferenceLayoutType;
8-
/** The Swagger/OpenAPI spec to render */
9-
spec?: SpecConfiguration;
10-
/** URL to a request proxy for the API client */
11-
proxy?: string;
12-
/** Whether the spec input should show */
13-
isEditable?: boolean;
14-
/** Whether to show the sidebar */
15-
showSidebar?: boolean;
16-
/** Remove the Scalar branding :( */
17-
/** Key used with CNTRL/CMD to open the search modal (defaults to 'k' e.g. CMD+k) */
18-
searchHotKey?: string;
19-
/** If used, passed data will be added to the HTML header. Read more: https://unhead.unjs.io/usage/composables/use-seo-meta */
20-
metaData?: MetaFlatInput;
21-
/** Custom CSS to be added to the page */
22-
customCss?: string;
23-
/** onSpecUpdate is fired on spec/swagger content change */
24-
onSpecUpdate?: (spec: string) => void;
25-
};
26-
271
export type SpecConfiguration = {
282
/** URL to a Swagger/OpenAPI file */
293
url?: string;

src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { OpenAPIV3 } from 'openapi-types'
2-
import type { ReferenceConfiguration } from './scalar/types'
2+
import type { ReferenceConfiguration } from '@scalar/api-reference'
33
import type { SwaggerUIOptions } from './swagger/types'
44

55
export interface ElysiaSwaggerConfig<Path extends string = '/swagger'> {

0 commit comments

Comments
 (0)