GithubHelp home page GithubHelp logo

kpowz / hapi-swaggered-ui Goto Github PK

View Code? Open in Web Editor NEW

This project forked from z0mt3c/hapi-swaggered-ui

0.0 1.0 0.0 157 KB

An easy swagger-ui drop-in plugin for hapi (to be used with hapi-swaggered).

JavaScript 68.55% HTML 31.45%

hapi-swaggered-ui's Introduction

hapi-swaggered-ui

Easy swagger-ui (v3) drop-in plugin for hapi to be used with hapi-swaggered.

Supports hapi 17.x and up For earlier versions check hapi-swaggered-ui 2.x (current default/latest npm install hapi-swaggered --save)

Build Status Dependency Status js-standard-style npm downloads

Install

npm install hapi-swaggered-ui@next

Configuration

  • title: string, title of swagger ui
  • path: string, optional path where the docs should be located at (e.g. '/docs', defaults to: null)
  • basePath: string, optional url base path (e.g. used to fix reverse proxy routes)
  • swaggerEndpoint: Override the auto-detection of hapi-swaggered with a specific URL. (not recommended in use with hapi-swaggered; optional)
  • swaggerOptions: object (according to swagger-ui)
    • operationsSorter: Apply a sort to the operation list of each API. It can be 'alpha' (sort by paths alphanumerically), 'method' (sort by HTTP method), null (server side sorting) or a custom function (see link above).
    • docExpansion: Controls how the API listing is displayed. It can be set to 'none' (default), 'list' (shows operations for each resource), or 'full' (fully expanded: shows operations and their details).
    • validatorUrl: By default, Swagger-UI attempts to validate specs against swagger.io's online validator (disabled for localhost). You can use this parameter to set a different validator URL, for example for locally deployed validators (Validator Badge). Setting it to false will disable validation. This parameter is relevant for Swagger 2.0 specs only.
    • In addition the following options are supported: oauth2RedirectUrl, configUrl, displayOperationId, displayRequestDuration, filter, deepLinking, maxDisplayedTags, tagsSorter, parameterMacro, modelPropertyMacro - have a look at swagger-ui
  • authorization: object - can be null or false to disable authorization through swagger-ui (e.g. in case of public apis without auth)
    • scope: string, 'query' or 'header'
    • field: string, name of the field
    • valuePrefix: string, prefix fields value (e.g. with 'bearer ')
    • defaultValue: string, default value of the api-key field
    • placeholder: string, placeholder of the api-key field
  • auth: object, auth options as specified in route options (hapi docs), will be applied to all registered plugin routes
  • defaultTags: array of strings, will be passed to the specs endpoint through the query param 'tags' (hapi-swaggered feature: tag filtering)

Example

Since hapi-swaggered exposes its plugin configuration hapi-swaggered-ui should find it's swagger endpoint automatically. In case you want to use hapi-swaggered-ui without hapi-swaggered (or the auto-detection doesn't work) you can manually set the swagger endpoint by the swaggerEndpoint option. In addition the page title can be changed through the option title.

await server.register([
  require('inert'),
  require('vision'),
  {
    plugin: require('hapi-swaggered-ui'),
    options: {
      title: 'Example API',
      path: '/docs',
      authorization: { // see above
        field: 'apiKey',
        scope: 'query', // header works as well
        // valuePrefix: 'bearer '// prefix incase
        defaultValue: 'demoKey',
        placeholder: 'Enter your apiKey here'
      },
      swaggerOptions: {} // see above
    }
  }
])

May have a look at the example listed at https://github.com/z0mt3c/hapi-swaggered

hapi-swaggered-ui's People

Contributors

craigbeck avatar dcharbonnier avatar felixheck avatar greenkeeperio-bot avatar savardc avatar tatort79 avatar z0mt3c avatar zachguo avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.