0.1.7 • Published 1 year ago

easy-swagger v0.1.7

Weekly downloads
-
License
CC-BY-NC-4.0
Repository
github
Last release
1 year ago

EASY SWAGGER

This package allows you to create your swagger documentation in a simple and easy way.

Getting Started

Install package

# npm
npm install easy-swagger
# yarn
yarn add easy-swagger

Create swagger document

npx easy-swagger --root=./src

Generate interactive API

npx easy-swagger-ui

Folder structure

API with controllers

└── src/
    └── api-name/
        └── api-version/
            ├── api.json
            └── controller-name/
                └── service-name/
                    ├── request.json
                    └── status-code/
                        └── response.json

Example:

└── src/
    └── pets/
        └── v1/
        │   ├── api.json
        │   └── users/
        │   │   └── login/
        │   │       ├── request.json
        │   │       └── 200/
        │   │       │   └── response.json
        │   │       └── 401/
        │   │       │   └── response.json
        │   │       └── 500/
        │   │           └── response.json
        │   └── stores/
        │       └── inventory/
        │           ├── request.json
        │           └── 200/
        │           │   └── response.json
        │           └── 400/
        │               └── response.json
        └── v2/
            ├── api.json
            └── users/
            │   └── sign-in/
            │       ├── request.json
            │       └── 200/
            │       │   └── response.json
            │       └── 401/
            │          └── response.json
            └── stores/
                └── inventory/
                    ├── request.json
                    └── 200/
                    │   └── response.json
                    └── 500/
                        └── response.json

API without controllers

└── src/
    └── api-name/
        └── api-version/
            ├── api.json
            └── service-name/
                ├── request.json
                └── status-code/
                    └── response.json

Example:

└── src/
    └── pets/
        └── v1/
        │   ├── api.json
        │   └── login/
        │   │   ├── request.json
        │   │   └── 200/
        │   │   │   └── response.json
        │   │   └── 401/
        │   │   │   └── response.json
        │   │   └── 500/
        │   │       └── response.json
        │   └── inventory/
        │       ├── request.json
        │       └── 200/
        │       │   └── response.json
        │       └── 400/
        │           └── response.json
        └── v2/
            ├── api.json
            └── sign-in/
            │   ├── request.json
            │   └── 200/
            │   │   └── response.json
            │   └── 401/
            │       └── response.json
            └── inventory/
                ├── request.json
                └── 200/
                │   └── response.json
                └── 500/
                    └── response.json

Documents

api.json

{
  "title": "API name",
  "description": "API description",
  "version": "v1",
  "servers": [
    {
      "description": "Production server URL",
      "url": "https://api.example.com/v1"
    },
    {
      "description": "Test server URL",
      "url": "https://test.example.com/v1"
    }
  ]
}
KeyDescriptionType Value
titleThe name of the APIstring
descriptionA description of the APIstring
versionThe version of the APIstring
serversList of server objectslist

Server list:

KeyDescriptionType Value
descriptionA description of the serverstring
urlThe URL of the serverstring

request.json

{
  "body": {
    "username": "",
    "password": "",
    "level": 10
  },
  "headers": {
    "token": "Bearer token",
    "x-api-key": "api-key"
  },
  "queries": {
    "limit": 10,
    "page": 1,
    "search": ""
  },
  "params": {
    "id": 10
  },
  "form": {},
  "contentType": "application/json",
  "method": "post",
  "description": "Generic description",
  "path": "/controller/endpoint/{id}",
  "tag": "tag-group"
}
KeyDescriptionType Value
bodyRequest body parametersObject
headersRequest headersObject
queriesURL query parametersObject
paramsURL path parametersObject
formForm data parametersObject
contentTypeContent type of the requeststring
methodHTTP methodstring
descriptionDescription of the requeststring
pathEndpoint pathstring
tagTag groupstring

response.json

{
  "body": {
    "message": "",
    "success": true,
    "errores": []
  },
  "headers": {
    "token": "Bearer token",
    "time-stamp": ""
  }
}
KeyDescriptionType Value
bodyResponse body parametersObject
headersResponse headersObject

License

The Easy Swagger is licensed under the CC-BY-NC-4.0 license.

0.1.7

1 year ago

0.1.6

1 year ago

0.1.5

1 year ago

0.1.4

1 year ago

0.1.3

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago

0.0.14

1 year ago

0.0.13

1 year ago

0.0.12

1 year ago

0.0.11

1 year ago

0.0.10

1 year ago

0.0.9

1 year ago

0.0.8

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago