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

swagger-ui-react

Package Overview
Dependencies
Maintainers
4
Versions
229
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

swagger-ui-react

[![NPM version](https://badge.fury.io/js/swagger-ui-react.svg)](http://badge.fury.io/js/swagger-ui-react)

  • 5.18.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
164K
decreased by-26.52%
Maintainers
4
Weekly downloads
 
Created

What is swagger-ui-react?

The swagger-ui-react npm package is a React component for integrating the Swagger UI into a React application. Swagger UI allows developers to visualize and interact with the API's resources without having any of the implementation logic in place. It is particularly useful for API documentation and testing.

What are swagger-ui-react's main functionalities?

Basic Integration

This code demonstrates how to integrate Swagger UI into a React application using the swagger-ui-react package. It imports the necessary components and styles, and then renders the Swagger UI with a given URL to the Swagger JSON.

import React from 'react';
import SwaggerUI from 'swagger-ui-react';
import 'swagger-ui-react/swagger-ui.css';

const App = () => (
  <SwaggerUI url="https://petstore.swagger.io/v2/swagger.json" />
);

export default App;

Custom Configuration

This code sample shows how to customize the Swagger UI component by passing additional props. In this example, the `docExpansion` prop is set to 'none' to collapse all sections by default, and `defaultModelsExpandDepth` is set to -1 to hide the models section.

import React from 'react';
import SwaggerUI from 'swagger-ui-react';
import 'swagger-ui-react/swagger-ui.css';

const App = () => (
  <SwaggerUI 
    url="https://petstore.swagger.io/v2/swagger.json"
    docExpansion="none"
    defaultModelsExpandDepth={-1}
  />
);

export default App;

Using Local Swagger JSON

This example demonstrates how to use a local Swagger JSON file with the Swagger UI component. The local Swagger JSON file is imported and passed to the `spec` prop of the SwaggerUI component.

import React from 'react';
import SwaggerUI from 'swagger-ui-react';
import 'swagger-ui-react/swagger-ui.css';
import swaggerDocument from './swagger.json';

const App = () => (
  <SwaggerUI spec={swaggerDocument} />
);

export default App;

Other packages similar to swagger-ui-react

FAQs

Package last updated on 07 Nov 2024

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