@povio/openapi-codegen-cli 0.8.3 → 0.9.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/dist/generators/const/deps.const.d.ts +7 -0
- package/dist/generators/const/zod.const.d.ts +1 -0
- package/dist/generators/core/SchemaResolver.class.d.ts +3 -10
- package/dist/generators/core/endpoints/getEndpointParameter.d.ts +2 -1
- package/dist/generators/core/zod/getZodSchema.d.ts +1 -0
- package/dist/generators/utils/generate/generate.endpoints.utils.d.ts +3 -2
- package/dist/generators/utils/generate/generate.utils.d.ts +1 -0
- package/dist/generators/utils/generate/generate.zod.utils.d.ts +1 -1
- package/dist/generators/utils/openapi-schema.utils.d.ts +1 -0
- package/dist/generators/utils/openapi.utils.d.ts +2 -2
- package/dist/generators/utils/string.utils.d.ts +1 -0
- package/dist/index.js +42 -42
- package/dist/sh.js +61 -61
- package/package.json +1 -1
- package/src/assets/zodExtended.ts +24 -0
- package/src/generators/templates/endpoints.hbs +4 -0
- package/src/generators/templates/partials/endpoint-config.hbs +2 -2
- package/src/generators/templates/partials/endpoint-param-sorting.hbs +1 -0
|
@@ -23,3 +23,10 @@ export declare const INVALIDATE_QUERIES: {
|
|
|
23
23
|
functionName: string;
|
|
24
24
|
};
|
|
25
25
|
export declare const INVALIDATE_QUERY_OPTIONS_FILE: GenerateFile;
|
|
26
|
+
export declare const ZOD_EXTENDED: {
|
|
27
|
+
name: string;
|
|
28
|
+
properties: {
|
|
29
|
+
sortingString: string;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
export declare const ZOD_EXTENDED_FILE: GenerateFile;
|
|
@@ -8,4 +8,5 @@ export declare const ERROR_RESPONSE_SCHEMA_SUFFIX = "ErrorResponse";
|
|
|
8
8
|
export declare const VOID_SCHEMA = "z.void()";
|
|
9
9
|
export declare const BLOB_SCHEMA = "z.instanceof(Blob)";
|
|
10
10
|
export declare const ENUM_SCHEMA = "z.enum";
|
|
11
|
+
export declare const STRING_SCHEMA = "z.string()";
|
|
11
12
|
export declare const ZOD_IMPORT: Import;
|
|
@@ -4,12 +4,6 @@ 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
|
-
}
|
|
13
7
|
export interface EnumZodSchemaData {
|
|
14
8
|
code: string;
|
|
15
9
|
zodSchemaName: string;
|
|
@@ -34,15 +28,14 @@ export declare class SchemaResolver {
|
|
|
34
28
|
private readonly compositeZodSchemaData;
|
|
35
29
|
readonly dependencyGraph: DependencyGraph;
|
|
36
30
|
readonly enumZodSchemas: EnumZodSchemaData[];
|
|
31
|
+
readonly extractedEnumZodSchemaData: ExtractedEnumZodSchemaData[];
|
|
37
32
|
readonly operationsByTag: Record<string, OperationObject[]>;
|
|
38
33
|
readonly operationNames: string[];
|
|
39
|
-
extractedEnumZodSchemaData: ExtractedEnumZodSchemaData[];
|
|
40
34
|
readonly validationErrors: ValidationError[];
|
|
41
35
|
private get docSchemas();
|
|
42
36
|
private get schemaRefs();
|
|
43
37
|
constructor(openApiDoc: OpenAPIV3.Document, options: GenerateOptions);
|
|
44
38
|
getSchemaByRef(ref: string): OpenAPIV3.SchemaObject;
|
|
45
|
-
getSchemaDataByRef(ref: string): SchemaData | undefined;
|
|
46
39
|
getZodSchemaNameByRef(ref: string): string;
|
|
47
40
|
getRefByZodSchemaName(zodSchemaName: string): string | undefined;
|
|
48
41
|
getTagByZodSchemaName(zodSchemaName: string): string;
|
|
@@ -54,7 +47,6 @@ export declare class SchemaResolver {
|
|
|
54
47
|
getSchemaByCompositeZodSchemaName(compositeZodSchemaName: string): OpenAPIV3.SchemaObject | undefined;
|
|
55
48
|
getEnumZodSchemaDataByCode(code: string): EnumZodSchemaData | undefined;
|
|
56
49
|
getExtractedEnumZodSchemaDataByCode(code: string): ExtractedEnumZodSchemaData | undefined;
|
|
57
|
-
getExtractedEnumZodSchemaDataByName(enumZodSchemaName: string): ExtractedEnumZodSchemaData | undefined;
|
|
58
50
|
getExtractedEnumZodSchemaNamesReferencedBySchemaRef(schemaRef: string): string[];
|
|
59
51
|
getZodSchemas(): {};
|
|
60
52
|
getExtractedEnumZodSchemas(): {};
|
|
@@ -63,7 +55,8 @@ export declare class SchemaResolver {
|
|
|
63
55
|
getCircularSchemaChain(ref: string, currentRef?: string, chain?: never[]): string[];
|
|
64
56
|
getBaseUrl(): string;
|
|
65
57
|
getZodSchemaObj(zodSchemaName: string): OpenAPIV3.ReferenceObject | OpenAPIV3.SchemaObject | undefined;
|
|
58
|
+
private getSchemaDataByRef;
|
|
59
|
+
private getExtractedEnumZodSchemaDataByName;
|
|
66
60
|
private initialize;
|
|
67
61
|
private handleDuplicateEnumZodSchemas;
|
|
68
62
|
}
|
|
69
|
-
export {};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { OpenAPIV3 } from "openapi-types";
|
|
2
2
|
import { EndpointParameter } from "src/generators/types/endpoint";
|
|
3
|
+
import { ParameterObject } from "src/generators/types/openapi";
|
|
3
4
|
import { SchemaResolver } from "../SchemaResolver.class";
|
|
4
5
|
export declare function getEndpointParameter({ resolver, param, operationName, isUniqueOperationName, tag, }: {
|
|
5
6
|
resolver: SchemaResolver;
|
|
6
|
-
param: OpenAPIV3.ReferenceObject |
|
|
7
|
+
param: OpenAPIV3.ReferenceObject | ParameterObject;
|
|
7
8
|
operationName: string;
|
|
8
9
|
isUniqueOperationName: boolean;
|
|
9
10
|
tag: string;
|
|
@@ -13,4 +13,5 @@ type GetZodSchemaParams = {
|
|
|
13
13
|
*/
|
|
14
14
|
export declare function getZodSchema({ schema, resolver, meta: inheritedMeta, tag }: GetZodSchemaParams): ZodSchema;
|
|
15
15
|
export declare function getEnumZodSchemaCode(schema: OpenAPIV3.SchemaObject): string;
|
|
16
|
+
export declare function getEnumZodSchemaCodeFromEnumNames(enumNames: string[]): string;
|
|
16
17
|
export {};
|
|
@@ -15,7 +15,7 @@ export declare function mapEndpointParamsToFunctionParams(resolver: SchemaResolv
|
|
|
15
15
|
type: string;
|
|
16
16
|
paramType: "Body" | "Query" | "Header" | "Path";
|
|
17
17
|
required: boolean;
|
|
18
|
-
parameterObject:
|
|
18
|
+
parameterObject: import("../../types/openapi").ParameterObject | undefined;
|
|
19
19
|
bodyObject: OpenAPIV3.RequestBodyObject | undefined;
|
|
20
20
|
}[];
|
|
21
21
|
export declare function getEndpointConfig(endpoint: Endpoint): {
|
|
@@ -26,7 +26,8 @@ export declare function getEndpointConfig(endpoint: Endpoint): {
|
|
|
26
26
|
description?: string | undefined;
|
|
27
27
|
type: "Body" | "Query" | "Header" | "Path";
|
|
28
28
|
zodSchema: string;
|
|
29
|
-
parameterObject?:
|
|
29
|
+
parameterObject?: import("../../types/openapi").ParameterObject | undefined;
|
|
30
|
+
parameterSortingEnumSchemaName?: string | undefined;
|
|
30
31
|
bodyObject?: OpenAPIV3.RequestBodyObject | undefined;
|
|
31
32
|
}[] | undefined;
|
|
32
33
|
};
|
|
@@ -17,4 +17,5 @@ export declare const getNamespaceName: ({ type, tag, options, }: {
|
|
|
17
17
|
export declare function getAppRestClientImportPath(options: GenerateOptions): string;
|
|
18
18
|
export declare function getQueryTypesImportPath(options: GenerateOptions): string;
|
|
19
19
|
export declare function getInvalidateQueriesImportPath(options: GenerateOptions): string;
|
|
20
|
+
export declare function getZodExtendedImportPath(options: GenerateOptions): string;
|
|
20
21
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { OpenAPIV3 } from "openapi-types";
|
|
1
2
|
import { SchemaResolver } from "src/generators/core/SchemaResolver.class";
|
|
2
3
|
import { GenerateZodSchemaData } from "src/generators/types/generate";
|
|
3
4
|
import { GenerateOptions } from "src/generators/types/options";
|
|
4
|
-
import { OpenAPIV3 } from "openapi-types";
|
|
5
5
|
export declare const getZodSchemaInferedTypeName: (zodSchemaName: string, options: GenerateOptions) => string;
|
|
6
6
|
export declare const getImportedZodSchemaName: (resolver: SchemaResolver, zodSchemaName: string) => string;
|
|
7
7
|
export declare const getImportedZodSchemaInferedTypeName: (resolver: SchemaResolver, zodSchemaName: string, currentTag?: string) => string;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { OpenAPIV3 } from "openapi-types";
|
|
2
|
+
export declare function isReferenceObject(obj: any): obj is OpenAPIV3.ReferenceObject;
|
|
2
3
|
export declare function isSchemaObject(schema: OpenAPIV3.SchemaObject | OpenAPIV3.ReferenceObject): schema is OpenAPIV3.SchemaObject;
|
|
3
4
|
export declare function isArraySchemaObject(schema: OpenAPIV3.SchemaObject): schema is OpenAPIV3.ArraySchemaObject;
|
|
4
5
|
export declare function inferRequiredSchema(schema: OpenAPIV3.SchemaObject): {
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { OpenAPIV3 } from "openapi-types";
|
|
2
2
|
import { ALLOWED_PARAM_MEDIA_TYPES } from "../const/openapi.const";
|
|
3
|
-
import { OperationObject, PrimitiveType, SingleType } from "../types/openapi";
|
|
3
|
+
import { OperationObject, ParameterObject, PrimitiveType, SingleType, SortingParameterObject } from "../types/openapi";
|
|
4
4
|
import { GenerateOptions } from "../types/options";
|
|
5
5
|
export declare const getSchemaRef: (schemaName: string) => string;
|
|
6
6
|
export declare const autocorrectRef: (ref: string) => string;
|
|
7
7
|
export declare const getSchemaNameByRef: (ref: string) => string;
|
|
8
|
-
export declare function isReferenceObject(obj: any): obj is OpenAPIV3.ReferenceObject;
|
|
9
8
|
export declare function normalizeString(text: string): string;
|
|
10
9
|
export declare function wrapWithQuotesIfNeeded(str: string): string;
|
|
11
10
|
export declare function unwrapQuotesIfNeeded(value: string | number): string | number;
|
|
@@ -37,3 +36,4 @@ export declare function getUniqueOperationNamesWithoutSplitByTags(openApiDoc: Op
|
|
|
37
36
|
/** @example turns `/media-objects/{id}` into `MediaObjectsById` */
|
|
38
37
|
export declare function pathToVariableName(path: string): string;
|
|
39
38
|
export declare function replaceHyphenatedPath(path: string): string;
|
|
39
|
+
export declare const isSortingParameterObject: (param: ParameterObject) => param is SortingParameterObject;
|
|
@@ -11,3 +11,4 @@ export declare const splitByUppercase: (str: string) => string[];
|
|
|
11
11
|
export declare const camelToSpaceSeparated: (text: string) => string;
|
|
12
12
|
export declare const getAdjacentStringCombinations: (strs: string[], ignoreStrs?: string[]) => string[];
|
|
13
13
|
export declare const removeWord: (source: string, wordToRemove: string) => string;
|
|
14
|
+
export declare const isString: (str: string | undefined) => str is string;
|