-
Notifications
You must be signed in to change notification settings - Fork 55
/
gtad.yaml
273 lines (246 loc) · 9.66 KB
/
gtad.yaml
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
analyzer:
subst:
"%CLIENT_RELEASE_LABEL%": r0
"%CLIENT_MAJOR_VERSION%": r0
identifiers:
signed: signedData
unsigned: unsignedData
PushRule/default: isDefault
default: defaultVersion # getCapabilities/RoomVersionsCapability
origin_server_ts: originServerTimestamp # Instead of originServerTs
start: begin # Because start() is a method in BaseJob
m.upload.size: uploadSize
m.homeserver: homeserver
m.identity_server: identityServer
m.change_password: changePassword
m.room_versions: roomVersions
AuthenticationData/additionalProperties: authInfo
/^/(Location|Protocol|User)$/: 'ThirdParty$1'
# Change some request body parameter names
/.*AccountData.*>/data/: content
uploadCrossSigningSignatures>/data: signatures
defineFilter>/data: filter
putRoomKeysByRoomId>/data: backupData
uploadContent>/data: content
uploadContentToMXC>/data: content
sendMessage>/data: content
setRoomStateWithKey>/data: content
requestOpenIdToken>/data: dontUse # parameter reserved for future use
# Change some response names
/requestTokenTo.*</data/: response
requestOpenIdToken</data: tokenData
getDevice</data: device
getFilter</data: filter
getProtocols</data: protocols
getOneRoomEvent</data: event
getRoomState</data: events
getRoomStateWithKey</data: content
getPushRule</data: pushRule
# These parameters are deprecated and unused in Quotient; so drop them
login>/user: ""
login>/medium: ""
login>/address: ""
login</home_server: ""
register</home_server: ""
# This is a quirk in the API - the same parameter with the same name is
# passed twice; the below removes the instance inside the request body
putRoomKeysVersion>/version: ""
# 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 +set/+on pair; attributes from the map under +set
# are added to each type from the sequence under +on.
types:
- +set: &UseOptional
useOptional:
omittedValue: 'std::nullopt'
+on:
- integer:
- int64: qint64
- int32: qint32
- //: int
- number:
- float: float
- //: double
- boolean: bool
- string:
- byte: &ByteStream
type: QIODevice*
imports: <QtCore/QIODevice>
- binary: *ByteStream
- +set: { avoidCopy: }
+on:
- date:
type: QDate
initializer: QDate::fromString("{{defaultValue}}")
- dateTime:
type: QDateTime
initializer: QDateTime::fromString("{{defaultValue}}")
- uri:
type: QUrl
initializer: QUrl::fromEncoded("{{defaultValue}}")
- //: &QString
type: QString
initializer: QStringLiteral("{{defaultValue}}")
isString:
- file: *ByteStream
- +set: { avoidCopy: }
+on:
- object: &QJsonObject { type: QJsonObject }
- schema:
- RequestEmailValidation:
title: EmailValidationData
- RequestMsisdnValidation:
title: MsisdnValidationData
- getTurnServer<: *QJsonObject # It's used as an opaque JSON object
- StrippedChildStateEvent: void # only used in an array, see below
# - defineFilter>: &Filter # Force folding into a structure
# type: Filter
# imports: '"csapi/definitions/sync_filter.h"'
# - getFilter<: *Filter
- OneTimeKeys:
type: OneTimeKeys
imports: '<Quotient/e2ee/e2ee_common.h>'
- /(Room|Event|RoomEvent)Filter$/: # These do not need std::optional<>
- //: *UseOptional
- array:
- /^string(,null)?$/: QStringList
- +set: { moveOnly: }
+on:
- /^Notification|Result|SpaceHierarchyRoomsChunk$/: "std::vector<{{1}}>"
- /^StrippedChildStateEvent$|state_event.yaml$/:
type: StateEvents
imports: '<Quotient/events/stateevent.h>' # For StrippedChildStateEvent
- /(room|client)_event.yaml$/: RoomEvents
- /event(_without_room_id)?.yaml$/: Events
- //: "QVector<{{1}}>"
- map: # `additionalProperties` in OpenAPI
- RoomState:
type: "std::unordered_map<QString, {{1}}>"
moveOnly:
- /.+/: "QHash<QString, {{1}}>"
- //: QVariantHash # QJsonObject?..
- variant: # A sequence `type` or a 'oneOf' group in OpenAPI
- /^string,null|null,string$/: *QString
- //: QVariant
references:
# This renderer applies to everything actually imported (not substituted/inlined)
importRenderer: '<Quotient/{{#segments}}{{_}}{{#_join}}/{{/_join}}{{/segments}}.h>'
inline:
# Inline whatever is used from the identity spec
- /identity/definitions/
# Despite being used in two calls, it's more practical to have those
# fields available as getters right from the respective job classes
- /public_rooms_response.yaml$/
# public_rooms_response.yaml uses public_rooms_chunk.yaml as a base structure, overriding
# one field to update its description. Unfortunately, GTAD cannot handle overriding fields
# quite well on its own (you can have two fields with the same name in the base class
# and in the derived class but that's inefficient and very confusing). Since
# public_rooms_chunk.yaml is only used in one other place (space_hierarchy.yaml), it's
# not terribly bad to just inline it for now; and eventually, GTAD will have to learn
# how to automatically flatten and override structures like this.
- /public_rooms_chunk.yaml$/
- /relations.yaml#/components/schemas/response/
replace:
- +set: { moveOnly: }
+on:
- /state_event.yaml$/:
type: StateEventPtr
imports: '<Quotient/events/stateevent.h>'
- /(room|client)_event.yaml$/:
type: RoomEventPtr
imports: '<Quotient/events/roomevent.h>'
- /event(_without_room_id)?.yaml$/:
type: EventPtr
imports: '<Quotient/events/event.h>'
#operations:
mustache:
# delimiter: '%| |%' # or something else instead of '{{ }}'
constants:
# Syntax elements used by GTAD
# _quote: '"' # Common quote for left and right
# _leftQuote: '"'
# _rightQuote: '"_ls'
_comment: '//'
copyrightName: Kitsune Ral
copyrightEmail: <kitsune-ral@users.sf.net>
partials:
_typeRenderer: "{{#scope}}{{#_titleCase}}{{scope}}{{/_titleCase}}Job::{{/scope}}{{>name}}"
omittedValue: '{}' # default value to initialize omitted parameters with
initializer: '{{defaultValue}}'
cjoin: '{{#hasMore}}, {{/hasMore}}'
openOptional:
"{{^required?}}{{#useOptional}}\
{{^defaultValue}}std::optional<{{/defaultValue}}\
{{/useOptional}}{{/required?}}"
closeOptional:
"{{^required?}}{{#useOptional}}\
{{^defaultValue}}>{{/defaultValue}}\
{{/useOptional}}{{/required?}}"
maybeOptionalType: "{{>openOptional}}{{dataType.name}}{{>closeOptional}}"
maybeCrefType:
"{{#avoidCopy}}const {{/avoidCopy}}{{>maybeOptionalType}}{{#avoidCopy}}&{{/avoidCopy}}"
maybeCrefJsonObject:
"{{^propertyMap}}const QJsonObject&{{/propertyMap}}\
{{#propertyMap}}QJsonObject{{/propertyMap}}"
takeOrValue:
"{{#propertyMap}}take{{/propertyMap}}{{^propertyMap}}value{{/propertyMap}}"
takeOrLoad: "{{#moveOnly}}take{{/moveOnly}}{{^moveOnly}}load{{/moveOnly}}"
initializeField:
"{{^required}}{ {{#defaultValue}}{{>initializer}}{{/defaultValue}} }{{/required}}"
paramDefaultValue:
"{{#defaultValue}}{{>initializer}}{{/defaultValue}}\
{{^defaultValue}}{{>omittedValue}}{{/defaultValue}}"
# No inner indents in folded values!
joinedParamDecl: >-
{{>maybeCrefType}} {{paramName}}
{{^required?}} = {{>paramDefaultValue}}{{/required?}}{{>cjoin}}
joinedParamDef: "{{>maybeCrefType}} {{paramName}}{{>cjoin}}"
titleCaseOperationId: '{{#_titleCase}}{{operationId}}{{/_titleCase}}'
passPathAndMaybeQuery: >-
makePath("{{basePathWithoutHost}}"{{#pathParts}},
{{_}}{{/pathParts}}){{#queryParams?}},
queryTo{{>titleCaseOperationId}}(
{{#queryParams}}{{paramName}}{{>cjoin}}{{/queryParams}}){{/queryParams?}}
nonInlineResponseSignature: |-
{{>docCommentShort}}
{{>maybeOptionalType}} {{paramName}}(){{^moveOnly}} const{{/moveOnly}}
overloadCollectResponse: |-
inline auto collectResponse({{^moveOnly}}const {{/moveOnly}}{{>titleCaseOperationId}}Job* job)
{
return job->{{paramName}}();
}
# Doc-comment blocks. Comment indent is managed by clang-format
# (without clang-format there'd have to be a separate partial definition
# for each indent...) but we take care of line breaks to maintain
# some sanity even before clang-format
# This is for structures that don't expect a summary (e.g., JSON schema)
docCommentShort: |-
{{#description}}
//! {{_}}{{/description}}
structDefinition: |-
{{>docCommentShort}}
struct QUOTIENT_API {{name}}{{#parents?}} : {{#parents}}{{name}}{{>cjoin}}{{/parents}}{{/parents?}}
{ {{#vars}}
{{>docCommentShort}}
{{>maybeOptionalType}} {{nameCamelCase}}{{>initializeField}};
{{/vars}}
{{#propertyMap}}
{{>docCommentShort}}
{{>maybeOptionalType}} {{nameCamelCase}}{};
{{/propertyMap}}
};
templates:
data:
.h: "{{>data.h.mustache}}"
api:
.h: "{{>operation.h.mustache}}"
.cpp: "{{>operation.cpp.mustache}}"
#outFilesList: apifiles.txt