@povio/openapi-codegen-cli 0.3.9 → 0.4.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 +14 -3
- package/dist/commands/generate.d.ts +1 -1
- package/dist/generators/checkOpenAPIDoc.d.ts +1 -4
- package/dist/generators/const/validation.const.d.ts +2 -0
- package/dist/generators/const/zod.const.d.ts +1 -0
- package/dist/generators/core/SchemaResolver.class.d.ts +34 -11
- package/dist/generators/core/endpoints/getEndpointBody.d.ts +1 -3
- package/dist/generators/core/endpoints/getEndpointParameter.d.ts +1 -3
- package/dist/generators/core/endpoints/getEndpointsFromOpenAPIDoc.d.ts +1 -10
- package/dist/generators/core/getDataFromOpenAPIDoc.d.ts +1 -5
- package/dist/generators/core/getMetadataFromOpenAPIDoc.d.ts +1 -4
- package/dist/generators/core/openapi/getOpenAPISchemaComplexity.d.ts +1 -4
- package/dist/generators/core/openapi/getOpenAPISchemaDependencyGraph.d.ts +3 -2
- package/dist/generators/core/openapi/getSchemaRefObjs.d.ts +4 -0
- package/dist/generators/core/openapi/iterateSchema.d.ts +22 -0
- package/dist/generators/core/zod/ZodSchema.class.d.ts +7 -5
- package/dist/generators/core/zod/getZodSchema.d.ts +3 -4
- package/dist/generators/core/zod/getZodSchemaRefs.d.ts +1 -4
- package/dist/generators/core/zod/getZodSchemasFromOpenAPIDoc.d.ts +1 -7
- package/dist/generators/core/zod/resolveZodSchemaName.d.ts +1 -3
- package/dist/generators/core/zod/sortZodSchemasByTopology.d.ts +1 -4
- package/dist/generators/core/zod/updateEnumZodSchemaData.d.ts +13 -0
- package/dist/generators/core/zod/wrapCircularZodSchemas.d.ts +1 -6
- package/dist/generators/generate/generateEndpoints.d.ts +1 -3
- package/dist/generators/generate/generateModels.d.ts +1 -3
- package/dist/generators/generate/generateQueries.d.ts +1 -3
- package/dist/generators/generateCodeFromOpenAPIDoc.d.ts +1 -4
- package/dist/generators/utils/array.utils.d.ts +1 -0
- package/dist/generators/utils/generate/generate.endpoints.utils.d.ts +1 -5
- package/dist/generators/utils/generate/generate.imports.utils.d.ts +1 -2
- package/dist/generators/utils/generate/generate.zod.utils.d.ts +2 -10
- package/dist/generators/utils/hbs/hbs-template.utils.d.ts +1 -6
- package/dist/generators/utils/hbs/hbs.endpoints.utils.d.ts +1 -2
- package/dist/generators/utils/hbs/hbs.zod.utils.d.ts +1 -2
- package/dist/generators/utils/openapi.utils.d.ts +3 -5
- package/dist/generators/utils/string.utils.d.ts +4 -0
- package/dist/generators/utils/tag.utils.d.ts +20 -0
- package/dist/generators/utils/ts.utils.d.ts +2 -5
- package/dist/generators/utils/validation.utils.d.ts +7 -0
- package/dist/generators/utils/zod-schema.utils.d.ts +7 -0
- package/dist/index.js +42 -38
- package/dist/sh.js +79 -77
- package/package.json +1 -1
- package/dist/generators/core/openapi/getSchemaRefsDependencyGraph.d.ts +0 -11
package/README.md
CHANGED
|
@@ -20,21 +20,32 @@ yarn openapi-codegen generate --input http://localhost:3001/docs-json
|
|
|
20
20
|
|
|
21
21
|
## Options
|
|
22
22
|
|
|
23
|
-
### Generate command
|
|
23
|
+
### Generate command (generates Zod schemas, API definitions and React queries)
|
|
24
24
|
|
|
25
25
|
```sh
|
|
26
|
-
--input
|
|
27
|
-
--output
|
|
26
|
+
--input Path/url to OpenAPI/Swagger document as json/yaml
|
|
27
|
+
--output Output path (default: 'output')
|
|
28
28
|
--includeNamespaces Include namespaces inside generated files (default: true)
|
|
29
29
|
--splitByTags Split output into directories based on tags in OpenAPI operations (default: true)
|
|
30
30
|
--defaultTag Default tag name for code shared accross multiple tags (default: 'Common')
|
|
31
31
|
--excludeTags Comma separated list of tags excluded from the output
|
|
32
|
+
--extractEnums Enums are extracted as seperate Zod schemas (default: true)
|
|
32
33
|
--removeOperationPrefixEndingWith Removes prefix that ends with value from operation names (default: 'Controller_')
|
|
33
34
|
--importPath Import path (default: 'ts', possible: 'ts' | 'relative' | 'absolute')
|
|
34
35
|
--prettier Run prettier command on output after code generation (default: true)
|
|
35
36
|
--verbose Show log messages during execution
|
|
36
37
|
```
|
|
37
38
|
|
|
39
|
+
### Check command (checks if OpenAPI spec is compliant)
|
|
40
|
+
|
|
41
|
+
```sh
|
|
42
|
+
--input Path/url to OpenAPI/Swagger document as json/yaml
|
|
43
|
+
--splitByTags Split output into directories based on tags in OpenAPI operations (default: true)
|
|
44
|
+
--defaultTag Default tag name for code shared accross multiple tags (default: 'Common')
|
|
45
|
+
--excludeTags Comma separated list of tags excluded from the output
|
|
46
|
+
--verbose Show log messages during execution
|
|
47
|
+
```
|
|
48
|
+
|
|
38
49
|
## Development
|
|
39
50
|
|
|
40
51
|
### Test locally
|
|
@@ -3,5 +3,5 @@ export type GenerateParams = {
|
|
|
3
3
|
excludeTags: string;
|
|
4
4
|
prettier: boolean;
|
|
5
5
|
verbose: boolean;
|
|
6
|
-
} & Pick<GenerateOptions, "input" | "output" | "includeNamespaces" | "splitByTags" | "defaultTag" | "removeOperationPrefixEndingWith" | "importPath">;
|
|
6
|
+
} & Pick<GenerateOptions, "input" | "output" | "includeNamespaces" | "splitByTags" | "defaultTag" | "removeOperationPrefixEndingWith" | "importPath" | "extractEnums">;
|
|
7
7
|
export declare function generate({ input, excludeTags, prettier, verbose, ...params }: GenerateParams): Promise<void>;
|
|
@@ -1,6 +1,3 @@
|
|
|
1
1
|
import { OpenAPIV3 } from "openapi-types";
|
|
2
2
|
import { GenerateOptions } from "./types/options";
|
|
3
|
-
export declare function checkOpenAPIDoc(
|
|
4
|
-
openApiDoc: OpenAPIV3.Document;
|
|
5
|
-
options?: Partial<GenerateOptions>;
|
|
6
|
-
}): string[];
|
|
3
|
+
export declare function checkOpenAPIDoc(openApiDoc: OpenAPIV3.Document, cliOptions?: Partial<GenerateOptions>): import("./types/validation").ValidationError[];
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Import } from "../types/generate";
|
|
2
2
|
export declare const SCHEMA_SUFFIX = "Schema";
|
|
3
|
+
export declare const ENUM_SUFFIX = "Enum";
|
|
3
4
|
export declare const BODY_SCHEMA_SUFFIX = "Body";
|
|
4
5
|
export declare const PARAM_SCHEMA_SUFFIX = "Param";
|
|
5
6
|
export declare const RESPONSE_SCHEMA_SUFFIX = "Response";
|
|
@@ -1,19 +1,40 @@
|
|
|
1
1
|
import { OpenAPIV3 } from "openapi-types";
|
|
2
2
|
import { GenerateOptions } from "../types/options";
|
|
3
|
-
import {
|
|
3
|
+
import { ValidationError } from "../types/validation";
|
|
4
|
+
import { DependencyGraph } from "./openapi/getOpenAPISchemaDependencyGraph";
|
|
4
5
|
import { ZodSchema } from "./zod/ZodSchema.class";
|
|
6
|
+
interface SchemaData {
|
|
7
|
+
ref: string;
|
|
8
|
+
name: string;
|
|
9
|
+
zodSchemaName: string;
|
|
10
|
+
tags: string[];
|
|
11
|
+
}
|
|
12
|
+
export interface EnumZodSchemaData {
|
|
13
|
+
code: string;
|
|
14
|
+
zodSchemaName?: string;
|
|
15
|
+
tag?: string;
|
|
16
|
+
meta: {
|
|
17
|
+
zodSchemaNameSegments: string[][];
|
|
18
|
+
tags: string[];
|
|
19
|
+
schemaRefs: string[];
|
|
20
|
+
};
|
|
21
|
+
}
|
|
5
22
|
export declare class SchemaResolver {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
private schemaData;
|
|
9
|
-
private zodSchemaData;
|
|
10
|
-
private compositeZodSchemaData;
|
|
11
|
-
readonly
|
|
12
|
-
readonly
|
|
23
|
+
readonly openApiDoc: OpenAPIV3.Document;
|
|
24
|
+
readonly options: GenerateOptions;
|
|
25
|
+
private readonly schemaData;
|
|
26
|
+
private readonly zodSchemaData;
|
|
27
|
+
private readonly compositeZodSchemaData;
|
|
28
|
+
readonly enumZodSchemaData: EnumZodSchemaData[];
|
|
29
|
+
readonly dependencyGraph: DependencyGraph;
|
|
30
|
+
readonly operationsByTag: Record<string, OpenAPIV3.OperationObject[]>;
|
|
31
|
+
readonly operationNames: string[];
|
|
32
|
+
readonly validationErrors: ValidationError[];
|
|
13
33
|
private get docSchemas();
|
|
14
34
|
private get schemaRefs();
|
|
15
35
|
constructor(openApiDoc: OpenAPIV3.Document, options: GenerateOptions);
|
|
16
36
|
getSchemaByRef(ref: string): OpenAPIV3.SchemaObject;
|
|
37
|
+
getSchemaDataByRef(ref: string): SchemaData | undefined;
|
|
17
38
|
getZodSchemaNameByRef(ref: string): string;
|
|
18
39
|
getRefByZodSchemaName(zodSchemaName: string): string | undefined;
|
|
19
40
|
getTagByZodSchemaName(zodSchemaName: string): string;
|
|
@@ -23,10 +44,12 @@ export declare class SchemaResolver {
|
|
|
23
44
|
addZodSchemaForCompositeCode(code: string, zodSchema: ZodSchema, zodSchemaName: string, schema?: OpenAPIV3.SchemaObject): void;
|
|
24
45
|
getCompositeZodSchemaByZodSchemaName(zodSchemaName: string): ZodSchema | undefined;
|
|
25
46
|
getSchemaByCompositeZodSchemaName(compositeZodSchemaName: string): OpenAPIV3.SchemaObject | undefined;
|
|
47
|
+
getEnumZodSchemaDataByCode(code: string): EnumZodSchemaData | undefined;
|
|
48
|
+
getEnumZodSchemaNamesReferencedBySchemaRef(schemaRef: string): string[];
|
|
26
49
|
getZodSchemas(): {};
|
|
50
|
+
getEnumZodSchemas(): {};
|
|
27
51
|
resolveObject<T>(obj: OpenAPIV3.ReferenceObject | T): T;
|
|
28
52
|
isSchemaCircular(ref: string): boolean;
|
|
29
|
-
private
|
|
30
|
-
private initializeSchemaTags;
|
|
31
|
-
private getOperationSchemaRefs;
|
|
53
|
+
private initialize;
|
|
32
54
|
}
|
|
55
|
+
export {};
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import { OpenAPIV3 } from "openapi-types";
|
|
2
2
|
import { EndpointParameter } from "src/generators/types/endpoint";
|
|
3
|
-
import { GenerateOptions } from "src/generators/types/options";
|
|
4
3
|
import { SchemaResolver } from "../SchemaResolver.class";
|
|
5
|
-
export declare function getEndpointBody({ resolver, operation, operationName, isUniqueOperationName, tag,
|
|
4
|
+
export declare function getEndpointBody({ resolver, operation, operationName, isUniqueOperationName, tag, }: {
|
|
6
5
|
resolver: SchemaResolver;
|
|
7
6
|
operation: OpenAPIV3.OperationObject;
|
|
8
7
|
operationName: string;
|
|
9
8
|
isUniqueOperationName: boolean;
|
|
10
9
|
tag: string;
|
|
11
|
-
options: GenerateOptions;
|
|
12
10
|
}): {
|
|
13
11
|
endpointParameter: EndpointParameter;
|
|
14
12
|
requestFormat: string;
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { OpenAPIV3 } from "openapi-types";
|
|
2
2
|
import { EndpointParameter } from "src/generators/types/endpoint";
|
|
3
|
-
import { GenerateOptions } from "src/generators/types/options";
|
|
4
3
|
import { SchemaResolver } from "../SchemaResolver.class";
|
|
5
|
-
export declare function getEndpointParameter({ resolver, param, operationName, isUniqueOperationName, tag,
|
|
4
|
+
export declare function getEndpointParameter({ resolver, param, operationName, isUniqueOperationName, tag, }: {
|
|
6
5
|
resolver: SchemaResolver;
|
|
7
6
|
param: OpenAPIV3.ReferenceObject | OpenAPIV3.ParameterObject;
|
|
8
7
|
operationName: string;
|
|
9
8
|
isUniqueOperationName: boolean;
|
|
10
9
|
tag: string;
|
|
11
|
-
options: GenerateOptions;
|
|
12
10
|
}): EndpointParameter | undefined;
|
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
import { OpenAPIV3 } from "openapi-types";
|
|
2
1
|
import { Endpoint } from "../../types/endpoint";
|
|
3
|
-
import { GenerateOptions } from "../../types/options";
|
|
4
2
|
import { SchemaResolver } from "../SchemaResolver.class";
|
|
5
|
-
export declare function getEndpointsFromOpenAPIDoc(
|
|
6
|
-
openApiDoc: OpenAPIV3.Document;
|
|
7
|
-
resolver: SchemaResolver;
|
|
8
|
-
options: GenerateOptions;
|
|
9
|
-
}): {
|
|
10
|
-
endpoints: Endpoint[];
|
|
11
|
-
validationErrorMessages: string[];
|
|
12
|
-
};
|
|
3
|
+
export declare function getEndpointsFromOpenAPIDoc(resolver: SchemaResolver): Endpoint[];
|
|
@@ -2,11 +2,7 @@ import { OpenAPIV3 } from "openapi-types";
|
|
|
2
2
|
import { GenerateData } from "../types/generate";
|
|
3
3
|
import { GenerateOptions } from "../types/options";
|
|
4
4
|
import { SchemaResolver } from "./SchemaResolver.class";
|
|
5
|
-
export declare function getDataFromOpenAPIDoc(
|
|
6
|
-
openApiDoc: OpenAPIV3.Document;
|
|
7
|
-
options: GenerateOptions;
|
|
8
|
-
}): {
|
|
5
|
+
export declare function getDataFromOpenAPIDoc(openApiDoc: OpenAPIV3.Document, options: GenerateOptions): {
|
|
9
6
|
resolver: SchemaResolver;
|
|
10
7
|
data: GenerateData;
|
|
11
|
-
validationErrorMessages: string[];
|
|
12
8
|
};
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
import { OpenAPIV3 } from "openapi-types";
|
|
2
2
|
import { GenerateMetadata } from "../types/metadata";
|
|
3
3
|
import { GenerateOptions } from "../types/options";
|
|
4
|
-
export declare function getMetadataFromOpenAPIDoc(
|
|
5
|
-
openApiDoc: OpenAPIV3.Document;
|
|
6
|
-
options: GenerateOptions;
|
|
7
|
-
}): Promise<GenerateMetadata>;
|
|
4
|
+
export declare function getMetadataFromOpenAPIDoc(openApiDoc: OpenAPIV3.Document, options: GenerateOptions): Promise<GenerateMetadata>;
|
|
@@ -1,5 +1,2 @@
|
|
|
1
1
|
import { OpenAPIV3 } from "openapi-types";
|
|
2
|
-
export declare function getOpenAPISchemaComplexity(
|
|
3
|
-
current: number;
|
|
4
|
-
schema: OpenAPIV3.SchemaObject | OpenAPIV3.ReferenceObject | undefined;
|
|
5
|
-
}): number;
|
|
2
|
+
export declare function getOpenAPISchemaComplexity(current: number, schema?: OpenAPIV3.SchemaObject | OpenAPIV3.ReferenceObject): number;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { OpenAPIV3 } from "openapi-types";
|
|
2
|
-
export
|
|
2
|
+
export interface DependencyGraph {
|
|
3
3
|
refsDependencyGraph: Record<string, Set<string>>;
|
|
4
4
|
deepDependencyGraph: Record<string, Set<string>>;
|
|
5
|
-
}
|
|
5
|
+
}
|
|
6
|
+
export declare function getOpenAPISchemaDependencyGraph(schemaRef: string[], getSchemaByRef: (ref: string) => OpenAPIV3.SchemaObject | OpenAPIV3.ReferenceObject): DependencyGraph;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { OpenAPIV3 } from "openapi-types";
|
|
2
|
+
import { SchemaResolver } from "../SchemaResolver.class";
|
|
3
|
+
export declare function getSchemaRefObjs(resolver: SchemaResolver, schema: OpenAPIV3.ReferenceObject | OpenAPIV3.SchemaObject | undefined, schemaInfo: string): OpenAPIV3.ReferenceObject[];
|
|
4
|
+
export declare function getDeepSchemaRefObjs(resolver: SchemaResolver, schemaRefs: OpenAPIV3.ReferenceObject[]): string[];
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { OpenAPIV3 } from "openapi-types";
|
|
2
|
+
export type OnSchemaCallbackData<TData> = {
|
|
3
|
+
data?: TData;
|
|
4
|
+
} & ({
|
|
5
|
+
type: "reference";
|
|
6
|
+
schema: OpenAPIV3.ReferenceObject;
|
|
7
|
+
} | {
|
|
8
|
+
type: "property" | "additionalProperty";
|
|
9
|
+
parentSchema: OpenAPIV3.SchemaObject | OpenAPIV3.ReferenceObject;
|
|
10
|
+
schema: OpenAPIV3.SchemaObject | OpenAPIV3.ReferenceObject;
|
|
11
|
+
propertyName: string;
|
|
12
|
+
} | {
|
|
13
|
+
type: "composite" | "array";
|
|
14
|
+
parentSchema: OpenAPIV3.SchemaObject | OpenAPIV3.ReferenceObject;
|
|
15
|
+
schema: OpenAPIV3.SchemaObject | OpenAPIV3.ReferenceObject;
|
|
16
|
+
});
|
|
17
|
+
type OnSchemaCallbackType<TData> = (data: OnSchemaCallbackData<TData>) => any;
|
|
18
|
+
export declare function iterateSchema<TData>(schema: OpenAPIV3.SchemaObject | OpenAPIV3.ReferenceObject | undefined, options: {
|
|
19
|
+
data?: TData;
|
|
20
|
+
onSchema: OnSchemaCallbackType<TData>;
|
|
21
|
+
}): void;
|
|
22
|
+
export {};
|
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
import { OpenAPIV3 } from "openapi-types";
|
|
2
|
+
import { WithRequired } from "src/generators/types/common";
|
|
2
3
|
import { GenerateOptions } from "src/generators/types/options";
|
|
3
4
|
import { SchemaResolver } from "../SchemaResolver.class";
|
|
4
|
-
export
|
|
5
|
+
export interface ZodSchemaMetaData {
|
|
5
6
|
isRequired?: boolean;
|
|
6
7
|
name?: string;
|
|
7
8
|
parent?: ZodSchema;
|
|
8
9
|
referencedBy?: ZodSchema[];
|
|
9
|
-
}
|
|
10
|
+
}
|
|
10
11
|
export declare class ZodSchema {
|
|
11
12
|
schema: OpenAPIV3.SchemaObject | OpenAPIV3.ReferenceObject;
|
|
12
|
-
resolver
|
|
13
|
+
resolver: SchemaResolver;
|
|
13
14
|
private code?;
|
|
14
15
|
ref?: string;
|
|
16
|
+
enumRef?: string;
|
|
15
17
|
children: ZodSchema[];
|
|
16
|
-
meta:
|
|
17
|
-
constructor(schema: OpenAPIV3.SchemaObject | OpenAPIV3.ReferenceObject, resolver
|
|
18
|
+
meta: WithRequired<ZodSchemaMetaData, "referencedBy">;
|
|
19
|
+
constructor(schema: OpenAPIV3.SchemaObject | OpenAPIV3.ReferenceObject, resolver: SchemaResolver, meta?: ZodSchemaMetaData, enumRef?: string);
|
|
18
20
|
getCodeString(tag?: string, options?: GenerateOptions): string;
|
|
19
21
|
get complexity(): number;
|
|
20
22
|
assign(code: string): this;
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import { OpenAPIV3 } from "openapi-types";
|
|
2
|
-
import { GenerateOptions } from "src/generators/types/options";
|
|
3
2
|
import { SchemaResolver } from "../SchemaResolver.class";
|
|
4
3
|
import { ZodSchema, ZodSchemaMetaData } from "./ZodSchema.class";
|
|
5
4
|
type GetZodSchemaParams = {
|
|
6
5
|
schema: OpenAPIV3.SchemaObject | OpenAPIV3.ReferenceObject;
|
|
7
|
-
resolver
|
|
6
|
+
resolver: SchemaResolver;
|
|
8
7
|
meta?: ZodSchemaMetaData;
|
|
9
8
|
tag: string;
|
|
10
|
-
options: GenerateOptions;
|
|
11
9
|
};
|
|
12
10
|
/**
|
|
13
11
|
* @see https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#schemaObject
|
|
14
12
|
* @see https://github.com/colinhacks/zod
|
|
15
13
|
*/
|
|
16
|
-
export declare function getZodSchema({ schema, resolver, meta: inheritedMeta, tag
|
|
14
|
+
export declare function getZodSchema({ schema, resolver, meta: inheritedMeta, tag }: GetZodSchemaParams): ZodSchema;
|
|
15
|
+
export declare function getEnumZodSchemaCode(schema: OpenAPIV3.SchemaObject): string;
|
|
17
16
|
export {};
|
|
@@ -1,5 +1,2 @@
|
|
|
1
1
|
import { SchemaResolver } from "../SchemaResolver.class";
|
|
2
|
-
export declare function getZodSchemaRefs(
|
|
3
|
-
resolver: SchemaResolver;
|
|
4
|
-
zodSchemaName: string;
|
|
5
|
-
}): string[];
|
|
2
|
+
export declare function getZodSchemaRefs(resolver: SchemaResolver, zodSchemaName: string): string[];
|
|
@@ -1,8 +1,2 @@
|
|
|
1
|
-
import { OpenAPIV3 } from "openapi-types";
|
|
2
|
-
import { GenerateOptions } from "../../types/options";
|
|
3
1
|
import { SchemaResolver } from "../SchemaResolver.class";
|
|
4
|
-
export declare function getZodSchemasFromOpenAPIDoc(
|
|
5
|
-
resolver: SchemaResolver;
|
|
6
|
-
openApiDoc: OpenAPIV3.Document;
|
|
7
|
-
options: GenerateOptions;
|
|
8
|
-
}): Record<string, string>;
|
|
2
|
+
export declare function getZodSchemasFromOpenAPIDoc(resolver: SchemaResolver): Record<string, string>;
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { OpenAPIV3 } from "openapi-types";
|
|
2
|
-
import { GenerateOptions } from "src/generators/types/options";
|
|
3
2
|
import { SchemaResolver } from "../SchemaResolver.class";
|
|
4
3
|
import { ZodSchema } from "./ZodSchema.class";
|
|
5
|
-
export declare function resolveZodSchemaName({ schema, zodSchema, fallbackName, resolver, tag,
|
|
4
|
+
export declare function resolveZodSchemaName({ schema, zodSchema, fallbackName, resolver, tag, }: {
|
|
6
5
|
schema?: OpenAPIV3.SchemaObject;
|
|
7
6
|
zodSchema: ZodSchema;
|
|
8
7
|
fallbackName?: string;
|
|
9
8
|
resolver: SchemaResolver;
|
|
10
9
|
tag: string;
|
|
11
|
-
options: GenerateOptions;
|
|
12
10
|
}): string;
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
import { SchemaResolver } from "../SchemaResolver.class";
|
|
2
|
-
export declare function sortZodSchemasByTopology(
|
|
3
|
-
resolver: SchemaResolver;
|
|
4
|
-
zodSchemas: Record<string, string>;
|
|
5
|
-
}): {
|
|
2
|
+
export declare function sortZodSchemasByTopology(resolver: SchemaResolver, zodSchemas: Record<string, string>): {
|
|
6
3
|
[k: string]: string;
|
|
7
4
|
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { OpenAPIV3 } from "openapi-types";
|
|
2
|
+
import { SchemaResolver } from "../SchemaResolver.class";
|
|
3
|
+
export declare function updateEnumZodSchemaData({ schema, nameSegments, includeSelf, ...params }: {
|
|
4
|
+
resolver: SchemaResolver;
|
|
5
|
+
schema: OpenAPIV3.ReferenceObject | OpenAPIV3.SchemaObject | undefined;
|
|
6
|
+
schemaRef?: string;
|
|
7
|
+
schemaInfo?: string;
|
|
8
|
+
tags: string[];
|
|
9
|
+
nameSegments?: string[];
|
|
10
|
+
includeSelf?: boolean;
|
|
11
|
+
}): void;
|
|
12
|
+
export declare function resolveEnumZodSchemaNames(resolver: SchemaResolver): void;
|
|
13
|
+
export declare function resolveEnumZodSchemaTags(resolver: SchemaResolver): void;
|
|
@@ -1,7 +1,2 @@
|
|
|
1
|
-
import { GenerateOptions } from "../../types/options";
|
|
2
1
|
import { SchemaResolver } from "../SchemaResolver.class";
|
|
3
|
-
export declare function wrapCircularZodSchemas(
|
|
4
|
-
resolver: SchemaResolver;
|
|
5
|
-
zodSchemas: Record<string, string>;
|
|
6
|
-
options: GenerateOptions;
|
|
7
|
-
}): Record<string, string>;
|
|
2
|
+
export declare function wrapCircularZodSchemas(resolver: SchemaResolver, zodSchemas: Record<string, string>): Record<string, string>;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { SchemaResolver } from "../core/SchemaResolver.class";
|
|
2
2
|
import { GenerateData } from "../types/generate";
|
|
3
|
-
|
|
4
|
-
export declare function generateEndpoints({ resolver, data, tag, options, }: {
|
|
3
|
+
export declare function generateEndpoints({ resolver, data, tag, }: {
|
|
5
4
|
resolver: SchemaResolver;
|
|
6
5
|
data: GenerateData;
|
|
7
6
|
tag?: string;
|
|
8
|
-
options: GenerateOptions;
|
|
9
7
|
}): string | undefined;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { SchemaResolver } from "../core/SchemaResolver.class";
|
|
2
2
|
import { GenerateData } from "../types/generate";
|
|
3
|
-
|
|
4
|
-
export declare function generateModels({ resolver, data, tag, options, }: {
|
|
3
|
+
export declare function generateModels({ resolver, data, tag, }: {
|
|
5
4
|
resolver: SchemaResolver;
|
|
6
5
|
data: GenerateData;
|
|
7
6
|
tag?: string;
|
|
8
|
-
options: GenerateOptions;
|
|
9
7
|
}): string | undefined;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { SchemaResolver } from "../core/SchemaResolver.class";
|
|
2
2
|
import { GenerateData } from "../types/generate";
|
|
3
|
-
|
|
4
|
-
export declare function generateQueries({ resolver, data, tag, options, }: {
|
|
3
|
+
export declare function generateQueries({ resolver, data, tag, }: {
|
|
5
4
|
resolver: SchemaResolver;
|
|
6
5
|
data: GenerateData;
|
|
7
6
|
tag?: string;
|
|
8
|
-
options: GenerateOptions;
|
|
9
7
|
}): string | undefined;
|
|
@@ -1,6 +1,3 @@
|
|
|
1
1
|
import { OpenAPIV3 } from "openapi-types";
|
|
2
2
|
import { GenerateOptions } from "./types/options";
|
|
3
|
-
export declare function generateCodeFromOpenAPIDoc(
|
|
4
|
-
openApiDoc: OpenAPIV3.Document;
|
|
5
|
-
options?: Partial<GenerateOptions>;
|
|
6
|
-
}): void;
|
|
3
|
+
export declare function generateCodeFromOpenAPIDoc(openApiDoc: OpenAPIV3.Document, cliOptions?: Partial<GenerateOptions>): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getUniqueArray: <T>(...arrs: T[][]) => T[];
|
|
@@ -6,11 +6,7 @@ export declare const getEndpointName: (endpoint: Endpoint) => string;
|
|
|
6
6
|
export declare function getImportedEndpointName(endpoint: Endpoint, options: GenerateOptions): string;
|
|
7
7
|
export declare const getEndpointPath: (endpoint: Endpoint) => string;
|
|
8
8
|
export declare function getEndpointTag(endpoint: Endpoint, options: GenerateOptions): string;
|
|
9
|
-
export declare function mapEndpointParamsToFunctionParams(
|
|
10
|
-
resolver: SchemaResolver;
|
|
11
|
-
endpoint: Endpoint;
|
|
12
|
-
options: GenerateOptions;
|
|
13
|
-
}): {
|
|
9
|
+
export declare function mapEndpointParamsToFunctionParams(resolver: SchemaResolver, endpoint: Endpoint): {
|
|
14
10
|
name: string;
|
|
15
11
|
type: string;
|
|
16
12
|
paramType: "Query" | "Body" | "Header" | "Path";
|
|
@@ -2,12 +2,11 @@ import { SchemaResolver } from "src/generators/core/SchemaResolver.class";
|
|
|
2
2
|
import { Endpoint } from "../../types/endpoint";
|
|
3
3
|
import { Import } from "../../types/generate";
|
|
4
4
|
import { GenerateOptions } from "../../types/options";
|
|
5
|
-
export declare function getModelsImports({ resolver, tag, zodSchemas, zodSchemasAsTypes,
|
|
5
|
+
export declare function getModelsImports({ resolver, tag, zodSchemas, zodSchemasAsTypes, }: {
|
|
6
6
|
resolver: SchemaResolver;
|
|
7
7
|
tag: string;
|
|
8
8
|
zodSchemas?: string[];
|
|
9
9
|
zodSchemasAsTypes?: string[];
|
|
10
|
-
options: GenerateOptions;
|
|
11
10
|
}): Import[];
|
|
12
11
|
export declare function getEndpointsImports({ tag, endpoints, options, }: {
|
|
13
12
|
tag: string;
|
|
@@ -1,13 +1,5 @@
|
|
|
1
1
|
import { SchemaResolver } from "src/generators/core/SchemaResolver.class";
|
|
2
2
|
import { GenerateOptions } from "src/generators/types/options";
|
|
3
3
|
export declare const getZodSchemaInferedTypeName: (zodSchemaName: string, options: GenerateOptions) => string;
|
|
4
|
-
export declare const getImportedZodSchemaName: (
|
|
5
|
-
|
|
6
|
-
zodSchemaName: string;
|
|
7
|
-
options: GenerateOptions;
|
|
8
|
-
}) => string;
|
|
9
|
-
export declare const getImportedZodSchemaInferedTypeName: ({ resolver, zodSchemaName, options, }: {
|
|
10
|
-
resolver: SchemaResolver;
|
|
11
|
-
zodSchemaName: string;
|
|
12
|
-
options: GenerateOptions;
|
|
13
|
-
}) => string;
|
|
4
|
+
export declare const getImportedZodSchemaName: (resolver: SchemaResolver, zodSchemaName: string) => string;
|
|
5
|
+
export declare const getImportedZodSchemaInferedTypeName: (resolver: SchemaResolver, zodSchemaName: string) => string;
|
|
@@ -1,8 +1,3 @@
|
|
|
1
1
|
import { SchemaResolver } from "src/generators/core/SchemaResolver.class";
|
|
2
|
-
|
|
3
|
-
export declare function getHbsTemplateDelegate({ resolver, templateName, options, }: {
|
|
4
|
-
resolver: SchemaResolver;
|
|
5
|
-
templateName: string;
|
|
6
|
-
options: GenerateOptions;
|
|
7
|
-
}): HandlebarsTemplateDelegate<any>;
|
|
2
|
+
export declare function getHbsTemplateDelegate(resolver: SchemaResolver, templateName: string): HandlebarsTemplateDelegate<any>;
|
|
8
3
|
export declare function getHbsPartialTemplateDelegate(templateName: string): HandlebarsTemplateDelegate<any>;
|
|
@@ -1,3 +1,2 @@
|
|
|
1
1
|
import { SchemaResolver } from "src/generators/core/SchemaResolver.class";
|
|
2
|
-
|
|
3
|
-
export declare function registerEndpointsHbsHelpers(resolver: SchemaResolver, options: GenerateOptions): void;
|
|
2
|
+
export declare function registerEndpointsHbsHelpers(resolver: SchemaResolver): void;
|
|
@@ -1,3 +1,2 @@
|
|
|
1
1
|
import { SchemaResolver } from "src/generators/core/SchemaResolver.class";
|
|
2
|
-
|
|
3
|
-
export declare function registerZodHbsHelpers(resolver: SchemaResolver, options: GenerateOptions): void;
|
|
2
|
+
export declare function registerZodHbsHelpers(resolver: SchemaResolver): void;
|
|
@@ -24,16 +24,14 @@ export declare function getOperationName({ path, method, operation, options, kee
|
|
|
24
24
|
options: GenerateOptions;
|
|
25
25
|
keepOperationPrefixWithoutEnding?: boolean;
|
|
26
26
|
}): string;
|
|
27
|
-
export declare function getUniqueOperationName({ path, method, operation,
|
|
27
|
+
export declare function getUniqueOperationName({ path, method, operation, operationsByTag, options, }: {
|
|
28
28
|
path: string;
|
|
29
29
|
method: string;
|
|
30
30
|
operation: OpenAPIV3.OperationObject;
|
|
31
|
-
|
|
31
|
+
operationsByTag: Record<string, OpenAPIV3.OperationObject[]>;
|
|
32
32
|
options: GenerateOptions;
|
|
33
33
|
}): string;
|
|
34
|
-
export declare function
|
|
35
|
-
export declare function formatTag(tag: string): string;
|
|
36
|
-
export declare function getOperationTag(operation: OpenAPIV3.OperationObject, options: GenerateOptions): string;
|
|
34
|
+
export declare function getUniqueOperationNamesWithoutSplitByTags(openApiDoc: OpenAPIV3.Document, operationsByTag: Record<string, OpenAPIV3.OperationObject[]>, options: GenerateOptions): string[];
|
|
37
35
|
/** @example turns `/media-objects/{id}` into `MediaObjectsById` */
|
|
38
36
|
export declare function pathToVariableName(path: string): string;
|
|
39
37
|
export declare function replaceHyphenatedPath(path: string): string;
|
|
@@ -5,3 +5,7 @@ export declare const snakeToCamel: (str: string) => string;
|
|
|
5
5
|
export declare const nonWordCharactersToCamel: (str: string) => string;
|
|
6
6
|
export declare const suffixIfNeeded: (text: string, suffix?: string) => string;
|
|
7
7
|
export declare const removeSuffix: (text: string, suffix: string) => string;
|
|
8
|
+
export declare const getLongestMostCommon: (strs: string[]) => string | undefined;
|
|
9
|
+
export declare const getMostCommonAdjacentCombinationSplit: (strs: string[]) => string | undefined;
|
|
10
|
+
export declare const splitByUppercase: (str: string) => string[];
|
|
11
|
+
export declare const getAdjacentStringCombinations: (strs: string[], ignoreStrs?: string[]) => string[];
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { OpenAPIV3 } from "openapi-types";
|
|
2
|
+
import { GenerateOptions } from "../types/options";
|
|
3
|
+
export declare function formatTag(tag: string): string;
|
|
4
|
+
export declare function getOperationTag(operation: OpenAPIV3.OperationObject, options: GenerateOptions): string;
|
|
5
|
+
export declare function getOperationsByTag(openApiDoc: OpenAPIV3.Document, options: GenerateOptions): Record<string, {
|
|
6
|
+
tags?: string[] | undefined;
|
|
7
|
+
summary?: string | undefined;
|
|
8
|
+
description?: string | undefined;
|
|
9
|
+
externalDocs?: OpenAPIV3.ExternalDocumentationObject | undefined;
|
|
10
|
+
operationId?: string | undefined;
|
|
11
|
+
parameters?: (OpenAPIV3.ReferenceObject | OpenAPIV3.ParameterObject)[] | undefined;
|
|
12
|
+
requestBody?: OpenAPIV3.ReferenceObject | OpenAPIV3.RequestBodyObject | undefined;
|
|
13
|
+
responses: OpenAPIV3.ResponsesObject;
|
|
14
|
+
callbacks?: {
|
|
15
|
+
[callback: string]: OpenAPIV3.ReferenceObject | OpenAPIV3.CallbackObject;
|
|
16
|
+
} | undefined;
|
|
17
|
+
deprecated?: boolean | undefined;
|
|
18
|
+
security?: OpenAPIV3.SecurityRequirementObject[] | undefined;
|
|
19
|
+
servers?: OpenAPIV3.ServerObject[] | undefined;
|
|
20
|
+
}[]>;
|
|
@@ -2,18 +2,15 @@ import { OpenAPIV3 } from "openapi-types";
|
|
|
2
2
|
import { SchemaResolver } from "../core/SchemaResolver.class";
|
|
3
3
|
import { TsMetaType, TsTypeBase } from "../types/metadata";
|
|
4
4
|
import { PrimitiveType } from "../types/openapi";
|
|
5
|
-
import { GenerateOptions } from "../types/options";
|
|
6
5
|
export declare function primitiveTypeToTsType(type: PrimitiveType): string;
|
|
7
|
-
export declare function getTsTypeBase({ zodSchemaName, schema, resolver,
|
|
6
|
+
export declare function getTsTypeBase({ zodSchemaName, schema, resolver, }: {
|
|
8
7
|
zodSchemaName?: string;
|
|
9
8
|
schema?: OpenAPIV3.SchemaObject;
|
|
10
9
|
resolver: SchemaResolver;
|
|
11
|
-
options: GenerateOptions;
|
|
12
10
|
}): TsTypeBase;
|
|
13
|
-
export declare function getSchemaTsMetaType({ schema, isCircular, parentTypes, resolver,
|
|
11
|
+
export declare function getSchemaTsMetaType({ schema, isCircular, parentTypes, resolver, }: {
|
|
14
12
|
schema?: OpenAPIV3.SchemaObject;
|
|
15
13
|
isCircular?: boolean;
|
|
16
14
|
parentTypes: TsTypeBase[];
|
|
17
15
|
resolver: SchemaResolver;
|
|
18
|
-
options: GenerateOptions;
|
|
19
16
|
}): TsMetaType;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { EndpointParameter } from "../types/endpoint";
|
|
2
|
+
import { ValidationError, ValidationErrorType } from "../types/validation";
|
|
3
|
+
export declare function getInvalidSchemaError(schemaInfo: string): ValidationError;
|
|
4
|
+
export declare function getInvalidOperationIdError(operationId: string): ValidationError;
|
|
5
|
+
export declare function getMissingPathParameterError(params: EndpointParameter[], path: string): ValidationError;
|
|
6
|
+
export declare function getNotAllowedInlineEnumError(info: string): ValidationError;
|
|
7
|
+
export declare function groupByType(validationErrors: ValidationError[]): Record<ValidationErrorType, string[]>;
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
export declare const getZodSchemaName: (name: string, schemaSuffix: string) => string;
|
|
2
|
+
export declare const getEnumZodSchemaName: (name: string, enumSuffix: string, schemaSuffix: string) => string;
|
|
2
3
|
export declare const isNamedZodSchema: (schema: string) => boolean;
|
|
3
4
|
export declare const getZodSchemaOperationName: (operationName: string, isUniqueOperationName: boolean, tag: string) => string;
|
|
4
5
|
export declare const getBodyZodSchemaName: (operationName: string) => string;
|
|
5
6
|
export declare const getParamZodSchemaName: (operationName: string, paramName: string) => string;
|
|
6
7
|
export declare const getMainResponseZodSchemaName: (operationName: string) => string;
|
|
7
8
|
export declare const getErrorResponseZodSchemaName: (operationName: string, statusCode: string) => string;
|
|
9
|
+
export declare function getResponseZodSchemaName({ statusCode, operationName, isUniqueOperationName, tag, }: {
|
|
10
|
+
statusCode: string;
|
|
11
|
+
operationName: string;
|
|
12
|
+
isUniqueOperationName: boolean;
|
|
13
|
+
tag: string;
|
|
14
|
+
}): string;
|