@websublime/vite-plugin-open-api-server 0.24.0-next.4 → 0.24.0-next.5

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.
package/dist/index.d.ts CHANGED
@@ -243,13 +243,44 @@ declare function resolveOptions(options: OpenApiServerOptions): ResolvedOptions;
243
243
  /**
244
244
  * Vite Plugin Implementation
245
245
  *
246
- * What: Main Vite plugin for OpenAPI mock server
247
- * How: Uses configureServer hook to start mock server and configure proxy
248
- * Why: Integrates OpenAPI mock server seamlessly into Vite dev workflow
246
+ * What: Main Vite plugin for OpenAPI mock server (multi-spec)
247
+ * How: Uses orchestrator to create N spec instances, configures multi-proxy
248
+ * Why: Integrates multiple OpenAPI mock servers seamlessly into Vite dev workflow
249
249
  *
250
250
  * @module plugin
251
251
  */
252
252
 
253
+ /**
254
+ * Create the OpenAPI Server Vite plugin
255
+ *
256
+ * This plugin starts mock servers based on OpenAPI specifications
257
+ * and configures Vite to proxy API requests to them. Supports
258
+ * multiple specs via the orchestrator pattern.
259
+ *
260
+ * @example
261
+ * ```typescript
262
+ * // vite.config.ts
263
+ * import { defineConfig } from 'vite';
264
+ * import vue from '@vitejs/plugin-vue';
265
+ * import { openApiServer } from '@websublime/vite-plugin-open-api-server';
266
+ *
267
+ * export default defineConfig({
268
+ * plugins: [
269
+ * vue(),
270
+ * openApiServer({
271
+ * specs: [
272
+ * { spec: './openapi/petstore.yaml', proxyPath: '/api/pets' },
273
+ * { spec: './openapi/inventory.yaml', proxyPath: '/api/inventory' },
274
+ * ],
275
+ * port: 4000,
276
+ * }),
277
+ * ],
278
+ * });
279
+ * ```
280
+ *
281
+ * @param options - Plugin configuration options
282
+ * @returns Vite plugin
283
+ */
253
284
  declare function openApiServer(options: OpenApiServerOptions): Plugin;
254
285
 
255
286
  /**
@@ -467,7 +498,13 @@ interface SpecInstance {
467
498
  * individual spec instances, aggregated metadata, and lifecycle methods.
468
499
  */
469
500
  interface OrchestratorResult {
470
- /** Main Hono app with all specs mounted via X-Spec-Id dispatch */
501
+ /**
502
+ * Main Hono app with all specs mounted via X-Spec-Id dispatch.
503
+ *
504
+ * **Note**: Consumers using this property directly must have `hono`
505
+ * as a dependency. The `start()`/`stop()` lifecycle methods do not
506
+ * require direct interaction with this Hono instance.
507
+ */
471
508
  app: Hono;
472
509
  /** All spec instances (in config order) */
473
510
  instances: SpecInstance[];
@@ -491,9 +528,10 @@ interface OrchestratorResult {
491
528
  * 3. **Phase 3 — Build main app**: Create a single Hono app with CORS,
492
529
  * DevTools, Internal API, and X-Spec-Id dispatch middleware.
493
530
  *
494
- * **Note**: This function mutates `options.specs[i]` to write back resolved
495
- * values (id, proxyPath, proxyPathSource, handlersDir, seedsDir) so that
496
- * downstream consumers (banner, file watcher, plugin.ts) see the final values.
531
+ * **Note**: This function populates the resolved values (id, proxyPath,
532
+ * proxyPathSource, handlersDir, seedsDir) on each `options.specs[i]` object.
533
+ * Since `instances[i].config` is the same object reference, consumers should
534
+ * access resolved values through `instances[i].config` (the authoritative view).
497
535
  *
498
536
  * @param options - Resolved plugin options (from `resolveOptions()`)
499
537
  * @param vite - Vite dev server instance (for ssrLoadModule)
@@ -513,6 +551,17 @@ declare function createOrchestrator(options: ResolvedOptions, vite: ViteDevServe
513
551
  * @module multi-proxy
514
552
  */
515
553
 
554
+ /**
555
+ * Shared service proxy path prefixes.
556
+ *
557
+ * These constants are the single source of truth for the reserved proxy paths
558
+ * used by the DevTools iframe, internal API, and WebSocket connections.
559
+ * Both `configureMultiProxy()` and the virtual DevTools tab module in
560
+ * `plugin.ts` reference these to prevent divergence.
561
+ */
562
+ declare const DEVTOOLS_PROXY_PATH = "/_devtools";
563
+ declare const API_PROXY_PATH = "/_api";
564
+ declare const WS_PROXY_PATH = "/_ws";
516
565
  /**
517
566
  * Configure Vite proxy for multiple spec instances and shared services.
518
567
  *
@@ -766,7 +815,7 @@ declare function debounce<T extends (...args: unknown[]) => unknown>(fn: T, dela
766
815
  interface RegisterDevToolsOptions {
767
816
  /**
768
817
  * The port where the OpenAPI server is running
769
- * @default 3000
818
+ * @default 4000
770
819
  */
771
820
  port?: number;
772
821
  /**
@@ -808,7 +857,7 @@ interface RegisterDevToolsOptions {
808
857
  *
809
858
  * // Register OpenAPI Server DevTools
810
859
  * if (import.meta.env.DEV) {
811
- * await registerDevTools(app, { port: 3000 });
860
+ * await registerDevTools(app);
812
861
  * }
813
862
  *
814
863
  * app.mount('#app');
@@ -824,11 +873,11 @@ declare function registerDevTools(app: App, options?: RegisterDevToolsOptions):
824
873
  * When running in a browser, protocol and host are automatically derived from
825
874
  * window.location if not explicitly provided.
826
875
  *
827
- * @param port - Server port (default: 3000)
876
+ * @param port - Server port (default: 4000, matching OpenApiServerOptions.port)
828
877
  * @param host - Server host (default: 'localhost' or window.location.hostname)
829
878
  * @param protocol - Protocol to use (default: 'http' or window.location.protocol)
830
879
  * @returns DevTools SPA URL
831
880
  */
832
881
  declare function getDevToolsUrl(port?: number, host?: string, protocol?: 'http' | 'https'): string;
833
882
 
834
- export { type DeriveProxyPathResult, type FileWatcher, type FileWatcherOptions, type LoadHandlersResult, type LoadSeedsResult, type OpenApiServerOptions, type OrchestratorResult, type ProxyPathSource, type RegisterDevToolsOptions, type ResolvedOptions, type ResolvedSpecConfig, SPEC_COLORS, type SpecConfig, type SpecInstance, ValidationError, type ValidationErrorCode, configureMultiProxy, createFileWatcher, createOrchestrator, debounce, deriveProxyPath, deriveSpecId, getDevToolsUrl, getHandlerFiles, getSeedFiles, loadHandlers, loadSeeds, normalizeProxyPath, openApiServer, registerDevTools, resolveOptions, slugify, validateSpecs, validateUniqueIds, validateUniqueProxyPaths };
883
+ export { API_PROXY_PATH, DEVTOOLS_PROXY_PATH, type DeriveProxyPathResult, type FileWatcher, type FileWatcherOptions, type LoadHandlersResult, type LoadSeedsResult, type OpenApiServerOptions, type OrchestratorResult, type ProxyPathSource, type RegisterDevToolsOptions, type ResolvedOptions, type ResolvedSpecConfig, SPEC_COLORS, type SpecConfig, type SpecInstance, ValidationError, type ValidationErrorCode, WS_PROXY_PATH, configureMultiProxy, createFileWatcher, createOrchestrator, debounce, deriveProxyPath, deriveSpecId, getDevToolsUrl, getHandlerFiles, getSeedFiles, loadHandlers, loadSeeds, normalizeProxyPath, openApiServer, registerDevTools, resolveOptions, slugify, validateSpecs, validateUniqueIds, validateUniqueProxyPaths };