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-rc.4 to 1.0.0

48

CHANGELOG.md

@@ -0,1 +1,49 @@

<a name="1.0.0"></a>
# [1.0.0](2018-06-10)
## Features
### itemType
Example:
```ts
...
@ApiModelProperty({
description: "Name of author",
required: true,
itemType: SwaggerDefinitionConstant.Model.Property.Type.STRING
})
name: string[];
...
```
or
```ts
...
app.use(
swagger.express({
definition: {
...
models: {
Author: {
name: {
description: "Name of author",
type: SwaggerDefinitionConstant.Model.Property.Type.ARRAY,
itemType:
SwaggerDefinitionConstant.Model.Property.ItemType.STRING,
required: true
}
}
}
}
...
}
})
);
...
```
<a name="1.0.0-rc.4"></a>

@@ -2,0 +50,0 @@

export interface IApiModelPropertyArgs {
/**
* Define if property is required.
* Optional. Default is false.
*/
required?: boolean;
/**
* Define format of property. Example: SwaggerDefinitionConstant.Definition.Property.Format.INT_64
* Optional.
*/
format?: string;
/**
* Define type of property. Example: SwaggerDefinitionConstant.Definition.Property.Type.STRING
* Optional.
*/
type?: string;
/**
* Define description.
* Optional.
*/
description?: string;
/**
* Define enum;
* Optional.
*/
enum?: string[];
/**
* Define model.
* Optional.
*/
model?: string;
/**
* Define type of item. Example: SwaggerDefinitionConstant.Definition.Property.Type.STRING
* Optional.
*/
itemType?: string;
}
export declare function ApiModelProperty(args?: IApiModelPropertyArgs): PropertyDecorator;

3

dist/api-model-property.decorator.js

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

return function (target, propertyKey) {
var propertyType = Reflect.getMetadata("design:type", target, propertyKey).name.toLowerCase();
var propertyType = Reflect.getMetadata("design:type", target, propertyKey)
.name;
swagger_service_1.SwaggerService.getInstance().addApiModelProperty(args, target, propertyKey, propertyType);

@@ -9,0 +10,0 @@ };

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

export interface ISwaggerDefinitionPropertyItems {
$ref: string;
$ref?: string;
type?: string;
}

@@ -90,0 +91,0 @@ export interface ISwaggerDefinitionProperty {

@@ -55,2 +55,8 @@ export declare class SwaggerDefinitionConstant {

};
ItemType: {
STRING: string;
NUMBER: string;
INTEGER: string;
BOOLEAN: string;
};
Format: {

@@ -57,0 +63,0 @@ INT_64: string;

@@ -59,2 +59,8 @@ "use strict";

},
ItemType: {
STRING: SwaggerDefinitionConstant.STRING,
NUMBER: SwaggerDefinitionConstant.NUMBER,
INTEGER: SwaggerDefinitionConstant.INTEGER,
BOOLEAN: SwaggerDefinitionConstant.BOOLEAN
},
Format: {

@@ -61,0 +67,0 @@ INT_64: "int64"

import { ISwaggerInfo, ISwaggerExternalDocs } from "./i-swagger";
import { IApiOperationArgsBaseResponse } from "./i-api-operation-args.base";
export interface ISwaggerBuildDefinitionModelPropertyType {
type?: string | ISwaggerBuildDefinitionModelPropertyType;
}
export interface ISwaggerBuildDefinitionModelProperty {

@@ -31,4 +34,10 @@ /**

* Define description.
* Optional.
*/
description?: string;
/**
* Define type of item. Example: SwaggerDefinitionConstant.Definition.Property.Type.STRING
* Optional.
*/
itemType?: string;
}

@@ -35,0 +44,0 @@ export interface ISwaggerBuildDefinitionModel {

@@ -16,6 +16,6 @@ import { ISwagger, ISwaggerInfo, ISwaggerExternalDocs } from "./i-swagger";

private globalResponses;
private constructeur();
private constructeur;
static getInstance(): SwaggerService;
resetData(): void;
private initData();
private initData;
getData(): ISwagger;

@@ -45,12 +45,12 @@ setBasePath(basePath: string): void;

}): void;
private addOperation(operation, args, target, propertyKey);
private buildOperation(args, target, propertyKey);
private buildOperationResponses(responses);
private buildOperationSecurity(argsSecurity);
private buildParameters(type, parameters);
private addOperation;
private buildOperation;
private buildOperationResponses;
private buildOperationSecurity;
private buildParameters;
buildSwagger(): void;
private buildSwaggerOperation(operation, controller);
private buildRef(definition);
private buildSwaggerOperation;
private buildRef;
addApiModelProperty(args: IApiModelPropertyArgs, target: any, propertyKey: string | symbol, propertyType: string): void;
addApiModel(args: IApiModelArgs, target: any): any;
}

@@ -90,2 +90,7 @@ "use strict";

}
if (property.itemType) {
newProperty.items = {
type: property.itemType
};
}
if (property.model) {

@@ -287,3 +292,4 @@ if (_.isEqual(swagger_definition_constant_1.SwaggerDefinitionConstant.Model.Property.Type.ARRAY, property.type)) {

case "203":
newSwaggerOperationResponse.description = "Non-Authoritative Information";
newSwaggerOperationResponse.description =
"Non-Authoritative Information";
break;

@@ -300,12 +306,16 @@ case "204":

case "400":
newSwaggerOperationResponse.description = "Client error and Bad Request";
newSwaggerOperationResponse.description =
"Client error and Bad Request";
break;
case "401":
newSwaggerOperationResponse.description = "Client error and Unauthorized";
newSwaggerOperationResponse.description =
"Client error and Unauthorized";
break;
case "404":
newSwaggerOperationResponse.description = "Client error and Not Found";
newSwaggerOperationResponse.description =
"Client error and Not Found";
break;
case "406":
newSwaggerOperationResponse.description = "Client error and Not Acceptable";
newSwaggerOperationResponse.description =
"Client error and Not Acceptable";
break;

@@ -448,3 +458,4 @@ case "500":

var definitionKey = target.constructor.name;
var swaggerBuildDefinitionModel = this.modelsMap[definitionKey];
var swaggerBuildDefinitionModel = this
.modelsMap[definitionKey];
if (!swaggerBuildDefinitionModel) {

@@ -457,3 +468,3 @@ swaggerBuildDefinitionModel = {

var swaggerBuildDefinitionModelProperty = {
type: propertyType
type: _.lowerCase(propertyType)
};

@@ -464,5 +475,14 @@ if (args) {

swaggerBuildDefinitionModelProperty.enum = args.enum;
swaggerBuildDefinitionModelProperty.model = args.model;
swaggerBuildDefinitionModelProperty.itemType = args.itemType;
if (args.model) {
swaggerBuildDefinitionModelProperty.model = args.model;
if (!_.isEqual("Array", propertyType)) {
swaggerBuildDefinitionModelProperty.type = undefined;
}
}
if (args.type) {
swaggerBuildDefinitionModelProperty.type = args.type;
}
}
swaggerBuildDefinitionModel.properties[propertyKey] = swaggerBuildDefinitionModelProperty;
swaggerBuildDefinitionModel.properties[propertyKey.toString()] = swaggerBuildDefinitionModelProperty;
this.setDefinitions(this.modelsMap);

@@ -472,3 +492,4 @@ };

var definitionKey = target.name;
var swaggerBuildDefinitionModel = this.modelsMap[definitionKey];
var swaggerBuildDefinitionModel = this
.modelsMap[definitionKey];
if (!swaggerBuildDefinitionModel) {

@@ -475,0 +496,0 @@ swaggerBuildDefinitionModel = {

{
"name": "swagger-express-ts",
"version": "1.0.0-rc.4",
"version": "1.0.0",
"description": "Generate and serve swagger.json",

@@ -9,8 +9,6 @@ "main": "./dist/index.js",

"scripts": {
"package":
"echo \"Packaging...\" && npm run clean && node node_modules/typescript/bin/tsc -p tsconfig.package.json",
"package": "echo \"Packaging...\" && npm run clean && node node_modules/typescript/bin/tsc -p tsconfig.package.json",
"build": "echo \"Building...\" && node node_modules/gulp/bin/gulp.js build",
"test": "echo \"Testing...\" && node node_modules/gulp/bin/gulp.js test",
"test:coverage":
"echo \"Testing coverage...\" && node node_modules/gulp/bin/gulp.js test:coverage",
"test:coverage": "echo \"Testing coverage...\" && node node_modules/gulp/bin/gulp.js test:coverage",
"clean": "echo \"Cleaning...\" && node node_modules/gulp/bin/gulp.js clean",

@@ -50,41 +48,39 @@ "tslint": "echo \"TsLint...\" && node node_modules/gulp/bin/gulp.js tslint",

"dependencies": {
"@types/lodash": "^4.14.92",
"lodash": "^4.17.4",
"@types/lodash": "^4.14.109",
"lodash": "^4.17.10",
"reflect-metadata": "^0.1.10"
},
"devDependencies": {
"@types/body-parser": "^1.16.8",
"@types/chai": "^4.0.10",
"@types/body-parser": "^1.17.0",
"@types/chai": "^4.1.3",
"@types/compression": "0.0.35",
"@types/helmet": "0.0.37",
"@types/mocha": "^2.2.44",
"@types/sinon": "^4.1.2",
"body-parser": "^1.18.2",
"@types/mocha": "^2.2.48",
"@types/sinon": "^4.3.3",
"body-parser": "^1.18.3",
"chai": "^4.1.2",
"compression": "^1.7.1",
"compression": "^1.7.2",
"gulp": "^3.9.1",
"gulp-clean": "^0.3.2",
"gulp-istanbul": "^1.1.2",
"gulp-jenkins-reporter": "^1.0.2",
"gulp-mocha": "^3.0.1",
"gulp-mocha": "^6.0.0",
"gulp-nodemon": "^2.2.1",
"gulp-prettier-plugin": "^1.3.0",
"gulp-sourcemaps": "^2.6.1",
"gulp-tslint": "^8.1.2",
"gulp-tslint-jenkins-reporter": "^1.1.0",
"gulp-typescript": "^3.2.3",
"helmet": "^3.9.0",
"inversify": "^4.5.1",
"gulp-sourcemaps": "^2.6.4",
"gulp-tslint": "^8.1.3",
"gulp-tslint-jenkins-reporter": "^1.1.1",
"gulp-typescript": "^3.2.4",
"helmet": "^3.12.1",
"inversify": "^4.13.0",
"inversify-express-utils": "^4.2.2",
"mocha": "^4.0.1",
"mocha-jenkins-reporter": "^0.3.10",
"prettier": "1.12.0",
"pretty-quick": "^1.4.1",
"rimraf": "^2.6.2",
"sinon": "^4.1.2",
"swagger-ui-dist": "^3.6.1",
"tslint": "^5.8.0",
"sinon": "^4.5.0",
"swagger-ui-dist": "^3.17.0",
"tslint": "^5.10.0",
"tslint-config-prettier": "^1.10.0",
"typescript": "^2.6.2"
"typescript": "^2.9.1"
}
}

@@ -52,2 +52,7 @@ # @ApiModelProperty(args?: IApiModelPropertyArgs)

Define model
- Optional
## itemType: string
Define item type.
- Optional

@@ -30,2 +30,34 @@ # ISwaggerBuildDefinitionModelProperty

Define enum of property.
- Optional
- Optional
## itemType: string
Define item type.
- Optional
Example:
```ts
...
app.use(
swagger.express({
definition: {
...
models: {
Author: {
name: {
description: "Name of author",
type: SwaggerDefinitionConstant.Model.Property.Type.ARRAY,
itemType:
SwaggerDefinitionConstant.Model.Property.ItemType.STRING,
required: true
}
}
}
}
...
}
})
);
...
```
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