1.0.2 • Published 11 months ago

@sjeremich23/docs v1.0.2

Weekly downloads
-
License
MIT
Repository
-
Last release
11 months ago

📚 Swagger Integration for Express.js

This project provides middleware for integrating Swagger UI into the Week 1 - Creating Your Backend API assignment for class WDV3322, Programming for Web Applications.

✨ Features

  • Swagger UI Integration: Easily serve your Swagger documentation.
  • Customizable Configuration: Load Swagger configuration from a JSON file.

📦 Installation

To install the package, use npm:

npm install @sjeremich23/docs

📖 Step-by-Step Integration

  1. Import or require the middleware in your Express.js application.
    import swaggerRouter from "@sjeremich23/docs";
    or
    const swaggerRouter = require("@sjeremich23/docs");
  2. Add the endpoint /api-docs to serve the Swagger UI.
    app.use("/api-docs", swaggerRouter);

🚀 Usage

ES6 Module

Import the middleware in your Express.js application:

import express from "express";
import swaggerRouter from "@sjeremich23/docs";

const app = express();

app.use("/api-docs", swaggerRouter);

app.listen(3000, () => {
  console.log("Server is running on port 3000");
});

CommonJS Module

Import the middleware in your Express.js application:

const express = require("express");
const swaggerRouter = require("@sjeremich23/docs");

const app = express();

app.use("/api-docs", swaggerRouter);

app.listen(3000, () => {
  console.log("Server is running on port 3000");
});

🛠️ Configuration

The package comes with a default swaggerConfig.json file. You can customize it as needed.

📄 License

This project is licensed under the MIT License.

1.0.2

11 months ago

1.0.1

11 months ago

1.0.0

11 months ago