8000 GitHub - tobyqin/swagger-master: A lightweight, single-file Swagger UI manager for multiple OpenAPI specifications
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

A lightweight, single-file Swagger UI manager for multiple OpenAPI specifications

License

Notifications You must be signed in to change notification settings

tobyqin/swagger-master

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Swagger Master

中文文档

Swagger Master Logo
A lightweight, single-file Swagger UI manager for multiple OpenAPI specifications

FeaturesScreenshotDemoQuick StartCustomizationContributingLicenseAcknowledgments

license stars forks

⭐️ If you find this project useful, please consider giving it a star to show your support! ⭐️

Features

  • 📦 Single File - No build process, no dependencies to install
  • 🔄 Multiple API Support - Switch between different OpenAPI specifications seamlessly
  • 🚀 Easy Deployment - Host anywhere as a static file
  • Fast Loading - Uses CDN for all external resources
  • 🎨 Clean UI - Intuitive interface with API selector
  • 🔧 Easy Configuration - Simple API list customization

Screenshot

Swagger Master Screenshot
Swagger Master in action - managing multiple API specifications

Demo

Visit our live demo to see Swagger Master in action.

Quick Start

  1. Download the index.html file
  2. Add your API list to the API_LIST array in the index.html file
  3. Open the index.html file in your browser to test it out
  4. Host anywhere as a static file

Customization

Styling

The UI is customizable through the CSS section in the index.html file. Key style classes:

  • #api-selector - The API selection dropdown container
  • #swagger-ui - The main Swagger UI container
  • .info-icon - The information icon styling

Configuration Options

The API list is configured in the index.html file. The API_LIST array contains the API specifications. Each API specification is an object with the following properties:

const API_LIST = [
  {
    name: "Petstore API",
    url: "https://petstore3.swagger.io/api/v3/openapi.json",
    description:
      "This is the Swagger Petstore API, a sample API that demonstrates OpenAPI specification features.",
    maintainer: {
      name: "Swagger Team",
      email: "swagger@example.com",
    },
  },
  // Add more APIs as needed
];

Each API configuration supports:

  • name: Display name for the API
  • url: URL to the OpenAPI specification JSON/YAML
  • description: A detailed description of the API's purpose and features
  • maintainer: Contact information for the API maintainer
    • name: Maintainer's name
    • email: Maintainer's email address

The description and maintainer information can be viewed by clicking the info icon (i) next to the API selector.

FAQ

How to fix CORS (Cross-Origin Resource Sharing) errors?

If you see errors like "Failed to load API definition" or "Possible cross-origin (CORS) issue", you can try one of these solutions:

  1. Configure Backend Server (Recommended for Production)

    • Configure your API server to allow CORS requests by adding appropriate headers:
    Access-Control-Allow-Origin: *  # Or your Swagger Master domain
    Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS
    Access-Control-Allow-Headers: *
    
    • This is the most secure and recommended solution for production environments
  2. Use a Proxy Server (Alternative for Production)

    • Set up a proxy server (e.g., Nginx) to forward requests and add CORS headers
    • Example Nginx configuration:
    location /api/ {
        proxy_pass http://your-api-server/;
        add_header 'Access-Control-Allow-Origin' '*';
        add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS';
        add_header 'Access-Control-Allow-Headers' '*';
    }
  3. Use Browser Extensions (Development Only)

    • Install CORS-disabling browser extensions (e.g., "CORS Unblock" for Chrome)
    • ⚠️ Warning: Only use this method for development/testing
    • Disable the extension when not needed for security reasons

Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments


Made with ❤️ by Toby Qin

About

A lightweight, single-file Swagger UI manager for multiple OpenAPI specifications

Topics

Resources

License

Stars

Watchers

Forks

Languages

0