@povio/openapi-codegen-cli 0.2.9 → 0.3.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.
@@ -2,6 +2,7 @@ export type GenerateParams = {
2
2
  input: string;
3
3
  output: string;
4
4
  includeNamespaces: boolean;
5
+ useRelativeImports: boolean;
5
6
  splitByTags: boolean;
6
7
  defaultTag: string;
7
8
  excludeTags: string;
@@ -9,4 +10,4 @@ export type GenerateParams = {
9
10
  prettier: boolean;
10
11
  verbose: boolean;
11
12
  };
12
- export declare function generate({ input, output, includeNamespaces, splitByTags, defaultTag, excludeTags, removeOperationPrefixEndingWith, prettier, verbose, }: GenerateParams): Promise<void>;
13
+ export declare function generate({ input, output, includeNamespaces, useRelativeImports, splitByTags, defaultTag, excludeTags, removeOperationPrefixEndingWith, prettier, verbose, }: GenerateParams): Promise<void>;
@@ -2,10 +2,11 @@ import { OpenAPIV3 } from "openapi-types";
2
2
  import { EndpointParameter } from "src/generators/types/endpoint";
3
3
  import { GenerateOptions } from "src/generators/types/options";
4
4
  import { SchemaResolver } from "../SchemaResolver.class";
5
- export declare function getEndpointBody({ resolver, operation, operationName, tag, options, }: {
5
+ export declare function getEndpointBody({ resolver, operation, operationName, isUniqueOperationName, tag, options, }: {
6
6
  resolver: SchemaResolver;
7
7
  operation: OpenAPIV3.OperationObject;
8
8
  operationName: string;
9
+ isUniqueOperationName: boolean;
9
10
  tag: string;
10
11
  options: GenerateOptions;
11
12
  }): {
@@ -2,10 +2,11 @@ import { OpenAPIV3 } from "openapi-types";
2
2
  import { EndpointParameter } from "src/generators/types/endpoint";
3
3
  import { GenerateOptions } from "src/generators/types/options";
4
4
  import { SchemaResolver } from "../SchemaResolver.class";
5
- export declare function getEndpointParameter({ resolver, param, operationName, tag, options, }: {
5
+ export declare function getEndpointParameter({ resolver, param, operationName, isUniqueOperationName, tag, options, }: {
6
6
  resolver: SchemaResolver;
7
7
  param: OpenAPIV3.ReferenceObject | OpenAPIV3.ParameterObject;
8
8
  operationName: string;
9
+ isUniqueOperationName: boolean;
9
10
  tag: string;
10
11
  options: GenerateOptions;
11
12
  }): EndpointParameter | undefined;
@@ -4,45 +4,45 @@ export interface GenerateMetadataParams {
4
4
  input: string;
5
5
  options?: Partial<GenerateOptions>;
6
6
  }
7
- export interface TsType {
7
+ export interface TsTypeBase {
8
8
  type: string;
9
9
  namespace?: string;
10
10
  filePath?: string;
11
11
  }
12
- export type TsNestedType = TsType & TsMetaType;
13
- export type TsProperty = {
12
+ export type TsType = TsTypeBase & TsMetaType;
13
+ export type TsPropertyBase = {
14
14
  name: string;
15
15
  isRequired: boolean;
16
- } & TsType;
17
- export type TsNestedProperty = TsProperty & TsMetaType;
16
+ } & TsTypeBase;
17
+ export type TsProperty = TsPropertyBase & TsMetaType;
18
18
  export interface TsPrimitiveMetaType {
19
19
  metaType: "primitive";
20
20
  }
21
21
  export interface TsObjectMetaType {
22
22
  metaType: "object";
23
- objectProperties: TsNestedProperty[];
23
+ objectProperties: TsProperty[];
24
24
  isCircular?: boolean;
25
25
  }
26
26
  export interface TsArrayMetaType {
27
27
  metaType: "array";
28
- arrayType: TsNestedType;
28
+ arrayType: TsType;
29
29
  }
30
30
  export interface TsCompositeMetaType {
31
31
  metaType: "composite";
32
- allOf?: TsNestedType[];
33
- oneOf?: TsNestedType[];
34
- anyOf?: TsNestedType[];
32
+ allOf?: TsType[];
33
+ oneOf?: TsType[];
34
+ anyOf?: TsType[];
35
35
  }
36
36
  export type TsMetaType = TsPrimitiveMetaType | TsObjectMetaType | TsArrayMetaType | TsCompositeMetaType;
37
- export type ModelMetadata = TsNestedType;
37
+ export type ModelMetadata = TsType;
38
38
  export type QueryMetadata = {
39
39
  name: string;
40
40
  filePath: string;
41
41
  namespace?: string;
42
42
  isQuery: boolean;
43
43
  isMutation: boolean;
44
- params: TsNestedProperty[];
45
- response: TsNestedType;
44
+ params: TsProperty[];
45
+ response: TsType;
46
46
  };
47
47
  export interface GenerateMetadata {
48
48
  openApiDoc: OpenAPIV3.Document;
@@ -14,4 +14,4 @@ export declare function getEndpointsImports({ tag, endpoints, options, }: {
14
14
  endpoints: Endpoint[];
15
15
  options: GenerateOptions;
16
16
  }): Import[];
17
- export declare function getTsPath(options: Pick<GenerateOptions, "output">): string;
17
+ export declare function getImportPath(options: Pick<GenerateOptions, "output" | "useRelativeImports">): string;
@@ -31,6 +31,7 @@ export declare function getUniqueOperationName({ path, method, operation, openAp
31
31
  openApiDoc: OpenAPIV3.Document;
32
32
  options: GenerateOptions;
33
33
  }): string;
34
+ export declare function isUniqueOperationNameWithoutSplitByTags(operationName: string, openApiDoc: OpenAPIV3.Document, options: GenerateOptions): boolean;
34
35
  export declare function formatTag(tag: string): string;
35
36
  export declare function getOperationTag(operation: OpenAPIV3.OperationObject, options: GenerateOptions): string;
36
37
  /** @example turns `/media-objects/{id}` into `MediaObjectsById` */
@@ -1,19 +1,19 @@
1
1
  import { OpenAPIV3 } from "openapi-types";
2
2
  import { SchemaResolver } from "../core/SchemaResolver.class";
3
- import { TsMetaType, TsType } from "../types/metadata";
3
+ import { TsMetaType, TsTypeBase } from "../types/metadata";
4
4
  import { PrimitiveType } from "../types/openapi";
5
5
  import { GenerateOptions } from "../types/options";
6
6
  export declare function primitiveTypeToTsType(type: PrimitiveType): string;
7
- export declare function getTsType({ zodSchemaName, schema, resolver, options, }: {
7
+ export declare function getTsTypeBase({ zodSchemaName, schema, resolver, options, }: {
8
8
  zodSchemaName?: string;
9
9
  schema?: OpenAPIV3.SchemaObject;
10
10
  resolver: SchemaResolver;
11
11
  options: GenerateOptions;
12
- }): TsType;
12
+ }): TsTypeBase;
13
13
  export declare function getSchemaTsMetaType({ schema, isCircular, parentTypes, resolver, options, }: {
14
14
  schema?: OpenAPIV3.SchemaObject;
15
15
  isCircular?: boolean;
16
- parentTypes: TsType[];
16
+ parentTypes: TsTypeBase[];
17
17
  resolver: SchemaResolver;
18
18
  options: GenerateOptions;
19
19
  }): TsMetaType;
@@ -1,5 +1,6 @@
1
1
  export declare const getZodSchemaName: (name: string, schemaSuffix: string) => string;
2
2
  export declare const isNamedZodSchema: (schema: string) => boolean;
3
+ export declare const getZodSchemaOperationName: (operationName: string, isUniqueOperationName: boolean, tag: string) => string;
3
4
  export declare const getBodyZodSchemaName: (operationName: string) => string;
4
5
  export declare const getParamZodSchemaName: (operationName: string, paramName: string) => string;
5
6
  export declare const getMainResponseZodSchemaName: (operationName: string) => string;