All Projects → scttcper → koa2-swagger-ui

scttcper / koa2-swagger-ui

Licence: MIT license
Swagger UI as Koa v2 middleware

Projects that are alternatives of or similar to koa2-swagger-ui

Github Ranking
🔍GitHub不同语言热门项目排行,Vue.js做页面展示
Stars: ✭ 160 (+68.42%)
Mutual labels:  koa, koa2
Koa Webpack Middleware
webpack dev&hot middleware for koa2
Stars: ✭ 215 (+126.32%)
Mutual labels:  koa, koa2
Blog Service
blog service @nestjs
Stars: ✭ 188 (+97.89%)
Mutual labels:  koa, koa2
Sactive Web
🚀 A dependency injection web framework for Node.js.
Stars: ✭ 143 (+50.53%)
Mutual labels:  koa, koa2
node-typescript-starter
REST API using Node with typescript, KOA framework. TypeORM for SQL. Middlewares JWT (auth), CORS, Winston Logger, Error, Response
Stars: ✭ 19 (-80%)
Mutual labels:  koa, koa2
Vue Webpack Config
Koa2、Webpack、Vue、React、Node
Stars: ✭ 151 (+58.95%)
Mutual labels:  koa, koa2
Egg Core
A core Pluggable framework based on koa.
Stars: ✭ 194 (+104.21%)
Mutual labels:  koa, koa2
Postgraphile
GraphQL is a new way of communicating with your server. It eliminates the problems of over- and under-fetching, incorporates strong data types, has built-in introspection, documentation and deprecation capabilities, and is implemented in many programming languages. This all leads to gloriously low-latency user experiences, better developer experiences, and much increased productivity. Because of all this, GraphQL is typically used as a replacement for (or companion to) RESTful API services.
Stars: ✭ 10,967 (+11444.21%)
Mutual labels:  koa, koa2
monero-merchant
Monero Merchant is a RESTful API wrapper for the official Monero wallet RPC. This project is mainly for merchants who hope to accept Monero as payment, which is currently the most robust and privacy-oriented cryptocurrency with extremely low transaction fees.
Stars: ✭ 27 (-71.58%)
Mutual labels:  swagger-ui, koa2
koa-mongoDB
😊😊Koa and mongoose build services
Stars: ✭ 24 (-74.74%)
Mutual labels:  koa, koa2
koa2-proxy
基于koa@next的代理工具,支持http和https,并且可以当做本地服务器使用
Stars: ✭ 42 (-55.79%)
Mutual labels:  koa, koa2
nodejs-koa-blog
基于 Node.js Koa2 实战开发的一套完整的博客项目网站
Stars: ✭ 1,611 (+1595.79%)
Mutual labels:  koa, koa2
Koa Proxies
a [email protected] proxy middleware
Stars: ✭ 125 (+31.58%)
Mutual labels:  koa, koa2
Koa Hbs
Handlebars templates for Koa.js
Stars: ✭ 156 (+64.21%)
Mutual labels:  koa, koa2
Koalerplate
Simple Koa Boilerplate for APIs
Stars: ✭ 118 (+24.21%)
Mutual labels:  koa, koa2
Cool Admin Api
cool-admin-api 是基于egg.js、typeorm、jwt等封装的api开发脚手架、快速开发api接口
Stars: ✭ 188 (+97.89%)
Mutual labels:  koa, koa2
Chatroom
vue2聊天室,图灵机器人,node爬虫
Stars: ✭ 103 (+8.42%)
Mutual labels:  koa, koa2
Strapi
🚀 Open source Node.js Headless CMS to easily build customisable APIs
Stars: ✭ 41,786 (+43885.26%)
Mutual labels:  koa, koa2
Strapi Sdk Javascript
🔌 Official JavaScript SDK for APIs built with Strapi.
Stars: ✭ 247 (+160%)
Mutual labels:  koa, koa2
koa-xml-body
koa middleware to parse xml request body
Stars: ✭ 36 (-62.11%)
Mutual labels:  koa, koa2

koa2-swagger-ui NPM version CircleCI

Host swagger ui at a given directory from your koa v2 app

Inspired by:

install

npm install koa2-swagger-ui --save

config

for more swaggerOptions see swagger-ui defaults:

title: 'swagger', // page title
oauthOptions: {}, // passed to initOAuth
swaggerOptions: { // passed to SwaggerUi()
  dom_id: 'swagger-ui-container',
  url: 'http://petstore.swagger.io/v2/swagger.json', // link to swagger.json
  supportedSubmitMethods: ['get', 'post', 'put', 'delete', 'patch'],
  docExpansion: 'none',
  jsonEditor: false,
  defaultModelRendering: 'schema',
  showRequestHeaders: false,
  swaggerVersion: 'x.x.x' // read from package.json,
  validatorUrl: null, // disable swagger-ui validator
},
routePrefix: '/docs', // route where the view is returned
specPrefix: '/docs/spec', // route where the spec is returned
exposeSpec: false, // expose spec file
hideTopbar: false, // hide swagger top bar
favicon: '/favicon.png', // default favicon
customCSS: `h1 { color: red }`, // Add Custom CSS on the html

example

import Koa from 'koa';
import { koaSwagger } from 'koa2-swagger-ui';

const app = new Koa();

app.use(
  koaSwagger({
    routePrefix: '/swagger', // host at /swagger instead of default /docs
    swaggerOptions: {
      url: 'http://petstore.swagger.io/v2/swagger.json', // example path to json
    },
  }),
);

app.listen(3000);

example with koa-router and yaml source

depends on yamljs to turn your Yaml into a JS object

npm install --save yamljs
const Koa = require('koa');
const Router = require('koa-router');
const yamljs = require('yamljs');
const koaSwagger = require('koa2-swagger-ui');

const router = new Router({ prefix: '/' });

const app = new Koa();
const router = new Router();

// .load loads file from root.
const spec = yamljs.load('./openapi.yaml');

// example 1 using router.use()
router.use(koaSwagger({ swaggerOptions: { spec } }));

// example 2 using more explicit .get()
router.get('/docs', koaSwagger({ routePrefix: false, swaggerOptions: { spec } }));

app.use(router.routes());
app.listen(3000);
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].