Skip to content

Commit 11d968c

Browse files
committed
🎉 release: 1.1.1
1 parent bf58e93 commit 11d968c

File tree

14 files changed

+1625
-2
lines changed

14 files changed

+1625
-2
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# 1.1.1 - 12 Aug 2024
2+
Feature:
3+
- add hide flag
14

25
# 1.1.0 - 16 Jul 2024
36
Change:

generated/index.d.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { Elysia } from 'elysia';
2+
declare const app: Elysia<"", false, {
3+
decorator: {};
4+
store: {};
5+
derive: {};
6+
resolve: {};
7+
}, {
8+
type: {};
9+
error: {};
10+
}, {
11+
schema: {};
12+
macro: {};
13+
macroFn: {};
14+
}, {
15+
id: {
16+
":id?": {
17+
get: {
18+
body: unknown;
19+
params: {
20+
id?: string;
21+
};
22+
query: unknown;
23+
headers: unknown;
24+
response: {
25+
200: "a";
26+
};
27+
};
28+
};
29+
};
30+
}, {
31+
derive: {};
32+
resolve: {};
33+
schema: {};
34+
}, {
35+
derive: {};
36+
resolve: {};
37+
schema: {};
38+
}>;
39+
export type app = typeof app;
40+
export {};

generated/plugin.d.ts

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
import { Elysia } from 'elysia';
2+
export declare const plugin: Elysia<"/a", false, {
3+
decorator: {};
4+
store: {};
5+
derive: {};
6+
resolve: {};
7+
}, {
8+
type: {
9+
readonly sign: {
10+
username: string;
11+
password: string;
12+
};
13+
readonly number: number;
14+
};
15+
error: {};
16+
}, {
17+
schema: {};
18+
macro: {};
19+
macroFn: {};
20+
}, {
21+
a: {
22+
index: {
23+
get: {
24+
body: unknown;
25+
params: {};
26+
query: unknown;
27+
headers: unknown;
28+
response: {
29+
200: string;
30+
};
31+
};
32+
};
33+
};
34+
} & {
35+
a: {
36+
unpath: {
37+
":id": {
38+
get: {
39+
body: unknown;
40+
params: {
41+
id: string;
42+
};
43+
query: unknown;
44+
headers: unknown;
45+
response: {
46+
200: string;
47+
};
48+
};
49+
};
50+
};
51+
};
52+
} & {
53+
a: {
54+
json: {
55+
post: {
56+
body: unknown;
57+
params: {};
58+
query: unknown;
59+
headers: unknown;
60+
response: {
61+
200: unknown;
62+
};
63+
};
64+
};
65+
};
66+
} & {
67+
a: {
68+
json: {
69+
":id": {
70+
post: {
71+
body: unknown;
72+
params: {
73+
id: string;
74+
};
75+
query: unknown;
76+
headers: unknown;
77+
response: {
78+
200: unknown;
79+
418: unknown;
80+
};
81+
};
82+
};
83+
};
84+
};
85+
} & {
86+
a: {
87+
file: {
88+
post: {
89+
body: unknown;
90+
params: {};
91+
query: unknown;
92+
headers: unknown;
93+
response: {
94+
200: unknown;
95+
};
96+
};
97+
};
98+
};
99+
}, {
100+
derive: {};
101+
resolve: {};
102+
schema: {};
103+
}, {
104+
derive: {};
105+
resolve: {};
106+
schema: {};
107+
}>;

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@elysiajs/swagger",
3-
"version": "1.1.0",
3+
"version": "1.1.1",
44
"description": "Plugin for Elysia to auto-generate Swagger page",
55
"author": {
66
"name": "saltyAom",
@@ -78,4 +78,4 @@
7878
"lodash.clonedeep": "^4.5.0",
7979
"openapi-types": "^12.1.3"
8080
}
81-
}
81+
}

src/codegen.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// import { TypeScriptToModel, ModelToJsonSchema } from '@sinclair/typebox-codegen'
2+
// import { cwd } from 'process'
3+
// import { join } from 'path'
4+
5+
// // await Bun.$` tsc example/index.ts --declaration --emitDeclarationOnly --esModuleInterop --skipLibCheck --declarationDir generated --rootDir example`
6+
7+
// // Bun.file(join(cwd(), 'generated/index.d.ts'))
8+
9+
// const type = TypeScriptToModel.Generate(`
10+
// type A = {
11+
// body: unknown;
12+
// params: {
13+
// id?: string;
14+
// };
15+
// query: unknown;
16+
// headers: unknown;
17+
// response: {
18+
// 200: "a";
19+
// };
20+
// }
21+
// `)
22+
23+
// console.dir(type, { depth: null })

src/index.d.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { Elysia } from 'elysia';
2+
import type { ElysiaSwaggerConfig } from './types';
3+
/**
4+
* Plugin for [elysia](https://github.com/elysiajs/elysia) that auto-generate Swagger page.
5+
*
6+
* @see https://github.com/elysiajs/elysia-swagger
7+
*/
8+
export declare const swagger: <Path extends string = "/swagger">({ provider, scalarVersion, scalarCDN, scalarConfig, documentation, version, excludeStaticFile, path, exclude, swaggerOptions, theme, autoDarkMode, excludeMethods, excludeTags }?: ElysiaSwaggerConfig<Path>) => Promise<Elysia<"", false, {
9+
decorator: {};
10+
store: {};
11+
derive: {};
12+
resolve: {};
13+
}, {
14+
type: {};
15+
error: {};
16+
}, {
17+
schema: {};
18+
macro: {};
19+
macroFn: {};
20+
}, {}, {
21+
derive: {};
22+
resolve: {};
23+
schema: {};
24+
}, {
25+
derive: {};
26+
resolve: {};
27+
schema: {};
28+
}>>;
29+
export type { ElysiaSwaggerConfig };
30+
export default swagger;

src/scalar/index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import type { ReferenceConfiguration } from './types';
2+
export declare const ScalarRender: (version: string, config: ReferenceConfiguration, cdn: string) => string;

src/scalar/theme.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
declare const _default: "\n/* basic theme */\n.light-mode {\n --theme-color-1: #2a2f45;\n --theme-color-2: #757575;\n --theme-color-3: #8e8e8e;\n --theme-color-accent: #f06292;\n\n --theme-background-1: #fff;\n --theme-background-2: #f6f6f6;\n --theme-background-3: #e7e7e7;\n --theme-background-accent: #f062921f;\n\n --theme-border-color: rgba(0, 0, 0, 0.1);\n}\n.dark-mode {\n --theme-color-1: rgba(255, 255, 255, 0.9);\n --theme-color-2: rgba(156, 163, 175, 1);\n --theme-color-3: rgba(255, 255, 255, 0.44);\n --theme-color-accent: #f06292;\n\n --theme-background-1: #111728;\n --theme-background-2: #1e293b;\n --theme-background-3: #334155;\n --theme-background-accent: #f062921f;\n\n --theme-border-color: rgba(255, 255, 255, 0.1);\n}\n/* Document Sidebar */\n.light-mode .sidebar,\n.dark-mode .sidebar {\n --sidebar-background-1: var(--theme-background-1);\n --sidebar-item-hover-color: currentColor;\n --sidebar-item-hover-background: var(--theme-background-2);\n --sidebar-item-active-background: var(--theme-background-accent);\n --sidebar-border-color: transparent;\n --sidebar-color-1: var(--theme-color-1);\n --sidebar-color-2: var(--theme-color-2);\n --sidebar-color-active: var(--theme-color-accent);\n --sidebar-search-background: transparent;\n --sidebar-search-border-color: var(--theme-border-color);\n --sidebar-search--color: var(--theme-color-3);\n}\n/* Document header only shows on mobile*/\n.dark-mode .t-doc__header,\n.light-mode .t-doc__header {\n --header-background-1: rgba(255, 255, 255, 0.85);\n --header-border-color: transparent;\n --header-color-1: var(--theme-color-1);\n --header-color-2: var(--theme-color-2);\n --header-background-toggle: var(--theme-color-3);\n --header-call-to-action-color: var(--theme-color-accent);\n}\n\n.dark-mode .t-doc__header {\n --header-background-1: rgba(17, 23, 40, 0.75);\n}\n\n/* advanced */\n.light-mode {\n --theme-button-1: rgb(49 53 56);\n --theme-button-1-color: #fff;\n --theme-button-1-hover: rgb(28 31 33);\n\n --theme-color-green: #069061;\n --theme-color-red: #ef0006;\n --theme-color-yellow: #edbe20;\n --theme-color-blue: #0082d0;\n --theme-color-orange: #fb892c;\n --theme-color-purple: #5203d1;\n\n --theme-scrollbar-color: rgba(0, 0, 0, 0.18);\n --theme-scrollbar-color-active: rgba(0, 0, 0, 0.36);\n}\n.dark-mode {\n --theme-button-1: #f6f6f6;\n --theme-button-1-color: #000;\n --theme-button-1-hover: #e7e7e7;\n\n --theme-color-green: #a3ffa9;\n --theme-color-red: #ffa3a3;\n --theme-color-yellow: #fffca3;\n --theme-color-blue: #a5d6ff;\n --theme-color-orange: #e2ae83;\n --theme-color-purple: #d2a8ff;\n\n --theme-scrollbar-color: rgba(255, 255, 255, 0.24);\n --theme-scrollbar-color-active: rgba(255, 255, 255, 0.48);\n}\n/* Elysia Specific */\n.scalar-api-client__send-request-button,\n.show-api-client-button {\n background: #3c82f6 !important;\n}\n.show-api-client-button:before {\n display: none;\n}\n\n.sidebar-search:hover {\n transition: all 0.15s ease-in-out;\n --sidebar-search-border-color: var(--theme-color-accent) !important;\n color: var(--sidebar-color-1) !important;\n}\n.scalar-api-client__container .sidebar {\n --sidebar-border-color: var(--theme-border-color);\n}\n@media (min-width: 1150px) {\n .section-container:has( ~ .footer):before,\n .tag-section-container:before {\n content: \"\";\n position: absolute;\n top: -5px;\n left: 0;\n width: 100%;\n height: 10px;\n background: linear-gradient(90deg, var(--theme-background-1) 3%,transparent 10%);\n }\n}\n.section-flare {\n position: absolute;\n width: 100vw;\n height: 300px;\n --stripes: repeating-linear-gradient(\n 100deg,\n #fff 0%,\n #fff 7%,\n transparent 10%,\n transparent 12%,\n #fff 16%\n );\n --stripesDark: repeating-linear-gradient(\n 100deg,\n #000 0%,\n #000 7%,\n transparent 10%,\n transparent 12%,\n #000 16%\n );\n --rainbow: repeating-linear-gradient(\n 100deg,\n #60a5fa 10%,\n #e879f9 16%,\n #5eead4 22%,\n #60a5fa 30%\n );\n background-image: var(--stripes), var(--rainbow);\n background-size: 300%, 200%;\n background-position: 50% 50%, 50% 50%;\n filter: invert(100%);\n -webkit-mask-image: radial-gradient(\n ellipse at 100% 0%,\n black 40%,\n transparent 70%\n );\n mask-image: radial-gradient(ellipse at 100% 0%, black 40%, transparent 70%);\n pointer-events: none;\n opacity: 0.15;\n}\n.dark-mode .section-flare {\n background-image: var(--stripesDark), var(--rainbow);\n filter: opacity(50%) saturate(200%);\n opacity: 0.25;\n}\n.section-flare:after {\n content: \"\";\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n background-image: var(--stripes), var(--rainbow);\n background-size: 200%, 100%;\n background-attachment: fixed;\n mix-blend-mode: difference;\n}\n.dark-mode .section-flare:after {\n background-image: var(--stripesDark), var(--rainbow);\n}\n@keyframes headerbackground {\n from {\n background: transparent;\n backdrop-filter: none;\n }\n to {\n background: var(--header-background-1);\n backdrop-filter: blur(12px);\n }\n}\n.light-mode .t-doc__header,\n.dark-mode .t-doc__header {\n animation: headerbackground forwards;\n animation-timeline: scroll();\n animation-range: 0px 200px;\n --header-border-color: transparent;\n}\n";
2+
export default _default;

src/scalar/types/index.d.ts

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

0 commit comments

Comments
 (0)