aboutsummaryrefslogtreecommitdiff
path: root/lib/csapi/gtad.yaml
blob: b83e489bf792f9cead9f913dc7459d006be31c18 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
analyzer:
  subst:
    "%CLIENT_RELEASE_LABEL%": r0
    "%CLIENT_MAJOR_VERSION%": r0
  identifiers:
    signed: signedData
    unsigned: unsignedData
    default: isDefault
    origin_server_ts: originServerTimestamp # Instead of originServerTs
    start: begin # Because start() is a method in BaseJob

  # Structure inside `types`:
  # - swaggerType: <targetTypeSpec>
  # OR
  # - swaggerType:
  #   - swaggerFormat: <targetTypeSpec>
  #   - /swaggerFormatRegEx/: <targetTypeSpec>
  #   - //: <targetTypeSpec> # default, if the format doesn't mach anything above
  # WHERE
  # targetTypeSpec = targetType OR
  #   { type: targetType, imports: <filename OR [ filenames... ]>, <other attributes...> }
  # swaggerType can be @apply/@on pair; attributes from the map under @apply
  # are added to each type from the sequence under @on.
  types:
  - +set: &UseOmittable
      useOmittable:
      imports: [ '"converters.h"' ]
      omittedValue: none # See `none` in converters.h
    +on:
    - integer:
      - int64: qint64
      - int32: qint32
      - //: int
    - number:
      - float: float
      - //: double
  - boolean: { type: bool, omittedValue: 'false' }
  - string:
    - byte: &ByteStream
        type: QIODevice*
        imports: <QtCore/QIODevice>
    - binary: *ByteStream
    - +set: { avoidCopy: }
      +on:
      - date:
          type: QDate
          initializer: QDate::fromString("{{defaultValue}}")
          imports: <QtCore/QDate>
      - dateTime:
          type: QDateTime
          initializer: QDateTime::fromString("{{defaultValue}}")
          imports: <QtCore/QDateTime>
      - //:
          type: QString
          initializer: QStringLiteral("{{defaultValue}}")
          isString:
  - file: *ByteStream
  - +set: { avoidCopy: }
    +on:
    - object: { type: QJsonObject, imports: <QtCore/QJsonObject> }
    - $ref:
      - /m\.room\.member$/: pass # This $ref is only used in an array, see below
      - +set: { moveOnly: }
        +on:
        - /state_event.yaml$/:
            { type: StateEventPtr, imports: '"events/event.h"' }
        - /room_event.yaml$/:
            { type: RoomEventPtr, imports: '"events/event.h"' }
        - /event.yaml$/:
            { type: EventPtr, imports: '"events/event.h"' }
    - array:
      - string: { type: QStringList, imports: <QtCore/QStringList> }
      - +set: { moveOnly: }
        +on:
        - /^Notification|Result$/:
            type: "std::vector<{{1}}>"
            imports: '"events/event.h"'
        - /m\.room\.member$/:
            type: "EventsArray<RoomMemberEvent>"
            imports: '"events/roommemberevent.h"'
        - /state_event.yaml$/:
            type: StateEvents
        - /room_event.yaml$/:
            type: RoomEvents
        - /event.yaml$/:
            type: Events
      - /.+/: { type: "QVector<{{1}}>", imports: <QtCore/QVector> }
      - //: { type: QJsonArray, imports: <QtCore/QJsonArray> }
    # `additionalProperties` in OpenAPI
    - map:
      - RoomState:
          type: "std::unordered_map<QString, {{1}}>"
          moveOnly:
          imports: <unordered_map>
      - /.+/:
          type: "QHash<QString, {{1}}>"
          imports: <QtCore/QHash>
      - //:
          type: QVariantHash
          imports: '"variant_converters.h"'
    # A sequence `type` in OpenAPI
    - variant: { type: QVariant, imports: '"variant_converters.h"' }
    - schema: # Properties of inline structure definitions
        *UseOmittable

  #operations:

mustache:
  definitions:
    _scopeRenderer: "{{scopeCamelCase}}Job::"
    _literalQuote: '"'
    omittedValue: '{}' # default value to initialize omitted parameters with
    openOmittable: "{{^required?}}{{#useOmittable}}Omittable<{{/useOmittable}}{{/required?}}"
    closeOmittable: "{{^required?}}{{#useOmittable}}>{{/useOmittable}}{{/required?}}"
    maybeOmittableType: "{{>openOmittable}}{{dataType.name}}{{>closeOmittable}}"
    qualifiedMaybeOmittableType: "{{>openOmittable}}{{dataType.qualifiedName}}{{>closeOmittable}}"
    maybeCrefType: "{{#avoidCopy}}const {{/avoidCopy}}{{>maybeOmittableType}}{{#avoidCopy}}&{{/avoidCopy}}{{#moveOnly}}&&{{/moveOnly}}"
    qualifiedMaybeCrefType:
      "{{#avoidCopy}}const {{/avoidCopy}}{{>qualifiedMaybeOmittableType}}{{#avoidCopy}}&{{/avoidCopy}}{{#moveOnly}}&&{{/moveOnly}}"
    initializeDefaultValue: "{{#defaultValue}}{{#initializer}}{{>initializer}}{{/initializer}}{{/defaultValue}}{{^defaultValue}}{{>omittedValue}}{{/defaultValue}}"
    joinedParamDecl: '{{>maybeCrefType}} {{paramName}}{{^required?}} = {{>initializeDefaultValue}}{{/required?}}{{#@join}}, {{/@join}}'
    joinedParamDef: '{{>maybeCrefType}} {{paramName}}{{#@join}}, {{/@join}}'
    passQueryParams: '{{#queryParams}}{{paramName}}{{#@join}}, {{/@join}}{{/queryParams}}'
    paramToString: '{{#isString}}{{nameCamelCase}}{{/isString}}{{^isString}}QString("%1").arg({{nameCamelCase}}{{^required?}}{{#useOmittable}}.value(){{/useOmittable}}{{/required?}}){{/isString}}'
  #  preamble: preamble.mustache
    copyrightName: Kitsune Ral
    copyrightEmail: <kitsune-ral@users.sf.net>

  templates:
  - "{{base}}.h.mustache"
  - "{{base}}.cpp.mustache"

  #outFilesList: apifiles.txt