ng-openapi 0.0.41 → 0.0.42-pr-9-feature-http-resource-e6134bb.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli.cjs +427 -511
- package/index.d.ts +108 -23
- package/index.js +484 -516
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ScriptTarget, ModuleKind } from 'ts-morph';
|
|
1
|
+
import { Project, ScriptTarget, ModuleKind, MethodDeclaration, FunctionDeclaration } from 'ts-morph';
|
|
2
2
|
import { HttpInterceptor } from '@angular/common/http';
|
|
3
3
|
import { Info, ExternalDocs, Path, ParameterType, XML, BodyParameter, QueryParameter, Security, Tag } from 'swagger-schema-official';
|
|
4
4
|
|
|
@@ -25,6 +25,17 @@ interface TypeSchema {
|
|
|
25
25
|
enum?: Array<string | number>;
|
|
26
26
|
[key: string]: any;
|
|
27
27
|
}
|
|
28
|
+
interface GetMethodGenerationContext {
|
|
29
|
+
pathParams: Array<{
|
|
30
|
+
name: string;
|
|
31
|
+
in: string;
|
|
32
|
+
}>;
|
|
33
|
+
queryParams: Array<{
|
|
34
|
+
name: string;
|
|
35
|
+
in: string;
|
|
36
|
+
}>;
|
|
37
|
+
responseType: "json" | "blob" | "arraybuffer" | "text";
|
|
38
|
+
}
|
|
28
39
|
|
|
29
40
|
interface Parameter {
|
|
30
41
|
name: string;
|
|
@@ -133,6 +144,57 @@ type EnumValueObject = {
|
|
|
133
144
|
Value: number;
|
|
134
145
|
};
|
|
135
146
|
|
|
147
|
+
declare class SwaggerParser {
|
|
148
|
+
private readonly spec;
|
|
149
|
+
private constructor();
|
|
150
|
+
static create(swaggerPathOrUrl: string, config: GeneratorConfig): Promise<SwaggerParser>;
|
|
151
|
+
private static loadContent;
|
|
152
|
+
private static isUrl;
|
|
153
|
+
private static fetchUrlContent;
|
|
154
|
+
private static parseSpecContent;
|
|
155
|
+
private static detectFormat;
|
|
156
|
+
getDefinitions(): Record<string, SwaggerDefinition>;
|
|
157
|
+
getDefinition(name: string): SwaggerDefinition | undefined;
|
|
158
|
+
resolveReference(ref: string): SwaggerDefinition | undefined;
|
|
159
|
+
getAllDefinitionNames(): string[];
|
|
160
|
+
getSpec(): SwaggerSpec;
|
|
161
|
+
getPaths(): Record<string, any>;
|
|
162
|
+
isValidSpec(): boolean;
|
|
163
|
+
getSpecVersion(): {
|
|
164
|
+
type: "swagger" | "openapi";
|
|
165
|
+
version: string;
|
|
166
|
+
} | null;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Interface for generator instances
|
|
171
|
+
*/
|
|
172
|
+
interface IPluginGenerator {
|
|
173
|
+
/**
|
|
174
|
+
* Generate code files
|
|
175
|
+
*/
|
|
176
|
+
generate(outputRoot: string): void;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Interface for generator constructor with static methods
|
|
180
|
+
*/
|
|
181
|
+
interface IPluginGeneratorConstructor {
|
|
182
|
+
/**
|
|
183
|
+
* Create a generator instance
|
|
184
|
+
*/
|
|
185
|
+
create(swaggerPathOrUrl: string, project: Project, config: GeneratorConfig): Promise<IPluginGenerator>;
|
|
186
|
+
/**
|
|
187
|
+
* Constructor signature
|
|
188
|
+
*/
|
|
189
|
+
new (parser: SwaggerParser, project: Project, config: GeneratorConfig): IPluginGenerator;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Combined type that includes both static and instance methods
|
|
193
|
+
*/
|
|
194
|
+
type IPluginGeneratorClass = IPluginGeneratorConstructor & {
|
|
195
|
+
prototype: IPluginGenerator;
|
|
196
|
+
};
|
|
197
|
+
|
|
136
198
|
interface GeneratorConfig {
|
|
137
199
|
input: string;
|
|
138
200
|
output: string;
|
|
@@ -155,6 +217,7 @@ interface GeneratorConfig {
|
|
|
155
217
|
module?: ModuleKind;
|
|
156
218
|
strict?: boolean;
|
|
157
219
|
};
|
|
220
|
+
plugins?: (new (...args: any) => IPluginGenerator)[];
|
|
158
221
|
}
|
|
159
222
|
interface NgOpenapiClientConfig {
|
|
160
223
|
clientName: string;
|
|
@@ -163,31 +226,53 @@ interface NgOpenapiClientConfig {
|
|
|
163
226
|
interceptors?: (new (...args: HttpInterceptor[]) => HttpInterceptor)[];
|
|
164
227
|
}
|
|
165
228
|
|
|
166
|
-
declare
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
229
|
+
declare function camelCase(str: string): string;
|
|
230
|
+
declare function kebabCase(str: string): string;
|
|
231
|
+
declare function pascalCase(str: string): string;
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Convert OpenAPI/Swagger types to TypeScript types
|
|
235
|
+
* @param schemaOrType - Either a schema object or a type string
|
|
236
|
+
* @param config - generator configuration
|
|
237
|
+
* @param formatOrNullable - Either format string (if first param is string) or nullable boolean
|
|
238
|
+
* @param isNullable - Nullable boolean (only used if first param is string)
|
|
239
|
+
* @param context - Whether this is for type generation or service generation
|
|
240
|
+
*/
|
|
241
|
+
declare function getTypeScriptType(schemaOrType: TypeSchema | string | undefined, config: GeneratorConfig, formatOrNullable?: string | boolean, isNullable?: boolean, context?: "type" | "service"): string;
|
|
242
|
+
declare function nullableType(type: string, isNullable?: boolean): string;
|
|
243
|
+
declare function escapeString(str: string): string;
|
|
244
|
+
|
|
245
|
+
type placeHolder = {};
|
|
246
|
+
|
|
247
|
+
declare function collectUsedTypes(operations: PathInfo[]): Set<string>;
|
|
248
|
+
|
|
249
|
+
declare function getClientContextTokenName(clientName?: string): string;
|
|
250
|
+
declare function getBasePathTokenName(clientName?: string): string;
|
|
251
|
+
|
|
252
|
+
declare function hasDuplicateFunctionNames<T extends MethodDeclaration | FunctionDeclaration>(arr: T[]): boolean;
|
|
253
|
+
|
|
254
|
+
declare function extractPaths(swaggerPaths?: {
|
|
255
|
+
[p: string]: Path;
|
|
256
|
+
}, methods?: string[]): PathInfo[];
|
|
257
|
+
|
|
258
|
+
declare function getResponseTypeFromResponse(response: SwaggerResponse, responseTypeMapping?: {
|
|
259
|
+
[p: string]: "json" | "blob" | "arraybuffer" | "text";
|
|
260
|
+
}): "json" | "blob" | "arraybuffer" | "text";
|
|
261
|
+
declare function isPrimitiveType(schema: any): boolean;
|
|
262
|
+
declare function inferResponseTypeFromContentType(contentType: string): "json" | "blob" | "arraybuffer" | "text";
|
|
263
|
+
declare function getResponseType(response: SwaggerResponse, config: GeneratorConfig): string;
|
|
264
|
+
|
|
265
|
+
declare const TYPE_GENERATOR_HEADER_COMMENT: string;
|
|
266
|
+
declare const SERVICE_INDEX_GENERATOR_HEADER_COMMENT: string;
|
|
267
|
+
declare const SERVICE_GENERATOR_HEADER_COMMENT: (controllerName: string) => string;
|
|
268
|
+
declare const MAIN_INDEX_GENERATOR_HEADER_COMMENT: string;
|
|
269
|
+
declare const PROVIDER_GENERATOR_HEADER_COMMENT: string;
|
|
270
|
+
declare const BASE_INTERCEPTOR_HEADER_COMMENT: (clientName: string) => string;
|
|
271
|
+
declare const HTTP_RESOURCE_GENERATOR_HEADER_COMMENT: (resourceName: string) => string;
|
|
187
272
|
|
|
188
273
|
/**
|
|
189
274
|
* Generates Angular services and types from a configuration object
|
|
190
275
|
*/
|
|
191
276
|
declare function generateFromConfig(config: GeneratorConfig): Promise<void>;
|
|
192
277
|
|
|
193
|
-
export { type EnumValueObject, type GeneratorConfig, type MethodGenerationContext, type NgOpenapiClientConfig, type Parameter, type PathInfo, type RequestBody, type SwaggerDefinition, SwaggerParser, type SwaggerResponse, type SwaggerSpec, type TypeSchema, generateFromConfig };
|
|
278
|
+
export { BASE_INTERCEPTOR_HEADER_COMMENT, type EnumValueObject, type GeneratorConfig, type GetMethodGenerationContext, HTTP_RESOURCE_GENERATOR_HEADER_COMMENT, type IPluginGenerator, type IPluginGeneratorClass, type IPluginGeneratorConstructor, MAIN_INDEX_GENERATOR_HEADER_COMMENT, type MethodGenerationContext, type NgOpenapiClientConfig, PROVIDER_GENERATOR_HEADER_COMMENT, type Parameter, type PathInfo, type RequestBody, SERVICE_GENERATOR_HEADER_COMMENT, SERVICE_INDEX_GENERATOR_HEADER_COMMENT, type SwaggerDefinition, SwaggerParser, type SwaggerResponse, type SwaggerSpec, TYPE_GENERATOR_HEADER_COMMENT, type TypeSchema, camelCase, collectUsedTypes, escapeString, extractPaths, generateFromConfig, getBasePathTokenName, getClientContextTokenName, getResponseType, getResponseTypeFromResponse, getTypeScriptType, hasDuplicateFunctionNames, inferResponseTypeFromContentType, isPrimitiveType, kebabCase, nullableType, pascalCase, type placeHolder };
|