@elysiajs/openapi 1.4.14 → 1.4.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -24,29 +24,30 @@ __export(scalar_exports, {
24
24
  });
25
25
  module.exports = __toCommonJS(scalar_exports);
26
26
  var elysiaCSS = `.light-mode {
27
- --scalar-color-1: #2a2f45;
28
- --scalar-color-2: #757575;
29
- --scalar-color-3: #8e8e8e;
30
- --scalar-color-accent: #f06292;
27
+ --scalar-color-1: oklch(43.5% 0.029 321.78);
28
+ --scalar-color-2: oklch(54.2% 0.034 322.5);
29
+ --scalar-color-3: oklch(71.1% 0.019 323.02);
30
+ --scalar-color-accent: oklch(71.2% 0.194 13.428);
31
31
 
32
- --scalar-background-1: #fff;
33
- --scalar-background-2: #f6f6f6;
34
- --scalar-background-3: #e7e7e7;
32
+ --scalar-background-1: oklch(98.5% 0 0);
33
+ --scalar-background-2: oklch(96% 0.003 325.6);
34
+ --scalar-background-3: oklch(92.2% 0.005 325.62);
35
35
 
36
- --scalar-border-color: rgba(0, 0, 0, 0.1);
36
+ --scalar-border-color: oklch(92.2% 0.005 325.62);
37
37
  }
38
+
38
39
  .dark-mode {
39
- --scalar-color-1: rgba(255, 255, 255, 0.9);
40
- --scalar-color-2: rgba(156, 163, 175, 1);
41
- --scalar-color-3: rgba(255, 255, 255, 0.44);
42
- --scalar-color-accent: #f06292;
40
+ --scalar-color-1: oklch(98.5% 0 0);
41
+ --scalar-color-2: oklch(71.1% 0.019 323.02);
42
+ --scalar-color-3: oklch(86.5% 0.012 325.68);
43
+ --scalar-color-accent: oklch(89.2% 0.058 10.001);
43
44
 
44
- --scalar-background-1: #111728;
45
- --scalar-background-2: #1e293b;
46
- --scalar-background-3: #334155;
47
- --scalar-background-accent: #f062921f;
45
+ --scalar-background-1: oklch(21.2% 0.019 322.12);
46
+ --scalar-background-2: oklch(26.3% 0.024 320.12);
47
+ --scalar-background-3: oklch(36.4% 0.029 323.89);
48
+ --scalar-background-accent: oklch(43.5% 0.029 321.78);
48
49
 
49
- --scalar-border-color: rgba(255, 255, 255, 0.1);
50
+ --scalar-border-color: oklch(36.4% 0.029 323.89);
50
51
  }
51
52
 
52
53
  /* Document Sidebar */
@@ -1,9 +1,11 @@
1
1
  import type { TSchema } from 'elysia';
2
- import type { OpenAPIV3 } from 'openapi-types';
2
+ import type { OpenAPIV3, OpenAPIV3_1 } from 'openapi-types';
3
3
  import type { ApiReferenceConfiguration } from '@scalar/types';
4
4
  import type { SwaggerUIOptions } from './swagger/types';
5
5
  export type OpenAPIProvider = 'scalar' | 'swagger-ui' | null;
6
+ export type OpenAPIVersion = `3.0.${number}` | `3.1.${number}`;
6
7
  type MaybeArray<T> = T | T[];
8
+ type OpenAPIDocumentation = Omit<Partial<OpenAPIV3.Document>, 'x-express-openapi-additional-middleware' | 'x-express-openapi-validation-strict'> | Omit<Partial<OpenAPIV3_1.Document>, 'x-express-openapi-additional-middleware' | 'x-express-openapi-validation-strict'>;
7
9
  export type MapJsonSchema = {
8
10
  [vendor: string]: Function;
9
11
  } & {
@@ -28,12 +30,18 @@ export interface ElysiaOpenAPIConfig<Enabled extends boolean = true, Path extend
28
30
  * @default true
29
31
  */
30
32
  enabled?: Enabled;
33
+ /**
34
+ * OpenAPI document version to emit
35
+ *
36
+ * @default '3.1.2'
37
+ */
38
+ openapiVersion?: OpenAPIVersion;
31
39
  /**
32
40
  * OpenAPI config
33
41
  *
34
- * @see https://spec.openapis.org/oas/v3.0.3.html
42
+ * @see https://spec.openapis.org/oas/latest.html
35
43
  */
36
- documentation?: Omit<Partial<OpenAPIV3.Document>, 'x-express-openapi-additional-middleware' | 'x-express-openapi-validation-strict'>;
44
+ documentation?: OpenAPIDocumentation;
37
45
  exclude?: {
38
46
  /**
39
47
  * Exclude methods from OpenAPI
@@ -53,7 +53,49 @@ export interface OpenAPIGeneratorOptions {
53
53
  silent?: boolean;
54
54
  }
55
55
  export declare function extractRootObjects(code: string): string[];
56
- export declare function declarationToJSONSchema(declaration: string): AdditionalReference;
56
+ /**
57
+ * Extract type alias definitions from a declaration string and return
58
+ * a map of name -> body (e.g. `User` -> `{ id: string; name: string; }`)
59
+ */
60
+ export declare function extractTypeAliases(declaration: string): Record<string, string>;
61
+ /**
62
+ * Replace type references with their inlined definitions so that
63
+ * TypeBox can produce concrete schemas instead of unresolvable $refs
64
+ */
65
+ export declare function inlineTypeReferences(code: string, aliases: Record<string, string>): string;
66
+ /**
67
+ * Scan a declaration for `import("...").TypeName` references,
68
+ * use TypeScript's module resolution to find the source files,
69
+ * and extract the type aliases from them.
70
+ *
71
+ * This allows TypeBox to produce concrete schemas for cross-module types
72
+ * (e.g. Drizzle ORM types imported from another package).
73
+ */
74
+ export declare function resolveImportedTypes(declaration: string, projectRoot: string, tsconfigPath: string, sourceFilePath: string, existingAliases: Record<string, string>, fs: {
75
+ existsSync: (path: string) => boolean;
76
+ readFileSync: (path: string, encoding: BufferEncoding) => string;
77
+ }): Record<string, string>;
78
+ /**
79
+ * Flatten nested intersections so that each root object represents a single route.
80
+ *
81
+ * Multi-route Elysia plugins produce declarations like:
82
+ * { api: { v3: { a: {...} } & { b: {...} } } }
83
+ *
84
+ * This distributes the outer structure over the inner intersection:
85
+ * { api: { v3: { a: {...} } } } & { api: { v3: { b: {...} } } }
86
+ *
87
+ * This way `extractRootObjects` and TypeBox can process each route individually.
88
+ */
89
+ export declare function flattenNestedIntersections(declaration: string): string;
90
+ export declare function declarationToJSONSchema(declaration: string, typeAliases?: Record<string, string>): AdditionalReference;
91
+ /**
92
+ * Extract the Nth (0-indexed) top-level generic parameter from
93
+ * a string that starts with `: Elysia<...>` or `Elysia<...>`.
94
+ *
95
+ * Tracks `<>`, `{}`, `[]`, `()` depth so that commas inside
96
+ * nested generics or object literals are not counted as separators.
97
+ */
98
+ export declare function extractGenericParam(instance: string, paramIndex: number): string | undefined;
57
99
  /**
58
100
  * Auto generate OpenAPI schema from Elysia instance
59
101
  *