@contractkit/openapi-to-ck 0.8.1 → 0.9.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/dist/index.js CHANGED
@@ -11,7 +11,7 @@ import {
11
11
  schemasToModels,
12
12
  serializeType,
13
13
  splitByTag
14
- } from "./chunk-YOTHJ2V4.js";
14
+ } from "./chunk-FMEMOXYD.js";
15
15
  export {
16
16
  astToCk,
17
17
  convertOpenApiToCk,
package/dist/plugin.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  __name,
3
3
  convertOpenApiToCk
4
- } from "./chunk-YOTHJ2V4.js";
4
+ } from "./chunk-FMEMOXYD.js";
5
5
 
6
6
  // src/plugin.ts
7
7
  import { writeFileSync, mkdirSync } from "fs";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contractkit/openapi-to-ck",
3
- "version": "0.8.1",
3
+ "version": "0.9.0",
4
4
  "description": "Convert OpenAPI specs (2.0/3.0/3.1) to Contract Kit .ck files",
5
5
  "author": {
6
6
  "name": "Marooned Software",
@@ -29,11 +29,11 @@
29
29
  "dependencies": {
30
30
  "@scalar/openapi-parser": "^0.26.1",
31
31
  "yaml": "^2.8.3",
32
- "@contractkit/core": "0.19.0"
32
+ "@contractkit/core": "0.21.0"
33
33
  },
34
34
  "devDependencies": {
35
- "@repo/config-typescript": "0.1.0",
36
- "@repo/config-eslint": "0.3.1"
35
+ "@repo/config-eslint": "0.3.1",
36
+ "@repo/config-typescript": "0.1.0"
37
37
  },
38
38
  "scripts": {
39
39
  "build": "tsup src/index.ts src/plugin.ts --format esm --sourcemap --dts && tsc --emitDeclarationOnly --declaration",
package/src/ast-to-ck.ts CHANGED
@@ -294,7 +294,14 @@ function serializeOperation(lines: string[], op: OpOperationNode, depth: number,
294
294
  // Signature
295
295
  if (op.signature) {
296
296
  const sigComment = ctx.includeComments && op.signatureDescription ? ` # ${op.signatureDescription}` : '';
297
- lines.push(`${inner}signature: ${op.signature}${sigComment}`);
297
+ if (op.signaturePolicy) {
298
+ lines.push(`${inner}signature: {`);
299
+ lines.push(`${inner} options: ${op.signature}${sigComment}`);
300
+ lines.push(`${inner} policy: ${op.signaturePolicy}`);
301
+ lines.push(`${inner}}`);
302
+ } else {
303
+ lines.push(`${inner}signature: ${op.signature}${sigComment}`);
304
+ }
298
305
  }
299
306
 
300
307
  // Security
@@ -312,6 +312,32 @@ describe('route serialization', () => {
312
312
  expect(result).toContain('operation(internal) /webhooks/stripe: {');
313
313
  });
314
314
 
315
+ it('serializes a bare signature key', () => {
316
+ const root = ckRoot({
317
+ routes: [opRoute('/webhooks', [opOperation('post', { signature: 'SLACK_WEBHOOK', responses: [opResponse(204)] })])],
318
+ });
319
+ const result = astToCk(root);
320
+ expect(result).toContain('signature: SLACK_WEBHOOK');
321
+ });
322
+
323
+ it('serializes a block-form signature with options and policy', () => {
324
+ const root = ckRoot({
325
+ routes: [
326
+ opRoute('/webhooks', [
327
+ opOperation('post', {
328
+ signature: 'SLACK_WEBHOOK',
329
+ signaturePolicy: 'slackSignatureValid',
330
+ responses: [opResponse(204)],
331
+ }),
332
+ ]),
333
+ ],
334
+ });
335
+ const result = astToCk(root);
336
+ expect(result).toContain('signature: {');
337
+ expect(result).toContain('options: SLACK_WEBHOOK');
338
+ expect(result).toContain('policy: slackSignatureValid');
339
+ });
340
+
315
341
  it('serializes security: none', () => {
316
342
  const root = ckRoot({
317
343
  routes: [