@ioka-technologies/asyncapi-ts-client-template 0.0.11 → 0.0.12
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/package.json +2 -1
- package/template/src/models.ts.js +11 -3
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ioka-technologies/asyncapi-ts-client-template",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.12",
|
|
4
4
|
"description": "TypeScript AsyncAPI client generator template compatible with rust-asyncapi patterns",
|
|
5
5
|
"main": "template/index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "npm run test:generate",
|
|
8
8
|
"test:generate": "asyncapi generate fromTemplate examples/auth-retry/asyncapi.yaml . -o test-output-auth-retry --force-write -p enableAuth=true && cd test-output-auth-retry && npm install && npm run build",
|
|
9
9
|
"test:realworld": "asyncapi generate fromTemplate ../examples/realworld/asyncapi.yaml . -o test-output-realworld --force-write -p enableAuth=true",
|
|
10
|
+
"test:simple": "asyncapi generate fromTemplate ../examples/simple/asyncapi.yaml . -o test-output-simple --force-write -p enableAuth=true",
|
|
10
11
|
"clean": "rm -rf test-output-*"
|
|
11
12
|
},
|
|
12
13
|
"keywords": [
|
|
@@ -311,9 +311,17 @@ function generateModels(asyncapi) {
|
|
|
311
311
|
componentSchemas.forEach(schema => {
|
|
312
312
|
const doc = schema.description ? `/** ${schema.description} */\n` : `/** ${schema.name} */\n`;
|
|
313
313
|
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
314
|
+
// Check if this is a standalone enum schema
|
|
315
|
+
if (schema.schema.type === 'string' && schema.schema.enum && Array.isArray(schema.schema.enum)) {
|
|
316
|
+
// Generate union type for enum
|
|
317
|
+
const enumValues = schema.schema.enum.map(val => `'${val}'`).join(' | ');
|
|
318
|
+
content += `${doc}export type ${schema.typeName} = ${enumValues};\n\n`;
|
|
319
|
+
} else {
|
|
320
|
+
// Generate interface for object schema
|
|
321
|
+
content += `${doc}export interface ${schema.typeName} {\n`;
|
|
322
|
+
content += generateMessageInterface(schema.schema, schema.typeName);
|
|
323
|
+
content += '\n}\n\n';
|
|
324
|
+
}
|
|
317
325
|
|
|
318
326
|
// Track generated types to avoid duplicates
|
|
319
327
|
generatedTypes.add(schema.typeName);
|