Skip to content

Commit ece1df2

Browse files
scarf005Goopher Maijenburg
authored andcommitted
[typescript-axios]: slim down jsdoc (OpenAPITools#21776)
* feat: remove `@export` and more * feat: remove `@memberof` * feat: only add description jsdoc if it exists * feat: remove obvious `@type` * feat: only display JSDoc when `description` OR `deprecated` exists * chore: update generator output --------- Co-authored-by: nocontribute <>
1 parent 1ce3ade commit ece1df2

File tree

81 files changed

+148
-6181
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+148
-6181
lines changed

modules/openapi-generator/src/main/resources/typescript-axios/apiInner.mustache

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import type { {{classname}} } from '{{apiRelativeToRoot}}{{tsModelPackage}}{{imp
3131
/**
3232
* {{classname}} - axios parameter creator{{#description}}
3333
* {{&description}}{{/description}}
34-
* @export
3534
*/
3635
export const {{classname}}AxiosParamCreator = function (configuration?: Configuration) {
3736
return {
@@ -246,7 +245,6 @@ export const {{classname}}AxiosParamCreator = function (configuration?: Configur
246245
/**
247246
* {{classname}} - functional programming interface{{#description}}
248247
* {{{.}}}{{/description}}
249-
* @export
250248
*/
251249
export const {{classname}}Fp = function(configuration?: Configuration) {
252250
const localVarAxiosParamCreator = {{classname}}AxiosParamCreator(configuration)
@@ -277,7 +275,6 @@ export const {{classname}}Fp = function(configuration?: Configuration) {
277275
/**
278276
* {{classname}} - factory interface{{#description}}
279277
* {{&description}}{{/description}}
280-
* @export
281278
*/
282279
export const {{classname}}Factory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
283280
const localVarFp = {{classname}}Fp(configuration)
@@ -320,8 +317,6 @@ export const {{classname}}Factory = function (configuration?: Configuration, bas
320317
/**
321318
* {{classname}} - interface{{#description}}
322319
* {{&description}}{{/description}}
323-
* @export
324-
* @interface {{classname}}
325320
*/
326321
export interface {{classname}}Interface {
327322
{{#operation}}
@@ -343,7 +338,6 @@ export interface {{classname}}Interface {
343338
* @param {*} [options] Override http request option.{{#isDeprecated}}
344339
* @deprecated{{/isDeprecated}}
345340
* @throws {RequiredError}
346-
* @memberof {{classname}}Interface
347341
*/
348342
{{#useSingleRequestParameter}}
349343
{{nickname}}({{#allParams.0}}requestParameters{{^hasRequiredParams}}?{{/hasRequiredParams}}: {{classname}}{{operationIdCamelCase}}Request, {{/allParams.0}}options?: RawAxiosRequestConfig): AxiosPromise<{{{returnType}}}{{^returnType}}void{{/returnType}}>;
@@ -361,16 +355,14 @@ export interface {{classname}}Interface {
361355
{{#allParams.0}}
362356
/**
363357
* Request parameters for {{nickname}} operation in {{classname}}.
364-
* @export
365-
* @interface {{classname}}{{operationIdCamelCase}}Request
366358
*/
367359
export interface {{classname}}{{operationIdCamelCase}}Request {
368360
{{#allParams}}
361+
{{#description}}
369362
/**
370363
* {{description}}
371-
* @type {{=<% %>=}}{<%&dataType%>}<%={{ }}=%>
372-
* @memberof {{classname}}{{operationIdCamelCase}}
373364
*/
365+
{{/description}}
374366
readonly {{paramName}}{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{#isNullable}} | null{{/isNullable}}{{/isEnum}}
375367
{{^-last}}
376368

@@ -384,9 +376,6 @@ export interface {{classname}}{{operationIdCamelCase}}Request {
384376
/**
385377
* {{classname}} - object-oriented interface{{#description}}
386378
* {{{.}}}{{/description}}
387-
* @export
388-
* @class {{classname}}
389-
* @extends {BaseAPI}
390379
*/
391380
{{#withInterfaces}}
392381
export class {{classname}} extends BaseAPI implements {{classname}}Interface {
@@ -413,7 +402,6 @@ export class {{classname}} extends BaseAPI {
413402
* @param {*} [options] Override http request option.{{#isDeprecated}}
414403
* @deprecated{{/isDeprecated}}
415404
* @throws {RequiredError}
416-
* @memberof {{classname}}
417405
*/
418406
{{#useSingleRequestParameter}}
419407
public {{nickname}}({{#allParams.0}}requestParameters: {{classname}}{{operationIdCamelCase}}Request{{^hasRequiredParams}} = {}{{/hasRequiredParams}}, {{/allParams.0}}options?: RawAxiosRequestConfig) {
@@ -437,10 +425,6 @@ export class {{classname}} extends BaseAPI {
437425
{{#allParams}}
438426
{{#isEnum}}
439427
{{#stringEnums}}
440-
/**
441-
* @export
442-
* @enum {string}
443-
*/
444428
export enum {{operationIdCamelCase}}{{enumName}} {
445429
{{#allowableValues}}
446430
{{#enumVars}}
@@ -450,9 +434,6 @@ export enum {{operationIdCamelCase}}{{enumName}} {
450434
}
451435
{{/stringEnums}}
452436
{{^stringEnums}}
453-
/**
454-
* @export
455-
*/
456437
export const {{operationIdCamelCase}}{{enumName}} = {
457438
{{#allowableValues}}
458439
{{#enumVars}}

modules/openapi-generator/src/main/resources/typescript-axios/baseApi.mustache

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -11,32 +11,18 @@ import globalAxios from 'axios';
1111

1212
export const BASE_PATH = "{{{basePath}}}".replace(/\/+$/, "");
1313

14-
/**
15-
*
16-
* @export
17-
*/
1814
export const COLLECTION_FORMATS = {
1915
csv: ",",
2016
ssv: " ",
2117
tsv: "\t",
2218
pipes: "|",
2319
};
2420

25-
/**
26-
*
27-
* @export
28-
* @interface RequestArgs
29-
*/
3021
export interface RequestArgs {
3122
url: string;
3223
options: RawAxiosRequestConfig;
3324
}
3425

35-
/**
36-
*
37-
* @export
38-
* @class BaseAPI
39-
*/
4026
export class BaseAPI {
4127
protected configuration: Configuration | undefined;
4228
@@ -48,12 +34,6 @@ export class BaseAPI {
4834
}
4935
};
5036

51-
/**
52-
*
53-
* @export
54-
* @class RequiredError
55-
* @extends {Error}
56-
*/
5737
export class RequiredError extends Error {
5838
constructor(public field: string, msg?: string) {
5939
super(msg);
@@ -68,10 +48,6 @@ interface ServerMap {
6848
}[];
6949
}
7050

71-
/**
72-
*
73-
* @export
74-
*/
7551
export const operationServerMap: ServerMap = {
7652
{{#apiInfo}}
7753
{{#apis}}

modules/openapi-generator/src/main/resources/typescript-axios/common.mustache

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,18 @@ import { RequiredError } from "./base{{importFileExtension}}";
1111
import { URL, URLSearchParams } from 'url';
1212
{{/withNodeImports}}
1313

14-
/**
15-
*
16-
* @export
17-
*/
1814
export const DUMMY_BASE_URL = 'https://example.com'
1915

2016
/**
2117
*
2218
* @throws {RequiredError}
23-
* @export
2419
*/
2520
export const assertParamExists = function (functionName: string, paramName: string, paramValue: unknown) {
2621
if (paramValue === null || paramValue === undefined) {
2722
throw new RequiredError(paramName, `Required parameter ${paramName} was null or undefined when calling ${functionName}.`);
2823
}
2924
}
3025

31-
/**
32-
*
33-
* @export
34-
*/
3526
export const setApiKeyToObject = async function (object: any, keyParamName: string, configuration?: Configuration) {
3627
if (configuration && configuration.apiKey) {
3728
const localVarApiKeyValue = typeof configuration.apiKey === 'function'
@@ -41,20 +32,12 @@ export const setApiKeyToObject = async function (object: any, keyParamName: stri
4132
}
4233
}
4334

44-
/**
45-
*
46-
* @export
47-
*/
4835
export const setBasicAuthToObject = function (object: any, configuration?: Configuration) {
4936
if (configuration && (configuration.username || configuration.password)) {
5037
object["auth"] = { username: configuration.username, password: configuration.password };
5138
}
5239
}
5340

54-
/**
55-
*
56-
* @export
57-
*/
5841
export const setBearerAuthToObject = async function (object: any, configuration?: Configuration) {
5942
if (configuration && configuration.accessToken) {
6043
const accessToken = typeof configuration.accessToken === 'function'
@@ -64,10 +47,6 @@ export const setBearerAuthToObject = async function (object: any, configuration?
6447
}
6548
}
6649

67-
/**
68-
*
69-
* @export
70-
*/
7150
export const setOAuthToObject = async function (object: any, name: string, scopes: string[], configuration?: Configuration) {
7251
if (configuration && configuration.accessToken) {
7352
const localVarAccessTokenValue = typeof configuration.accessToken === 'function'
@@ -99,20 +78,12 @@ function setFlattenedQueryParams(urlSearchParams: URLSearchParams, parameter: an
9978
}
10079
}
10180

102-
/**
103-
*
104-
* @export
105-
*/
10681
export const setSearchParams = function (url: URL, ...objects: any[]) {
10782
const searchParams = new URLSearchParams(url.search);
10883
setFlattenedQueryParams(searchParams, objects);
10984
url.search = searchParams.toString();
11085
}
11186

112-
/**
113-
*
114-
* @export
115-
*/
11687
export const serializeDataIfNeeded = function (value: any, requestOptions: any, configuration?: Configuration) {
11788
const nonString = typeof value !== 'string';
11889
const needsSerialization = nonString && configuration && configuration.isJsonMime
@@ -123,18 +94,10 @@ export const serializeDataIfNeeded = function (value: any, requestOptions: any,
12394
: (value || "");
12495
}
12596

126-
/**
127-
*
128-
* @export
129-
*/
13097
export const toPathString = function (url: URL) {
13198
return url.pathname + url.search + url.hash
13299
}
133100

134-
/**
135-
*
136-
* @export
137-
*/
138101
export const createRequestFunction = function (axiosArgs: RequestArgs, globalAxios: AxiosInstance, BASE_PATH: string, configuration?: Configuration) {
139102
return <T = unknown, R = AxiosResponse<T>>(axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
140103
const axiosRequestArgs = {...axiosArgs.options, url: (axios.defaults.baseURL ? '' : configuration?.basePath ?? basePath) + axiosArgs.url};

modules/openapi-generator/src/main/resources/typescript-axios/configuration.mustache

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,49 +18,32 @@ export class Configuration {
1818
/**
1919
* parameter for apiKey security
2020
* @param name security name
21-
* @memberof Configuration
2221
*/
2322
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
2423
/**
2524
* parameter for basic security
26-
*
27-
* @type {string}
28-
* @memberof Configuration
2925
*/
3026
username?: string;
3127
/**
3228
* parameter for basic security
33-
*
34-
* @type {string}
35-
* @memberof Configuration
3629
*/
3730
password?: string;
3831
/**
3932
* parameter for oauth2 security
4033
* @param name security name
4134
* @param scopes oauth2 scope
42-
* @memberof Configuration
4335
*/
4436
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
4537
/**
4638
* override base path
47-
*
48-
* @type {string}
49-
* @memberof Configuration
5039
*/
5140
basePath?: string;
5241
/**
5342
* override server index
54-
*
55-
* @type {number}
56-
* @memberof Configuration
5743
*/
5844
serverIndex?: number;
5945
/**
6046
* base options for axios calls
61-
*
62-
* @type {any}
63-
* @memberof Configuration
6447
*/
6548
baseOptions?: any;
6649
/**
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/**
22
* @type {{classname}}{{#description}}
33
* {{{.}}}{{/description}}
4-
* @export
54
*/
65
export type {{classname}} = {{#allOf}}{{{.}}}{{^-last}} & {{/-last}}{{/allOf}};

modules/openapi-generator/src/main/resources/typescript-axios/modelEnum.mustache

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
{{#description}}
12
/**
23
* {{{description}}}
3-
* @export
4-
* @enum {{=<% %>=}}{<%&dataType%>}<%={{ }}=%>
54
*/
5+
{{/description}}
66
{{#isBoolean}}
77
export type {{classname}} = {{#allowableValues}}{{#enumVars}}{{{value}}}{{^-last}} | {{/-last}}{{/enumVars}}{{/allowableValues}}
88
{{/isBoolean}}

modules/openapi-generator/src/main/resources/typescript-axios/modelGeneric.mustache

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,39 @@
1+
{{#description}}
12
/**
23
* {{{description}}}
3-
* @export
4-
* @interface {{classname}}
54
*/
5+
{{/description}}
66
export interface {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{
77
{{#additionalPropertiesType}}
88
[key: string]: {{{additionalPropertiesType}}}{{#additionalPropertiesIsAnyType}}{{#hasVars}} | any{{/hasVars}}{{/additionalPropertiesIsAnyType}};
99

1010
{{/additionalPropertiesType}}
1111
{{#vars}}
12+
{{#description}}
1213
/**
13-
* {{{description}}}
14-
* @type {{=<% %>=}}{<%&datatype%>}<%={{ }}=%>
15-
* @memberof {{classname}}
14+
* {{{description}}}
1615
{{#deprecated}}
17-
* @deprecated
16+
* @deprecated
1817
{{/deprecated}}
19-
*/
18+
*/
19+
{{/description}}
20+
{{^description}}
21+
{{#deprecated}}
22+
/**
23+
*
24+
{{#deprecated}}
25+
* @deprecated
26+
{{/deprecated}}
27+
*/
28+
{{/deprecated}}
29+
{{/description}}
2030
'{{baseName}}'{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}{{#isNullable}} | null{{/isNullable}};
2131
{{/vars}}
2232
}{{#hasEnums}}
2333

2434
{{#vars}}
2535
{{#isEnum}}
2636
{{#stringEnums}}
27-
/**
28-
* @export
29-
* @enum {string}
30-
*/
3137
export enum {{enumName}} {
3238
{{#allowableValues}}
3339
{{#enumVars}}

modules/openapi-generator/src/main/resources/typescript-axios/modelOneOf.mustache

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/**
22
* @type {{classname}}{{#description}}
33
* {{{.}}}{{/description}}
4-
* @export
54
*/
65
export type {{classname}} = {{#discriminator}}{{!
76

0 commit comments

Comments
 (0)