OpenAPITools/openapi-generator

[REQ][Qt][C++] Callback support for Qt5

Open

#8,410 opened on 2021年1月11日

GitHub で見る
 (1 comment) (0 reactions) (0 assignees)Java (26,243 stars) (7,516 forks)batch import
Client: C++Client: QTEnhancement: FeatureHacktoberfesthelp wanted

説明

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&#x3D;&#39;{
  &quot;description&quot; : &quot;subscription payload&quot;,
  &quot;content&quot; : {
    &quot;application/json&quot; : {
      &quot;schema&quot; : {
        &quot;properties&quot; : {
          &quot;timestamp&quot; : {
            &quot;type&quot; : &quot;string&quot;,
            &quot;format&quot; : &quot;date-time&quot;
          },
          &quot;userData&quot; : {
            &quot;type&quot; : &quot;string&quot;
          }
        }
      }

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!

コントリビューターガイド