OpenAPITools / OpenAPITools/openapi-generator
[REQ][Qt][C++] Callback support for Qt5
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Is your feature request related to a problem? Please describe.
I would like to add callback support for Qt5. I started to implement it but i came across a problem i could not solve.
As far is I know, the callback URL has to be put in the query and if it requires parameters in the request body, those parameters have to be put in the body. I can retrieve the callback URL but i cant get the parameters for the body in the mustache template. I am using THIS YAML file. I tried to change the AbstractCppCodegen.java to create a new Mustache variable (line 339f.):
public void preprocessOpenAPI(OpenAPI openAPI) {
List<Server> serverList = openAPI.getServers();
Map<String, Callback> callbacks = openAPI.getComponents().getCallbacks();
(...)
this.additionalProperties.put("test", callbacks);
}
Unfortunatly this will result in an empty map even though the YAML file proviedes callbacks.
Only way I could get the callback is to use {{#callbacks}} inside {{#operations}}. This is where i can get the callback URL but I cant get the parameters, since they are defined in jsonSchma, which is a big string with the whole request body:
jsonSchema='{
"description" : "subscription payload",
"content" : {
"application/json" : {
"schema" : {
"properties" : {
"timestamp" : {
"type" : "string",
"format" : "date-time"
},
"userData" : {
"type" : "string"
}
}
}
The parameters from the callbacks are defined in the callbacks section of the YAML file:
callbacks:
onData:
'{$request.query.callbackUrl}/data':
post:
requestBody:
description: subscription payload
content:
application/json:
schema:
properties:
timestamp:
type: string
format: date-time
userData:
type: string
Does anyone knows how to get the single parameters from the requestBody field without the big string?
Thanks in advance!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with AbstractCppCodegen.java and the Qt5 C++ templates, then inspect how callbacks are exposed under operations using the linked OpenAPI callback example. Determine how requestBody data is represented for Mustache; done means the individual callback body parameters are available to the Qt5 templates instead of only the serialized jsonSchema string.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, java
- Domain
- api, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100