Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@iodigital/vite-plugin-prism

Package Overview
Dependencies
Maintainers
3
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@iodigital/vite-plugin-prism

Prism, OpenAPI mocking server, integration for Vite

  • 0.10.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
275
decreased by-22.54%
Maintainers
3
Weekly downloads
 
Created
Source

@iodigital/vite-plugin-prism

Prism, OpenAPI mocking server, integration for Vite

Usage

Install

npm install --save-dev @iodigital/vite-plugin-prism
# yarn add --dev @iodigital/vite-plugin-prism
# pnpm add --save-dev @iodigital/vite-plugin-prism

Vite

// Import plugin
import prism from "@iodigital/vite-plugin-prism";

// Pass them to plugin
export default defineConfig({
  plugins: [
    prism([
      {
        // OpenAPI doc
        specFilePathOrObject:
          "https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v3.0/petstore-expanded.yaml",
      },
    ]),
  ],
});

Nuxt

import { defineNuxtConfig } from "nuxt";

// https://v3.nuxtjs.org/api/configuration/nuxt.config
export default defineNuxtConfig({
  modules: [
    [
      "@iodigital/vite-plugin-prism/dist/nuxt",
      [
        {
          specFilePathOrObject:
            "https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v3.0/petstore-expanded.yaml",
        },
      ],
    ],
  ],

  // or
  modules: ["@iodigital/vite-plugin-prism/dist/nuxt"],
  prism: [
    {
      specFilePathOrObject:
        "https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v3.0/petstore-expanded.yaml",
    },
  ],
});

Config

interface PrismPluginOptions {
  // Base path for API
  // Default: /api
  route?: string;

  // URL to OpenAPI document or OpenAPI document object
  specFilePathOrObject: string | object;

  // Prism HTTP server configuration, same as Prism's IHttpConfig
  // https://github.com/stoplightio/prism/tree/master/packages/http#config-object
  // Default:
  // {
  //   mock: { dynamic: true },
  //   validateRequest: true,
  //   validateResponse: true,
  //   checkSecurity: true,
  //   errors: true,
  // };
  prismConfig?: PrismConfig;

  // Turn on Prism logging
  // Default: false
  debug?: boolean;
}

Development

npm run dev

Example vite application with plugin

npm run build
cd examples/with-vite
npm run dev
curl http://localhost:3000/api/pets

Example Nuxt application with plugin

npm run build
cd examples/with-nuxt
npm run dev
curl http://localhost:3000/api/pets

Build

npm run build

Keywords

FAQs

Package last updated on 18 Sep 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc