codegen-openapi-ts 0.8.0-alpha.10 → 0.8.0-alpha.12

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.
Files changed (2) hide show
  1. package/dist/index.d.ts +50 -3
  2. package/package.json +1 -1
package/dist/index.d.ts CHANGED
@@ -51,18 +51,37 @@ export declare function generate({ input, output, httpClient, useOptions, useUni
51
51
  */
52
52
  export declare function convertAndGenerate({ from, source }: ConverterInput, { input, output, useOptions, useUnionTypes }: Options, urlMethodMapping?: ServiceConfigWithMappings['urlMethodMapping'], selectedOnly?: ServiceConfigWithMappings['selectedOnly'], modelNameMapping?: BaseServiceConfig['modelNameMapping'], appendTemplate?: ReturnType<typeof defineConfig>['appendTemplate'], proxyConfig?: BaseServiceConfig['proxyConfig']): Promise<void>;
53
53
  export declare type BaseServiceConfig = {
54
+ /**
55
+ * API Docs request url for the json response
56
+ */
54
57
  source: string;
58
+ /**
59
+ * Specify the API specs response format version
60
+ */
55
61
  from: 'swagger_1' | 'swagger_2' | 'openapi_3' | 'api_blueprint' | 'io_docs' | 'google' | 'raml' | 'wadl';
62
+ /**
63
+ * Specify the folder for the codegen output
64
+ */
56
65
  output: string;
66
+ /**
67
+ * Create a function for proxying the request
68
+ * @example
69
+ * {
70
+ * // ... other config
71
+ * proxyConfig: (path) => {
72
+ * return path.replace('/api/', '/be/')
73
+ * }
74
+ * }
75
+ * @param {string} path
76
+ */
57
77
  proxyConfig?: (path: string) => string;
58
78
  /**
59
79
  * Can be used to replace long model names specified on the schema.
60
- * Please use the api-schema.json generated on root project files
80
+ * Please use the api-schema.json generated on root project folder
61
81
  * to debug the desired results. Also note that the original schema name
62
82
  * with dot (.) will be generated as underscore (_). Example:
63
83
  * some.long.name will be generated as some_long_name,
64
84
  * if this modelNameMapping supplied
65
- * @param {string} json: stringified json schema
66
85
  * @example
67
86
  * {
68
87
  * // ... other config
@@ -71,7 +90,8 @@ export declare type BaseServiceConfig = {
71
90
  * return config.replace(new RegExp('some.long.name', g), 'shortname')
72
91
  * }
73
92
  * }
74
- * @returns {string}
93
+ *
94
+ * @param {string} json - stringified json schema
75
95
  */
76
96
  modelNameMapping?: (json: string) => string;
77
97
  };
@@ -80,16 +100,43 @@ export declare type ServiceConfigDefault = BaseServiceConfig & {
80
100
  selectedOnly: undefined;
81
101
  };
82
102
  export declare type ServiceConfigWithMappings = BaseServiceConfig & {
103
+ /**
104
+ * Custom spec paths mapping. You can configure to rename the method name
105
+ * or customise the proxyUrl for the specific API
106
+ *
107
+ * @example
108
+ * {
109
+ * // ... other config
110
+ * urlMethodMapping: [
111
+ * { originalUrl: '/pokemon-list', method: 'get', methodName: 'GetPokemonList' },
112
+ * { originalUrl: '/pokemon-detail/{id}', method: 'get', methodName: 'GetPokemonList', proxyUrl: '/proxy/pokemon-detail/{id}' }
113
+ * ]
114
+ * }
115
+ *
116
+ */
83
117
  urlMethodMapping: {
84
118
  originalUrl: string;
85
119
  method: 'get' | 'post' | 'put' | 'delete';
86
120
  methodName: string;
87
121
  proxyUrl?: string;
88
122
  }[];
123
+ /**
124
+ * Flag to only generate listed specs based on urlMethodMapping.
125
+ * The codegen will still generate all the models listed on the api specs
126
+ */
89
127
  selectedOnly: boolean;
90
128
  };
129
+ /**
130
+ * Type helper to make it easier to use codegen.config.js
131
+ */
91
132
  export declare function defineConfig(config: {
133
+ /**
134
+ * Custom api templates append on top of service files
135
+ */
92
136
  appendTemplate?: string;
137
+ /**
138
+ * List config for every services
139
+ */
93
140
  services: (ServiceConfigDefault | ServiceConfigWithMappings)[];
94
141
  }): {
95
142
  appendTemplate?: string | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codegen-openapi-ts",
3
- "version": "0.8.0-alpha.10",
3
+ "version": "0.8.0-alpha.12",
4
4
  "description": "Library that generates Typescript clients based on the OpenAPI specification.",
5
5
  "author": "devteaa",
6
6
  "homepage": "https://github.com/devteaa/codegen-openapi-ts",