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

commons-excel2swagger

v2.0.0

Published

Make sure to have 1 sheet named **"meta"** for swagger metadata and at least 1 sheet that contains **swagger definitions**

Downloads

99

Readme

EXCEL to SWAGGER Generator

Step 1: Prepare Excel File

Required Sheets:

Make sure to have 1 sheet named "meta" for swagger metadata and at least 1 sheet that contains swagger definitions

Note:

You can find the example sheets and generated swagger with the code
find the sample excel and swagger

1. meta sheet:

This sheet must contain the following properties:
Note: the key and value are headers in this sheet

| key | value | |--------------|-------------------------------------------------| | version | 1.0.0 | | title | Node Template | | description | Terms of service | | serviceTerms | http://swagger.io/terms/ | | email | [email protected] | | licenseName | Apache License Version 2.0 | | licenseUrl | http://www.apache.org/licenses/LICENSE-2.0.html | | host | localhost:8000 | | basePath | / |

2. swagger definitions:

At least 1 sheet is needed with the following format. Note that the first row is header in our case.
All the sheets containing this header will be counted as valid swagger definition sheet. | controller | endpoint | method | param.name | param.type | param.dataType | param.minlen | param.maxlen | param.description | param.required | param.example | response.name | response.dataType | summary | description | |------------|----------|--------|------------|------------|----------------|--------------|--------------|-------------------|----------------|---------------|---------------|-------------------|---------|-------------|

An example of sample sheet will look like this:

| controller | endpoint | method | param.name | param.type | param.dataType | param.minlen | param.maxlen | param.description | param.required | param.example | response.name | response.dataType | summary | description | |------------|----------------------------|--------|---------------|------------|----------------|--------------|--------------|-----------------------|----------------|----------------------|---------------|-------------------|--------------------------------------|------------------------------| | | | | | | | | | | | | | | | | | books | /books/v1/getBook/{bookId} | get | bookId | path | string | 4 | 10 | | | 24 | success | boolean | API to get single book by id summary | API to get single book by id | | | | | token | header | string | 50 | 100 | A token used for auth | | | | | | | | books | /books/v1/books | get | sort | query | string | | | | | date | success | boolean | API to get data of books | API to get data of books | | | | | order | query | string | | | | | A | message | string | | | | | | | page | query | string | | | | TRUE | 1 | data | object | | | | | | | limit | query | string | | | | TRUE | 10 | | | | | | | | | token | header | string | | | | | | | | | | | books | /books/v1/books | post | contents | body | string | | | | | | success | boolean | API to add books | API to add books | | | | | id | query | string | | | | | | | | | | | | | | token | header | string | | | | | | | | | | | books | /books/v1/addbooks | post | name | body | string | | | | TRUE | A tale of two cities | success | boolean | API to add data from pbooks | API to add data from pbooks | | | | | pages | body | number | | | | TRUE | 450 | | | | | | | | | author | body | string | | | | | Charles Dickens | | | | | | | | | example1 | query | string | | | example 2 description | TRUE | | | | | | | | | | example2 | query | string | | | | | | | | | | | | | | token | header | string | | | | | | | | | | | employees | /employees/v1/getEmployees | post | contents | body | string | 3 | 100 | contents description | | | success | boolean | API to get Employees | API to get Employees | | | | | id | query | string | 16 | 32 | | | | | | | | | | | | token | header | string | | | | TRUE | | | | | | | | | | emp | body | object | | | | TRUE | | | | | | | | | | qualification | body | array | | | | | | | | | | | employees | /employees/v1/uploadData | post | excelFile | formData | file | | | | | | | | | | | | | | data | formData | string | | | | | | | | | |

Step 2: Generate swagger file

Once you are done with your excel file as instructed above you now have to follow the steps:

1. Install the package as a dev dependency

npm i -D commons-excel2swagger

2. Running commands

Open terminal/console from the root of your project directory where this package is installed.
npx exSwag

npx exSwag C:\downloads\project\project_swagger.xlsx

3. Output

Running the above command will generate a swagger file where your excel file is present In the above example it will be generated as:
C:\downloads\project\project_swagger.json

4. Verify the output (Optional)

Visit swagger editor and paste the generated swagger json in this editor.
This will show the error(s) if present on the right side of the screen.