@workos/oagen-emitters 0.10.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -187,6 +187,64 @@ describe('ruby/resources', () => {
187
187
  expect(content).toContain('ListStruct.from_response(');
188
188
  });
189
189
 
190
+ it('reads pagination order default from the spec rather than hardcoding "desc"', () => {
191
+ const services: Service[] = [
192
+ {
193
+ name: 'Organizations',
194
+ operations: [
195
+ makeOp({
196
+ name: 'listOrganizations',
197
+ queryParams: [
198
+ { name: 'after', type: { kind: 'primitive', type: 'string' }, required: false },
199
+ { name: 'limit', type: { kind: 'primitive', type: 'integer' }, required: false },
200
+ {
201
+ name: 'order',
202
+ type: { kind: 'primitive', type: 'string' },
203
+ required: false,
204
+ default: 'desc',
205
+ },
206
+ ],
207
+ pagination: {
208
+ strategy: 'cursor',
209
+ param: 'after',
210
+ dataPath: 'data',
211
+ itemType: { kind: 'model', name: 'Organization' },
212
+ },
213
+ }),
214
+ ],
215
+ },
216
+ ];
217
+ const content = generateResources(services, makeCtx(makeSpec(services)))[0].content;
218
+ expect(content).toContain("order: 'desc'");
219
+ });
220
+
221
+ it("emits order: nil when the spec carries no default (no 'desc' hardcode)", () => {
222
+ const services: Service[] = [
223
+ {
224
+ name: 'Organizations',
225
+ operations: [
226
+ makeOp({
227
+ name: 'listOrganizations',
228
+ queryParams: [
229
+ { name: 'after', type: { kind: 'primitive', type: 'string' }, required: false },
230
+ { name: 'limit', type: { kind: 'primitive', type: 'integer' }, required: false },
231
+ { name: 'order', type: { kind: 'primitive', type: 'string' }, required: false },
232
+ ],
233
+ pagination: {
234
+ strategy: 'cursor',
235
+ param: 'after',
236
+ dataPath: 'data',
237
+ itemType: { kind: 'model', name: 'Organization' },
238
+ },
239
+ }),
240
+ ],
241
+ },
242
+ ];
243
+ const content = generateResources(services, makeCtx(makeSpec(services)))[0].content;
244
+ expect(content).toContain('order: nil');
245
+ expect(content).not.toContain("order: 'desc'");
246
+ });
247
+
190
248
  // ── P0-3: paginated response shape detection ──────────────────────────
191
249
 
192
250
  it('generates ListStruct for paginated endpoints with array response type', () => {