klasik 1.0.20 → 1.0.22
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/.claude/settings.local.json +18 -0
- package/README.md +196 -0
- package/dist/cli.js +4 -0
- package/dist/k8s-client-generator.d.ts +25 -0
- package/dist/k8s-client-generator.js +45 -1
- package/package.json +7 -3
- package/{test-discriminated-output/configuration.ts → templates/configuration.mustache} +4 -12
- package/test-discriminated-output/.openapi-generator-ignore +0 -23
- package/test-discriminated-output/api/default-api.ts +0 -142
- package/test-discriminated-output/api.ts +0 -19
- package/test-discriminated-output/base.ts +0 -86
- package/test-discriminated-output/common.ts +0 -151
- package/test-discriminated-output/index.ts +0 -18
- package/test-discriminated-output/models/capability.js +0 -80
- package/test-discriminated-output/models/capability.ts +0 -74
- package/test-discriminated-output/models/helm-component.js +0 -82
- package/test-discriminated-output/models/helm-component.ts +0 -83
- package/test-discriminated-output/models/index.ts +0 -4
- package/test-discriminated-output/models/kustomize-component.js +0 -70
- package/test-discriminated-output/models/kustomize-component.ts +0 -70
- package/test-discriminated-output/models/manifest-component.js +0 -58
- package/test-discriminated-output/models/manifest-component.ts +0 -57
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"permissions": {
|
|
3
|
+
"allow": [
|
|
4
|
+
"Bash(grep:*)",
|
|
5
|
+
"WebSearch",
|
|
6
|
+
"Bash(npx @openapitools/openapi-generator-cli help generate:*)",
|
|
7
|
+
"Bash(node dist/cli.js generate:*)",
|
|
8
|
+
"Bash(npx tsc:*)",
|
|
9
|
+
"Bash(npm install:*)",
|
|
10
|
+
"WebFetch(domain:dev.to)",
|
|
11
|
+
"WebFetch(domain:saintlouvent.com)",
|
|
12
|
+
"WebFetch(domain:zod.dev)",
|
|
13
|
+
"Bash(node test-disc-union.js:*)",
|
|
14
|
+
"Bash(node test-disc-code.js:*)",
|
|
15
|
+
"Bash(node test-new-validators.js:*)"
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
}
|
package/README.md
CHANGED
|
@@ -104,6 +104,14 @@ Generate a TypeScript client from an OpenAPI spec (remote URL or local file).
|
|
|
104
104
|
- Perfect for authorization: `--header "Authorization: Bearer token"`
|
|
105
105
|
- `-r, --resolve-refs` - Resolve and download external `$ref` references
|
|
106
106
|
- `--esm` - Add `.js` extensions to imports for ESM compatibility (Node.js modules)
|
|
107
|
+
- `--nestjs-swagger` - Include NestJS Swagger `@ApiProperty` decorators in generated models
|
|
108
|
+
- Automatically adds `@nestjs/swagger` to generated package.json
|
|
109
|
+
- Ideal for NestJS applications with Swagger/OpenAPI documentation
|
|
110
|
+
- Works with both `full` and `models-only` generation modes
|
|
111
|
+
- `--class-validator` - Include class-validator decorators for runtime validation (requires openapi-class-transformer v2.0+)
|
|
112
|
+
- Automatically adds `class-validator` and `class-transformer` to generated package.json
|
|
113
|
+
- Enables runtime validation with decorators like `@IsString`, `@IsEmail`, `@Min`, `@Max`
|
|
114
|
+
- Forward-compatible flag - full decorator generation coming in future version
|
|
107
115
|
- `-t, --template <dir>` - Custom template directory (klasik includes enhanced TSDoc templates by default)
|
|
108
116
|
- `-k, --keep-spec` - Keep the downloaded spec file after generation
|
|
109
117
|
- `--timeout <ms>` - Request timeout in milliseconds for HTTP requests (default: 30000)
|
|
@@ -125,6 +133,28 @@ klasik generate \
|
|
|
125
133
|
--header "Authorization: Bearer token123" \
|
|
126
134
|
--resolve-refs
|
|
127
135
|
|
|
136
|
+
# NestJS integration with Swagger decorators
|
|
137
|
+
klasik generate \
|
|
138
|
+
--url https://api.example.com/openapi.json \
|
|
139
|
+
--output ./src/generated \
|
|
140
|
+
--mode models-only \
|
|
141
|
+
--nestjs-swagger
|
|
142
|
+
|
|
143
|
+
# With runtime validation decorators
|
|
144
|
+
klasik generate \
|
|
145
|
+
--url https://api.example.com/openapi.json \
|
|
146
|
+
--output ./src/generated \
|
|
147
|
+
--mode models-only \
|
|
148
|
+
--class-validator
|
|
149
|
+
|
|
150
|
+
# Full NestJS setup: Swagger docs + validation
|
|
151
|
+
klasik generate \
|
|
152
|
+
--url https://api.example.com/openapi.json \
|
|
153
|
+
--output ./src/generated \
|
|
154
|
+
--mode models-only \
|
|
155
|
+
--nestjs-swagger \
|
|
156
|
+
--class-validator
|
|
157
|
+
|
|
128
158
|
# Multiple headers
|
|
129
159
|
klasik generate \
|
|
130
160
|
--url https://api.example.com/openapi.json \
|
|
@@ -183,11 +213,14 @@ const generator = new K8sClientGenerator();
|
|
|
183
213
|
await generator.generate({
|
|
184
214
|
specUrl: 'https://api.example.com/openapi.json',
|
|
185
215
|
outputDir: './client',
|
|
216
|
+
mode: 'models-only',
|
|
186
217
|
headers: {
|
|
187
218
|
'Authorization': 'Bearer token123',
|
|
188
219
|
'X-Custom-Header': 'value'
|
|
189
220
|
},
|
|
190
221
|
resolveReferences: true, // Download external $ref files
|
|
222
|
+
nestJsSwagger: true, // Include @ApiProperty decorators
|
|
223
|
+
classValidator: true, // Include validation decorators
|
|
191
224
|
templateDir: './custom-templates', // Optional
|
|
192
225
|
keepSpec: true, // Keep downloaded spec file
|
|
193
226
|
timeout: 60000 // Request timeout in ms
|
|
@@ -229,6 +262,8 @@ The generated TypeScript client includes:
|
|
|
229
262
|
- ✅ **Vendor extensions** - Preserved in JSDoc comments and metadata
|
|
230
263
|
- ✅ **Error handling** - Configurable transformation error handlers
|
|
231
264
|
- ✅ **Configuration options** - Enable/disable transformation, custom error handlers
|
|
265
|
+
- ✅ **NestJS Swagger decorators** (optional) - `@ApiProperty` with type, description, example, required, and nullable when `--nestjs-swagger` is enabled
|
|
266
|
+
- ✅ **class-validator decorators** (optional) - Runtime validation decorators when `--class-validator` is enabled (full support in v2.0+)
|
|
232
267
|
|
|
233
268
|
### Enhanced TSDoc Documentation
|
|
234
269
|
|
|
@@ -422,6 +457,167 @@ await new K8sClientGenerator().generate({
|
|
|
422
457
|
});
|
|
423
458
|
```
|
|
424
459
|
|
|
460
|
+
## NestJS Integration
|
|
461
|
+
|
|
462
|
+
### Using with NestJS Applications
|
|
463
|
+
|
|
464
|
+
Klasik-generated models integrate seamlessly with NestJS applications. Use `--mode models-only` with decorator flags for best results.
|
|
465
|
+
|
|
466
|
+
#### Swagger Documentation Support
|
|
467
|
+
|
|
468
|
+
Generate models with `@ApiProperty` decorators for automatic Swagger documentation:
|
|
469
|
+
|
|
470
|
+
```bash
|
|
471
|
+
npx klasik generate \
|
|
472
|
+
--url https://api.example.com/openapi.json \
|
|
473
|
+
--output ./src/generated/dto \
|
|
474
|
+
--mode models-only \
|
|
475
|
+
--nestjs-swagger
|
|
476
|
+
```
|
|
477
|
+
|
|
478
|
+
This generates DTOs like:
|
|
479
|
+
|
|
480
|
+
```typescript
|
|
481
|
+
import { Expose } from 'class-transformer';
|
|
482
|
+
import { ApiProperty } from '@nestjs/swagger';
|
|
483
|
+
|
|
484
|
+
export class UserDto {
|
|
485
|
+
@ApiProperty({
|
|
486
|
+
type: String,
|
|
487
|
+
description: 'Unique identifier',
|
|
488
|
+
required: true,
|
|
489
|
+
example: '123e4567-e89b-41d3-a456-426614174000',
|
|
490
|
+
})
|
|
491
|
+
@Expose()
|
|
492
|
+
id: string;
|
|
493
|
+
|
|
494
|
+
@ApiProperty({
|
|
495
|
+
type: String,
|
|
496
|
+
description: 'User email address',
|
|
497
|
+
required: true,
|
|
498
|
+
format: 'email',
|
|
499
|
+
})
|
|
500
|
+
@Expose()
|
|
501
|
+
email: string;
|
|
502
|
+
}
|
|
503
|
+
```
|
|
504
|
+
|
|
505
|
+
Use in your NestJS controllers:
|
|
506
|
+
|
|
507
|
+
```typescript
|
|
508
|
+
import { Controller, Get, Post, Body } from '@nestjs/common';
|
|
509
|
+
import { ApiTags, ApiResponse } from '@nestjs/swagger';
|
|
510
|
+
import { UserDto } from './generated/dto';
|
|
511
|
+
|
|
512
|
+
@ApiTags('users')
|
|
513
|
+
@Controller('users')
|
|
514
|
+
export class UsersController {
|
|
515
|
+
@Get()
|
|
516
|
+
@ApiResponse({ type: [UserDto], status: 200 })
|
|
517
|
+
async findAll(): Promise<UserDto[]> {
|
|
518
|
+
// Your implementation
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
@Post()
|
|
522
|
+
@ApiResponse({ type: UserDto, status: 201 })
|
|
523
|
+
async create(@Body() createUserDto: UserDto): Promise<UserDto> {
|
|
524
|
+
// Your implementation
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
```
|
|
528
|
+
|
|
529
|
+
Your Swagger UI automatically displays complete documentation from the `@ApiProperty` decorators.
|
|
530
|
+
|
|
531
|
+
#### Runtime Validation Support
|
|
532
|
+
|
|
533
|
+
Add the `--class-validator` flag for runtime validation decorators:
|
|
534
|
+
|
|
535
|
+
```bash
|
|
536
|
+
npx klasik generate \
|
|
537
|
+
--url https://api.example.com/openapi.json \
|
|
538
|
+
--output ./src/generated/dto \
|
|
539
|
+
--mode models-only \
|
|
540
|
+
--nestjs-swagger \
|
|
541
|
+
--class-validator
|
|
542
|
+
```
|
|
543
|
+
|
|
544
|
+
**Note**: Full decorator generation requires openapi-class-transformer v2.0+. For now, the dependencies are added to package.json, and you can manually add validation decorators:
|
|
545
|
+
|
|
546
|
+
```typescript
|
|
547
|
+
import { Expose } from 'class-transformer';
|
|
548
|
+
import { ApiProperty } from '@nestjs/swagger';
|
|
549
|
+
import { IsString, IsEmail } from 'class-validator';
|
|
550
|
+
|
|
551
|
+
export class UserDto {
|
|
552
|
+
@ApiProperty({ type: String, required: true })
|
|
553
|
+
@IsString()
|
|
554
|
+
@Expose()
|
|
555
|
+
id: string;
|
|
556
|
+
|
|
557
|
+
@ApiProperty({ type: String, required: true, format: 'email' })
|
|
558
|
+
@IsEmail()
|
|
559
|
+
@Expose()
|
|
560
|
+
email: string;
|
|
561
|
+
}
|
|
562
|
+
```
|
|
563
|
+
|
|
564
|
+
Use with NestJS ValidationPipe:
|
|
565
|
+
|
|
566
|
+
```typescript
|
|
567
|
+
import { ValidationPipe } from '@nestjs/common';
|
|
568
|
+
|
|
569
|
+
// In main.ts
|
|
570
|
+
app.useGlobalPipes(new ValidationPipe({
|
|
571
|
+
transform: true,
|
|
572
|
+
whitelist: true,
|
|
573
|
+
}));
|
|
574
|
+
|
|
575
|
+
// In controller
|
|
576
|
+
@Post()
|
|
577
|
+
async create(@Body() dto: UserDto): Promise<UserDto> {
|
|
578
|
+
// dto is already validated and transformed to UserDto instance!
|
|
579
|
+
}
|
|
580
|
+
```
|
|
581
|
+
|
|
582
|
+
#### Required Dependencies for NestJS
|
|
583
|
+
|
|
584
|
+
When using `--nestjs-swagger` or `--class-validator`, ensure your project has these peer dependencies:
|
|
585
|
+
|
|
586
|
+
```bash
|
|
587
|
+
npm install @nestjs/swagger swagger-ui-express
|
|
588
|
+
npm install class-validator class-transformer
|
|
589
|
+
npm install reflect-metadata
|
|
590
|
+
```
|
|
591
|
+
|
|
592
|
+
Update your `tsconfig.json`:
|
|
593
|
+
|
|
594
|
+
```json
|
|
595
|
+
{
|
|
596
|
+
"compilerOptions": {
|
|
597
|
+
"experimentalDecorators": true,
|
|
598
|
+
"emitDecoratorMetadata": true
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
```
|
|
602
|
+
|
|
603
|
+
#### Best Practices
|
|
604
|
+
|
|
605
|
+
1. **Use models-only mode**: Generate only DTOs, keep your NestJS business logic separate
|
|
606
|
+
2. **Separate directories**: Generate into `src/generated/dto` or similar
|
|
607
|
+
3. **Extend generated classes**: For complex validation, extend generated DTOs
|
|
608
|
+
4. **Version control**: Commit generated files or regenerate in CI/CD
|
|
609
|
+
|
|
610
|
+
```typescript
|
|
611
|
+
// Custom DTO extending generated model
|
|
612
|
+
import { UserDto } from '../generated/dto';
|
|
613
|
+
import { IsStrongPassword } from 'class-validator';
|
|
614
|
+
|
|
615
|
+
export class CreateUserDto extends UserDto {
|
|
616
|
+
@IsStrongPassword()
|
|
617
|
+
password: string;
|
|
618
|
+
}
|
|
619
|
+
```
|
|
620
|
+
|
|
425
621
|
## Best Practices for Existing Projects
|
|
426
622
|
|
|
427
623
|
When integrating klasik into an existing TypeScript project, follow these best practices to avoid conflicts:
|
package/dist/cli.js
CHANGED
|
@@ -53,6 +53,8 @@ program
|
|
|
53
53
|
.option('-k, --keep-spec', 'Keep the downloaded spec file after generation', false)
|
|
54
54
|
.option('-r, --resolve-refs', 'Resolve and download external $ref references', false)
|
|
55
55
|
.option('--esm', 'Add .js extensions to imports for ESM compatibility', false)
|
|
56
|
+
.option('--nestjs-swagger', 'Include NestJS Swagger @ApiProperty decorators in generated models', false)
|
|
57
|
+
.option('--class-validator', 'Include class-validator decorators in generated models', false)
|
|
56
58
|
.option('--timeout <ms>', 'Request timeout in milliseconds', '30000')
|
|
57
59
|
.action(async (options) => {
|
|
58
60
|
try {
|
|
@@ -84,6 +86,8 @@ program
|
|
|
84
86
|
keepSpec: options.keepSpec,
|
|
85
87
|
resolveReferences: options.resolveRefs,
|
|
86
88
|
fixEsmImports: options.esm,
|
|
89
|
+
nestJsSwagger: options.nestjsSwagger,
|
|
90
|
+
classValidator: options.classValidator,
|
|
87
91
|
timeout: parseInt(options.timeout, 10),
|
|
88
92
|
});
|
|
89
93
|
process.exit(0);
|
|
@@ -38,6 +38,27 @@ export interface K8sClientGeneratorOptions {
|
|
|
38
38
|
* @default false
|
|
39
39
|
*/
|
|
40
40
|
fixEsmImports?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Include NestJS Swagger @ApiProperty decorators in generated models
|
|
43
|
+
* Adds @nestjs/swagger to generated package.json
|
|
44
|
+
* @default false
|
|
45
|
+
*/
|
|
46
|
+
nestJsSwagger?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Include class-validator decorators in generated models
|
|
49
|
+
* Adds class-validator to generated package.json
|
|
50
|
+
* Decorators include: @IsString, @IsNumber, @IsOptional, @Min, @Max, @IsEmail, etc.
|
|
51
|
+
* Note: Full decorator generation requires openapi-class-transformer v2.0+
|
|
52
|
+
* @default false
|
|
53
|
+
*/
|
|
54
|
+
classValidator?: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Skip adding .js extensions to imports/exports
|
|
57
|
+
* Useful for bundlers like webpack/Next.js that don't want file extensions
|
|
58
|
+
* When true, imports will be: import { Foo } from './foo' instead of './foo.js'
|
|
59
|
+
* @default false
|
|
60
|
+
*/
|
|
61
|
+
skipJsExtensions?: boolean;
|
|
41
62
|
/**
|
|
42
63
|
* Request timeout for downloading spec in milliseconds
|
|
43
64
|
* @default 30000
|
|
@@ -64,4 +85,8 @@ export declare class K8sClientGenerator {
|
|
|
64
85
|
* Clean up the downloaded spec file
|
|
65
86
|
*/
|
|
66
87
|
private cleanupSpecFile;
|
|
88
|
+
/**
|
|
89
|
+
* Add decorator dependencies to generated package.json
|
|
90
|
+
*/
|
|
91
|
+
private addDecoratorDependencies;
|
|
67
92
|
}
|
|
@@ -48,7 +48,7 @@ class K8sClientGenerator {
|
|
|
48
48
|
* Generate TypeScript client from a remote OpenAPI spec URL
|
|
49
49
|
*/
|
|
50
50
|
async generate(options) {
|
|
51
|
-
const { specUrl, outputDir, mode = 'full', headers, templateDir, keepSpec = false, resolveReferences = false, fixEsmImports = false, timeout, } = options;
|
|
51
|
+
const { specUrl, outputDir, mode = 'full', headers, templateDir, keepSpec = false, resolveReferences = false, fixEsmImports = false, nestJsSwagger = false, classValidator = false, skipJsExtensions = false, timeout, } = options;
|
|
52
52
|
let specPath;
|
|
53
53
|
try {
|
|
54
54
|
// Step 1: Download the OpenAPI spec
|
|
@@ -74,6 +74,8 @@ class K8sClientGenerator {
|
|
|
74
74
|
inputSpec: jsonSpecPath,
|
|
75
75
|
outputDir,
|
|
76
76
|
modelsOnly: mode === 'models-only',
|
|
77
|
+
nestJsSwagger,
|
|
78
|
+
skipJsExtensions,
|
|
77
79
|
};
|
|
78
80
|
// Only add templateDir if it's provided
|
|
79
81
|
if (templateDir) {
|
|
@@ -81,6 +83,11 @@ class K8sClientGenerator {
|
|
|
81
83
|
}
|
|
82
84
|
const generator = new openapi_class_transformer_1.Generator(generatorOptions);
|
|
83
85
|
await generator.generate();
|
|
86
|
+
// Step 3.5: Update generated package.json with decorator dependencies
|
|
87
|
+
if (nestJsSwagger || classValidator) {
|
|
88
|
+
console.log('Step 3.5: Adding decorator dependencies to package.json...');
|
|
89
|
+
this.addDecoratorDependencies(outputDir, nestJsSwagger, classValidator);
|
|
90
|
+
}
|
|
84
91
|
// Step 4: Fix ESM imports if requested
|
|
85
92
|
if (fixEsmImports) {
|
|
86
93
|
console.log('Step 4: Fixing ESM imports...');
|
|
@@ -172,5 +179,42 @@ class K8sClientGenerator {
|
|
|
172
179
|
console.warn('Warning: Failed to cleanup spec file:', error);
|
|
173
180
|
}
|
|
174
181
|
}
|
|
182
|
+
/**
|
|
183
|
+
* Add decorator dependencies to generated package.json
|
|
184
|
+
*/
|
|
185
|
+
addDecoratorDependencies(outputDir, nestJsSwagger, classValidator) {
|
|
186
|
+
const packageJsonPath = path.join(outputDir, 'package.json');
|
|
187
|
+
if (!fs.existsSync(packageJsonPath)) {
|
|
188
|
+
console.warn('Warning: package.json not found in output directory');
|
|
189
|
+
console.log('Tip: In models-only mode, add these dependencies to your project manually');
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
try {
|
|
193
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
|
|
194
|
+
// Initialize dependencies if missing
|
|
195
|
+
if (!packageJson.dependencies) {
|
|
196
|
+
packageJson.dependencies = {};
|
|
197
|
+
}
|
|
198
|
+
// Add @nestjs/swagger if enabled
|
|
199
|
+
if (nestJsSwagger) {
|
|
200
|
+
packageJson.dependencies['@nestjs/swagger'] = '^7.0.0';
|
|
201
|
+
console.log(' ✓ Added @nestjs/swagger@^7.0.0 to dependencies');
|
|
202
|
+
}
|
|
203
|
+
// Add class-validator if enabled
|
|
204
|
+
if (classValidator) {
|
|
205
|
+
packageJson.dependencies['class-validator'] = '^0.14.0';
|
|
206
|
+
packageJson.dependencies['class-transformer'] = '^0.5.1'; // Required peer dependency
|
|
207
|
+
console.log(' ✓ Added class-validator@^0.14.0 to dependencies');
|
|
208
|
+
console.log(' ✓ Added class-transformer@^0.5.1 to dependencies');
|
|
209
|
+
console.log(' Note: Full decorator generation requires openapi-class-transformer v2.0+');
|
|
210
|
+
console.log(' For now, you can manually add validation decorators to the generated models');
|
|
211
|
+
}
|
|
212
|
+
// Write back with formatting
|
|
213
|
+
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2) + '\n', 'utf-8');
|
|
214
|
+
}
|
|
215
|
+
catch (error) {
|
|
216
|
+
console.warn('Warning: Failed to update package.json:', error);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
175
219
|
}
|
|
176
220
|
exports.K8sClientGenerator = K8sClientGenerator;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "klasik",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.22",
|
|
4
4
|
"description": "Download OpenAPI specs from remote URLs and generate TypeScript clients with class-transformer support",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -22,14 +22,18 @@
|
|
|
22
22
|
"api-client",
|
|
23
23
|
"generator"
|
|
24
24
|
],
|
|
25
|
-
"author": "",
|
|
25
|
+
"author": "hisco",
|
|
26
|
+
"repository": {
|
|
27
|
+
"type": "git",
|
|
28
|
+
"url": "https://github.com/hisco/klasik.git"
|
|
29
|
+
},
|
|
26
30
|
"license": "MIT",
|
|
27
31
|
"dependencies": {
|
|
28
32
|
"axios": "^1.6.0",
|
|
29
33
|
"class-transformer": "^0.5.1",
|
|
30
34
|
"commander": "^11.0.0",
|
|
31
35
|
"js-yaml": "^4.1.0",
|
|
32
|
-
"openapi-class-transformer": "^1.0.
|
|
36
|
+
"openapi-class-transformer": "^1.0.13",
|
|
33
37
|
"reflect-metadata": "^0.2.2"
|
|
34
38
|
},
|
|
35
39
|
"devDependencies": {
|
|
@@ -1,17 +1,6 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
|
-
|
|
4
|
-
* Test API with Discriminated Unions
|
|
5
|
-
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
|
6
|
-
*
|
|
7
|
-
* The version of the OpenAPI document: 1.0.0
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
11
|
-
* https://openapi-generator.tech
|
|
12
|
-
* Do not edit the class manually.
|
|
13
|
-
*/
|
|
14
|
-
|
|
3
|
+
{{>licenseInfo}}
|
|
15
4
|
|
|
16
5
|
export interface ConfigurationParameters {
|
|
17
6
|
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
|
|
@@ -127,6 +116,9 @@ export class Configuration {
|
|
|
127
116
|
this.baseOptions = {
|
|
128
117
|
...param.baseOptions,
|
|
129
118
|
headers: {
|
|
119
|
+
{{#httpUserAgent}}
|
|
120
|
+
'User-Agent': "{{httpUserAgent}}",
|
|
121
|
+
{{/httpUserAgent}}
|
|
130
122
|
...param.baseOptions?.headers,
|
|
131
123
|
},
|
|
132
124
|
};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
# OpenAPI Generator Ignore
|
|
2
|
-
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
|
|
3
|
-
|
|
4
|
-
# Use this file to prevent files from being overwritten by the generator.
|
|
5
|
-
# The patterns follow closely to .gitignore or .dockerignore.
|
|
6
|
-
|
|
7
|
-
# As an example, the C# client generator defines ApiClient.cs.
|
|
8
|
-
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
|
|
9
|
-
#ApiClient.cs
|
|
10
|
-
|
|
11
|
-
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
|
|
12
|
-
#foo/*/qux
|
|
13
|
-
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
|
|
14
|
-
|
|
15
|
-
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
|
|
16
|
-
#foo/**/qux
|
|
17
|
-
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
|
|
18
|
-
|
|
19
|
-
# You can also negate patterns with an exclamation (!).
|
|
20
|
-
# For example, you can ignore all files in a docs folder with the file extension .md:
|
|
21
|
-
#docs/*.md
|
|
22
|
-
# Then explicitly reverse the ignore rule for a single file:
|
|
23
|
-
#!docs/README.md
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
/* tslint:disable */
|
|
2
|
-
/* eslint-disable */
|
|
3
|
-
/**
|
|
4
|
-
* Test API with Discriminated Unions
|
|
5
|
-
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
|
6
|
-
*
|
|
7
|
-
* The version of the OpenAPI document: 1.0.0
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
11
|
-
* https://openapi-generator.tech
|
|
12
|
-
* Do not edit the class manually.
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
import type { Configuration } from '../configuration.js';
|
|
17
|
-
import type { AxiosPromise, AxiosInstance, RawAxiosRequestConfig } from 'axios';
|
|
18
|
-
import globalAxios, { type AxiosResponse } from 'axios';
|
|
19
|
-
import { plainToInstance } from 'class-transformer';
|
|
20
|
-
// URLSearchParams not necessarily used
|
|
21
|
-
// @ts-ignore
|
|
22
|
-
import { URL, URLSearchParams } from 'url';
|
|
23
|
-
// Some imports not used depending on template conditions
|
|
24
|
-
// @ts-ignore
|
|
25
|
-
import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setOAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction } from '../common.js';
|
|
26
|
-
// @ts-ignore
|
|
27
|
-
import { BASE_PATH, COLLECTION_FORMATS, type RequestArgs, BaseAPI, RequiredError, operationServerMap } from '../base.js';
|
|
28
|
-
// @ts-ignore
|
|
29
|
-
import { Capability } from '../models/index.js';
|
|
30
|
-
/**
|
|
31
|
-
* DefaultApi - axios parameter creator
|
|
32
|
-
* @export
|
|
33
|
-
*/
|
|
34
|
-
export const DefaultApiAxiosParamCreator = function (configuration?: Configuration) {
|
|
35
|
-
return {
|
|
36
|
-
/**
|
|
37
|
-
*
|
|
38
|
-
* @param {*} [options] Override http request option.
|
|
39
|
-
* @throws {RequiredError}
|
|
40
|
-
*/
|
|
41
|
-
getCapabilities: async (options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
|
|
42
|
-
const localVarPath = `/capabilities`;
|
|
43
|
-
// use dummy base URL string because the URL constructor only accepts absolute URLs.
|
|
44
|
-
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
|
|
45
|
-
let baseOptions;
|
|
46
|
-
if (configuration) {
|
|
47
|
-
baseOptions = configuration.baseOptions;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options};
|
|
51
|
-
const localVarHeaderParameter = {} as any;
|
|
52
|
-
const localVarQueryParameter = {} as any;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
setSearchParams(localVarUrlObj, localVarQueryParameter);
|
|
57
|
-
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
|
58
|
-
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
|
|
59
|
-
|
|
60
|
-
return {
|
|
61
|
-
url: toPathString(localVarUrlObj),
|
|
62
|
-
options: localVarRequestOptions,
|
|
63
|
-
};
|
|
64
|
-
},
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* DefaultApi - functional programming interface
|
|
70
|
-
* @export
|
|
71
|
-
*/
|
|
72
|
-
export const DefaultApiFp = function(configuration?: Configuration) {
|
|
73
|
-
const localVarAxiosParamCreator = DefaultApiAxiosParamCreator(configuration)
|
|
74
|
-
return {
|
|
75
|
-
/**
|
|
76
|
-
*
|
|
77
|
-
* @param {*} [options] Override http request option.
|
|
78
|
-
* @throws {RequiredError}
|
|
79
|
-
*/
|
|
80
|
-
async getCapabilities(options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<Array<Capability>>> {
|
|
81
|
-
const localVarAxiosArgs = await localVarAxiosParamCreator.getCapabilities(options);
|
|
82
|
-
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
|
|
83
|
-
const localVarOperationServerBasePath = operationServerMap['DefaultApi.getCapabilities']?.[localVarOperationServerIndex]?.url;
|
|
84
|
-
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath).then(response => {
|
|
85
|
-
// Check if response transformation is enabled (default: true)
|
|
86
|
-
if (configuration?.enableResponseTransformation !== false) {
|
|
87
|
-
try {
|
|
88
|
-
response.data = plainToInstance(Capability, response.data as any[]);
|
|
89
|
-
} catch (error) {
|
|
90
|
-
// Handle transformation errors
|
|
91
|
-
if (configuration?.onTransformationError) {
|
|
92
|
-
configuration.onTransformationError(error as Error, Capability, response.data);
|
|
93
|
-
} else {
|
|
94
|
-
console.error('class-transformer failed to transform response:', error);
|
|
95
|
-
console.error('Returning original response data. To handle this error, provide onTransformationError in Configuration.');
|
|
96
|
-
}
|
|
97
|
-
// Return original data on error (cast for type safety)
|
|
98
|
-
response.data = response.data as any as Capability[];
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
return response as AxiosResponse<Capability[]>;
|
|
102
|
-
});
|
|
103
|
-
},
|
|
104
|
-
}
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* DefaultApi - factory interface
|
|
109
|
-
* @export
|
|
110
|
-
*/
|
|
111
|
-
export const DefaultApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
|
|
112
|
-
const localVarFp = DefaultApiFp(configuration)
|
|
113
|
-
return {
|
|
114
|
-
/**
|
|
115
|
-
*
|
|
116
|
-
* @param {*} [options] Override http request option.
|
|
117
|
-
* @throws {RequiredError}
|
|
118
|
-
*/
|
|
119
|
-
getCapabilities(options?: RawAxiosRequestConfig): AxiosPromise<Array<Capability>> {
|
|
120
|
-
return localVarFp.getCapabilities(options).then((request) => request(axios, basePath));
|
|
121
|
-
},
|
|
122
|
-
};
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* DefaultApi - object-oriented interface
|
|
127
|
-
* @export
|
|
128
|
-
* @class DefaultApi
|
|
129
|
-
* @extends {BaseAPI}
|
|
130
|
-
*/
|
|
131
|
-
export class DefaultApi extends BaseAPI {
|
|
132
|
-
/**
|
|
133
|
-
*
|
|
134
|
-
* @param {*} [options] Override http request option.
|
|
135
|
-
* @throws {RequiredError}
|
|
136
|
-
* @memberof DefaultApi
|
|
137
|
-
*/
|
|
138
|
-
public getCapabilities(options?: RawAxiosRequestConfig) {
|
|
139
|
-
return DefaultApiFp(this.configuration).getCapabilities(options).then((request) => request(this.axios, this.basePath));
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/* tslint:disable */
|
|
2
|
-
/* eslint-disable */
|
|
3
|
-
/**
|
|
4
|
-
* Test API with Discriminated Unions
|
|
5
|
-
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
|
6
|
-
*
|
|
7
|
-
* The version of the OpenAPI document: 1.0.0
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
11
|
-
* https://openapi-generator.tech
|
|
12
|
-
* Do not edit the class manually.
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
export { Configuration } from './configuration.js';
|
|
18
|
-
export * from './api/default-api.js';
|
|
19
|
-
|