@amqp-contract/asyncapi 0.2.1 → 0.3.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.
Files changed (3) hide show
  1. package/README.md +22 -11
  2. package/docs/index.md +6 -6
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -19,11 +19,19 @@ pnpm add @amqp-contract/asyncapi
19
19
  ## Usage
20
20
 
21
21
  ```typescript
22
- import { generateAsyncAPI } from '@amqp-contract/asyncapi';
22
+ import { AsyncAPIGenerator } from '@amqp-contract/asyncapi';
23
+ import { ZodToJsonSchemaConverter } from '@orpc/zod/zod4';
24
+ import { writeFileSync } from 'fs';
25
+
23
26
  import { contract } from './contract';
24
27
 
28
+ // Create generator with schema converters
29
+ const generator = new AsyncAPIGenerator({
30
+ schemaConverters: [new ZodToJsonSchemaConverter()],
31
+ });
32
+
25
33
  // Generate AsyncAPI specification
26
- const asyncAPISpec = generateAsyncAPI(contract, {
34
+ const asyncAPISpec = await generator.generate(contract, {
27
35
  info: {
28
36
  title: 'My AMQP API',
29
37
  version: '1.0.0',
@@ -47,24 +55,27 @@ const asyncAPISpec = generateAsyncAPI(contract, {
47
55
  console.log(JSON.stringify(asyncAPISpec, null, 2));
48
56
 
49
57
  // Or write to file
50
- import { writeFileSync } from 'fs';
51
58
  writeFileSync('asyncapi.json', JSON.stringify(asyncAPISpec, null, 2));
52
59
  ```
53
60
 
54
61
  ## API
55
62
 
56
- ### `generateAsyncAPI(contract, options)`
63
+ ### `AsyncAPIGenerator`
64
+
65
+ Generator class for creating AsyncAPI 3.0.0 specifications from AMQP contracts.
57
66
 
58
- Generate an AsyncAPI 3.0.0 specification from an AMQP contract.
67
+ **Constructor Parameters:**
59
68
 
60
- **Parameters:**
69
+ - `options.schemaConverters`: Array of schema converters (e.g., `ZodToJsonSchemaConverter`)
61
70
 
62
- - `contract`: The AMQP contract definition
63
- - `options`: Configuration options
64
- - `info`: API information (title, version, description, etc.)
65
- - `servers`: Server configurations (optional)
71
+ **Methods:**
66
72
 
67
- **Returns:** AsyncAPI 3.0.0 document
73
+ - `generate(contract, options)`: Generate an AsyncAPI specification
74
+ - `contract`: The AMQP contract definition
75
+ - `options`: Configuration options
76
+ - `info`: API information (title, version, description, etc.)
77
+ - `servers`: Server configurations (optional)
78
+ - Returns: `Promise<AsyncAPIObject>` - AsyncAPI 3.0.0 document
68
79
 
69
80
  ## Features
70
81
 
package/docs/index.md CHANGED
@@ -8,7 +8,7 @@
8
8
 
9
9
  ### AsyncAPIGenerator
10
10
 
11
- Defined in: [index.ts:92](https://github.com/btravers/amqp-contract/blob/f0945f098387fd3a6a40beac8cbe2ed7a4de210a/packages/asyncapi/src/index.ts#L92)
11
+ Defined in: [index.ts:92](https://github.com/btravers/amqp-contract/blob/63bb54252f8a9109544152686427ef223964c15c/packages/asyncapi/src/index.ts#L92)
12
12
 
13
13
  Generator for creating AsyncAPI 3.0 documentation from AMQP contracts.
14
14
 
@@ -65,7 +65,7 @@ const asyncapi = await generator.generate(contract, {
65
65
  new AsyncAPIGenerator(options): AsyncAPIGenerator;
66
66
  ```
67
67
 
68
- Defined in: [index.ts:100](https://github.com/btravers/amqp-contract/blob/f0945f098387fd3a6a40beac8cbe2ed7a4de210a/packages/asyncapi/src/index.ts#L100)
68
+ Defined in: [index.ts:100](https://github.com/btravers/amqp-contract/blob/63bb54252f8a9109544152686427ef223964c15c/packages/asyncapi/src/index.ts#L100)
69
69
 
70
70
  Create a new AsyncAPI generator instance.
71
71
 
@@ -87,7 +87,7 @@ Create a new AsyncAPI generator instance.
87
87
  generate(contract, options): Promise<AsyncAPIObject>;
88
88
  ```
89
89
 
90
- Defined in: [index.ts:132](https://github.com/btravers/amqp-contract/blob/f0945f098387fd3a6a40beac8cbe2ed7a4de210a/packages/asyncapi/src/index.ts#L132)
90
+ Defined in: [index.ts:132](https://github.com/btravers/amqp-contract/blob/63bb54252f8a9109544152686427ef223964c15c/packages/asyncapi/src/index.ts#L132)
91
91
 
92
92
  Generate an AsyncAPI 3.0 document from a contract definition.
93
93
 
@@ -130,7 +130,7 @@ const asyncapi = await generator.generate(contract, {
130
130
 
131
131
  ### AsyncAPIGeneratorOptions
132
132
 
133
- Defined in: [index.ts:31](https://github.com/btravers/amqp-contract/blob/f0945f098387fd3a6a40beac8cbe2ed7a4de210a/packages/asyncapi/src/index.ts#L31)
133
+ Defined in: [index.ts:31](https://github.com/btravers/amqp-contract/blob/63bb54252f8a9109544152686427ef223964c15c/packages/asyncapi/src/index.ts#L31)
134
134
 
135
135
  Options for configuring the AsyncAPI generator.
136
136
 
@@ -149,7 +149,7 @@ const generator = new AsyncAPIGenerator({
149
149
 
150
150
  | Property | Type | Description | Defined in |
151
151
  | ------ | ------ | ------ | ------ |
152
- | <a id="schemaconverters"></a> `schemaConverters?` | `ConditionalSchemaConverter`[] | Schema converters for transforming validation schemas to JSON Schema. Supports Zod, Valibot, ArkType, and other Standard Schema v1 compatible libraries. | [index.ts:36](https://github.com/btravers/amqp-contract/blob/f0945f098387fd3a6a40beac8cbe2ed7a4de210a/packages/asyncapi/src/index.ts#L36) |
152
+ | <a id="schemaconverters"></a> `schemaConverters?` | `ConditionalSchemaConverter`[] | Schema converters for transforming validation schemas to JSON Schema. Supports Zod, Valibot, ArkType, and other Standard Schema v1 compatible libraries. | [index.ts:36](https://github.com/btravers/amqp-contract/blob/63bb54252f8a9109544152686427ef223964c15c/packages/asyncapi/src/index.ts#L36) |
153
153
 
154
154
  ## Type Aliases
155
155
 
@@ -159,7 +159,7 @@ const generator = new AsyncAPIGenerator({
159
159
  type AsyncAPIGeneratorGenerateOptions = Pick<AsyncAPIObject, "id" | "info" | "servers">;
160
160
  ```
161
161
 
162
- Defined in: [index.ts:43](https://github.com/btravers/amqp-contract/blob/f0945f098387fd3a6a40beac8cbe2ed7a4de210a/packages/asyncapi/src/index.ts#L43)
162
+ Defined in: [index.ts:43](https://github.com/btravers/amqp-contract/blob/63bb54252f8a9109544152686427ef223964c15c/packages/asyncapi/src/index.ts#L43)
163
163
 
164
164
  Options for generating an AsyncAPI document.
165
165
  These correspond to the top-level AsyncAPI document fields.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amqp-contract/asyncapi",
3
- "version": "0.2.1",
3
+ "version": "0.3.0",
4
4
  "description": "AsyncAPI specification generator for amqp-contract",
5
5
  "keywords": [
6
6
  "amqp",
@@ -44,7 +44,7 @@
44
44
  "dependencies": {
45
45
  "@orpc/openapi": "1.13.0",
46
46
  "@standard-schema/spec": "1.1.0",
47
- "@amqp-contract/contract": "0.2.1"
47
+ "@amqp-contract/contract": "0.3.0"
48
48
  },
49
49
  "devDependencies": {
50
50
  "@asyncapi/parser": "3.4.0",