expresso-swagger 0.0.1

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/README.md ADDED
@@ -0,0 +1,94 @@
1
+ # โ˜• ExpressoSwagger
2
+
3
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
4
+ [![Build Status](https://img.shields.io/badge/build-passing-brightgreen.svg)]()
5
+
6
+ > This library was entirely made by Gemini.
7
+
8
+ **ExpressoSwagger** is a modern, high-performance, and visually stunning alternative to Swagger UI. Designed for developers who care about aesthetics and functionality, it offers a seamless way to document and test your APIs without the clunky overhead of traditional tools.
9
+
10
+ ![ExpressoSwagger Interface](https://raw.githubusercontent.com/ExpressoMacchiato/ExpressoMacchiato/refs/heads/master/_assets/image.png)
11
+
12
+ ## ๐ŸŒŸ Why ExpressoSwagger?
13
+
14
+ Traditional Swagger can be rigid and visually dated. ExpressoSwagger was built to solve specific pain points:
15
+
16
+ * **โšก Modern 3-Column Layout**: A clean, ergonomic interface inspired by Stripe and Redoc. Navigation on the left, Documentation in the center, and a powerful Console on the right.
17
+ * **๐Ÿช Native Session Support**: Tired of CORS and credential issues? ExpressoSwagger supports `withCredentials` natively, making cookie-based and session-based authentication testing a breeze.
18
+ * **๐Ÿ› ๏ธ Zero Decorators**: No more polluting your controllers with bulky decorators. Configure everything programmatically with simple, strongly-typed TypeScript objects.
19
+ * **โ™ป๏ธ DRY Models**: Define your data structures once and reuse them across multiple endpoints.
20
+ * **๐Ÿ” Smart Method Search**: Search not just for paths or titles, but also by HTTP method (e.g., type "POST" to see all creation endpoints).
21
+ * **๐Ÿ’พ Persistent Global Headers**: Set your Authorization tokens or API keys once in the Global Config panel; they are saved in your browser and injected into every call automatically.
22
+
23
+ ## ๐Ÿ“ฆ Installation
24
+
25
+ ```bash
26
+ npm i expresso-swagger
27
+ ```
28
+
29
+ ## ๐Ÿš€ Quick Start
30
+
31
+ ExpressoSwagger is **framework-agnostic**. Whether you use Express, Fastify, Koa, or a custom solution, integration takes seconds.
32
+
33
+ ### 1. Configure your API
34
+
35
+ ```typescript
36
+ const { ExpressoSwagger } = require('expresso-swagger');
37
+
38
+ const doc = new ExpressoSwagger({
39
+ info: {
40
+ title: "Store Management API",
41
+ version: "1.0.0",
42
+ description: "Manage products, users, and orders with ease."
43
+ },
44
+ baseUrl: "https://api.myapp.com",
45
+ models: {
46
+ User: { id: 1, username: "dev_user", role: "admin" }
47
+ },
48
+ settings: { withCredentials: true }
49
+ });
50
+
51
+ doc.addEndpoint({
52
+ path: "/users",
53
+ method: "GET",
54
+ group: "Users",
55
+ summary: "Retrieve all users",
56
+ responses: {
57
+ 200: { description: "List of users", body: ["User"] }
58
+ }
59
+ });
60
+ ```
61
+
62
+ ### 2. Serve the UI (Example with Express)
63
+
64
+ ```typescript
65
+ const express = require('express');
66
+ const { getUIPath } = require('expresso-swagger');
67
+
68
+ const app = express();
69
+
70
+ // Serve the compiled UI assets
71
+ app.use('/docs', express.static(getUIPath()));
72
+
73
+ // Serve the documentation JSON (the UI looks for it at ./docs.json)
74
+ app.get('/docs/docs.json', (req, res) => {
75
+ res.json(doc.getDocument());
76
+ });
77
+
78
+ app.listen(3000, () => console.log('API Docs: http://localhost:3000/docs'));
79
+ ```
80
+
81
+ ## ๐ŸŽจ UI Features
82
+
83
+ - **Color-coded Methods**: Instantly distinguish between GET, POST, PUT, and DELETE with vibrant badges.
84
+ - **Inline Descriptions**: Support for multiline descriptions (`\n`) to keep your documentation detailed but readable.
85
+ - **Real-time URL Building**: Watch your final API URL update dynamically as you type parameters.
86
+ - **Schema Preview**: Elegant, foldable JSON previews for every response type.
87
+
88
+ ## ๐Ÿค Contributing
89
+
90
+ Contributions are welcome! If you have ideas for new features or improvements, feel free to open an issue or submit a pull request.
91
+
92
+ ## ๐Ÿ“œ License
93
+
94
+ This project is licensed under the MIT License.
@@ -0,0 +1,21 @@
1
+ import { ExpressoSwaggerConfig, EndpointConfig } from './types';
2
+ export declare class ExpressoSwagger {
3
+ private config;
4
+ private endpoints;
5
+ constructor(config: ExpressoSwaggerConfig);
6
+ /**
7
+ * Aggiunge un nuovo endpoint alla documentazione.
8
+ * L'interfaccia รจ pensata per essere intuitiva e guidata dai tipi.
9
+ */
10
+ addEndpoint(endpoint: EndpointConfig): this;
11
+ /**
12
+ * Ritorna l'intera configurazione e gli endpoint in un unico oggetto JSON.
13
+ */
14
+ getDocument(): {
15
+ endpoints: EndpointConfig[];
16
+ info: import("./types").ExpressoSwaggerInfo;
17
+ baseUrl?: string;
18
+ settings?: import("./types").ExpressoSwaggerSettings;
19
+ models?: Record<string, any>;
20
+ };
21
+ }
@@ -0,0 +1,42 @@
1
+ export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'OPTIONS' | 'HEAD';
2
+ export interface ParamDefinition {
3
+ type: 'string' | 'number' | 'boolean' | 'object' | 'array';
4
+ required?: boolean;
5
+ description?: string;
6
+ default?: any;
7
+ example?: any;
8
+ }
9
+ export interface EndpointResponse {
10
+ description: string;
11
+ body?: any;
12
+ headers?: Record<string, string>;
13
+ }
14
+ export interface EndpointConfig {
15
+ path: string;
16
+ method: HttpMethod;
17
+ baseUrl?: string;
18
+ group?: string;
19
+ summary?: string;
20
+ description?: string;
21
+ tags?: string[];
22
+ params?: Record<string, ParamDefinition>;
23
+ query?: Record<string, ParamDefinition>;
24
+ body?: any;
25
+ responses: Record<number | string, EndpointResponse>;
26
+ }
27
+ export interface ExpressoSwaggerInfo {
28
+ title: string;
29
+ version: string;
30
+ description?: string;
31
+ }
32
+ export interface ExpressoSwaggerSettings {
33
+ withCredentials?: boolean;
34
+ theme?: 'light' | 'dark' | 'system';
35
+ primaryColor?: string;
36
+ }
37
+ export interface ExpressoSwaggerConfig {
38
+ info: ExpressoSwaggerInfo;
39
+ baseUrl?: string;
40
+ settings?: ExpressoSwaggerSettings;
41
+ models?: Record<string, any>;
42
+ }