Example with default configuration:
app.use( swagger.express({
definition : {
info : {
title : "My api" ,
version : "1.0"
} ,
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"
}
}
}) );
Define path to serve swagger.json
- Optional.
- Default is "/api-docs/swagger.json".
definition: ISwaggerBuildDefinition
Define swagger definition.
- Required
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"
}
}
}
}
) );
Example:
...
@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 : []
}
} )
...