@workos/oagen-emitters 0.12.4 → 0.13.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.
- package/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +14 -0
- package/dist/index.mjs +1 -1
- package/dist/{plugin-nmiHN7Ko.mjs → plugin-B9F2jmwy.mjs} +1432 -1203
- package/dist/plugin-B9F2jmwy.mjs.map +1 -0
- package/dist/plugin.mjs +1 -1
- package/package.json +7 -7
- package/src/kotlin/client.ts +3 -2
- package/src/kotlin/naming.ts +34 -0
- package/src/kotlin/resources.ts +5 -3
- package/src/kotlin/tests.ts +12 -3
- package/src/node/client.ts +11 -2
- package/src/node/field-plan.ts +27 -13
- package/src/node/manifest.ts +5 -3
- package/src/node/models.ts +52 -6
- package/src/node/naming.ts +24 -0
- package/src/node/resources.ts +21 -9
- package/src/node/tests.ts +52 -9
- package/src/php/client.ts +3 -2
- package/src/php/naming.ts +22 -0
- package/src/php/resources.ts +3 -2
- package/src/python/client.ts +16 -5
- package/src/python/naming.ts +25 -0
- package/src/python/resources.ts +4 -1
- package/src/ruby/client.ts +18 -5
- package/src/ruby/manifest.ts +5 -0
- package/src/ruby/naming.ts +30 -0
- package/src/ruby/rbi.ts +15 -8
- package/src/ruby/resources.ts +10 -3
- package/src/ruby/tests.ts +22 -5
- package/src/shared/service-name-collision.ts +56 -0
- package/test/node/models.test.ts +56 -0
- package/test/node/tests.test.ts +57 -0
- package/dist/plugin-nmiHN7Ko.mjs.map +0 -1
package/test/node/tests.test.ts
CHANGED
|
@@ -211,4 +211,61 @@ describe('node test generation ownership', () => {
|
|
|
211
211
|
fs.rmSync(tmpRoot, { recursive: true, force: true });
|
|
212
212
|
}
|
|
213
213
|
});
|
|
214
|
+
|
|
215
|
+
it('asserts wire format on all-optional request bodies instead of toBeDefined()', () => {
|
|
216
|
+
// For PATCH/Update bodies where every field is optional, the test
|
|
217
|
+
// emitter previously fell back to `expect(fetchBody()).toBeDefined()`,
|
|
218
|
+
// which passes even if the serializer writes the wrong keys. Picking a
|
|
219
|
+
// couple of optional fields with deterministic fixture values makes the
|
|
220
|
+
// test actually validate snake_case conversion on the wire.
|
|
221
|
+
const updateModel: Model = {
|
|
222
|
+
name: 'UpdateGroup',
|
|
223
|
+
fields: [
|
|
224
|
+
{ name: 'name', type: { kind: 'primitive', type: 'string' }, required: false },
|
|
225
|
+
{ name: 'description', type: { kind: 'primitive', type: 'string' }, required: false },
|
|
226
|
+
],
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
const updateOp = {
|
|
230
|
+
name: 'updateGroup',
|
|
231
|
+
httpMethod: 'patch' as const,
|
|
232
|
+
path: '/organizations/{organizationId}/groups/{id}',
|
|
233
|
+
pathParams: [
|
|
234
|
+
{ name: 'organizationId', type: { kind: 'primitive' as const, type: 'string' as const }, required: true },
|
|
235
|
+
{ name: 'id', type: { kind: 'primitive' as const, type: 'string' as const }, required: true },
|
|
236
|
+
],
|
|
237
|
+
queryParams: [],
|
|
238
|
+
headerParams: [],
|
|
239
|
+
response: { kind: 'model' as const, name: 'Group' },
|
|
240
|
+
requestBody: { kind: 'model' as const, name: 'UpdateGroup' },
|
|
241
|
+
errors: [],
|
|
242
|
+
injectIdempotencyKey: false,
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
const updateService: Service = { name: 'Groups', operations: [updateOp] };
|
|
246
|
+
const updateSpec: ApiSpec = {
|
|
247
|
+
...spec,
|
|
248
|
+
models: [groupModel, updateModel],
|
|
249
|
+
services: [updateService],
|
|
250
|
+
};
|
|
251
|
+
const tmpRoot = createTrackedSdkRoot();
|
|
252
|
+
try {
|
|
253
|
+
const result = nodeEmitter.generateTests!(updateSpec, {
|
|
254
|
+
...ctx,
|
|
255
|
+
spec: updateSpec,
|
|
256
|
+
outputDir: tmpRoot,
|
|
257
|
+
emitterOptions: { ownedServices: ['Groups'], regenerateOwnedTests: true },
|
|
258
|
+
} as EmitterContext);
|
|
259
|
+
|
|
260
|
+
const testFile = result.find((f) => f.path === 'src/groups/groups.spec.ts');
|
|
261
|
+
expect(testFile).toBeDefined();
|
|
262
|
+
const content = testFile!.content;
|
|
263
|
+
// The body assertion picks at least one optional field and checks its
|
|
264
|
+
// snake_case wire format — not just `.toBeDefined()`.
|
|
265
|
+
expect(content).toContain('expect(fetchBody()).toEqual(');
|
|
266
|
+
expect(content).toMatch(/expect\.objectContaining\(\{[^}]*\bname\b/);
|
|
267
|
+
} finally {
|
|
268
|
+
fs.rmSync(tmpRoot, { recursive: true, force: true });
|
|
269
|
+
}
|
|
270
|
+
});
|
|
214
271
|
});
|