jszy-swagger-doc-generator 1.4.1 → 1.5.1
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 +327 -113
- package/dist/cli.js +34 -1
- package/dist/cli.js.map +1 -1
- package/dist/generators/swagger.generator.d.ts +90 -0
- package/dist/generators/swagger.generator.js +626 -0
- package/dist/generators/swagger.generator.js.map +1 -0
- package/dist/helpers/handlebars.helpers.d.ts +4 -0
- package/dist/helpers/handlebars.helpers.js +92 -0
- package/dist/helpers/handlebars.helpers.js.map +1 -0
- package/dist/helpers/string.helpers.d.ts +8 -0
- package/dist/helpers/string.helpers.js +25 -0
- package/dist/helpers/string.helpers.js.map +1 -0
- package/dist/helpers/template.helpers.d.ts +4 -0
- package/dist/helpers/template.helpers.js +105 -0
- package/dist/helpers/template.helpers.js.map +1 -0
- package/dist/helpers/type.helpers.d.ts +18 -0
- package/dist/helpers/type.helpers.js +229 -0
- package/dist/helpers/type.helpers.js.map +1 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.js +403 -158
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +97 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/package.json +6 -2
- package/src/cli.ts +35 -1
- package/src/generators/swagger.generator.ts +664 -0
- package/src/helpers/template.helpers.ts +72 -0
- package/src/helpers/type.helpers.ts +232 -0
- package/src/index.ts +435 -161
- package/src/types.ts +98 -0
- package/templates/hooks/individual-hook.hbs +55 -0
- package/templates/hooks/react-hook.hbs +14 -0
- package/templates/types/type-definition.hbs +5 -0
- package/test-openapi-swagger.json +454 -0
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { SwaggerDoc } from '../types';
|
|
2
|
+
export declare class SwaggerDocGenerator {
|
|
3
|
+
/**
|
|
4
|
+
* Fetches the Swagger/OpenAPI JSON from a given URL
|
|
5
|
+
*/
|
|
6
|
+
fetchSwaggerJSON(url: string): Promise<SwaggerDoc>;
|
|
7
|
+
/**
|
|
8
|
+
* Loads Swagger JSON from a local file
|
|
9
|
+
*/
|
|
10
|
+
loadSwaggerFromFile(filePath: string): SwaggerDoc;
|
|
11
|
+
/**
|
|
12
|
+
* Generates frontend resources using Handlebars templates
|
|
13
|
+
*/
|
|
14
|
+
generateHandlebarsResources(swaggerDoc: SwaggerDoc, templatePaths?: {
|
|
15
|
+
hooks?: string;
|
|
16
|
+
types?: string;
|
|
17
|
+
components?: string;
|
|
18
|
+
pages?: string;
|
|
19
|
+
}): Map<string, {
|
|
20
|
+
hooks: string;
|
|
21
|
+
types: string;
|
|
22
|
+
}>;
|
|
23
|
+
/**
|
|
24
|
+
* Checks if a schema is used in any of the endpoints
|
|
25
|
+
*/
|
|
26
|
+
isSchemaUsedInEndpoints(schemaName: string, endpoints: Array<{
|
|
27
|
+
path: string;
|
|
28
|
+
method: string;
|
|
29
|
+
endpointInfo: any;
|
|
30
|
+
}>, allSchemas: {
|
|
31
|
+
[key: string]: any;
|
|
32
|
+
}): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Checks if a schema contains a reference to another schema
|
|
35
|
+
*/
|
|
36
|
+
schemaContainsRef(schema: any, targetSchemaName: string, allSchemas: {
|
|
37
|
+
[key: string]: any;
|
|
38
|
+
}): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Find all referenced schemas from a set of directly used schemas
|
|
41
|
+
*/
|
|
42
|
+
findAllReferencedSchemas(initialSchemas: Set<string>, allSchemas: {
|
|
43
|
+
[key: string]: any;
|
|
44
|
+
}): Set<string>;
|
|
45
|
+
/**
|
|
46
|
+
* Find schema references in a given schema
|
|
47
|
+
*/
|
|
48
|
+
findSchemaReferences(schema: any, allSchemas: {
|
|
49
|
+
[key: string]: any;
|
|
50
|
+
}): Set<string>;
|
|
51
|
+
/**
|
|
52
|
+
* Generates a parameter interface for an API endpoint
|
|
53
|
+
*/
|
|
54
|
+
generateParamInterface(path: string, method: string, endpointInfo: any, schemas: {
|
|
55
|
+
[key: string]: any;
|
|
56
|
+
}): string;
|
|
57
|
+
/**
|
|
58
|
+
* Generates a React Query hook using axios
|
|
59
|
+
*/
|
|
60
|
+
generateReactQueryHook(path: string, method: string, endpointInfo: any, schemas: {
|
|
61
|
+
[key: string]: any;
|
|
62
|
+
}): string;
|
|
63
|
+
/**
|
|
64
|
+
* Generate operation ID from path and method if not provided
|
|
65
|
+
*/
|
|
66
|
+
generateOperationId(path: string, method: string): string;
|
|
67
|
+
/**
|
|
68
|
+
* Formats code using Prettier - sync version with child process
|
|
69
|
+
*/
|
|
70
|
+
private formatCode;
|
|
71
|
+
/**
|
|
72
|
+
* Gets the parser based on file extension
|
|
73
|
+
*/
|
|
74
|
+
private getParserForFile;
|
|
75
|
+
/**
|
|
76
|
+
* Saves the generated documentation to a file
|
|
77
|
+
*/
|
|
78
|
+
saveDocumentationToFile(documentation: string, outputPath: string): void;
|
|
79
|
+
/**
|
|
80
|
+
* Saves the generated TypeScript types to a file
|
|
81
|
+
*/
|
|
82
|
+
saveTypesToFile(types: string, outputPath: string): void;
|
|
83
|
+
/**
|
|
84
|
+
* Saves the generated React hooks to files organized by tag
|
|
85
|
+
*/
|
|
86
|
+
saveHooksByTag(hooksByTag: Map<string, {
|
|
87
|
+
hooks: string;
|
|
88
|
+
types: string;
|
|
89
|
+
}>, outputDir: string): void;
|
|
90
|
+
}
|