swaggular 1.0.3 → 1.0.4

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 (2) hide show
  1. package/README.md +45 -2
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -59,7 +59,49 @@ You can configure Swaggular using CLI arguments or a configuration file (e.g., `
59
59
 
60
60
  ### Configuration File (`SwaggularConfig`)
61
61
 
62
- You can create a `swaggular.config.json` file in your project root to define advanced configurations, such as custom templates, base classes for DTOs, or generic types.
62
+ You can create a `swaggular.config.json` file in your project root to define advanced configurations. Below is the detailed structure of the configuration object.
63
+
64
+ #### **Properties**
65
+
66
+ - **`input`** _(optional)_: `string` - Path to the input Swagger/OpenAPI file (e.g., `swagger.json`). If not specified, defaults to the basic input.
67
+ - **`output`** _(optional)_: `string` - Path to the output directory where generated files will be saved. Default: `results`.
68
+ - **`groupingMode`** _(optional)_: `'tags' | 'path'` - Strategy for grouping services.
69
+ - `'tags'`: Groups operations based on their Swagger tags.
70
+ - `'path'`: Groups operations based on their URL path segments.
71
+ - **`segmentsToIgnore`** _(optional)_: `string[]` - List of URL segments to ignore when generating service names (e.g., `['api', 'v1']`).
72
+ - **`types`** _(optional)_: `object` - Configuration for type generation and inheritance.
73
+ - **`extendsFrom`** _(optional)_: `InterfaceData[]` - Defines base classes that generated DTOs should extend if they match the properties.
74
+ - **`generic`** _(optional)_: `InterfaceData[]` - Defines generic types to replace duplicate generated classes (e.g., `PagedResultDto<T>`).
75
+ - **`templates`** _(optional)_: `object` - Configuration for templates used in generation.
76
+ - **`service`** _(optional)_: `object` - Service template configuration.
77
+ - **`path`**: `string` - Path to the internal or custom service template file (e.g., `'templates/angular-service.template'`).
78
+ - **`httpParamsHandler`** _(optional)_: `string` - Custom logic to handle HTTP parameters (e.g., `'const params = HttpHelper.toHttpParams(${params} || {});'`). The `${params}` is a placeholder for the query parameters, it MUST exist in the string.
79
+ - **`httpParamsHandlerImport`** _(optional)_: `string` - Import statement for the custom parameters handler (e.g., `'import { HttpHelper } from "@shared/utils";'`).
80
+
81
+ ---
82
+
83
+ #### **Object Structures**
84
+
85
+ **`InterfaceData`**
86
+
87
+ Used in `types.extendsFrom` and `types.generic`.
88
+
89
+ - **`name`**: `string` - The name of the interface or class.
90
+ - **`imports`**: `string[]` - List of imports required for this interface. It has to be the name of other generated interfaces, e.g. `['SomeProperty']`.
91
+ - **`type`**: `'interface' | 'enum' | 'type'` - The kind of TypeScript structure.
92
+ - **`properties`**: `InterfaceDataProperty[]` - Array of properties belonging to this interface.
93
+ - **`extendsFrom`** _(optional)_: `string[]` - Names of other interfaces this one extends. It has to be the name of other generated interfaces, e.g. `['SomeProperty']`.
94
+
95
+ **`InterfaceDataProperty`**
96
+
97
+ Used in `InterfaceData.properties`.
98
+
99
+ - **`name`**: `string` - The name of the property.
100
+ - **`type`**: `string` - The TypeScript type of the property (e.g., `'string'`, `'number'`, `'T[]'`).
101
+ - **`optional`**: `boolean` - Whether the property is optional (`?`).
102
+ - **`comments`**: `string` - JSDoc comments or other annotations for the property. It must be surrounded by the `/** ... */` .
103
+
104
+ ---
63
105
 
64
106
  #### Example `swaggular.config.json`
65
107
 
@@ -95,6 +137,7 @@ You can create a `swaggular.config.json` file in your project root to define adv
95
137
  },
96
138
  "templates": {
97
139
  "service": {
140
+ "path": "templates/angular-service.template",
98
141
  "httpParamsHandlerImport": "import { HttpHelper } from '@shared/utils/http-helper';",
99
142
  "httpParamsHandler": "const params = HttpHelper.toHttpParams(${params} || {});"
100
143
  }
@@ -106,7 +149,7 @@ This configuration allows you to:
106
149
 
107
150
  1. **extendsFrom**: Automatically make generated DTOs extend a base class (e.g., `PagedRequestDto`) if they share the same properties.
108
151
  2. **generic**: Automatically detect and use generic types (e.g., `PagedResultDto<T>`) instead of generating duplicate classes like `PagedResultDtoOfUser`.
109
- 3. **templates.service.options**: Customize how HTTP parameters are handled in generated services, allowing you to use your own helper functions.
152
+ 3. **templates.service**: Customize how HTTP parameters are handled in generated services, allowing you to use your own helper functions.
110
153
 
111
154
  ## Development
112
155
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "swaggular",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "bin": {