mirror of
https://github.com/zoriya/elysia-swagger.git
synced 2025-12-06 00:36:10 +00:00
Merge pull request #131 from zAlweNy26/scalar_config
Update scalar configuration
This commit is contained in:
@@ -66,7 +66,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@apidevtools/swagger-parser": "^10.1.0",
|
||||
"@scalar/api-reference": "^1.12.5",
|
||||
"@scalar/api-reference": "^1.25.21",
|
||||
"@types/bun": "1.1.6",
|
||||
"elysia": ">= 1.1.0-rc.2",
|
||||
"eslint": "9.6.0",
|
||||
|
||||
@@ -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 <Path extends string = '/swagger'>(
|
||||
stringifiedSwaggerOptions,
|
||||
autoDarkMode
|
||||
)
|
||||
: ScalarRender(scalarVersion, scalarConfiguration, scalarCDN),
|
||||
: ScalarRender(info, scalarVersion, scalarConfiguration, scalarCDN),
|
||||
{
|
||||
headers: {
|
||||
'content-type': 'text/html; charset=utf8'
|
||||
|
||||
@@ -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
|
||||
) => `<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>API Reference</title>
|
||||
<title>${info.title}</title>
|
||||
<meta
|
||||
name="description"
|
||||
content="${info.description}"
|
||||
/>
|
||||
<meta
|
||||
name="og:description"
|
||||
content="${info.description}"
|
||||
/>
|
||||
<meta charset="utf-8" />
|
||||
<meta
|
||||
name="viewport"
|
||||
|
||||
@@ -1,29 +1,3 @@
|
||||
import type { MetaFlatInput } from "./unjead";
|
||||
|
||||
export type ReferenceConfiguration = {
|
||||
/** A string to use one of the color presets */
|
||||
theme?: ThemeId;
|
||||
/** The layout to use for the references */
|
||||
layout?: ReferenceLayoutType;
|
||||
/** The Swagger/OpenAPI spec to render */
|
||||
spec?: SpecConfiguration;
|
||||
/** URL to a request proxy for the API client */
|
||||
proxy?: string;
|
||||
/** Whether the spec input should show */
|
||||
isEditable?: boolean;
|
||||
/** Whether to show the sidebar */
|
||||
showSidebar?: boolean;
|
||||
/** Remove the Scalar branding :( */
|
||||
/** Key used with CNTRL/CMD to open the search modal (defaults to 'k' e.g. CMD+k) */
|
||||
searchHotKey?: string;
|
||||
/** If used, passed data will be added to the HTML header. Read more: https://unhead.unjs.io/usage/composables/use-seo-meta */
|
||||
metaData?: MetaFlatInput;
|
||||
/** Custom CSS to be added to the page */
|
||||
customCss?: string;
|
||||
/** onSpecUpdate is fired on spec/swagger content change */
|
||||
onSpecUpdate?: (spec: string) => void;
|
||||
};
|
||||
|
||||
export type SpecConfiguration = {
|
||||
/** URL to a Swagger/OpenAPI file */
|
||||
url?: string;
|
||||
|
||||
@@ -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<Path extends string = '/swagger'> {
|
||||
|
||||
Reference in New Issue
Block a user