npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

gulp-swagger-endpoint

v1.0.16

Published

Endpoint exporter for swagger

Downloads

6

Readme

Swagger Endpoints

Install

Install with npm

npm install gulp-swagger-endpoint --save-dev

Configuration File.

Set plugin configuration

endpoints: This takes an array of objects, multiple domain and endpoint combinations can be added

useCommonJs: If using common js to build your app, set this to true. If false, a JS object will be created with your endpoints as Key/Value pairs

fileName: Your filename

prefix: If you wish to change the prefix of your URL, assign prefix.change to true. e.g. /api/product will change to /_api/product

gulp.swagger.conf.json file

This is the default configuration file located in the package root, please copy this file into your app root (where your package.json file is), and edit your configuartions there. This is to avoid your beautiful config file being overwritten on an npm update command.

{
  "Default": {
    "endpoints": [{
    "domain": "http://petstore.swagger.io",
    "swaggerUrl": "http://petstore.swagger.io/v2/swagger.json",
    "prefix": { 
      "change": false,
      "oldPrefix" : "api",
      "newPrefix" : "_api"
    }
  }],
  "useCommonJs": true,
  "fileName": "endpoint.js"
  }
}

You can add more environment variables as properties; so your file could end up looking like this:

{
  "Default": {
    "endpoints": [{
    "domain": "http://petstore.swagger.io",
    "swaggerUrl": "http://petstore.swagger.io/v2/swagger.json",
    "prefix": { 
      "change": false,
      "oldPrefix" : "api",
      "newPrefix" : "_api"
    }
  }],
  "useCommonJs": true,
  "fileName": "endpoint.js"
  },
  "Local": {
    "endpoints": [{
    "domain": "http://petstore.swagger.io",
    "swaggerUrl": "http://petstore.swagger.io/v2/swagger.json",
    "prefix": { 
      "change": false,
      "oldPrefix" : "api",
      "newPrefix" : "_api"
    }
  }],
  "useCommonJs": true,
  "fileName": "local.endpoint.js"
  }
}

Example

gulpfile.js

Plugin creates a js file which is containing all endpoints in your restfull API

You can pass a parameter to the swagger function (in this case: 'Local') to create the endpoints for a specific environment. If left blank or '', default environment will be used

gulp.task('endPoint', function() {
    return gulp.src("./node_modules/gulp-swagger-endpoint/index.js")
          .pipe(swagger('Default'))
          .pipe(gulp.dest('./Scripts/Common/angularjs/config'));
});

endpoints.js

Sample output file w/ commonJS = true

module.exports = {
     API_URLS: {
      /*  Endpoints from http://petstore.swagger.io/v2/swagger.json */ 
         Get_Product: "http://petstore.swagger.io/api/product",
         Get_ProductById: "http://petstore.swagger.io/api/product/{Id}",
         Get_ProductByCategoryId: "http://petstore.swagger.io/api/product/{CategoryId}",
         Post_Product: "http://petstore.swagger.io/api/product"
     }
};

Sample output file w/ commonJS = false

 API_URLS = {
    /*  Endpoints from http://petstore.swagger.io/v2/swagger.json */ 
     "Get_Product": "http://petstore.swagger.io/api/product",
     "Get_ProductById": "http://petstore.swagger.io/api/product/{Id}",
     "Get_ProductByCategoryId": "http://petstore.swagger.io/api/product/{CategoryId}",
     "Post_Product": "http://petstore.swagger.io/api/product"
 };