Forum Discussion
hello pwd
can you please share more details? such as codegen version you use, also what jax-rs language (in codegen options) are you using to generated code? and if it's possible, share the api documentation used on your sample
- hugomario5 years agoStaff
do you think you can share client code or part of the client code used to invoke request ?
- pwd5 years agoOccasional Contributor
Sure - I use a C++ tool using cpprest stubs generated from the same API. The calling code looks as follows (let me know if there are other parts of interest):
std::shared_ptr<ApiConfiguration> apiConfig = std::make_shared<ApiConfiguration>(); apiConfig->setUserAgent("Agent-42"); apiConfig->setBaseUrl("http://XXX:8080/XXX/XXX-backend/1.0"); std::shared_ptr<ApiClient> apiClient = std::make_shared<ApiClient>(); apiClient->setConfiguration(apiConfig); std::shared_ptr<HostManagementApi> hostMgmtApi = std::make_shared<HostManagementApi>(apiClient); std::shared_ptr<HostSpec> hs = std::make_shared<HostSpec>(); hs->setHostId(hostID); pplx::task<std::shared_ptr<Empty_success_response>> requestTask = hostMgmtApi->addHost(hs); requestTask.then([=](pplx::task<std::shared_ptr<Empty_success_response>> task) { fprintf(stderr, "Task completed; collecting response...\n"); try { std::shared_ptr<Empty_success_response> response = task.get(); } catch (const std::exception &e) { printf("Error exception during task.get(): %s\n", e.what()); } });
- pwd5 years agoOccasional Contributor
I'm just using whatever codegen version is current on Swaggerhub, which I'm using for development. I exported the server stubs for plain "jaxrs", IIRC.
Again, the strange part is that the whole operation works fine end-to-end if the body is included in the original request packet; it's when the body is sent in a separate packet that the API is just called with a "null" value for a required [body] parameter.
I'm having some trouble accessing the API through Swaggerhub at the moment but the API definition (in the original yaml) for the Swagger 2.0 version of the API, was as follows:
swagger: '2.0' info: version: '1.0' title: '...' ... HostSpec: type: object required: - host-id properties: host-id: type: string ... paths: /hosts: ... put: description: ... tags: - Host Management operationId: AddHost consumes: - application/json - application/xml produces: - application/json - application/xml parameters: - name: HostSpec description: ... in: body schema: $ref: '#/definitions/HostSpec' required: true responses: 200: description: Successful operation schema: $ref: '#/definitions/empty-success-response' ...
Let me know if there's anything else of possible interest?
Thanks a lot,
-Patrick.
Related Content
- 7 months agosinis
- 4 years agokrasnoludpauli
- 2 years agovericomms
Recent Discussions
- 10 hours agoKrishnan79
- 2 days agosuhaskr
- 11 days agoPrathik
swagger- specific_Api
Solved15 days agoyos123