Installations
npm install pip-services3-swagger-nodex
Developer Guide
Typescript
No
Module System
CommonJS
Min. Node Version
>=14.0.0
Node Version
15.9.0
NPM Version
7.5.3
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
TypeScript (70.64%)
PowerShell (15.61%)
HTML (13.75%)
Developer
pip-services3-nodex
Download Statistics
Total Downloads
11,505
Last Day
1
Last Week
9
Last Month
205
Last Year
2,060
GitHub Statistics
10 Commits
3 Watching
1 Branches
2 Contributors
Package Meta Information
Latest Version
1.0.0
Package Id
pip-services3-swagger-nodex@1.0.0
Unpacked Size
17.79 MB
Size
4.89 MB
File Count
76
NPM Version
7.5.3
Node Version
15.9.0
Total Downloads
Cumulative downloads
Total Downloads
11,505
Last day
-88.9%
1
Compared to previous day
Last week
-87%
9
Compared to previous week
Last month
44.4%
205
Compared to previous month
Last year
-55.7%
2,060
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Swagger UI for Pip.Services in Node.js / ES2017
This module is a part of the Pip.Services polyglot microservices toolkit.
The swagger module provides a Swagger UI that can be added into microservices and seamlessly integrated with existing REST and Commandable HTTP services.
The module contains the following packages:
- Build - Swagger service factory
- Services - Swagger UI service
Use
Install the NPM package as
1npm install pip-services3-swagger-nodex --save
Develop a RESTful service component. For example, it may look the following way.
In the register
method we load an Open API specification for the service.
You can also enable swagger by default in the constractor by setting _swaggerEnable
property.
1export class MyRestService extends RestService { 2 public constructor() { 3 super(); 4 this._baseRoute = "myservice"; 5 this._swaggerEnable = true; 6 } 7 8 private greeting(req, res) { 9 let name = req.params.name; 10 let response = "Hello, " + name + "!"; 11 this.sendResult(req, res, response); 12 } 13 14 public register() { 15 this.registerRoute( 16 'get', '/greeting', 17 new ObjectSchema(true) 18 .withRequiredProperty("name", TypeCode.String), 19 this.greeting 20 ); 21 22 this.registerOpenApiSpecFromFile('./src/services/myservice.yml'); 23 } 24}
The Open API specification for the service shall be prepared either manually or using Swagger Editor
1openapi: '3.0.2' 2info: 3 title: 'MyService' 4 description: 'MyService REST API' 5 version: '1' 6paths: 7 /myservice/greeting: 8 get: 9 tags: 10 - myservice 11 operationId: 'greeting' 12 parameters: 13 - name: correlation_id 14 in: query 15 description: Correlation ID 16 required: false 17 schema: 18 type: string 19 - name: name 20 in: query 21 description: Name of a person 22 required: true 23 schema: 24 type: string 25 responses: 26 200: 27 description: 'Successful response' 28 content: 29 application/json: 30 schema: 31 type: 'string'
Include Swagger service into config.yml
file and enable swagger for your REST or Commandable HTTP services.
Also explicitely adding HttpEndpoint allows to share the same port betwee REST services and the Swagger service.
1--- 2... 3# Shared HTTP Endpoint 4- descriptor: "pip-services:endpoint:http:default:1.0" 5 connection: 6 protocol: http 7 host: localhost 8 port: 8080 9 10# Swagger Service 11- descriptor: "pip-services:swagger-service:http:default:1.0" 12 13# My RESTful Service 14- descriptor: "myservice:service:rest:default:1.0" 15 swagger: 16 enable: true
Finally, remember to add factories to your container, to allow it creating required components.
1... 2import { DefaultRpcFactory } from 'pip-services3-rpc-nodex'; 3import { DefaultSwaggerFactory } from 'pip-services3-swagger-nodex'; 4 5export class MyProcess extends ProcessContainer { 6 public constructor() { 7 super("myservice", "MyService microservice"); 8 9 this._factories.add(new DefaultRpcFactory()); 10 this._factories.add(new DefaultSwaggerFactory()); 11 this._factories.add(new MyServiceFactory()); 12 ... 13 } 14}
Launch the microservice and open the browser to open the Open API specification at http://localhost:8080/greeting/swagger
Then open the Swagger UI using the link http://localhost:8080/swagger. The result shall look similar to the picture below.
![](swagger-ui.png)
Develop
For development you shall install the following prerequisites:
- Node.js 8+
- Visual Studio Code or another IDE of your choice
- Docker
- Typescript
Install dependencies:
1npm install
Compile the code:
1tsc
Run automated tests:
1npm test
Generate API documentation:
1./docgen.ps1
Before committing changes run dockerized build and test as:
1./build.ps1 2./test.ps1 3./clear.ps1
Contacts
The Node.js version of Pip.Services is created and maintained by:
- Sergey Seroukhov
![Empty State](/_next/static/media/empty.e5fae2e5.png)
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/10 approved changesets -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/github-ci.yml:1
- Info: no jobLevel write permissions found
Reason
no SAST tool detected
Details
- Warn: no pull requests merged into dev branch
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'main'
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/github-ci.yml:21: update your workflow using https://app.stepsecurity.io/secureworkflow/pip-services3-nodex/pip-services3-swagger-nodex/github-ci.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/github-ci.yml:39: update your workflow using https://app.stepsecurity.io/secureworkflow/pip-services3-nodex/pip-services3-swagger-nodex/github-ci.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/github-ci.yml:53: update your workflow using https://app.stepsecurity.io/secureworkflow/pip-services3-nodex/pip-services3-swagger-nodex/github-ci.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/github-ci.yml:56: update your workflow using https://app.stepsecurity.io/secureworkflow/pip-services3-nodex/pip-services3-swagger-nodex/github-ci.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/github-ci.yml:98: update your workflow using https://app.stepsecurity.io/secureworkflow/pip-services3-nodex/pip-services3-swagger-nodex/github-ci.yml/main?enable=pin
- Warn: containerImage not pinned by hash: docker/Dockerfile.build:1: pin your Docker image by updating node:14 to node:14@sha256:a158d3b9b4e3fa813fa6c8c590b8f0a860e015ad4e59bbce5744d2f6fd8461aa
- Warn: containerImage not pinned by hash: docker/Dockerfile.docs:1: pin your Docker image by updating node:14-alpine to node:14-alpine@sha256:434215b487a329c9e867202ff89e704d3a75e554822e07f3e0c0f9e606121b33
- Warn: npmCommand not pinned by hash: docker/Dockerfile.build:4
- Warn: npmCommand not pinned by hash: docker/Dockerfile.build:12
- Warn: pipCommand not pinned by hash: docker/Dockerfile.docs:11-13
- Warn: npmCommand not pinned by hash: docker/Dockerfile.docs:22-27
- Warn: npmCommand not pinned by hash: docker/Dockerfile.docs:22-27
- Warn: npmCommand not pinned by hash: docker/Dockerfile.docs:22-27
- Warn: npmCommand not pinned by hash: docker/Dockerfile.docs:22-27
- Warn: npmCommand not pinned by hash: docker/Dockerfile.docs:22-27
- Warn: npmCommand not pinned by hash: docker/Dockerfile.docs:22-27
- Info: 0 out of 5 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 2 containerImage dependencies pinned
- Info: 0 out of 8 npmCommand dependencies pinned
- Info: 0 out of 1 pipCommand dependencies pinned
Score
3.4
/10
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More