2.0.0 • Published 11 months ago

commons-excel2swagger v2.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
11 months ago

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*

keyvalue
version1.0.0
titleNode Template
descriptionTerms of service
serviceTermshttp://swagger.io/terms/
emailapiteam@swagger.io
licenseNameApache License Version 2.0
licenseUrlhttp://www.apache.org/licenses/LICENSE-2.0.html
hostlocalhost: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:

controllerendpointmethodparam.nameparam.typeparam.dataTypeparam.minlenparam.maxlenparam.descriptionparam.requiredparam.exampleresponse.nameresponse.dataTypesummarydescription
books/books/v1/getBook/{bookId}getbookIdpathstring41024successbooleanAPI to get single book by id summaryAPI to get single book by id
tokenheaderstring50100A token used for auth
books/books/v1/booksgetsortquerystringdatesuccessbooleanAPI to get data of booksAPI to get data of books
orderquerystringAmessagestring
pagequerystringTRUE1dataobject
limitquerystringTRUE10
tokenheaderstring
books/books/v1/bookspostcontentsbodystringsuccessbooleanAPI to add booksAPI to add books
idquerystring
tokenheaderstring
books/books/v1/addbookspostnamebodystringTRUEA tale of two citiessuccessbooleanAPI to add data from pbooksAPI to add data from pbooks
pagesbodynumberTRUE450
authorbodystringCharles Dickens
example1querystringexample 2 descriptionTRUE
example2querystring
tokenheaderstring
employees/employees/v1/getEmployeespostcontentsbodystring3100contents descriptionsuccessbooleanAPI to get EmployeesAPI to get Employees
idquerystring1632
tokenheaderstringTRUE
empbodyobjectTRUE
qualificationbodyarray
employees/employees/v1/uploadDatapostexcelFileformDatafile
dataformDatastring

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.

2.0.0

11 months ago

1.0.16

11 months ago

1.0.15

11 months ago

1.0.14

11 months ago

1.0.13

11 months ago

1.0.12

11 months ago

1.0.11

1 year ago

1.0.10

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago