@povio/openapi-codegen-cli 0.9.1 → 0.10.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/README.md +8 -2
- package/dist/generators/core/SchemaResolver.class.d.ts +10 -1
- package/dist/generators/core/zod/enumExtraction/resolveExtractedEnumZodSchemaNames.d.ts +2 -0
- package/dist/generators/core/zod/enumExtraction/resolveExtractedEnumZodSchemaTags.d.ts +2 -0
- package/dist/generators/core/zod/{updateExtractedEnumZodSchemaData.d.ts → enumExtraction/updateExtractedEnumZodSchemaData.d.ts} +1 -3
- package/dist/generators/utils/openapi.utils.d.ts +4 -20
- package/dist/generators/utils/operation.utils.d.ts +22 -0
- package/dist/generators/utils/tag.utils.d.ts +1 -2
- package/dist/index.js +43 -43
- package/dist/sh.js +66 -66
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -36,7 +36,10 @@ yarn openapi-codegen generate --input http://localhost:3001/docs-json --standalo
|
|
|
36
36
|
|
|
37
37
|
--splitByTags Organize output into separate folders based on OpenAPI operation tags (default: true)
|
|
38
38
|
--defaultTag (Requires `--splitByTags`) Default tag for shared code across multiple tags (default: 'Common')
|
|
39
|
-
|
|
39
|
+
|
|
40
|
+
--excludeTags Comma-separated list of tags to exclude from generation
|
|
41
|
+
--excludePathRegex Exclude operations whose paths match the given regular expression
|
|
42
|
+
--excludeRedundantZodSchemas Exclude any redundant Zod schemas (default: true)
|
|
40
43
|
|
|
41
44
|
--tsNamespaces Wrap generated files in TypeScript namespaces (default: true)
|
|
42
45
|
--importPath Module import style for generated files (default: 'ts'; options: 'ts' | 'relative' | 'absolute')
|
|
@@ -60,7 +63,10 @@ yarn openapi-codegen generate --input http://localhost:3001/docs-json --standalo
|
|
|
60
63
|
|
|
61
64
|
--splitByTags Organize output into separate folders based on OpenAPI operation tags (default: true)
|
|
62
65
|
--defaultTag (Requires `--splitByTags`) Default tag for shared code across multiple tags (default: 'Common')
|
|
63
|
-
|
|
66
|
+
|
|
67
|
+
--excludeTags Comma-separated list of tags to exclude from generation
|
|
68
|
+
--excludePathRegex Exclude operations whose paths match the given regular expression
|
|
69
|
+
--excludeRedundantZodSchemas Exclude any redundant Zod schemas (default: true)
|
|
64
70
|
```
|
|
65
71
|
|
|
66
72
|
## Development
|
|
@@ -4,6 +4,13 @@ import { GenerateOptions } from "../types/options";
|
|
|
4
4
|
import { ValidationError } from "../types/validation";
|
|
5
5
|
import { DependencyGraph } from "./openapi/getOpenAPISchemaDependencyGraph";
|
|
6
6
|
import { ZodSchema } from "./zod/ZodSchema.class";
|
|
7
|
+
interface SchemaData {
|
|
8
|
+
ref: string;
|
|
9
|
+
name: string;
|
|
10
|
+
zodSchemaName: string;
|
|
11
|
+
tags: string[];
|
|
12
|
+
deepRefOperations: OperationObject[];
|
|
13
|
+
}
|
|
7
14
|
export interface EnumZodSchemaData {
|
|
8
15
|
code: string;
|
|
9
16
|
zodSchemaName: string;
|
|
@@ -36,6 +43,7 @@ export declare class SchemaResolver {
|
|
|
36
43
|
private get schemaRefs();
|
|
37
44
|
constructor(openApiDoc: OpenAPIV3.Document, options: GenerateOptions);
|
|
38
45
|
getSchemaByRef(ref: string): OpenAPIV3.SchemaObject;
|
|
46
|
+
getSchemaDataByName(name: string): SchemaData | undefined;
|
|
39
47
|
getZodSchemaNameByRef(ref: string): string;
|
|
40
48
|
getRefByZodSchemaName(zodSchemaName: string): string | undefined;
|
|
41
49
|
getTagByZodSchemaName(zodSchemaName: string): string;
|
|
@@ -52,7 +60,7 @@ export declare class SchemaResolver {
|
|
|
52
60
|
getExtractedEnumZodSchemas(): {};
|
|
53
61
|
resolveObject<T>(obj: OpenAPIV3.ReferenceObject | T): T;
|
|
54
62
|
isSchemaCircular(ref: string): boolean;
|
|
55
|
-
getCircularSchemaChain(ref: string, currentRef?: string, chain?: never[]): string[];
|
|
63
|
+
getCircularSchemaChain(ref: string, currentRef?: string, chain?: never[], visited?: string[]): string[];
|
|
56
64
|
getBaseUrl(): string;
|
|
57
65
|
getZodSchemaObj(zodSchemaName: string): OpenAPIV3.ReferenceObject | OpenAPIV3.SchemaObject | undefined;
|
|
58
66
|
private getSchemaDataByRef;
|
|
@@ -60,3 +68,4 @@ export declare class SchemaResolver {
|
|
|
60
68
|
private initialize;
|
|
61
69
|
private handleDuplicateEnumZodSchemas;
|
|
62
70
|
}
|
|
71
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { OpenAPIV3 } from "openapi-types";
|
|
2
|
-
import { SchemaResolver } from "
|
|
2
|
+
import { SchemaResolver } from "../../SchemaResolver.class";
|
|
3
3
|
export declare function updateExtractedEnumZodSchemaData({ schema, nameSegments, includeSelf, ...params }: {
|
|
4
4
|
resolver: SchemaResolver;
|
|
5
5
|
schema: OpenAPIV3.ReferenceObject | OpenAPIV3.SchemaObject | undefined;
|
|
@@ -9,5 +9,3 @@ export declare function updateExtractedEnumZodSchemaData({ schema, nameSegments,
|
|
|
9
9
|
nameSegments?: string[];
|
|
10
10
|
includeSelf?: boolean;
|
|
11
11
|
}): void;
|
|
12
|
-
export declare function resolveExtractedEnumZodSchemaNames(resolver: SchemaResolver): void;
|
|
13
|
-
export declare function resolveExtractedEnumZodSchemaTags(resolver: SchemaResolver): void;
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { OpenAPIV3 } from "openapi-types";
|
|
2
1
|
import { ALLOWED_PARAM_MEDIA_TYPES } from "../const/openapi.const";
|
|
3
|
-
import {
|
|
4
|
-
import { GenerateOptions } from "../types/options";
|
|
2
|
+
import { ParameterObject, PrimitiveType, SingleType, SortingParameterObject } from "../types/openapi";
|
|
5
3
|
export declare const getSchemaRef: (schemaName: string) => string;
|
|
6
4
|
export declare const autocorrectRef: (ref: string) => string;
|
|
7
5
|
export declare const getSchemaNameByRef: (ref: string) => string;
|
|
@@ -16,24 +14,10 @@ export declare function isParamMediaTypeAllowed(mediaType: string): mediaType is
|
|
|
16
14
|
export declare function isMainResponseStatus(status: number): boolean;
|
|
17
15
|
export declare function isErrorStatus(status: number): boolean;
|
|
18
16
|
export declare function isMediaTypeAllowed(mediaType: string): boolean;
|
|
19
|
-
export declare function getOperationName({ path, method, operation, options, tag, keepOperationTag, keepOperationPrefix, }: {
|
|
20
|
-
path: string;
|
|
21
|
-
method: string;
|
|
22
|
-
operation: OperationObject;
|
|
23
|
-
options: GenerateOptions;
|
|
24
|
-
tag: string;
|
|
25
|
-
keepOperationTag?: boolean;
|
|
26
|
-
keepOperationPrefix?: boolean;
|
|
27
|
-
}): string;
|
|
28
|
-
export declare function getUniqueOperationName({ operationsByTag, ...params }: {
|
|
29
|
-
path: string;
|
|
30
|
-
method: string;
|
|
31
|
-
operation: OperationObject;
|
|
32
|
-
operationsByTag: Record<string, OperationObject[]>;
|
|
33
|
-
options: GenerateOptions;
|
|
34
|
-
}): string;
|
|
35
|
-
export declare function getUniqueOperationNamesWithoutSplitByTags(openApiDoc: OpenAPIV3.Document, operationsByTag: Record<string, OperationObject[]>, options: GenerateOptions): string[];
|
|
36
17
|
/** @example turns `/media-objects/{id}` into `MediaObjectsById` */
|
|
37
18
|
export declare function pathToVariableName(path: string): string;
|
|
38
19
|
export declare function replaceHyphenatedPath(path: string): string;
|
|
39
20
|
export declare const isSortingParameterObject: (param: ParameterObject) => param is SortingParameterObject;
|
|
21
|
+
export declare const isPathExcluded: (path: string, options: {
|
|
22
|
+
excludePathRegex: string;
|
|
23
|
+
}) => boolean;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { OpenAPIV3 } from "openapi-types";
|
|
2
|
+
import { OperationObject } from "../types/openapi";
|
|
3
|
+
import { GenerateOptions } from "../types/options";
|
|
4
|
+
export declare function isOperationExcluded(operation: OperationObject, options: GenerateOptions): boolean;
|
|
5
|
+
export declare function getOperationName({ path, method, operation, options, tag, keepOperationTag, keepOperationPrefix, }: {
|
|
6
|
+
path: string;
|
|
7
|
+
method: string;
|
|
8
|
+
operation: OperationObject;
|
|
9
|
+
options: GenerateOptions;
|
|
10
|
+
tag: string;
|
|
11
|
+
keepOperationTag?: boolean;
|
|
12
|
+
keepOperationPrefix?: boolean;
|
|
13
|
+
}): string;
|
|
14
|
+
export declare function getUniqueOperationName({ operationsByTag, ...params }: {
|
|
15
|
+
path: string;
|
|
16
|
+
method: string;
|
|
17
|
+
operation: OperationObject;
|
|
18
|
+
operationsByTag: Record<string, OperationObject[]>;
|
|
19
|
+
options: GenerateOptions;
|
|
20
|
+
}): string;
|
|
21
|
+
export declare function getUniqueOperationNamesWithoutSplitByTags(openApiDoc: OpenAPIV3.Document, operationsByTag: Record<string, OperationObject[]>, options: GenerateOptions): string[];
|
|
22
|
+
export declare function getOperationsByTag(openApiDoc: OpenAPIV3.Document, options: GenerateOptions): Record<string, OperationObject[]>;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { OpenAPIV3 } from "openapi-types";
|
|
2
1
|
import { OperationObject } from "../types/openapi";
|
|
3
2
|
import { GenerateOptions } from "../types/options";
|
|
4
3
|
export declare function formatTag(tag: string): string;
|
|
5
4
|
export declare function getOperationTag(operation: OperationObject, options: GenerateOptions): string;
|
|
6
|
-
export declare function
|
|
5
|
+
export declare function isTagExcluded(tag: string, options: GenerateOptions): boolean;
|