Skip to content

Commit 3afac74

Browse files
Bycobbeniz
authored andcommitted
docs: improve swagger documentation
...so that old documentation is no longer required
1 parent b75b013 commit 3afac74

10 files changed

+556
-10
lines changed

CMakeLists.txt

+9
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,11 @@ add_custom_target(
248248
DEPENDS ${CMAKE_BINARY_DIR}/src/caffe.pb.h ${CMAKE_BINARY_DIR}/src/caffe.pb.cc
249249
)
250250

251+
# read documentation
252+
file(
253+
READ "${CMAKE_SOURCE_DIR}/docs/api_swagger.md"
254+
API_DOC
255+
)
251256

252257
# dependency on Eigen for confusion matrix fast computation
253258
if (USE_TF)
@@ -1393,6 +1398,10 @@ configure_file (
13931398
"${PROJECT_SOURCE_DIR}/src/dd_config.h.in"
13941399
"${PROJECT_BINARY_DIR}/dd_config.h"
13951400
)
1401+
configure_file (
1402+
"${PROJECT_SOURCE_DIR}/src/dd_config.cc.in"
1403+
"${PROJECT_BINARY_DIR}/dd_config.cc"
1404+
)
13961405

13971406
# status
13981407
message(STATUS "RELEASE: ${RELEASE}")

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ curl -X GET https://docker.jolibrain.com/v2/deepdetect_cpu/tags/list
9292
- templates for the most useful neural architectures (e.g. Googlenet, Alexnet, ResNet, convnet, character-based convnet, mlp, logistic regression, SSD, DeepLab, PSPNet, U-Net, CRNN, ShuffleNet, SqueezeNet, MobileNet, RefineDet, VOVNet, ...)
9393
- support for sparse features and computations on both GPU and CPU
9494
- built-in similarity indexing and search of predicted features, images, objects and probability distributions
95+
- auto-generated documentation based on [Swagger](https://swagger.io/)
9596

9697

9798
## Machine Learning functionalities per library

docs/api_swagger.md

+312
Large diffs are not rendered by default.

src/CMakeLists.txt

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
set_source_files_properties(
44
${CMAKE_BINARY_DIR}/src/caffe.pb.cc
55
${CMAKE_BINARY_DIR}/src/caffe.pb.h
6+
${CMAKE_BINARY_DIR}/dd_config.cc
67
PROPERTIES GENERATED TRUE)
78
set_source_files_properties(
89
${CMAKE_BINARY_DIR}/src/caffe.pb.cc
@@ -23,7 +24,7 @@ set(ddetect_SOURCES deepdetect.h deepdetect.cc mllibstrategy.h mlmodel.h
2324
svminputfileconn.h svminputfileconn.cc txtinputfileconn.h
2425
txtinputfileconn.cc apidata.h apidata.cc chain_actions.h chain_actions.cc
2526
service_stats.h service_stats.cc chain.h chain.cc resources.cc ext/rmustache/mustache.h ext/rmustache/mustache.cc
26-
utils/oatpp.cc dto/ddtypes.cc utils/db.cpp utils/db_lmdb.cpp ${CMAKE_BINARY_DIR}/src/caffe.pb.cc)
27+
utils/oatpp.cc dto/ddtypes.cc utils/db.cpp utils/db_lmdb.cpp ${CMAKE_BINARY_DIR}/src/caffe.pb.cc ${CMAKE_BINARY_DIR}/dd_config.cc)
2728

2829
if (USE_JSON_API)
2930
list(APPEND ddetect_SOURCES jsonapi.h jsonapi.cc)
@@ -32,7 +33,7 @@ if (USE_HTTP_SERVER)
3233
list(APPEND ddetect_SOURCES httpjsonapi.cc httpjsonapi.h)
3334
endif()
3435
if (USE_HTTP_SERVER_OATPP)
35-
list(APPEND ddetect_SOURCES oatppjsonapi.cc oatppjsonapi.h http/app_component.hpp http/swagger_component.hpp http/controller.hpp http/error_handler.hpp http/error_handler.cpp http/access_log.cpp)
36+
list(APPEND ddetect_SOURCES oatppjsonapi.cc oatppjsonapi.h http/app_component.hpp http/swagger_component.hpp http/controller.hpp http/error_handler.hpp http/error_handler.cpp http/access_log.cpp http/documentation.cc)
3637
endif()
3738
if (USE_HTTP_SERVER OR USE_HTTP_SERVER_OATPP)
3839
list(APPEND ddetect_SOURCES http/flags.h)

src/dd_config.cc.in

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#include "dd_config.h"
2+
3+
std::string GET_API_DOC() {
4+
static std::string API_DOC = R"apidocumentation(@API_DOC@)apidocumentation";
5+
return API_DOC;
6+
}

src/dd_config.h.in

+5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#ifndef DD_CONFIG_H
22
#define DD_CONFIG_H
33

4+
#include <string>
5+
46
#define BUILD_TYPE "@BUILD_TYPE@"
57
#define GIT_VERSION "@GIT_VERSION@"
68
#define GIT_BRANCH "@GIT_BRANCH@"
@@ -20,4 +22,7 @@
2022
"CUDA_VERSION=@CUDA_VERSION_STRING@ CUDNN_VERSION=@CUDNN_VERSION@ " \
2123
"CUDA_ARCH=@CUDA_ARCH@ TENSORRT_VERSION=@TENSORRT_VERSION@"
2224

25+
// Swagger documentation
26+
std::string GET_API_DOC();
27+
2328
#endif

src/http/controller.hpp

+18-6
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#include "dto/service_create.hpp"
4040
#include "dto/stream.hpp"
4141
#include "dto/resource.hpp"
42+
#include "documentation.hpp"
4243

4344
#include OATPP_CODEGEN_BEGIN(ApiController)
4445

@@ -64,7 +65,8 @@ class DedeController : public oatpp::web::server::api::ApiController
6465

6566
ENDPOINT_INFO(get_info)
6667
{
67-
info->summary = "Retrieve server information";
68+
info->summary = "Returns general information about the deepdetect server, "
69+
"including the list of existing services.";
6870
info->addResponse<Object<dd::DTO::InfoResponse>>(Status::CODE_200,
6971
"application/json");
7072
}
@@ -100,7 +102,7 @@ class DedeController : public oatpp::web::server::api::ApiController
100102

101103
ENDPOINT_INFO(get_service)
102104
{
103-
info->summary = "Retrieve a service detail";
105+
info->summary = "Returns information on an existing service";
104106
}
105107
ENDPOINT("GET", "services/{service-name}", get_service,
106108
PATH(oatpp::String, service_name, "service-name"),
@@ -138,7 +140,7 @@ class DedeController : public oatpp::web::server::api::ApiController
138140

139141
ENDPOINT_INFO(create_service)
140142
{
141-
info->summary = "Create a service";
143+
info->summary = "Create a new machine learning service";
142144
info->addConsumes<Object<dd::DTO::ServiceCreate>>("application/json");
143145
}
144146
ENDPOINT("POST", "services/{service-name}", create_service,
@@ -164,6 +166,13 @@ class DedeController : public oatpp::web::server::api::ApiController
164166
ENDPOINT_INFO(delete_service)
165167
{
166168
info->summary = "Delete a service";
169+
info->queryParams.add("clear", String::Class::getType()).description
170+
= "`full`, `lib`, `mem`, `dir` or `index`. `full` clears the model "
171+
"and service repository, `lib` removes model files only according "
172+
"to the behavior specified by the service's ML library, `mem` "
173+
"removes the service from memory without affecting the files, `dir` "
174+
"removes the whole directory, `index` removes the index when using "
175+
"similarity search. default=`mem`";
167176
}
168177
ENDPOINT("DELETE", "services/{service-name}", delete_service,
169178
PATH(oatpp::String, service_name, "service-name"),
@@ -199,7 +208,9 @@ class DedeController : public oatpp::web::server::api::ApiController
199208

200209
ENDPOINT_INFO(post_train)
201210
{
202-
info->summary = "Do a training";
211+
info->summary
212+
= "Launches a blocking or asynchronous training job from a service.";
213+
info->body.description = dd::GET_TRAIN_PARAMETERS();
203214
}
204215
ENDPOINT("POST", "train", post_train, BODY_STRING(oatpp::String, train_data))
205216
{
@@ -219,7 +230,7 @@ class DedeController : public oatpp::web::server::api::ApiController
219230
}
220231
ENDPOINT_INFO(delete_train)
221232
{
222-
info->summary = "Delete a training";
233+
info->summary = "Stop and delete a training job";
223234
}
224235
ENDPOINT("DELETE", "train", delete_train, QUERIES(QueryParams, queryParams))
225236
{
@@ -230,7 +241,8 @@ class DedeController : public oatpp::web::server::api::ApiController
230241

231242
ENDPOINT_INFO(create_chain)
232243
{
233-
info->summary = "Run a chain";
244+
info->summary = "Run a chain call, that allows to call multiple models "
245+
"sequentially";
234246
}
235247
ENDPOINT("POST", "chain/{chain-name}", create_chain,
236248
PATH(oatpp::String, chain_name, "chain-name"),

0 commit comments

Comments
 (0)