@povio/openapi-codegen-cli 0.6.6 → 0.7.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 +24 -23
- package/dist/commands/generate.d.ts +1 -1
- package/dist/generators/const/deps.const.d.ts +6 -0
- package/dist/generators/const/{query.const.d.ts → queries.const.d.ts} +1 -0
- package/dist/generators/generate/generateQueryModules.d.ts +2 -0
- package/dist/generators/utils/generate/generate.imports.utils.d.ts +6 -3
- package/dist/generators/utils/generate/generate.query.utils.d.ts +2 -0
- package/dist/generators/utils/generate/generate.utils.d.ts +1 -0
- package/dist/index.js +46 -46
- package/dist/sh.js +66 -66
- package/package.json +1 -1
- package/src/assets/invalidateQueries.ts +31 -0
- package/src/assets/react-query.types.ts +1 -3
- package/src/generators/templates/partials/query-js-docs.hbs +1 -1
- package/src/generators/templates/partials/query-keys.hbs +1 -1
- package/src/generators/templates/partials/query-use-mutation.hbs +4 -6
- package/src/generators/templates/queries.hbs +10 -3
- package/src/generators/templates/query-modules.hbs +21 -0
package/README.md
CHANGED
|
@@ -29,26 +29,27 @@ yarn openapi-codegen generate --input http://localhost:3001/docs-json --standalo
|
|
|
29
29
|
#### Generate command (generates Zod schemas, API definitions and React queries)
|
|
30
30
|
|
|
31
31
|
```sh
|
|
32
|
-
--input Path/URL to OpenAPI
|
|
33
|
-
--output Output path (default: 'output')
|
|
34
|
-
--prettier
|
|
35
|
-
--verbose
|
|
36
|
-
|
|
37
|
-
--splitByTags
|
|
38
|
-
--defaultTag (Requires
|
|
39
|
-
--excludeTags (Requires
|
|
40
|
-
|
|
41
|
-
--tsNamespaces
|
|
42
|
-
--importPath
|
|
43
|
-
--removeOperationPrefixEndingWith Remove prefixes that end with the specified
|
|
44
|
-
--extractEnums Extract enums
|
|
45
|
-
--replaceOptionalWithNullish Replace
|
|
46
|
-
|
|
47
|
-
--axiosRequestConfig
|
|
48
|
-
--infiniteQueries
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
--
|
|
32
|
+
--input Path/URL to OpenAPI JSON/YAML document
|
|
33
|
+
--output Output directory path (default: 'output')
|
|
34
|
+
--prettier Format the generated code using Prettier (default: true)
|
|
35
|
+
--verbose Display detailed log messages during execution (default: false)
|
|
36
|
+
|
|
37
|
+
--splitByTags Organize output into separate folders based on OpenAPI operation tags (default: true)
|
|
38
|
+
--defaultTag (Requires `--splitByTags`) Default tag for shared code across multiple tags (default: 'Common')
|
|
39
|
+
--excludeTags (Requires `--splitByTags`) Comma-separated list of tags to exclude from generation
|
|
40
|
+
|
|
41
|
+
--tsNamespaces Wrap generated files in TypeScript namespaces (default: true)
|
|
42
|
+
--importPath Module import style for generated files (default: 'ts'; options: 'ts' | 'relative' | 'absolute')
|
|
43
|
+
--removeOperationPrefixEndingWith Remove operation name prefixes that end with the specified string (Default: 'Controller_')
|
|
44
|
+
--extractEnums Extract enums into separate Zod schemas (default: true)
|
|
45
|
+
--replaceOptionalWithNullish Replace `.optional()` chains with `.nullish()` in generated Zod schemas (default: false)
|
|
46
|
+
|
|
47
|
+
--axiosRequestConfig Include Axios request config parameters in query hooks (default: false)
|
|
48
|
+
--infiniteQueries Generate infinite queries for paginated API endpoints (default: false)
|
|
49
|
+
--invalidateQueryOptions Add query invalidation options to mutation hooks (default: true)
|
|
50
|
+
|
|
51
|
+
--standalone Generate any missing supporting classes/types, e.g., REST client class, React Query type extensions, etc. (default: false)
|
|
52
|
+
--baseUrl (Requires `--standalone`) Base URL for the REST client; falls back to the OpenAPI spec if not provided
|
|
52
53
|
```
|
|
53
54
|
|
|
54
55
|
#### Check command (checks if OpenAPI spec is compliant)
|
|
@@ -57,9 +58,9 @@ yarn openapi-codegen generate --input http://localhost:3001/docs-json --standalo
|
|
|
57
58
|
--input Path/URL to OpenAPI/Swagger document as JSON/YAML
|
|
58
59
|
--verbose Show log messages during execution
|
|
59
60
|
|
|
60
|
-
--splitByTags
|
|
61
|
-
--defaultTag Default tag
|
|
62
|
-
--excludeTags Comma-separated list of tags to exclude from
|
|
61
|
+
--splitByTags Organize output into separate folders based on OpenAPI operation tags (default: true)
|
|
62
|
+
--defaultTag (Requires `--splitByTags`) Default tag for shared code across multiple tags (default: 'Common')
|
|
63
|
+
--excludeTags (Requires `--splitByTags`) Comma-separated list of tags to exclude from generation
|
|
63
64
|
```
|
|
64
65
|
|
|
65
66
|
## Development
|
|
@@ -3,5 +3,5 @@ export type GenerateParams = {
|
|
|
3
3
|
excludeTags: string;
|
|
4
4
|
prettier: boolean;
|
|
5
5
|
verbose: boolean;
|
|
6
|
-
} & Pick<GenerateOptions, "input" | "output" | "tsNamespaces" | "splitByTags" | "defaultTag" | "removeOperationPrefixEndingWith" | "importPath" | "extractEnums" | "standalone" | "baseUrl" | "replaceOptionalWithNullish" | "infiniteQueries" | "axiosRequestConfig">;
|
|
6
|
+
} & Pick<GenerateOptions, "input" | "output" | "tsNamespaces" | "splitByTags" | "defaultTag" | "removeOperationPrefixEndingWith" | "importPath" | "extractEnums" | "standalone" | "baseUrl" | "replaceOptionalWithNullish" | "infiniteQueries" | "axiosRequestConfig" | "invalidateQueryOptions">;
|
|
7
7
|
export declare function generate({ input, excludeTags, prettier, verbose, ...params }: GenerateParams): Promise<void>;
|
|
@@ -16,3 +16,9 @@ export declare enum StandaloneAssetEnum {
|
|
|
16
16
|
}
|
|
17
17
|
export declare const STANDALONE_ASSETS: Record<StandaloneAssetEnum, GenerateFile>;
|
|
18
18
|
export declare const STANDALONE_APP_REST_CLIENT_FILE: GenerateFile;
|
|
19
|
+
export declare const INVALIDATE_QUERIES: {
|
|
20
|
+
optionsType: string;
|
|
21
|
+
functionName: string;
|
|
22
|
+
};
|
|
23
|
+
export declare const INVALIDATE_QUERY_OPTIONS_FILE: GenerateFile;
|
|
24
|
+
export declare const QUERY_MODULES_FILE: GenerateFile;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SchemaResolver } from "src/generators/core/SchemaResolver.class";
|
|
2
2
|
import { Endpoint } from "../../types/endpoint";
|
|
3
|
-
import { Import } from "../../types/generate";
|
|
3
|
+
import { GenerateType, Import } from "../../types/generate";
|
|
4
4
|
import { GenerateOptions } from "../../types/options";
|
|
5
5
|
export declare function getModelsImports({ resolver, tag, zodSchemas, zodSchemasAsTypes, }: {
|
|
6
6
|
resolver: SchemaResolver;
|
|
@@ -13,10 +13,13 @@ export declare function getEndpointsImports({ tag, endpoints, options, }: {
|
|
|
13
13
|
endpoints: Endpoint[];
|
|
14
14
|
options: GenerateOptions;
|
|
15
15
|
}): Import[];
|
|
16
|
-
export declare function
|
|
16
|
+
export declare function getEntityImports({ tags, entityName, getAliasEntityName, type, sameDir, options, }: {
|
|
17
17
|
tags: string[];
|
|
18
18
|
entityName: string;
|
|
19
19
|
getAliasEntityName?: (tag: string) => string;
|
|
20
|
+
type: GenerateType;
|
|
21
|
+
sameDir?: boolean;
|
|
20
22
|
options: GenerateOptions;
|
|
21
23
|
}): Import[];
|
|
22
|
-
export declare function getImportPath(options: Pick<GenerateOptions, "output" | "importPath"
|
|
24
|
+
export declare function getImportPath(options: Pick<GenerateOptions, "output" | "importPath">, sameDir?: boolean): string;
|
|
25
|
+
export declare function mergeImports(options: GenerateOptions, ...importArrs: Import[][]): Import[];
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import { Endpoint } from "../../types/endpoint";
|
|
2
2
|
export declare const getQueryName: (endpoint: Endpoint) => string;
|
|
3
3
|
export declare const getInfiniteQueryName: (endpoint: Endpoint) => string;
|
|
4
|
+
export declare const getTagModuleName: (tag: string) => string;
|
|
5
|
+
export declare const getTagKeys: (tag: string) => string;
|
|
@@ -16,4 +16,5 @@ export declare const getNamespaceName: ({ type, tag, options, }: {
|
|
|
16
16
|
}) => string;
|
|
17
17
|
export declare function getAppRestClientImportPath(options: GenerateOptions): string;
|
|
18
18
|
export declare function getQueryTypesImportPath(options: GenerateOptions): string;
|
|
19
|
+
export declare function getInvalidateQueriesImportPath(options: GenerateOptions): string;
|
|
19
20
|
export {};
|