如何使用 swagger-codegen cpprest 客户端库代码?
How do I use swagger-codegen cpprest client library code?
我最近使用 swagger-codegen 为我的 swagger 规范生成 cpprest 客户端代码。代码全部编译和链接在我的C++应用程序中膨胀。
但是,我如何在C++应用程序中实际使用它?我似乎已经初始化了ApiClient和ApiConfiguration。但是我不清楚如何将getXXX()调用合并到我的API对象上(例如:DefaultApi)。
我已经对使用生成的客户端代码演示的源代码进行了相当广泛的互联网搜索,但无济于事。我还注意到这里有 cpprest 的 swagger-codegen 示例宠物店客户端库:(https://github.com/swagger-api/swagger-codegen/tree/master/samples/client/petstore/cpprest),但是任何地方都有它的测试工具吗?
好吧,我为此制定了基础知识,这是一个微不足道的例子:
std::shared_ptr<ApiClient> apiClient(new ApiClient);
std::shared_ptr<ApiConfiguration> apiConfig(new ApiConfiguration);
apiConfig->setBaseUrl("http://example.com/api/v1");
apiClient->setConfiguration(apiConfig);
ExampleApi api(apiClient);
api.getExample().then([=](pplx::task<std::shared_ptr<Example>> example) {
try {
std::cout << example.get()->getDescription() << 'n';
} catch(const std::exception& e) {
std::cout << "getExample() exception: " << e.what() << 'n';
}
});
我仍然想了解如何测试宠物商店cpprest生成的代码。安全带在哪里?有吗?
相关文章:
- 如何在本地机器上运行c++和javascript客户端代码(hackerbank风格)
- 计算出有多少客户端可以连接到我正在使用的一些tcp服务器代码
- cpp / c ++中的grpc客户端代码,元数据x-api-key/x-goog-api-key不起作用,给了我语音A
- 为什么 JsonCpp http 客户端在 201 响应代码上失败?
- 客户端代码中的 Valgrind 钩子:特定函数的内存泄漏
- 如何使用 swagger-codegen cpprest 客户端库代码?
- 在 Ubuntu 上编译 Protobuf 客户端代码,但找不到包含文件
- 如何使用 Python 实验室机器作为我的C++客户端代码的服务器
- 将C 代码(本机客户端)移植到浏览器(Web应用程序)
- 当函数有很多参数和客户端代码只需更改其中时,如何处理情况就可以处理
- C++(不是 C)中的示例服务器/客户端代码
- 我的客户端服务器代码无法正常工作
- 应由库或客户端代码删除已加载库中的对象实例
- 基本服务器/客户端代码出现问题
- Qt服务器客户端代码
- 抽象工厂模式客户端代码
- 当服务器重新启动并且客户端收到WSAECONNRESET错误代码时,我应该重新创建整个套接字吗
- 将 c# asp.net Web 应用程序与C++ dll 链接时,是在服务器或客户端上运行的 dll 代码
- 如何使此代码适用于不同计算机上的服务器和客户端
- 使用Google Mock来模拟在客户端代码中复制的对象