@techspokes/typescript-wsdl-client 0.9.1 → 0.9.3

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/README.md CHANGED
@@ -9,57 +9,46 @@
9
9
  [![TechSpokes Org](https://img.shields.io/badge/org-techspokes-181717?logo=github)](https://github.com/techspokes)
10
10
  [![Sponsor](https://img.shields.io/badge/sponsor-GitHub-blue?logo=github-sponsors)](https://github.com/sponsors/TechSpokes)
11
11
 
12
- > **Mission**: Transform complex WSDL/XSD definitions into ergonomic, type-safe TypeScript SOAP clients with optional OpenAPI 3.1 specs and production-ready Fastify REST gateways — enabling confident integration with legacy enterprise services.
12
+ > **Transform complex WSDL/XSD definitions into type-safe TypeScript SOAP clients with optional OpenAPI 3.1 specs and production-ready REST gateways.**
13
13
 
14
- ---
14
+ ## Use This If You Need...
15
15
 
16
- ## Table of Contents
16
+ - **TypeScript-first SOAP clients** — Strongly typed, ergonomic client generation from WSDL
17
+ - ✅ **OpenAPI 3.1 specs** — Generate REST API documentation that mirrors your TypeScript types
18
+ - ✅ **REST gateway over SOAP** — Production-ready Fastify handlers with automatic request/response transformation
19
+ - ✅ **CI-friendly determinism** — Stable, diff-friendly output for safe regeneration in version control
20
+ - ✅ **Predictable modeling** — Flattened attributes, consistent `$value` convention, inheritance resolution
17
21
 
18
- - [1. Why This Project](#1-why-this-project-what-sets-it-apart)
19
- - [2. Installation](#2-installation)
20
- - [3. Quick Start](#3-quick-start)
21
- - [4. Commands Overview](#4-commands-overview)
22
- - [5. Command: `compile`](#5-command-compile)
23
- - [6. Command: `client`](#6-command-client)
24
- - [7. Command: `openapi`](#7-command-openapi)
25
- - [8. Command: `gateway`](#8-command-gateway)
26
- - [9. Command: `pipeline`](#9-command-pipeline)
27
- - [10. Working With Generated Clients](#10-working-with-generated-clients)
28
- - [11. OpenAPI Configuration](#11-openapi-configuration)
29
- - [12. Programmatic API](#12-programmatic-api)
30
- - [13. Advanced Topics](#13-advanced-topics)
31
- - [14. Troubleshooting](#14-troubleshooting)
32
- - [15. Contributing](#15-contributing)
33
- - [16. License](#16-license)
34
- - [17. Sponsors](#17-sponsors)
22
+ **Vendor**: [TechSpokes](https://www.techspokes.com) · **Maintainer**: Serge Liatko ([@sergeliatko](https://github.com/sergeliatko))
35
23
 
36
24
  ---
37
25
 
38
- ## 1. Why This Project (What Sets It Apart)
39
-
40
- Most WSDL generators produce loosely typed stubs or expose raw XML complexity to your application layer. This tool delivers **correct flattening, determinism, and multiple integration paths**:
41
-
42
- | Core Differentiator | What You Get |
43
- |--------------------------------------|------------------------------------------------------------------------------------------------------|
44
- | **Attribute + Element Flattening** | Attributes and child elements appear as peer properties (no nested wrapper noise). |
45
- | **`$value` Text Content Convention** | Simple text & mixed content always represented as a `$value` property (collision-safe & documented). |
46
- | **Inheritance Resolution** | `complexContent` and `simpleContent` extensions are merged or extended consistently. |
47
- | **Choice Strategy** | Predictable `all-optional` modeling today (future advanced discriminators planned). |
48
- | **WS-Policy Security Hints** | Inline scan of policies surfaces required auth hints (e.g. `usernameToken`, `https`). |
49
- | **Deterministic Output** | Sorted declarations and stable alias resolution for diff-friendly regeneration. |
50
- | **Primitive Mapping Controls** | Explicit flags for long / big integer / decimal / temporal families (string-first safety). |
51
- | **Catalog Introspection** | One JSON artifact (`catalog.json`) to drive further tooling (including OpenAPI & gateway). |
52
- | **OpenAPI 3.1 Bridge** | Mirrors the exact TypeScript model with no divergence between runtime and spec. |
53
- | **Standard Response Envelope** | Always-on, debuggable envelope structure (status, message, data, error) for REST gateways. |
54
- | **Fastify Gateway Generation** | Production-ready route handlers with SOAP client integration and standardized envelope responses. |
55
- | **Multi-format Output** | `--openapi-format json\|yaml\|both` with always-on validation (unless disabled). |
56
- | **One-Shot Pipeline** | Single pass (parse to TS to OpenAPI to Gateway) for CI & automation. |
26
+ ## Table of Contents
57
27
 
58
- **Vendor**: [TechSpokes](https://www.techspokes.com) · **Maintainer**: Serge Liatko ([@sergeliatko](https://github.com/sergeliatko))
28
+ - [Installation](#installation)
29
+ - [Quick Start (60 Seconds)](#quick-start-60-seconds)
30
+ - [What You Get (Outputs)](#what-you-get-outputs)
31
+ - [Core Concepts](#core-concepts)
32
+ - [Common Workflows](#common-workflows)
33
+ - [Command Reference](#command-reference)
34
+ - [pipeline (Recommended)](#command-pipeline-recommended)
35
+ - [client](#command-client)
36
+ - [openapi](#command-openapi)
37
+ - [gateway](#command-gateway)
38
+ - [app](#command-app)
39
+ - [compile (Advanced)](#command-compile-advanced)
40
+ - [Configuration Files](#configuration-files)
41
+ - [Working With Generated Clients](#working-with-generated-clients)
42
+ - [Production Concerns](#production-concerns)
43
+ - [Programmatic API](#programmatic-api)
44
+ - [Troubleshooting](#troubleshooting)
45
+ - [Contributing](#contributing)
46
+ - [License](#license)
47
+ - [Support](#support)
59
48
 
60
49
  ---
61
50
 
62
- ## 2. Installation
51
+ ## Installation
63
52
 
64
53
  ```bash
65
54
  npm install --save-dev @techspokes/typescript-wsdl-client
@@ -72,202 +61,557 @@ npm install soap # Runtime dependency for SOAP calls
72
61
 
73
62
  ---
74
63
 
75
- ## 3. Quick Start
64
+ ## Quick Start (60 Seconds)
65
+
66
+ Generate a complete SOAP-to-REST stack in one command:
67
+
68
+ ```bash
69
+ # Generate client, OpenAPI spec, gateway, and runnable app
70
+ npx wsdl-tsc pipeline \
71
+ --wsdl-source examples/minimal/weather.wsdl \
72
+ --client-dir ./tmp/client \
73
+ --openapi-file ./tmp/openapi.json \
74
+ --gateway-dir ./tmp/gateway \
75
+ --gateway-service-name weather \
76
+ --gateway-version-prefix v1 \
77
+ --generate-app
78
+ ```
76
79
 
77
- ### Generate TypeScript SOAP Client
80
+ **Start the server:**
78
81
 
79
82
  ```bash
80
- npx wsdl-tsc client --wsdl-source ./wsdl/Weather.wsdl --client-dir ./src/services/weather
83
+ cd tmp/app
84
+ cp .env.example .env
85
+ # Edit .env to set WSDL_SOURCE if needed
86
+ npx tsx server.js
81
87
  ```
82
88
 
83
- **Try with included example:**
89
+ **Test it:**
84
90
 
85
91
  ```bash
86
- npx wsdl-tsc client --wsdl-source examples/minimal/weather.wsdl --client-dir ./tmp/weather
92
+ # Health check
93
+ curl http://localhost:3000/health
94
+
95
+ # Get OpenAPI spec
96
+ curl http://localhost:3000/openapi.json | jq .
97
+
98
+ # Call a SOAP operation via REST
99
+ curl -X POST http://localhost:3000/get-weather-information \
100
+ -H "Content-Type: application/json" \
101
+ -d '{}'
102
+ ```
103
+
104
+ **What just happened?**
105
+ 1. Parsed the WSDL and compiled types
106
+ 2. Generated a TypeScript SOAP client with full type safety
107
+ 3. Created an OpenAPI 3.1 spec matching the client types
108
+ 4. Built Fastify gateway handlers that call SOAP and return JSON
109
+ 5. Created a runnable Express-style app with health/OpenAPI endpoints
110
+
111
+ ---
112
+
113
+ ## What You Get (Outputs)
114
+
115
+ ### TypeScript SOAP Client
116
+
87
117
  ```
118
+ client/
119
+ ├── client.ts # Strongly-typed SOAP client wrapper with methods
120
+ ├── types.ts # Flattened interfaces, type aliases, and enums
121
+ ├── utils.ts # Runtime metadata for JSON→SOAP conversion
122
+ └── catalog.json # Compiled schema representation (reusable)
123
+ ```
124
+
125
+ **Example usage:**
126
+
127
+ ```typescript
128
+ import { Weather } from './client/client.js';
129
+
130
+ const client = new Weather({
131
+ source: 'https://example.com/weather.wsdl',
132
+ });
133
+
134
+ const result = await client.GetCityWeatherByZIP({ ZIP: '10001' });
135
+ console.log(result.GetCityWeatherByZIPResult);
136
+ ```
137
+
138
+ ### OpenAPI 3.1 Specification
139
+
140
+ ```
141
+ openapi.json # or .yaml — Complete REST API documentation
142
+ ```
143
+
144
+ - Mirrors exact TypeScript type structure
145
+ - All responses wrapped in standard envelope (status, message, data, error)
146
+ - Deterministic ordering for version control
147
+ - Validates with `swagger-parser` by default
148
+
149
+ ### Fastify REST Gateway
150
+
151
+ ```
152
+ gateway/
153
+ ├── schemas/
154
+ │ ├── models/ # JSON Schema components with URN IDs
155
+ │ └── operations/ # Request/response validation schemas
156
+ ├── routes/ # Route handlers (fully implemented)
157
+ ├── schemas.ts # Schema registration module
158
+ ├── routes.ts # Route aggregator
159
+ ├── runtime.ts # Envelope builders, error handlers
160
+ └── plugin.ts # Fastify plugin wrapper
161
+ ```
162
+
163
+ **Example integration:**
164
+
165
+ ```typescript
166
+ import Fastify from 'fastify';
167
+ import weatherGateway from './gateway/plugin.js';
168
+ import { Weather } from './client/client.js';
169
+
170
+ const app = Fastify({ logger: true });
171
+ const client = new Weather({ source: 'weather.wsdl' });
172
+
173
+ await app.register(weatherGateway, { client });
174
+ await app.listen({ port: 3000 });
175
+ ```
176
+
177
+ ### Runnable Application
178
+
179
+ ```
180
+ app/
181
+ ├── server.js # Main entry point
182
+ ├── config.js # Configuration with env var support
183
+ ├── .env.example # Environment template
184
+ ├── README.md # Usage instructions
185
+ └── openapi.json # OpenAPI spec (when --openapi-mode=copy)
186
+ ```
187
+
188
+ ### Standard Response Envelope
189
+
190
+ All gateway responses follow this structure:
191
+
192
+ **Success:**
193
+ ```json
194
+ {
195
+ "status": "SUCCESS",
196
+ "message": null,
197
+ "data": { /* SOAP response */ },
198
+ "error": null
199
+ }
200
+ ```
201
+
202
+ **Error:**
203
+ ```json
204
+ {
205
+ "status": "ERROR",
206
+ "message": "Request validation failed",
207
+ "data": null,
208
+ "error": {
209
+ "code": "VALIDATION_ERROR",
210
+ "message": "Request validation failed",
211
+ "details": { /* validation errors */ }
212
+ }
213
+ }
214
+ ```
215
+
216
+ ---
217
+
218
+ ## Core Concepts
219
+
220
+ ### Flattening and `$value`
221
+
222
+ **Attributes and elements become peer properties** — No nested wrapper noise:
223
+
224
+ ```xml
225
+ <!-- WSDL -->
226
+ <xs:complexType name="Price">
227
+ <xs:simpleContent>
228
+ <xs:extension base="xs:decimal">
229
+ <xs:attribute name="currency" type="xs:string"/>
230
+ </xs:extension>
231
+ </xs:simpleContent>
232
+ </xs:complexType>
233
+ ```
234
+
235
+ ```typescript
236
+ // Generated TypeScript
237
+ interface Price {
238
+ currency?: string; // attribute
239
+ $value: string; // text content (decimal mapped to string by default)
240
+ }
241
+ ```
242
+
243
+ ### Primitive Mapping Defaults (String-First Safety)
244
+
245
+ Prevents precision loss and parsing errors at the cost of convenience:
246
+
247
+ | XSD Type | Default | Override Options | When to Override |
248
+ |---------------|----------|--------------------|----------------------------------------|
249
+ | `xs:long` | `string` | `number`, `bigint` | Use `number` if values fit JS range |
250
+ | `xs:integer` | `string` | `number` | Use `string` for arbitrary-size ints |
251
+ | `xs:decimal` | `string` | `number` | Use `string` for precise decimals |
252
+ | `xs:dateTime` | `string` | `Date` | Use `Date` if runtime parsing is okay |
253
+
254
+ **Override with flags:**
255
+ - `--client-int64-as number`
256
+ - `--client-decimal-as string`
257
+ - `--client-date-as Date`
258
+
259
+ ### Deterministic Generation
260
+
261
+ All output is **stable and diff-friendly** for CI/CD:
262
+
263
+ - ✅ Sorted type declarations
264
+ - ✅ Sorted OpenAPI paths, schemas, parameters
265
+ - ✅ Sorted JSON schema keys
266
+ - ✅ Stable alias resolution
267
+ - ✅ Consistent ordering of imports
268
+
269
+ Regenerate safely without spurious diffs in version control.
270
+
271
+ ### Catalog as Intermediate Artifact
272
+
273
+ `catalog.json` is the compiled representation of your WSDL:
274
+
275
+ - **Debuggable** — Inspect types, operations, and metadata as JSON
276
+ - **Cacheable** — Reuse across client/OpenAPI/gateway generation
277
+ - **Co-located** — Automatically placed alongside generated output
88
278
 
89
- ### Generate Everything (Pipeline)
279
+ **Common locations:**
280
+ - `client` command: `{client-dir}/catalog.json`
281
+ - `openapi` command: `{openapi-dir}/catalog.json`
282
+ - `pipeline` command: First available output directory
283
+
284
+ ---
285
+
286
+ ## Common Workflows
287
+
288
+ ### Which Command Should I Run?
289
+
290
+ | I Want... | Use Command | Example |
291
+ |-----------------------------------------------|--------------|----------------------------------------------------------------------------------------------------------------------|
292
+ | **Everything (client + OpenAPI + gateway)** | `pipeline` | `npx wsdl-tsc pipeline --wsdl-source service.wsdl --client-dir ./client --openapi-file ./api.json --gateway-dir ./gateway --gateway-service-name svc --gateway-version-prefix v1` |
293
+ | **Only a TypeScript SOAP client** | `client` | `npx wsdl-tsc client --wsdl-source service.wsdl --client-dir ./client` |
294
+ | **Only OpenAPI spec (for docs or SDKs)** | `openapi` | `npx wsdl-tsc openapi --wsdl-source service.wsdl --openapi-file ./api.json` |
295
+ | **Only REST gateway (have OpenAPI already)** | `gateway` | `npx wsdl-tsc gateway --openapi-file ./api.json --client-dir ./client --gateway-dir ./gateway --gateway-service-name svc --gateway-version-prefix v1` |
296
+ | **Runnable server for testing** | `app` | `npx wsdl-tsc app --client-dir ./client --gateway-dir ./gateway --openapi-file ./api.json` |
297
+ | **Debug/inspect WSDL compilation** | `compile` | `npx wsdl-tsc compile --wsdl-source service.wsdl --catalog-file ./catalog.json` |
298
+
299
+ ### Workflow 1: Generate Everything (Recommended)
300
+
301
+ Use `pipeline` for complete stack generation:
90
302
 
91
303
  ```bash
92
304
  npx wsdl-tsc pipeline \
93
305
  --wsdl-source examples/minimal/weather.wsdl \
94
- --client-dir ./tmp/client \
95
- --openapi-file ./tmp/openapi.json \
96
- --gateway-dir ./tmp/gateway \
306
+ --client-dir ./src/services/weather \
307
+ --openapi-file ./docs/weather-api.json \
308
+ --gateway-dir ./src/gateway/weather \
97
309
  --gateway-service-name weather \
98
310
  --gateway-version-prefix v1
99
311
  ```
100
312
 
101
- **Output**: Generates client files in `tmp/client/`, OpenAPI spec at `tmp/openapi.json`, gateway code in `tmp/gateway/`, and catalog at `tmp/client/catalog.json`.
313
+ **Output:**
314
+ - Client: `./src/services/weather/client.ts`, `types.ts`, `utils.ts`, `catalog.json`
315
+ - OpenAPI: `./docs/weather-api.json`
316
+ - Gateway: `./src/gateway/weather/` (routes, schemas, plugin)
102
317
 
103
- ---
318
+ ### Workflow 2: SOAP Client Only
104
319
 
105
- ## 4. Commands Overview
320
+ Generate TypeScript client for direct SOAP integration:
106
321
 
107
- The tool provides **five commands** for different integration scenarios:
322
+ ```bash
323
+ npx wsdl-tsc client \
324
+ --wsdl-source ./wsdl/Hotel.wsdl \
325
+ --client-dir ./src/services/hotel
326
+ ```
108
327
 
109
- | Command | Purpose | Typical Use Case |
110
- |------------|---------------------------------------------------------------|-----------------------------------------------|
111
- | `compile` | Parse WSDL and emit `catalog.json` only | Debugging, inspection, or multi-stage builds |
112
- | `client` | Generate TypeScript SOAP client from WSDL or catalog | Standard SOAP integration (most common) |
113
- | `openapi` | Generate OpenAPI 3.1 spec from WSDL or catalog | Documentation, REST proxies, API gateways |
114
- | `gateway` | Generate Fastify gateway with full handlers from OpenAPI spec | Production REST gateway with SOAP integration |
115
- | `pipeline` | Run full pipeline: client + OpenAPI + gateway in one pass | CI/CD automation, complete stack generation |
328
+ **Usage:**
116
329
 
117
- ---
330
+ ```typescript
331
+ import soap from 'soap';
332
+ import { Hotel } from './src/services/hotel/client.js';
118
333
 
119
- ## 5. Command: `compile`
334
+ const client = new Hotel({
335
+ source: 'https://example.com/hotel.wsdl',
336
+ security: new soap.WSSecurity('username', 'password'),
337
+ });
120
338
 
121
- **Purpose**: Parse WSDL and generate only the intermediate `catalog.json` representation without TypeScript client code.
339
+ const result = await client.SearchAvailableRooms({
340
+ checkIn: '2024-01-15',
341
+ checkOut: '2024-01-20',
342
+ guests: 2,
343
+ });
344
+ ```
122
345
 
123
- **When to use**:
124
- - Multi-stage builds where you want to cache the parsed WSDL
125
- - Debugging or inspecting the compiled schema structure
126
- - Sharing a compiled catalog across multiple generation targets
346
+ ### Workflow 3: OpenAPI for Documentation
127
347
 
128
- ### Usage
348
+ Generate OpenAPI spec for API documentation or SDK generation:
129
349
 
130
350
  ```bash
131
- npx wsdl-tsc compile --wsdl-source <file|url> --catalog-file <path> [options]
351
+ npx wsdl-tsc openapi \
352
+ --wsdl-source ./wsdl/Booking.wsdl \
353
+ --openapi-file ./docs/booking-api.yaml \
354
+ --openapi-format yaml \
355
+ --openapi-title "Hotel Booking API" \
356
+ --openapi-version "1.0.0" \
357
+ --openapi-servers https://api.example.com/v1
132
358
  ```
133
359
 
134
- ### Required Flags
360
+ **Use the spec:**
361
+ - Import into Postman, Insomnia, or Swagger UI
362
+ - Generate client SDKs with OpenAPI Generator
363
+ - Share as REST API documentation
135
364
 
136
- | Flag | Description |
137
- |---------------------|------------------------------------------|
138
- | `--wsdl-source` | Path or URL to the WSDL file |
139
- | `--catalog-file` | Output path for `catalog.json` |
365
+ ### Workflow 4: REST Gateway Over SOAP
140
366
 
141
- ### Optional Flags
367
+ Build a REST API layer over legacy SOAP services:
142
368
 
143
- | Flag | Default | Description |
144
- |------------------------------------|----------------|--------------------------------------------------------------|
145
- | `--import-extensions` | `js` | Import specifier style: `js`, `ts`, or `bare` |
146
- | `--client-attributes-key` | `$attributes` | Attribute bag key for runtime mapper |
147
- | `--client-class-name` | (derived) | Override generated client class name |
148
- | `--client-int64-as` | `string` | Map 64-bit integers: `string`, `number`, or `bigint` |
149
- | `--client-bigint-as` | `string` | Map arbitrary-size integers: `string` or `number` |
150
- | `--client-decimal-as` | `string` | Map `xs:decimal`: `string` or `number` |
151
- | `--client-date-as` | `string` | Map date/time types: `string` or `Date` |
152
- | `--client-choice-mode` | `all-optional` | Choice element strategy: `all-optional` or `union` |
153
- | `--client-fail-on-unresolved` | `false` | Fail build on unresolved type references |
154
- | `--client-nillable-as-optional` | `false` | Treat nillable elements as optional properties |
369
+ ```bash
370
+ # 1. Generate client + OpenAPI
371
+ npx wsdl-tsc pipeline \
372
+ --wsdl-source ./wsdl/Legacy.wsdl \
373
+ --client-dir ./src/services/legacy \
374
+ --openapi-file ./docs/legacy-api.json
155
375
 
156
- ### Examples
376
+ # 2. Generate gateway
377
+ npx wsdl-tsc gateway \
378
+ --openapi-file ./docs/legacy-api.json \
379
+ --client-dir ./src/services/legacy \
380
+ --gateway-dir ./src/gateway/legacy \
381
+ --gateway-service-name legacy \
382
+ --gateway-version-prefix v1
383
+ ```
157
384
 
158
- #### Basic Compilation
385
+ **Or in one command:**
159
386
 
160
387
  ```bash
161
- npx wsdl-tsc compile \
162
- --wsdl-source examples/minimal/weather.wsdl \
163
- --catalog-file tmp/catalog.json
388
+ npx wsdl-tsc pipeline \
389
+ --wsdl-source ./wsdl/Legacy.wsdl \
390
+ --client-dir ./src/services/legacy \
391
+ --openapi-file ./docs/legacy-api.json \
392
+ --gateway-dir ./src/gateway/legacy \
393
+ --gateway-service-name legacy \
394
+ --gateway-version-prefix v1
164
395
  ```
165
396
 
166
- #### With Custom Output Path
397
+ ### Workflow 5: CI/CD Integration
398
+
399
+ Cache compiled catalog for faster multi-stage builds:
167
400
 
168
401
  ```bash
402
+ # Stage 1: Compile catalog (cacheable)
169
403
  npx wsdl-tsc compile \
170
- --wsdl-source https://example.com/Hotel.wsdl \
171
- --catalog-file ./build/hotel-catalog.json \
172
- --client-int64-as number \
173
- --client-decimal-as string
404
+ --wsdl-source ./wsdl/Service.wsdl \
405
+ --catalog-file ./build/service-catalog.json
406
+
407
+ # Stage 2: Generate client from catalog
408
+ npx wsdl-tsc client \
409
+ --catalog-file ./build/service-catalog.json \
410
+ --client-dir ./src/services/service
411
+
412
+ # Stage 3: Generate OpenAPI from catalog
413
+ npx wsdl-tsc openapi \
414
+ --catalog-file ./build/service-catalog.json \
415
+ --openapi-file ./docs/service-api.json
174
416
  ```
175
417
 
176
- #### For Debugging
418
+ ### Workflow 6: Debugging Complex WSDL
419
+
420
+ Inspect compiled types and operations:
177
421
 
178
422
  ```bash
179
- # Compile to inspect types and operations
423
+ # Compile to catalog
180
424
  npx wsdl-tsc compile \
181
- --wsdl-source ./wsdl/ComplexService.wsdl \
182
- --catalog-file ./debug/catalog.json \
183
- --client-fail-on-unresolved false
425
+ --wsdl-source ./wsdl/Complex.wsdl \
426
+ --catalog-file ./debug/catalog.json
427
+
428
+ # Inspect types
429
+ cat ./debug/catalog.json | jq '.types'
430
+
431
+ # Inspect operations
432
+ cat ./debug/catalog.json | jq '.operations'
184
433
  ```
185
434
 
186
- ### Output
435
+ ---
436
+
437
+ ## Command Reference
187
438
 
188
- - `catalog.json` - Compiled schema representation including types, operations, and metadata
439
+ The tool provides **six commands** for different integration scenarios. Commands are listed in **recommended order of use**:
189
440
 
190
- ### Catalog Structure
441
+ | Command | Purpose | Typical Use Case |
442
+ |------------|----------------------------------------------------------------|-----------------------------------------------|
443
+ | `pipeline` | Run full pipeline: client + OpenAPI + gateway (+ app optional) | **CI/CD automation, complete stack generation (recommended)** |
444
+ | `client` | Generate TypeScript SOAP client from WSDL or catalog | Standard SOAP integration |
445
+ | `openapi` | Generate OpenAPI 3.1 spec from WSDL or catalog | Documentation, REST proxies, API gateways |
446
+ | `gateway` | Generate Fastify gateway with full handlers from OpenAPI spec | Production REST gateway with SOAP integration |
447
+ | `app` | Generate runnable Fastify app from client + gateway + OpenAPI | Local testing, quick iteration, demos |
448
+ | `compile` | Parse WSDL and emit `catalog.json` only | Debugging, inspection, or multi-stage builds (advanced) |
191
449
 
192
- The catalog.json file contains the compiled WSDL representation:
450
+ ---
193
451
 
194
- ```json
195
- {
196
- "wsdlUri": "path/to/service.wsdl",
197
- "targetNamespace": "http://example.com/service",
198
- "serviceName": "WeatherService",
199
- "types": [
200
- {
201
- "name": "GetWeatherRequest",
202
- "properties": []
203
- }
204
- ],
205
- "operations": [
206
- {
207
- "name": "GetWeather",
208
- "input": "GetWeatherRequest",
209
- "output": "GetWeatherResponse"
210
- }
211
- ],
212
- "options": {
213
- "imports": "js",
214
- "catalog": true
215
- }
216
- }
452
+ ### Command: `pipeline` (Recommended)
453
+
454
+ **Purpose**: Run the complete generation pipeline in a single pass: WSDL parsing → TypeScript client → OpenAPI spec → Fastify gateway (+ app optional).
455
+
456
+ **When to use**:
457
+ - CI/CD automation
458
+ - Complete stack generation
459
+ - Ensuring all artifacts are generated from the same WSDL parse
460
+ - One-command development workflows
461
+
462
+ #### Usage
463
+
464
+ ```bash
465
+ npx wsdl-tsc pipeline \
466
+ --wsdl-source <file|url> \
467
+ [--catalog-file <path>] \
468
+ [--client-dir <path>] \
469
+ [--openapi-file <path>] \
470
+ [--gateway-dir <path>] \
471
+ [options]
217
472
  ```
218
473
 
219
- **Key sections**:
220
- - `types` - All compiled type definitions with properties and inheritance
221
- - `operations` - SOAP operations with input/output type references
222
- - `options` - Compiler options used during generation
474
+ #### Required Flags
223
475
 
224
- This catalog can be reused with the `client` and `openapi` commands via `--catalog-file`.
476
+ | Flag | Description |
477
+ |---------------------|----------------------------------------------------------------------|
478
+ | `--wsdl-source` | Path or URL to WSDL file |
225
479
 
226
- ### Catalog File Organization
480
+ #### Output Flags
227
481
 
228
- **Default behavior**: Catalog files are **co-located** with their primary output files for better organization and discoverability.
482
+ | Flag | Default | Description |
483
+ |---------------------|---------------------------------------------|---------------------------------------------------|
484
+ | `--catalog-file` | Co-located with first output (see below) | Output path for `catalog.json` (always generated) |
229
485
 
230
- **Catalog Location by Command**:
231
- - `compile`: Always requires explicit `--catalog-file` (no default)
232
- - `client`: Defaults to `{client-dir}/catalog.json`
233
- - `openapi`: Defaults to `{openapi-file-dir}/catalog.json`
234
- - `pipeline`: Intelligent cascade - first available: `{client-dir}` > `{openapi-dir}` > `{gateway-dir}` > `tmp/`
486
+ **Catalog Default Location**: The catalog is automatically placed alongside the first available output:
487
+ - With `--client-dir`: `{client-dir}/catalog.json`
488
+ - With `--openapi-file` only: `{openapi-file-dir}/catalog.json`
489
+ - With `--gateway-dir` only: `{gateway-dir}/catalog.json`
235
490
 
236
- **Common patterns**:
491
+ **Note**: At least one of `--client-dir`, `--openapi-file`, or `--gateway-dir` must be provided.
237
492
 
238
- 1. **Co-located with client** (recommended for most projects):
239
- ```bash
240
- npx wsdl-tsc client --wsdl-source service.wsdl --client-dir src/services/weather
241
- ```
242
-
243
- Creates `src/services/weather/catalog.json` automatically.
244
-
245
- Result:
246
- ```
247
- src/services/weather/
248
- ├── client.ts
249
- ├── types.ts
250
- ├── utils.ts
251
- └── catalog.json
252
- ```
493
+ #### Generation Control Flags
253
494
 
254
- 2. **Pipeline with multiple outputs** (catalog in client directory):
255
- ```bash
256
- npx wsdl-tsc pipeline --wsdl-source service.wsdl --client-dir src/client --openapi-file docs/api.json
257
- ```
258
-
259
- Creates `src/client/catalog.json` (co-located with client).
495
+ | Flag | Description |
496
+ |-------------------------|------------------------------------------------|
497
+ | `--client-dir` | Generate TypeScript client in this directory |
498
+ | `--openapi-file` | Generate OpenAPI spec at this path |
499
+ | `--gateway-dir` | Generate Fastify gateway in this directory |
500
+ | `--generate-app` | Generate runnable app (requires gateway) |
260
501
 
261
- 3. **Shared catalog for multiple commands** (custom location):
262
- ```bash
263
- npx wsdl-tsc compile --wsdl-source service.wsdl --catalog-file build/shared-catalog.json
264
- npx wsdl-tsc client --catalog-file build/shared-catalog.json --client-dir src/client
265
- npx wsdl-tsc openapi --catalog-file build/shared-catalog.json --openapi-file docs/api.json
266
- ```
502
+ #### Optional Flags
503
+
504
+ All flags from `client`, `openapi`, and `gateway` commands are supported. Key flags:
505
+
506
+ **Client Flags:**
507
+ - `--import-extensions` (default: `js`)
508
+ - `--client-attributes-key` (default: `$attributes`)
509
+ - `--client-class-name`
510
+ - `--client-int64-as` (default: `string`)
511
+ - `--client-bigint-as` (default: `string`)
512
+ - `--client-decimal-as` (default: `string`)
513
+ - `--client-date-as` (default: `string`)
514
+ - `--client-choice-mode` (default: `all-optional`)
515
+ - `--client-fail-on-unresolved` (default: `false`)
516
+ - `--client-nillable-as-optional` (default: `false`)
517
+
518
+ **OpenAPI Flags:**
519
+ - `--openapi-format` (default: `json`)
520
+ - `--openapi-title`
521
+ - `--openapi-version` (default: `0.0.0`)
522
+ - `--openapi-description`
523
+ - `--openapi-servers` (default: `/`)
524
+ - `--openapi-base-path`
525
+ - `--openapi-path-style` (default: `kebab`)
526
+ - `--openapi-method` (default: `post`)
527
+ - `--openapi-tag-style` (default: `default`)
528
+ - `--openapi-closed-schemas` (default: `false`)
529
+ - `--openapi-prune-unused-schemas` (default: `false`)
530
+ - `--openapi-envelope-namespace` (default: `ResponseEnvelope`)
531
+ - `--openapi-error-namespace` (default: `ErrorObject`)
532
+ - `--openapi-validate` (default: `true`)
533
+ - `--openapi-security-config-file`
534
+ - `--openapi-tags-file`
535
+ - `--openapi-ops-file`
536
+
537
+ **Gateway Flags:**
538
+ - `--gateway-service-name` (required if `--gateway-dir` provided)
539
+ - `--gateway-version-prefix` (required if `--gateway-dir` provided)
540
+ - `--gateway-default-status-codes`
541
+ - `--gateway-stub-handlers` (default: `false`)
542
+
543
+ #### Examples
544
+
545
+ **Complete Stack Generation:**
546
+
547
+ ```bash
548
+ npx wsdl-tsc pipeline \
549
+ --wsdl-source examples/minimal/weather.wsdl \
550
+ --client-dir tmp/client \
551
+ --openapi-file tmp/openapi.json \
552
+ --gateway-dir tmp/gateway \
553
+ --gateway-service-name weather \
554
+ --gateway-version-prefix v1
555
+ ```
556
+
557
+ **With App Generation:**
558
+
559
+ ```bash
560
+ npx wsdl-tsc pipeline \
561
+ --wsdl-source examples/minimal/weather.wsdl \
562
+ --client-dir tmp/client \
563
+ --openapi-file tmp/openapi.json \
564
+ --gateway-dir tmp/gateway \
565
+ --gateway-service-name weather \
566
+ --gateway-version-prefix v1 \
567
+ --generate-app
568
+ ```
569
+
570
+ **Client + OpenAPI Only:**
571
+
572
+ ```bash
573
+ npx wsdl-tsc pipeline \
574
+ --wsdl-source https://example.com/Hotel.wsdl \
575
+ --client-dir ./build/client \
576
+ --openapi-file ./docs/hotel-api.json \
577
+ --openapi-format both
578
+ ```
579
+
580
+ **With Full Configuration:**
581
+
582
+ ```bash
583
+ npx wsdl-tsc pipeline \
584
+ --wsdl-source ./wsdl/Booking.wsdl \
585
+ --client-dir ./build/client \
586
+ --openapi-file ./docs/booking-api \
587
+ --gateway-dir ./build/gateway \
588
+ --openapi-format both \
589
+ --openapi-servers https://api.example.com/v1 \
590
+ --openapi-base-path /booking \
591
+ --openapi-security-config-file ./config/security.json \
592
+ --gateway-service-name booking \
593
+ --gateway-version-prefix v1 \
594
+ --client-int64-as number \
595
+ --client-decimal-as string
596
+ ```
597
+
598
+ #### Pipeline Workflow
599
+
600
+ The pipeline command executes these steps in order:
601
+
602
+ 1. **Parse WSDL** → Load and validate WSDL document
603
+ 2. **Compile Catalog** → Generate intermediate representation
604
+ 3. **Emit Catalog** → Write `catalog.json` (always)
605
+ 4. **Generate Client** → Emit TypeScript client files (if `--client-dir`)
606
+ 5. **Generate OpenAPI** → Create OpenAPI spec (if `--openapi-file`)
607
+ 6. **Generate Gateway** → Create Fastify gateway code (if `--gateway-dir`)
608
+ 7. **Generate App** → Create runnable application (if `--generate-app`)
609
+
610
+ All steps share the same parsed WSDL and compiled catalog, ensuring consistency.
267
611
 
268
612
  ---
269
613
 
270
- ## 6. Command: `client`
614
+ ### Command: `client`
271
615
 
272
616
  **Purpose**: Generate strongly-typed TypeScript SOAP client code from WSDL or a pre-compiled catalog.
273
617
 
@@ -382,7 +726,7 @@ npx wsdl-tsc client \
382
726
 
383
727
  ---
384
728
 
385
- ## 7. Command: `openapi`
729
+ ### Command: `openapi`
386
730
 
387
731
  **Purpose**: Generate OpenAPI 3.1 specification from WSDL or a pre-compiled catalog, mirroring the exact TypeScript type structure.
388
732
 
@@ -577,7 +921,7 @@ This ensures diff-friendly output for version control.
577
921
 
578
922
  ---
579
923
 
580
- ## 8. Command: `gateway`
924
+ ### Command: `gateway`
581
925
 
582
926
  **Purpose**: Generate a production-ready Fastify gateway with fully functional route handlers from an OpenAPI 3.1 specification. This creates a complete REST API layer over your SOAP client with automatic request/response transformation and standardized envelope responses.
583
927
 
@@ -860,189 +1204,334 @@ npx wsdl-tsc gateway \
860
1204
  --gateway-stub-handlers
861
1205
  ```
862
1206
 
863
- This generates minimal handler stubs that throw "Not implemented" errors, allowing you to implement fully custom logic while keeping the routing and validation infrastructure.
1207
+ This generates minimal handler stubs that throw "Not implemented" errors, allowing you to implement fully custom logic while keeping the routing and validation infrastructure.
1208
+
1209
+ ---
1210
+
1211
+ ### Command: `app`
1212
+
1213
+ **Purpose**: Generate a runnable Fastify application that integrates the generated client, gateway, and OpenAPI spec. This provides an immediately executable server for testing, development, and demonstrations.
1214
+
1215
+ **When to use**:
1216
+ - Local testing and development
1217
+ - Quick iteration on gateway configurations
1218
+ - Demonstrating the generated API
1219
+ - CI smoke testing
1220
+
1221
+ ### Usage
1222
+
1223
+ ```bash
1224
+ npx wsdl-tsc app \
1225
+ --client-dir <path> \
1226
+ --gateway-dir <path> \
1227
+ --openapi-file <path> \
1228
+ [--catalog-file <path>] \
1229
+ [--app-dir <path>] \
1230
+ [options]
1231
+ ```
1232
+
1233
+ ### Required Flags
1234
+
1235
+ | Flag | Description |
1236
+ |------------------|----------------------------------------------------------|
1237
+ | `--client-dir` | Path to client directory (where `client.ts` is located) |
1238
+ | `--gateway-dir` | Path to gateway directory (where `plugin.ts` is located) |
1239
+ | `--openapi-file` | Path to OpenAPI specification file |
1240
+
1241
+ ### Optional Flags
1242
+
1243
+ | Flag | Default | Description |
1244
+ |-----------------------|-------------------------------|---------------------------------------------------|
1245
+ | `--catalog-file` | `{client-dir}/catalog.json` | Path to catalog.json (for metadata extraction) |
1246
+ | `--app-dir` | `{gateway-dir}/../app` | Output directory for generated app |
1247
+ | `--import-extensions` | Inferred from catalog or `js` | Import-extension mode: `js`, `ts`, or `bare` |
1248
+ | `--host` | `127.0.0.1` | Default server host |
1249
+ | `--port` | `3000` | Default server port |
1250
+ | `--prefix` | `""` (empty) | Route prefix |
1251
+ | `--logger` | `true` | Enable Fastify logger |
1252
+ | `--openapi-mode` | `copy` | How to handle OpenAPI file: `copy` or `reference` |
1253
+
1254
+ ### Examples
1255
+
1256
+ #### Generate App After Pipeline
1257
+
1258
+ ```bash
1259
+ # First generate client, OpenAPI, and gateway
1260
+ npx wsdl-tsc pipeline \
1261
+ --wsdl-source weather.wsdl \
1262
+ --client-dir ./client \
1263
+ --openapi-file ./openapi.json \
1264
+ --gateway-dir ./gateway \
1265
+ --gateway-service-name weather \
1266
+ --gateway-version-prefix v1
1267
+
1268
+ # Then generate runnable app
1269
+ npx wsdl-tsc app \
1270
+ --client-dir ./client \
1271
+ --gateway-dir ./gateway \
1272
+ --openapi-file ./openapi.json \
1273
+ --app-dir ./app
1274
+ ```
1275
+
1276
+ #### Generate App with Custom Configuration
1277
+
1278
+ ```bash
1279
+ npx wsdl-tsc app \
1280
+ --client-dir ./client \
1281
+ --gateway-dir ./gateway \
1282
+ --openapi-file ./openapi.json \
1283
+ --app-dir ./my-app \
1284
+ --host 0.0.0.0 \
1285
+ --port 8080 \
1286
+ --prefix /api/v1
1287
+ ```
1288
+
1289
+ ### Generated App Structure
1290
+
1291
+ The `app` command generates the following files:
1292
+
1293
+ ```
1294
+ app/
1295
+ ├── server.js (or .ts) # Main application entry point
1296
+ ├── config.js (or .ts) # Configuration loader with env support
1297
+ ├── .env.example # Environment variable template
1298
+ ├── README.md # Usage instructions
1299
+ └── openapi.json # OpenAPI spec (when --openapi-mode=copy)
1300
+ ```
1301
+
1302
+ ### Running the Generated App
1303
+
1304
+ ```bash
1305
+ # Copy environment template
1306
+ cd app
1307
+ cp .env.example .env
1308
+
1309
+ # Edit .env to configure WSDL source and other settings
1310
+ # vim .env
1311
+
1312
+ # Run the server
1313
+ npx tsx server.js # For TypeScript files
1314
+ # or
1315
+ node server.js # For JavaScript files
1316
+ ```
1317
+
1318
+ ### Configuration
1319
+
1320
+ The generated app loads configuration from environment variables with the following precedence:
1321
+
1322
+ 1. **Environment variables** (runtime overrides)
1323
+ 2. **Catalog defaults** (from generation-time)
1324
+ 3. **Hard defaults** (in config file)
1325
+
1326
+ #### Environment Variables
1327
+
1328
+ | Variable | Default (from catalog or flags) | Description |
1329
+ |-----------------|---------------------------------|--------------------------------------|
1330
+ | `WSDL_SOURCE` | From catalog or **required** | WSDL URL or local file path |
1331
+ | `HOST` | `127.0.0.1` | Server bind address |
1332
+ | `PORT` | `3000` | Server listen port |
1333
+ | `PREFIX` | `""` (empty) | Route prefix |
1334
+ | `LOGGER` | `true` | Enable Fastify logger |
1335
+
1336
+ ### Endpoints
1337
+
1338
+ The generated app serves the following endpoints:
1339
+
1340
+ #### Health Check
1341
+ ```bash
1342
+ GET /health
1343
+ ```
1344
+ Returns: `{ "ok": true }`
1345
+
1346
+ #### OpenAPI Specification
1347
+ ```bash
1348
+ GET /openapi.json
1349
+ ```
1350
+ Returns: Complete OpenAPI 3.1 specification
864
1351
 
865
- ---
1352
+ #### Gateway Routes
1353
+ All SOAP operations are exposed as REST endpoints. See the OpenAPI spec for complete API documentation.
866
1354
 
867
- ## 9. Command: `pipeline`
1355
+ ### Example Usage
868
1356
 
869
- **Purpose**: Run the complete generation pipeline in a single pass: WSDL parsing → TypeScript client → OpenAPI spec → Fastify gateway.
1357
+ ```bash
1358
+ # Start the server
1359
+ cd app
1360
+ npx tsx server.js
870
1361
 
871
- **When to use**:
872
- - CI/CD automation
873
- - Complete stack generation
874
- - Ensuring all artifacts are generated from the same WSDL parse
875
- - One-command development workflows
1362
+ # Test health endpoint
1363
+ curl http://localhost:3000/health
876
1364
 
877
- ### Usage
1365
+ # Get OpenAPI spec
1366
+ curl http://localhost:3000/openapi.json | jq .
878
1367
 
879
- ```bash
880
- npx wsdl-tsc pipeline \
881
- --wsdl-source <file|url> \
882
- [--catalog-file <path>] \
883
- [--client-dir <path>] \
884
- [--openapi-file <path>] \
885
- [--gateway-dir <path>] \
886
- [options]
1368
+ # Call a gateway operation (example)
1369
+ curl -X POST http://localhost:3000/get-weather-information \
1370
+ -H "Content-Type: application/json" \
1371
+ -d '{}'
887
1372
  ```
888
1373
 
889
- ### Required Flags
1374
+ ### Integration with Pipeline
890
1375
 
891
- | Flag | Description |
892
- |---------------------|----------------------------------------------------------------------|
893
- | `--wsdl-source` | Path or URL to WSDL file |
1376
+ The `app` command can also be used via the pipeline with the `--generate-app` flag:
894
1377
 
895
- ### Output Flags
1378
+ ```bash
1379
+ npx wsdl-tsc pipeline \
1380
+ --wsdl-source weather.wsdl \
1381
+ --client-dir ./client \
1382
+ --openapi-file ./openapi.json \
1383
+ --gateway-dir ./gateway \
1384
+ --gateway-service-name weather \
1385
+ --gateway-version-prefix v1 \
1386
+ --generate-app
1387
+ ```
896
1388
 
897
- | Flag | Default | Description |
898
- |---------------------|---------------------------------------------|---------------------------------------------------|
899
- | `--catalog-file` | Co-located with first output (see below) | Output path for `catalog.json` (always generated) |
1389
+ This generates all artifacts including the runnable app in a single command.
900
1390
 
901
- **Catalog Default Location**: The catalog is automatically placed alongside the first available output:
902
- - With `--client-dir`: `{client-dir}/catalog.json`
903
- - With `--openapi-file` only: `{openapi-file-dir}/catalog.json`
904
- - With `--gateway-dir` only: `{gateway-dir}/catalog.json`
1391
+ ---
905
1392
 
906
- **Note**: At least one of `--client-dir`, `--openapi-file`, or `--gateway-dir` must be provided.
1393
+ ### Command: `compile` (Advanced)
907
1394
 
908
- ### Generation Control Flags
1395
+ **Purpose**: Parse WSDL and generate only the intermediate `catalog.json` representation without TypeScript client code.
909
1396
 
910
- | Flag | Description |
911
- |-------------------------|------------------------------------------------|
912
- | `--client-dir` | Generate TypeScript client in this directory |
913
- | `--openapi-file` | Generate OpenAPI spec at this path |
914
- | `--gateway-dir` | Generate Fastify gateway in this directory |
1397
+ **When to use**:
1398
+ - Multi-stage builds where you want to cache the parsed WSDL
1399
+ - Debugging or inspecting the compiled schema structure
1400
+ - Sharing a compiled catalog across multiple generation targets
915
1401
 
916
- ### Optional Flags
1402
+ #### Usage
917
1403
 
918
- All flags from `client`, `openapi`, and `gateway` commands are supported. Key flags:
1404
+ ```bash
1405
+ npx wsdl-tsc compile --wsdl-source <file|url> --catalog-file <path> [options]
1406
+ ```
919
1407
 
920
- #### Client Flags
921
- - `--import-extensions` (default: `js`)
922
- - `--client-attributes-key` (default: `$attributes`)
923
- - `--client-class-name`
924
- - `--client-int64-as` (default: `string`)
925
- - `--client-bigint-as` (default: `string`)
926
- - `--client-decimal-as` (default: `string`)
927
- - `--client-date-as` (default: `string`)
928
- - `--client-choice-mode` (default: `all-optional`)
929
- - `--client-fail-on-unresolved` (default: `false`)
930
- - `--client-nillable-as-optional` (default: `false`)
1408
+ #### Required Flags
931
1409
 
932
- #### OpenAPI Flags
933
- - `--openapi-format` (default: `json`)
934
- - `--openapi-title`
935
- - `--openapi-version` (default: `0.0.0`)
936
- - `--openapi-description`
937
- - `--openapi-servers` (default: `/`)
938
- - `--openapi-base-path`
939
- - `--openapi-path-style` (default: `kebab`)
940
- - `--openapi-method` (default: `post`)
941
- - `--openapi-tag-style` (default: `default`)
942
- - `--openapi-closed-schemas` (default: `false`)
943
- - `--openapi-prune-unused-schemas` (default: `false`)
944
- - `--openapi-envelope-namespace` (default: `ResponseEnvelope`)
945
- - `--openapi-error-namespace` (default: `ErrorObject`)
946
- - `--openapi-validate` (default: `true`)
947
- - `--openapi-security-config-file`
948
- - `--openapi-tags-file`
949
- - `--openapi-ops-file`
1410
+ | Flag | Description |
1411
+ |---------------------|------------------------------------------|
1412
+ | `--wsdl-source` | Path or URL to the WSDL file |
1413
+ | `--catalog-file` | Output path for `catalog.json` |
950
1414
 
951
- #### Gateway Flags
952
- - `--gateway-service-name` (required if `--gateway-dir` provided)
953
- - `--gateway-version-prefix` (required if `--gateway-dir` provided)
954
- - `--gateway-default-status-codes`
1415
+ #### Optional Flags
955
1416
 
956
- ### Examples
1417
+ | Flag | Default | Description |
1418
+ |------------------------------------|----------------|--------------------------------------------------------------|
1419
+ | `--import-extensions` | `js` | Import specifier style: `js`, `ts`, or `bare` |
1420
+ | `--client-attributes-key` | `$attributes` | Attribute bag key for runtime mapper |
1421
+ | `--client-class-name` | (derived) | Override generated client class name |
1422
+ | `--client-int64-as` | `string` | Map 64-bit integers: `string`, `number`, or `bigint` |
1423
+ | `--client-bigint-as` | `string` | Map arbitrary-size integers: `string` or `number` |
1424
+ | `--client-decimal-as` | `string` | Map `xs:decimal`: `string` or `number` |
1425
+ | `--client-date-as` | `string` | Map date/time types: `string` or `Date` |
1426
+ | `--client-choice-mode` | `all-optional` | Choice element strategy: `all-optional` or `union` |
1427
+ | `--client-fail-on-unresolved` | `false` | Fail build on unresolved type references |
1428
+ | `--client-nillable-as-optional` | `false` | Treat nillable elements as optional properties |
1429
+
1430
+ #### Examples
957
1431
 
958
- #### Complete Stack Generation (Using Default Catalog Location)
1432
+ **Basic Compilation:**
959
1433
 
960
1434
  ```bash
961
- npx wsdl-tsc pipeline \
1435
+ npx wsdl-tsc compile \
962
1436
  --wsdl-source examples/minimal/weather.wsdl \
963
- --client-dir tmp/client \
964
- --openapi-file tmp/openapi.json \
965
- --gateway-dir tmp/gateway \
966
- --gateway-service-name weather \
967
- --gateway-version-prefix v1
1437
+ --catalog-file tmp/catalog.json
968
1438
  ```
969
1439
 
970
- **Output**: Catalog at `tmp/client/catalog.json`.
971
-
972
- #### Client + OpenAPI Only
1440
+ **With Custom Mapping Options:**
973
1441
 
974
1442
  ```bash
975
- npx wsdl-tsc pipeline \
1443
+ npx wsdl-tsc compile \
976
1444
  --wsdl-source https://example.com/Hotel.wsdl \
977
- --client-dir ./build/client \
978
- --openapi-file ./docs/hotel-api.json \
979
- --openapi-format both
1445
+ --catalog-file ./build/hotel-catalog.json \
1446
+ --client-int64-as number \
1447
+ --client-decimal-as string
980
1448
  ```
981
1449
 
982
- **Output**: Catalog at `./build/client/catalog.json`.
983
-
984
- #### OpenAPI + Gateway Only
1450
+ **For Debugging:**
985
1451
 
986
1452
  ```bash
987
- npx wsdl-tsc pipeline \
988
- --wsdl-source ./wsdl/Booking.wsdl \
989
- --openapi-file ./docs/booking-api.json \
990
- --gateway-dir ./build/gateway \
991
- --gateway-service-name booking \
992
- --gateway-version-prefix v1
1453
+ # Compile to inspect types and operations
1454
+ npx wsdl-tsc compile \
1455
+ --wsdl-source ./wsdl/ComplexService.wsdl \
1456
+ --catalog-file ./debug/catalog.json \
1457
+ --client-fail-on-unresolved false
1458
+
1459
+ # Inspect types
1460
+ cat ./debug/catalog.json | jq '.types'
1461
+
1462
+ # Inspect operations
1463
+ cat ./debug/catalog.json | jq '.operations'
993
1464
  ```
994
1465
 
995
- **Output**: Catalog at `./docs/catalog.json`.
1466
+ #### Output
996
1467
 
997
- #### With Custom Catalog Path
1468
+ - `catalog.json` - Compiled schema representation including types, operations, and metadata
998
1469
 
999
- ```bash
1000
- npx wsdl-tsc pipeline \
1001
- --wsdl-source ./wsdl/Booking.wsdl \
1002
- --catalog-file ./build/shared/catalog.json \
1003
- --client-dir ./build/client \
1004
- --openapi-file ./docs/booking-api.json \
1005
- --gateway-dir ./build/gateway \
1006
- --gateway-service-name booking \
1007
- --gateway-version-prefix v1
1008
- ```
1470
+ #### Catalog Structure
1009
1471
 
1010
- #### With Full Configuration
1472
+ The catalog.json file contains the compiled WSDL representation:
1011
1473
 
1012
- ```bash
1013
- npx wsdl-tsc pipeline \
1014
- --wsdl-source ./wsdl/Booking.wsdl \
1015
- --client-dir ./build/client \
1016
- --openapi-file ./docs/booking-api \
1017
- --gateway-dir ./build/gateway \
1018
- --openapi-format both \
1019
- --openapi-servers https://api.example.com/v1 \
1020
- --openapi-base-path /booking \
1021
- --openapi-security-config-file ./config/security.json \
1022
- --gateway-service-name booking \
1023
- --gateway-version-prefix v1 \
1024
- --client-int64-as number \
1025
- --client-decimal-as string
1474
+ ```json
1475
+ {
1476
+ "wsdlUri": "path/to/service.wsdl",
1477
+ "targetNamespace": "http://example.com/service",
1478
+ "serviceName": "WeatherService",
1479
+ "types": [
1480
+ {
1481
+ "name": "GetWeatherRequest",
1482
+ "properties": []
1483
+ }
1484
+ ],
1485
+ "operations": [
1486
+ {
1487
+ "name": "GetWeather",
1488
+ "input": "GetWeatherRequest",
1489
+ "output": "GetWeatherResponse"
1490
+ }
1491
+ ],
1492
+ "options": {
1493
+ "imports": "js",
1494
+ "catalog": true
1495
+ }
1496
+ }
1026
1497
  ```
1027
1498
 
1028
- **Output**: Catalog at `./build/client/catalog.json`.
1499
+ **Key sections**:
1500
+ - `types` - All compiled type definitions with properties and inheritance
1501
+ - `operations` - SOAP operations with input/output type references
1502
+ - `options` - Compiler options used during generation
1029
1503
 
1030
- ### Pipeline Workflow
1504
+ This catalog can be reused with the `client` and `openapi` commands via `--catalog-file`.
1031
1505
 
1032
- The pipeline command executes these steps in order:
1506
+ #### Catalog Co-location
1033
1507
 
1034
- 1. **Parse WSDL** Load and validate WSDL document
1035
- 2. **Compile Catalog** → Generate intermediate representation
1036
- 3. **Emit Catalog** → Write `catalog.json` (always)
1037
- 4. **Generate Client** → Emit TypeScript client files (if `--client-dir`)
1038
- 5. **Generate OpenAPI** → Create OpenAPI spec (if `--openapi-file`)
1039
- 6. **Generate Gateway** → Create Fastify gateway code (if `--gateway-dir`)
1508
+ **Default behavior**: Catalog files are **co-located** with their primary output files for better organization and discoverability.
1040
1509
 
1041
- All steps share the same parsed WSDL and compiled catalog, ensuring consistency.
1510
+ **Catalog Location by Command**:
1511
+ - `compile`: Always requires explicit `--catalog-file` (no default)
1512
+ - `client`: Defaults to `{client-dir}/catalog.json`
1513
+ - `openapi`: Defaults to `{openapi-file-dir}/catalog.json`
1514
+ - `pipeline`: Intelligent cascade - first available: `{client-dir}` > `{openapi-dir}` > `{gateway-dir}` > `tmp/`
1515
+
1516
+ **Common patterns**:
1517
+
1518
+ 1. **Co-located with client** (recommended for most projects):
1519
+ ```bash
1520
+ npx wsdl-tsc client --wsdl-source service.wsdl --client-dir src/services/weather
1521
+ ```
1522
+
1523
+ Creates `src/services/weather/catalog.json` automatically.
1524
+
1525
+ 2. **Shared catalog for multiple commands** (custom location):
1526
+ ```bash
1527
+ npx wsdl-tsc compile --wsdl-source service.wsdl --catalog-file build/shared-catalog.json
1528
+ npx wsdl-tsc client --catalog-file build/shared-catalog.json --client-dir src/client
1529
+ npx wsdl-tsc openapi --catalog-file build/shared-catalog.json --openapi-file docs/api.json
1530
+ ```
1042
1531
 
1043
1532
  ---
1044
1533
 
1045
- ## 10. Working With Generated Clients
1534
+ ## Working With Generated Clients
1046
1535
 
1047
1536
  ### Client Construction
1048
1537
 
@@ -1109,7 +1598,7 @@ result.GetCityWeatherByZIPResult.Temperature; // number | string (depends on ma
1109
1598
 
1110
1599
  ---
1111
1600
 
1112
- ## 11. OpenAPI Configuration
1601
+ ## Configuration Files
1113
1602
 
1114
1603
  ### Security Configuration (`security.json`)
1115
1604
 
@@ -1168,7 +1657,106 @@ Per-operation overrides for method, summary, description, and deprecation:
1168
1657
 
1169
1658
  ---
1170
1659
 
1171
- ## 12. Programmatic API
1660
+ ## Production Concerns
1661
+
1662
+ ### Deterministic Output Guarantees
1663
+
1664
+ All generated code and specifications have **stable, deterministic ordering** for version control:
1665
+
1666
+ - ✅ **TypeScript files**: Sorted type declarations, imports, and exports
1667
+ - ✅ **OpenAPI specs**: Sorted paths, HTTP methods, schemas, parameters, security schemes, tags
1668
+ - ✅ **JSON Schemas**: Sorted property keys and component names
1669
+ - ✅ **Gateway routes**: Alphabetically organized route files
1670
+ - ✅ **Catalog JSON**: Consistent ordering of types and operations
1671
+
1672
+ **Benefit**: Safe regeneration in CI/CD without spurious diffs.
1673
+
1674
+ ### Validation Behavior
1675
+
1676
+ **OpenAPI Validation** (enabled by default):
1677
+ - Uses `@apidevtools/swagger-parser`
1678
+ - Validates schema structure
1679
+ - Resolves all `$ref` references
1680
+ - Catches missing schemas and circular dependencies
1681
+ - Disable with `--openapi-validate false`
1682
+
1683
+ **Gateway Contract Validation**:
1684
+ - All request/response bodies must use `$ref` to `components.schemas`
1685
+ - Every operation must have a default response with `application/json` content
1686
+ - All referenced schemas must exist in `components.schemas`
1687
+
1688
+ ### Error Handling
1689
+
1690
+ **Gateway Error Classification**:
1691
+
1692
+ | Error Type | HTTP Status | Error Code | When It Occurs |
1693
+ |-----------------------|-------------|-----------------------|---------------------------------------|
1694
+ | Validation errors | 400 | `VALIDATION_ERROR` | Request doesn't match JSON Schema |
1695
+ | SOAP faults | 502 | `SOAP_FAULT` | SOAP service returned a fault |
1696
+ | Connection refused | 503 | `SERVICE_UNAVAILABLE` | Cannot reach SOAP endpoint |
1697
+ | Timeout | 504 | `GATEWAY_TIMEOUT` | SOAP request exceeded timeout |
1698
+ | Other errors | 500 | `INTERNAL_ERROR` | Unexpected errors |
1699
+
1700
+ All errors are wrapped in the standard envelope format with `error` object populated.
1701
+
1702
+ ### SOAP Wire Logging
1703
+
1704
+ Enable SOAP request/response debugging:
1705
+
1706
+ ```bash
1707
+ NODE_DEBUG=soap node app.js
1708
+ ```
1709
+
1710
+ This logs full XML request/response payloads to console.
1711
+
1712
+ ### CI/CD Tips
1713
+
1714
+ **Caching Strategy:**
1715
+
1716
+ ```bash
1717
+ # Step 1: Compile catalog (cacheable artifact)
1718
+ npx wsdl-tsc compile \
1719
+ --wsdl-source ./wsdl/Service.wsdl \
1720
+ --catalog-file ./build/catalog.json
1721
+
1722
+ # Step 2: Generate code from cached catalog
1723
+ npx wsdl-tsc client --catalog-file ./build/catalog.json --client-dir ./src/client
1724
+ npx wsdl-tsc openapi --catalog-file ./build/catalog.json --openapi-file ./docs/api.json
1725
+ ```
1726
+
1727
+ **Recommended Build Script** (`package.json`):
1728
+
1729
+ ```json
1730
+ {
1731
+ "scripts": {
1732
+ "generate": "npx wsdl-tsc pipeline --wsdl-source ./wsdl/service.wsdl --client-dir ./src/client --openapi-file ./docs/api.json --gateway-dir ./src/gateway --gateway-service-name svc --gateway-version-prefix v1",
1733
+ "build": "npm run generate && tsc",
1734
+ "typecheck": "tsc --noEmit"
1735
+ }
1736
+ }
1737
+ ```
1738
+
1739
+ ### Known Limitations
1740
+
1741
+ **Choice Elements**:
1742
+ - Current strategy: `all-optional` (all branches optional)
1743
+ - Future: Discriminated union support (planned)
1744
+
1745
+ **Union Types**:
1746
+ - Experimental `--client-choice-mode union` available
1747
+ - May require manual refinement for complex patterns
1748
+
1749
+ **WS-Policy**:
1750
+ - Security hints extracted from policies
1751
+ - Custom policies may require manual security configuration
1752
+
1753
+ **Array Wrapper Flattening**:
1754
+ - Single-child sequences with `maxOccurs>1` become array schemas
1755
+ - Sequences with multiple children preserve wrapper
1756
+
1757
+ ---
1758
+
1759
+ ## Programmatic API
1172
1760
 
1173
1761
  All CLI commands are available as TypeScript functions for programmatic usage.
1174
1762
 
@@ -1435,7 +2023,7 @@ interface PipelineOptions {
1435
2023
 
1436
2024
  ---
1437
2025
 
1438
- ## 13. Advanced Topics
2026
+ ## Advanced Topics
1439
2027
 
1440
2028
  ### Primitive Mapping Philosophy
1441
2029
 
@@ -1510,7 +2098,7 @@ Disable with `--openapi-validate false` or `validate: false` in API.
1510
2098
 
1511
2099
  ---
1512
2100
 
1513
- ## 14. Troubleshooting
2101
+ ## Troubleshooting
1514
2102
 
1515
2103
  ### Common Issues
1516
2104
 
@@ -1591,7 +2179,7 @@ The catalog is automatically placed at `./src/services/hotel/catalog.json`.
1591
2179
 
1592
2180
  ---
1593
2181
 
1594
- ## 15. Contributing
2182
+ ## Contributing
1595
2183
 
1596
2184
  We welcome contributions! Here's how to get started:
1597
2185
 
@@ -1665,7 +2253,7 @@ See also: [CONTRIBUTING.md](CONTRIBUTING.md), [CODE_OF_CONDUCT.md](CODE_OF_CONDU
1665
2253
 
1666
2254
  ---
1667
2255
 
1668
- ## 16. License
2256
+ ## License
1669
2257
 
1670
2258
  MIT © TechSpokes
1671
2259
 
@@ -1675,7 +2263,7 @@ See [LICENSE](LICENSE) for full text.
1675
2263
 
1676
2264
  ---
1677
2265
 
1678
- ## 17. Sponsors
2266
+ ## Sponsors
1679
2267
 
1680
2268
  Support ongoing development and maintenance:
1681
2269