Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

swagger-express-ts

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

swagger-express-ts - npm Package Compare versions

Comparing version 1.0.0-beta.1 to 1.0.0-rc.1

.npmignore

179

CHANGELOG.md

@@ -0,1 +1,104 @@

<a name="1.0.0-rc.1"></a>
# [1.0.0-rc.1] (2018-04-08)
## Features
### Model
#### Configuration
example:
```ts
definition : {
...
models : {
Version : {
properties : {
id : {
type : SwaggerDefinitionConstant.Model.Property.Type.STRING,
required : true
},
name : {
type : SwaggerDefinitionConstant.Model.Property.Type.STRING,
required : true
},
description : {
type : SwaggerDefinitionConstant.Model.Property.Type.STRING
},
version : {
type : SwaggerDefinitionConstant.Model.Property.Type.STRING
},
author: {
model: "Author"
}
}
},
Author: {
properties: {
id: {
type: SwaggerDefinitionConstant.Model.Property.Type.STRING,
required : true
},
name : {
type : SwaggerDefinitionConstant.Model.Property.Type.STRING,
required : true
},
}
}
},
...
}
```
or
```ts
@ApiModel( {
description : "Version description" ,
name : "Version"
} )
export class VersionModel {
@ApiModelProperty( {
description : "Id of version" ,
required : true
} )
id : number;
@ApiModelProperty( {
description : "" ,
required : true
} )
name : string;
@ApiModelProperty( {
description : "Description of version" ,
required : true
} )
description : string;
@ApiModelProperty( {
description : "Author of version" ,
model : "Author"
} )
author : AuthorModel;
}
```
#### Controller
example:
```ts
@ApiOperationGet( {
...
responses : {
200 : { description : "Success" , type : SwaggerDefinitionConstant.Response.Type.ARRAY , model : "Version" }
} ,
...
} )
```
<a name="1.0.0-beta.1"></a>

@@ -13,19 +116,19 @@ # [1.0.0-beta.1] (2018-03-02)

```ts
app.use( swagger.express(
{
definition : {
...
securityDefinitions : {
basicAuth : {
type : SwaggerDefinitionConstant.Security.Type.BASIC_AUTHENTICATION
},
apiKeyHeader : {
type: SwaggerDefinitionConstant.Security.Type.API_KEY,
in: SwaggerDefinitionConstant.Security.In.HEADER,
name: "apiHeader"
}
app.use( swagger.express(
{
definition : {
...
securityDefinitions : {
basicAuth : {
type : SwaggerDefinitionConstant.Security.Type.BASIC_AUTHENTICATION
},
apiKeyHeader : {
type: SwaggerDefinitionConstant.Security.Type.API_KEY,
in: SwaggerDefinitionConstant.Security.In.HEADER,
name: "apiHeader"
}
}
}
) );
}
) );
```

@@ -38,10 +141,10 @@

```ts
...
@ApiOperationGet( {
...
@ApiOperationGet( {
...
security : {
basicAuth : []
}
} )
...
security : {
basicAuth : []
}
} )
...
```

@@ -54,10 +157,10 @@

```ts
...
@ApiOperationGet( {
...
@ApiOperationGet( {
...
security : {
apiKeyHeader : []
}
} )
...
security : {
apiKeyHeader : []
}
} )
...
```

@@ -70,8 +173,8 @@

```ts
...
@ApiPath( {
...
@ApiPath( {
...
deprecated: true
} )
...
deprecated: true
} )
...
```

@@ -82,8 +185,8 @@

```ts
...
@ApiOperationGet( {
...
@ApiOperationGet( {
...
deprecated: true
} )
...
deprecated: true
} )
...
```

@@ -90,0 +193,0 @@

@@ -12,3 +12,3 @@ export interface IApiOperationArgsBaseParameter {

description?: string;
isArray?: boolean;
type?: string;
model?: string;

@@ -15,0 +15,0 @@ }

@@ -50,3 +50,7 @@ import { ISwaggerSecurityDefinition } from "./swagger.builder";

$ref?: string;
format?: string;
}
export interface ISwaggerOperationSchemaItems {
$ref: string;
}
export interface ISwaggerOperationResponse {

@@ -83,5 +87,13 @@ description?: string;

}
export interface ISwaggerDefinitionPropertyItems {
$ref: string;
}
export interface ISwaggerDefinitionProperty {
type: string;
type?: string;
format?: string;
required?: boolean;
description?: string;
enum?: string[];
items?: ISwaggerDefinitionPropertyItems;
$ref?: string;
}

@@ -98,2 +110,3 @@ export interface ISwaggerDefinitionXML {

xml?: ISwaggerDefinitionXML;
description?: string;
}

@@ -100,0 +113,0 @@ export interface ISwagger {

@@ -0,1 +1,2 @@

import 'reflect-metadata';
export { IApiPathArgs, ApiPath } from "./api-path.decorator";

@@ -7,4 +8,6 @@ export { IApiOperationGetArgs, ApiOperationGet } from "./api-operation-get.decorator";

export { IApiOperationDeleteArgs, ApiOperationDelete } from "./api-operation-delete.decorator";
export { IApiModelPropertyArgs, ApiModelProperty } from "./api-model-property.decorator";
export { IApiModelArgs, ApiModel } from "./api-model.decorator";
export { SwaggerDefinitionConstant } from "./swagger-definition.constant";
export { express, ISwaggerExpressOptions } from "./express.configurator";
export { build } from "./swagger.builder";
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
require("reflect-metadata");
var api_path_decorator_1 = require("./api-path.decorator");

@@ -15,2 +16,6 @@ exports.ApiPath = api_path_decorator_1.ApiPath;

exports.ApiOperationDelete = api_operation_delete_decorator_1.ApiOperationDelete;
var api_model_property_decorator_1 = require("./api-model-property.decorator");
exports.ApiModelProperty = api_model_property_decorator_1.ApiModelProperty;
var api_model_decorator_1 = require("./api-model.decorator");
exports.ApiModel = api_model_decorator_1.ApiModel;
var swagger_definition_constant_1 = require("./swagger-definition.constant");

@@ -17,0 +22,0 @@ exports.SwaggerDefinitionConstant = swagger_definition_constant_1.SwaggerDefinitionConstant;

@@ -24,2 +24,3 @@ export declare class SwaggerDefinitionConstant {

OBJECT: string;
ARRAY: string;
};

@@ -29,2 +30,3 @@ Property: {

INTEGER: string;
ARRAY: string;
STRING: string;

@@ -31,0 +33,0 @@ };

@@ -27,3 +27,4 @@ "use strict";

Type: {
OBJECT: SwaggerDefinitionConstant.OBJECT
OBJECT: SwaggerDefinitionConstant.OBJECT,
ARRAY: SwaggerDefinitionConstant.ARRAY
},

@@ -33,2 +34,3 @@ Property: {

INTEGER: SwaggerDefinitionConstant.INTEGER,
ARRAY: SwaggerDefinitionConstant.ARRAY,
STRING: SwaggerDefinitionConstant.STRING

@@ -35,0 +37,0 @@ },

@@ -5,4 +5,5 @@ import { ISwaggerInfo, ISwaggerExternalDocs } from "./i-swagger";

* Define type of property. Example: SwaggerDefinitionConstant.Definition.Property.Type.STRING
* Optional.
*/
type: string;
type?: string;
/**

@@ -18,5 +19,23 @@ * Define format of property. Example: SwaggerDefinitionConstant.Definition.Property.Format.INT_64

required?: boolean;
/**
* Define model.
* Optional.
*/
model?: string;
/**
* Define enum;
* Optional.
*/
enum?: string[];
/**
* Define description.
*/
description?: string;
}
export interface ISwaggerBuildDefinitionModel {
/**
* Define description.
*/
description?: string;
/**
* Define all properties of model.

@@ -23,0 +42,0 @@ */

@@ -5,3 +5,2 @@ "use strict";

var swagger_service_1 = require("./swagger.service");
var swagger_definition_constant_1 = require("./swagger-definition.constant");
function build(buildDefinition) {

@@ -38,26 +37,3 @@ assert.ok(buildDefinition, "Definition are required.");

if (buildDefinition.models) {
var definitions = {};
for (var modelIndex in buildDefinition.models) {
var model = buildDefinition.models[modelIndex];
var newDefinition = {
type: swagger_definition_constant_1.SwaggerDefinitionConstant.Model.Type.OBJECT,
properties: {},
required: []
};
for (var propertyIndex in model.properties) {
var property = model.properties[propertyIndex];
var newProperty = {
type: property.type
};
if (property.format) {
newProperty.format = property.format;
}
if (property.required) {
newDefinition.required.push(propertyIndex);
}
newDefinition.properties[propertyIndex] = newProperty;
}
definitions[modelIndex] = newDefinition;
}
swagger_service_1.SwaggerService.getInstance().setDefinitions(definitions);
swagger_service_1.SwaggerService.getInstance().setDefinitions(buildDefinition.models);
}

@@ -64,0 +40,0 @@ swagger_service_1.SwaggerService.getInstance().buildSwagger();

@@ -1,11 +0,14 @@

import { ISwagger, ISwaggerInfo, ISwaggerDefinition, ISwaggerExternalDocs } from "./i-swagger";
import { ISwagger, ISwaggerInfo, ISwaggerExternalDocs } from "./i-swagger";
import { IApiPathArgs } from "./api-path.decorator";
import { IApiOperationPostArgs } from "./api-operation-post.decorator";
import { IApiOperationGetArgs } from "./api-operation-get.decorator";
import { IApiModelPropertyArgs } from "./api-model-property.decorator";
import { IApiModelArgs } from ".";
import { ISwaggerSecurityDefinition } from "./swagger.builder";
import { ISwaggerBuildDefinitionModel } from "./swagger.builder";
export declare class SwaggerService {
private static instance;
private controllerMap;
private definitionsMap;
private data;
private modelsMap;
private constructeur();

@@ -23,4 +26,4 @@ static getInstance(): SwaggerService;

setHost(host: string): void;
setDefinitions(definitions: {
[key: string]: ISwaggerDefinition;
setDefinitions(models: {
[key: string]: ISwaggerBuildDefinitionModel;
}): void;

@@ -44,2 +47,4 @@ setExternalDocs(externalDocs: ISwaggerExternalDocs): void;

private buildRef(definition);
addApiModelProperty(args: IApiModelPropertyArgs, target: any, propertyKey: string | symbol, propertyType: string): void;
addApiModel(args: IApiModelArgs, target: any): any;
}

@@ -9,3 +9,3 @@ "use strict";

this.controllerMap = [];
this.definitionsMap = {};
this.modelsMap = {};
}

@@ -24,3 +24,2 @@ SwaggerService.prototype.constructeur = function () {

this.controllerMap = [];
this.definitionsMap = {};
this.initData();

@@ -68,4 +67,46 @@ };

};
SwaggerService.prototype.setDefinitions = function (definitions) {
this.data.definitions = definitions;
SwaggerService.prototype.setDefinitions = function (models) {
var definitions = {};
for (var modelIndex in models) {
var model = models[modelIndex];
var newDefinition = {
type: swagger_definition_constant_1.SwaggerDefinitionConstant.Model.Type.OBJECT,
properties: {},
required: []
};
if (model.description) {
newDefinition.description = model.description;
}
for (var propertyIndex in model.properties) {
var property = model.properties[propertyIndex];
var newProperty = {
type: property.type
};
if (property.format) {
newProperty.format = property.format;
}
if (property.description) {
newProperty.description = property.description;
}
if (property.enum) {
newProperty.enum = property.enum;
}
if (property.model) {
if (_.isEqual(swagger_definition_constant_1.SwaggerDefinitionConstant.Model.Property.Type.ARRAY, property.type)) {
newProperty.items = {
$ref: this.buildRef(property.model)
};
}
else {
newProperty.$ref = this.buildRef(property.model);
}
}
if (property.required) {
newDefinition.required.push(propertyIndex);
}
newDefinition.properties[propertyIndex] = newProperty;
}
definitions[modelIndex] = newDefinition;
}
this.data.definitions = _.merge(this.data.definitions, definitions);
};

@@ -258,3 +299,3 @@ SwaggerService.prototype.setExternalDocs = function (externalDocs) {

};
if (response.isArray) {
if (_.isEqual(response.type, swagger_definition_constant_1.SwaggerDefinitionConstant.Response.Type.ARRAY)) {
newSwaggerOperationResponseSchema = {

@@ -376,4 +417,44 @@ items: {

};
SwaggerService.prototype.addApiModelProperty = function (args, target, propertyKey, propertyType) {
var definitionKey = target.constructor.name;
var swaggerBuildDefinitionModel = this.modelsMap[definitionKey];
if (!swaggerBuildDefinitionModel) {
swaggerBuildDefinitionModel = {
properties: {}
};
this.modelsMap[definitionKey] = swaggerBuildDefinitionModel;
}
var swaggerBuildDefinitionModelProperty = {
type: propertyType
};
if (args) {
swaggerBuildDefinitionModelProperty.required = args.required;
swaggerBuildDefinitionModelProperty.description = args.description;
swaggerBuildDefinitionModelProperty.enum = args.enum;
swaggerBuildDefinitionModelProperty.model = args.model;
}
swaggerBuildDefinitionModel.properties[propertyKey] = swaggerBuildDefinitionModelProperty;
this.setDefinitions(this.modelsMap);
};
SwaggerService.prototype.addApiModel = function (args, target) {
var definitionKey = target.name;
var swaggerBuildDefinitionModel = this.modelsMap[definitionKey];
if (!swaggerBuildDefinitionModel) {
swaggerBuildDefinitionModel = {
properties: {}
};
this.modelsMap[definitionKey] = swaggerBuildDefinitionModel;
}
if (args) {
swaggerBuildDefinitionModel.description = args.description;
if (args.name) {
this.modelsMap[_.capitalize(args.name)] = _.clone(this.modelsMap[definitionKey]);
delete this.modelsMap[definitionKey];
delete this.data.definitions[definitionKey];
}
}
this.setDefinitions(this.modelsMap);
};
return SwaggerService;
}());
exports.SwaggerService = SwaggerService;
{
"name": "swagger-express-ts",
"version": "1.0.0-beta.1",
"version": "1.0.0-rc.1",
"description": "Generate and serve swagger.json",

@@ -5,0 +5,0 @@ "main": "./dist/index.js",

@@ -7,10 +7,5 @@ ![](wiki/img/logo.png)

## Getting started
First, install [inversify-express-utils](https://www.npmjs.com/package/inversify-express-utils).
```sh
npm install inversify inversify-express-utils reflect-metadata --save
```
First, install [swagger-express-ts](https://www.npmjs.com/package/swagger-express-ts).
Install [swagger-express-ts](https://github.com/olivierlsc/swagger-express-ts).
```sh

@@ -22,2 +17,4 @@ npm install swagger-express-ts --save

In the examples below, we use [inversify-express-utils](https://www.npmjs.com/package/inversify-express-utils). inversify-express-utils is not required to work with swagger-express-ts.
### Step 1: configure express

@@ -57,25 +54,6 @@

} ,
models : {
Version : {
properties : {
id : {
type : SwaggerDefinitionConstant.Model.Property.Type.STRING ,
required : true
} ,
name : {
type : SwaggerDefinitionConstant.Model.Property.Type.STRING ,
required : true
} ,
description : {
type : SwaggerDefinitionConstant.Model.Property.Type.STRING
} ,
version : {
type : SwaggerDefinitionConstant.Model.Property.Type.STRING
}
}
}
} ,
externalDocs : {
url : "My url"
}
// Models can be defined here
}

@@ -100,141 +78,96 @@ }

### Step 2: Decorate your controllers
### Step 2: Decorate your models
```ts
import * as express from "express";
import { injectable } from "inversify";
import { controller, httpGet, interfaces, httpPost, requestParam, httpPut } from "inversify-express-utils";
import { SwaggerDefinitionConstant, ApiPath, ApiOperationGet, ApiOperationPost, ApiOperationPut } from "swagger-express-ts";
import "reflect-metadata";
const pkg = require ( "../../package.json" );
@ApiPath( {
path : "/versions" ,
@ApiModel( {
description : "Version description" ,
name : "Version"
} )
@controller( "/versions" )
export class VersionModel {
@ApiModelProperty( {
description : "Id of version" ,
required : true
} )
id : number;
@ApiModelProperty( {
description : "" ,
required : true
} )
name : string;
@ApiModelProperty( {
description : "Description of version" ,
required : true
} )
description : string;
}
```
### Step 3: Decorate your controllers
```ts
@ApiPath({
path: "/versions",
name: "Version",
security: { basicAuth: [] }
})
@controller("/versions")
@injectable()
export class VersionController implements interfaces.Controller {
public static TARGET_NAME : string = "VersionController";
private data : [any] = [
public static TARGET_NAME: string = "VersionController";
private data = [{
id: "1",
name: "Version 1",
description: "Description Version 1",
version: "1.0.0"
},
{
id : "1" ,
name : "Version 1" ,
description : "Description Version 1" ,
version : "1.0.0"
} ,
{
id : "2" ,
name : "Version 2" ,
description : "Description Version 2" ,
version : "2.0.0"
}
];
id: "2",
name: "Version 2",
description: "Description Version 2",
version: "2.0.0"
}];
@ApiOperationGet( {
description : "Get version object" ,
summary : "Get version" ,
responses : {
200 : { description : "Success" , isArray : true , model : "Version" }
@ApiOperationGet({
description: "Get versions objects list",
summary: "Get versions list",
responses: {
200: { description: "Success", type: SwaggerDefinitionConstant.Response.Type.ARRAY, model: "Version" }
},
security: {
apiKeyHeader: []
}
} )
@httpGet( "/" )
public getVersions ( request : express.Request , response : express.Response , next : express.NextFunction ) : void {
response.json( this.data );
})
@httpGet("/")
public getVersions(request: express.Request, response: express.Response, next: express.NextFunction): void {
response.json(this.data);
}
@ApiOperationPost( {
description : "Post version object" ,
summary : "Post new version" ,
parameters : {
body : { description : "New version" , required : true , model : "Version" }
} ,
responses : {
200 : { description : "Success" } ,
400 : { description : "Parameters fail" }
@ApiOperationPost({
description: "Post version object",
summary: "Post new version",
parameters: {
body: { description: "New version", required: true, model: "Version" }
},
responses: {
200: { description: "Success" },
400: { description: "Parameters fail" }
}
} )
@httpPost( "/" )
public postVersion ( request : express.Request , response : express.Response , next : express.NextFunction ) : void {
if ( ! request.body ) {
return response.status( 400 ).end();
})
@httpPost("/")
public postVersion(request: express.Request, response: express.Response, next: express.NextFunction): void {
if (!request.body) {
return response.status(400).end();
}
this.data.push( request.body );
response.json( request.body );
this.data.push(request.body);
response.json(request.body);
}
@ApiOperationGet( {
path : "/{id}" ,
description : "Get version by id" ,
summary : "Get version detail" ,
parameters : {
path : {
id : {
description : "Id of version" ,
type : SwaggerDefinitionConstant.Parameter.Type.STRING ,
required : true
}
}
} ,
responses : {
200 : { description : "Success" , model : "Version" } ,
404 : { description : "Version not exist" }
} ,
produces : [ SwaggerDefinitionConstant.Produce.JSON ]
} )
@httpGet( "/:id" )
public getVersion ( @requestParam( "id" ) id : string , request : express.Request , response : express.Response , next : express.NextFunction ) : void {
this.data.forEach( ( version : any )=> {
if ( version.id === id ) {
return response.json( version );
}
} );
response.status( 404 ).end();
}
@ApiOperationPut( {
path : "/{id}" ,
description: "Put version by id",
summary: "Put version",
parameters : {
path : {
id : {
description : "Id of version" ,
type : SwaggerDefinitionConstant.Parameter.Type.STRING ,
required : true
}
} ,
body : {
description : "Updated version" ,
model : "Version" ,
required : true
}
} ,
responses : {
200 : { model : "Version" }
}
} )
@httpPut( "/:id" )
public putVersion ( @requestParam( "id" ) id : string , request : express.Request , response : express.Response , next : express.NextFunction ) : void {
if ( ! request.body ) {
return response.status( 400 ).end();
}
this.data.forEach( ( version : any , index : number )=> {
if ( version.id === id ) {
let newVersion = request.body;
version.id = newVersion.id;
version.name = newVersion.name;
version.description = newVersion.description;
version.version = newVersion.version;
this.data[ index ] = version;
return response.json( version );
}
} );
response.status( 404 ).end();
}
}
```
### Step 3: Test
### Step 4: Test

@@ -375,2 +308,4 @@ Start your server and test on url : /api-docs/swagger.json

- [Configuration](./wiki/configuration.md)
- [@ApiModel](./wiki/api-model.decorator.md)
- [@ApiModelProperty](./wiki/api-model-property.decorator.md)
- [@ApiPath](./wiki/api-path.decorator.md)

@@ -382,3 +317,2 @@ - [@ApiOperationGet](./wiki/api-operation-get.decorator.md)

- [@ApiOperationDelete](./wiki/api-operation-delete.decorator.md)
- [Test](./wiki/test.md)

@@ -385,0 +319,0 @@ ## For any questions, suggestions, or feature requests

@@ -7,8 +7,2 @@ # @ApiOperationDelete(args: IApiOperationDeleteArgs)

```ts
import * as express from "express";
import { injectable } from "inversify";
import { controller, interfaces, requestParam, httpDelete } from "inversify-express-utils";
import { ApiPath, ApiOperationDelete, SwaggerDefinitionConstant } from "swagger-express-ts";
import "reflect-metadata";
@ApiPath( {

@@ -88,3 +82,3 @@ path : "/versions",

## setProduces: string[]
## produces: string[]
Define type list that resource produce.

@@ -91,0 +85,0 @@ - Optional

@@ -7,8 +7,2 @@ # @ApiOperationGet(args: IApiOperationGetArgs)

```ts
import * as express from "express";
import { injectable } from "inversify";
import { controller, interfaces, requestParam, httpGet } from "inversify-express-utils";
import { ApiPath, ApiOperationGet, SwaggerDefinitionConstant } from "swagger-express-ts";
import "reflect-metadata";
@ApiPath( {

@@ -41,3 +35,3 @@ path : "/versions",

responses : {
200 : { description : "Success", isArray : true, model : "Version" }
200 : { description : "Success", type : SwaggerDefinitionConstant.Response.Type.ARRAY , model : "Version" }
}

@@ -75,3 +69,3 @@ } )

## setProduces: string[]
## produces: string[]
Define type list that resource produce.

@@ -90,7 +84,3 @@ - Optional

@ApiOperationGet( {
description : "Get version object",
summary : "Get version",
responses : {
200 : { description : "Success", isArray : true, model : "Version" }
},
...
security : {

@@ -97,0 +87,0 @@ basicAuth : []

@@ -7,8 +7,2 @@ # @ApiOperationPatch(args: IApiOperationPatchArgs)

```ts
import * as express from "express";
import { injectable } from "inversify";
import { controller, interfaces, requestParam, httpPatch } from "inversify-express-utils";
import { ApiPath, ApiOperationPatch, SwaggerDefinitionConstant } from "swagger-express-ts";
import "reflect-metadata";
@ApiPath( {

@@ -96,3 +90,3 @@ path : "/versions",

## setProduces: string[]
## produces: string[]
Define type list that resource produce.

@@ -99,0 +93,0 @@ - Optional

@@ -7,8 +7,2 @@ # @ApiOperationPost(args: IApiOperationPostArgs)

```ts
import * as express from "express";
import { injectable } from "inversify";
import { controller, interfaces, requestParam, httpPost } from "inversify-express-utils";
import { ApiPath, ApiOperationPost, SwaggerDefinitionConstant } from "swagger-express-ts";
import "reflect-metadata";
@ApiPath( {

@@ -82,3 +76,3 @@ path : "/versions",

## setProduces: string[]
## produces: string[]
Define type list that resource produce.

@@ -85,0 +79,0 @@ - Optional

@@ -7,8 +7,2 @@ # @ApiOperationPut(args: IApiOperationPutArgs)

```ts
import * as express from "express";
import { injectable } from "inversify";
import { controller, interfaces, requestParam, httpPut } from "inversify-express-utils";
import { ApiPath, ApiOperationPut, SwaggerDefinitionConstant } from "swagger-express-ts";
import "reflect-metadata";
@ApiPath( {

@@ -101,3 +95,3 @@ path : "/versions",

## setProduces: string[]
## produces: string[]
Define type list that resource produce.

@@ -104,0 +98,0 @@ - Optional

@@ -61,19 +61,19 @@ # @ApiPath(args: IApiPathArgs)

```ts
app.use( swagger.express(
{
definition : {
...
securityDefinitions : {
basicAuth : {
type : SwaggerDefinitionConstant.Security.Type.BASIC_AUTHENTICATION
},
apiKeyHeader : {
type: SwaggerDefinitionConstant.Security.Type.API_KEY,
in: SwaggerDefinitionConstant.Security.In.HEADER,
name: "apiHeader"
}
app.use( swagger.express(
{
definition : {
...
securityDefinitions : {
basicAuth : {
type : SwaggerDefinitionConstant.Security.Type.BASIC_AUTHENTICATION
},
apiKeyHeader : {
type: SwaggerDefinitionConstant.Security.Type.API_KEY,
in: SwaggerDefinitionConstant.Security.In.HEADER,
name: "apiHeader"
}
}
}
) );
}
) );
```

@@ -80,0 +80,0 @@

@@ -58,19 +58,19 @@ # Configuration

```ts
app.use( swagger.express(
{
definition : {
...
securityDefinitions : {
basicAuth : {
type : SwaggerDefinitionConstant.Security.Type.BASIC_AUTHENTICATION
},
apiKeyHeader : {
type: SwaggerDefinitionConstant.Security.Type.API_KEY,
in: SwaggerDefinitionConstant.Security.In.HEADER,
name: "apiHeader"
}
app.use( swagger.express(
{
definition : {
...
securityDefinitions : {
basicAuth : {
type : SwaggerDefinitionConstant.Security.Type.BASIC_AUTHENTICATION
},
apiKeyHeader : {
type: SwaggerDefinitionConstant.Security.Type.API_KEY,
in: SwaggerDefinitionConstant.Security.In.HEADER,
name: "apiHeader"
}
}
}
) );
}
) );
```

@@ -83,22 +83,18 @@

```ts
...
@ApiPath( {
path : "/version",
name : "Version",
security : {
basicAuth : []
}
} )
...
@ApiOperationGet( {
...
@ApiPath( {
path : "/version",
name : "Version",
security : {
basicAuth : []
}
} )
...
@ApiOperationGet( {
description : "Get version object",
summary : "Get version",
responses : {
200 : { description : "Success", isArray : true, model : "Version" }
},
security : {
basicAuth : []
}
} )
...
security : {
basicAuth : []
}
} )
...
```

@@ -24,3 +24,4 @@ # IApiOperationArgsBaseParameter

## model: string
Define model of parameter.
Define model reference
- Optional
- If you want specify Array of model, you must set type with [SwaggerDefinitionConstant](./swagger-definition-constant.md).Definition.Property.Type.ARRAY

@@ -12,3 +12,4 @@ # IApiOperationArgsBaseResponse

## model: string
Define model of response.
Define model reference
- Optional
- If you want specify Array of model, you must set type with [SwaggerDefinitionConstant](./swagger-definition-constant.md).Definition.Property.Type.ARRAY

@@ -15,3 +15,17 @@ # ISwaggerBuildDefinitionModelProperty

Define if property is required.
- Optionnal
- Default is false.
- Optional
- Default is false.
## model: string
Define model reference
- Optional
- If you want specify Array of model, you must set type with [SwaggerDefinitionConstant](./swagger-definition-constant.md).Definition.Property.Type.ARRAY
## description: string
Define description of property.
- Optional
## enum: string[]
Define enum of property.
- Optional
# ISwaggerBuildDefinitionModel
## description: string;
Define description
- Optional
## properties: {[key: string]: [ISwaggerBuildDefinitionModelProperty](./i-swagger-build-definition-model-property.md)}
Define properties of model.
- Required

@@ -9,4 +9,3 @@ # Installation

The InversifyJS type setDefinitions are included in the inversify npm package.
InversifyJS requires the experimentalDecorators, emitDecoratorMetadataand lib compilation options in your tsconfig.json file.
swagger-express-ts requires the experimentalDecorators, emitDecoratorMetadata and lib compilation options in your tsconfig.json file.

@@ -13,0 +12,0 @@ ```json

@@ -11,3 +11,6 @@ # Wiki

- [Installation](./installation.md)
- [Configuration](./configuration.md)
- [@ApiModel](./api-model.decorator.md)
- [@ApiModelProperty](./api-model-property.decorator.md)
- [@ApiPath](./api-path.decorator.md)

@@ -22,2 +25,2 @@ - [@ApiOperationGet](./api-operation-get.decorator.md)

- [Test](./test.md)
- [example-swagger-express-ts](https://github.com/olivierlsc/example-swagger-express-ts)

@@ -35,2 +35,4 @@ # SwaggerDefinitionConstant

##### ARRAY: string = "array"
#### Format

@@ -37,0 +39,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc