Decorate method for deleting a resource in your controller.
Example:
@ApiPath( {
path : "/versions",
name : "Version"
} )
@controller( "/versions" )
@injectable()
export class VersionController implements interfaces.Controller {
public static TARGET_NAME: string = "VersionController";
private data: [any] = [
{
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"
}
];
@ApiOperationDelete( {
path : "/{id}",
parameters : {
path : {
id : {
description : "Id of version",
type : SwaggerDefinitionConstant.Parameter.Type.STRING,
required : true
}
}
},
responses : {
200 : { description: "Success" }
}
} )
@httpDelete( "/:id" )
public deleteVersion( @requestParam( "id" ) id: string, request: express.Request, response: express.Response, next: express.NextFunction ): void {
this.data.forEach( ( version: any, index: number )=> {
if ( version.id === id ) {
this.data.splice(index, 1);
return response.status(200).end();
}
} );
response.status( 404 ).end();
}
}
Define particular path of operation. Default is path parameter in @ApiPath.
- Optional
Define description of operation.
- Optional
Define summary of operation.
- Optional
parameters: IApiOperationArgsBaseParameters
Define parameters in path, body, query and formData.
- Required
responses: {[key: string]: IApiOperationArgsBaseResponse}
Define all responses.
- Required
Define type list that resource produce.
- Optional
- Default is global type list defined in ISwaggerBuildDefinition when execute .express(options: ISwaggerExpressOptions)
Define security
- Optional
Example:
...
@ApiOperationDelete( {
path : "/{id}",
parameters : {
path : {
id : {
description : "Id of version",
type : SwaggerDefinitionConstant.Parameter.Type.STRING,
required : true
}
}
},
responses : {
200 : { description: "Success" }
},
security : {
basicAuth : []
}
} )
...
}
Example:
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"
}
}
}
}
) );
Define deprecated
- Optional