From 020cbc4cb1bc76e00432945fbd95a8c807101fef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dan=20Michael=20O=2E=20Hegg=C3=B8?= Date: Tue, 27 Dec 2022 18:11:18 +0100 Subject: [PATCH 1/4] Rename 'extensionForDeno' to 'importFileExtension' --- .../languages/TypeScriptClientCodegen.java | 2 +- .../resources/typescript/api/api.mustache | 16 +++++----- .../resources/typescript/api/baseapi.mustache | 2 +- .../typescript/api/middleware.mustache | 4 +-- .../resources/typescript/auth/auth.mustache | 2 +- .../typescript/configuration.mustache | 10 +++--- .../resources/typescript/http/http.mustache | 2 +- .../typescript/http/isomorphic-fetch.mustache | 4 +-- .../typescript/http/servers.mustache | 2 +- .../main/resources/typescript/index.mustache | 32 +++++++++---------- .../model/ObjectSerializer.mustache | 4 +-- .../resources/typescript/model/model.mustache | 4 +-- .../typescript/model/models_all.mustache | 2 +- .../typescript/types/ObjectParamAPI.mustache | 10 +++--- .../typescript/types/ObservableAPI.mustache | 16 +++++----- .../typescript/types/PromiseAPI.mustache | 10 +++--- 16 files changed, 61 insertions(+), 61 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java index 2e4f34c64659..5c88a0f26f41 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java @@ -836,7 +836,7 @@ public void processOpts() { } if ("deno".equals(propPlatform)) { - additionalProperties.put("extensionForDeno", ".ts"); + additionalProperties.put("importFileExtension", ".ts"); } final boolean useRxJS = convertPropertyToBooleanAndWriteBack(USE_RXJS_SWITCH); diff --git a/modules/openapi-generator/src/main/resources/typescript/api/api.mustache b/modules/openapi-generator/src/main/resources/typescript/api/api.mustache index a28b911bd11c..1770f54dfa25 100644 --- a/modules/openapi-generator/src/main/resources/typescript/api/api.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/api/api.mustache @@ -1,24 +1,24 @@ // TODO: better import syntax? -import {BaseAPIRequestFactory, RequiredError, COLLECTION_FORMATS} from './baseapi{{extensionForDeno}}'; -import {Configuration} from '../configuration{{extensionForDeno}}'; -import {RequestContext, HttpMethod, ResponseContext, HttpFile} from '../http/http{{extensionForDeno}}'; +import {BaseAPIRequestFactory, RequiredError, COLLECTION_FORMATS} from './baseapi{{importFileExtension}}'; +import {Configuration} from '../configuration{{importFileExtension}}'; +import {RequestContext, HttpMethod, ResponseContext, HttpFile} from '../http/http{{importFileExtension}}'; {{#platforms}} {{#node}} import {{^supportsES6}}* as{{/supportsES6}} FormData from "form-data"; import { URLSearchParams } from 'url'; {{/node}} {{/platforms}} -import {ObjectSerializer} from '../models/ObjectSerializer{{extensionForDeno}}'; -import {ApiException} from './exception{{extensionForDeno}}'; -import {canConsumeForm, isCodeInRange} from '../util{{extensionForDeno}}'; -import {SecurityAuthentication} from '../auth/auth{{extensionForDeno}}'; +import {ObjectSerializer} from '../models/ObjectSerializer{{importFileExtension}}'; +import {ApiException} from './exception{{importFileExtension}}'; +import {canConsumeForm, isCodeInRange} from '../util{{importFileExtension}}'; +import {SecurityAuthentication} from '../auth/auth{{importFileExtension}}'; {{#useInversify}} import { injectable } from "inversify"; {{/useInversify}} {{#imports}} -import { {{classname}} } from '{{filename}}{{extensionForDeno}}'; +import { {{classname}} } from '{{filename}}{{importFileExtension}}'; {{/imports}} {{#operations}} diff --git a/modules/openapi-generator/src/main/resources/typescript/api/baseapi.mustache b/modules/openapi-generator/src/main/resources/typescript/api/baseapi.mustache index d2ee2290fb24..206a5f0cc55e 100644 --- a/modules/openapi-generator/src/main/resources/typescript/api/baseapi.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/api/baseapi.mustache @@ -1,4 +1,4 @@ -import { Configuration } from '../configuration{{extensionForDeno}}' +import { Configuration } from '../configuration{{importFileExtension}}' {{#useInversify}} import { injectable, inject } from "inversify"; import { AbstractConfiguration } from "../services/configuration"; diff --git a/modules/openapi-generator/src/main/resources/typescript/api/middleware.mustache b/modules/openapi-generator/src/main/resources/typescript/api/middleware.mustache index 259e594f5335..313188d3ed5c 100644 --- a/modules/openapi-generator/src/main/resources/typescript/api/middleware.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/api/middleware.mustache @@ -1,5 +1,5 @@ -import {RequestContext, ResponseContext} from './http/http{{extensionForDeno}}'; -import { Observable, from } from {{#useRxJS}}'rxjs'{{/useRxJS}}{{^useRxJS}}'./rxjsStub{{extensionForDeno}}'{{/useRxJS}}; +import {RequestContext, ResponseContext} from './http/http{{importFileExtension}}'; +import { Observable, from } from {{#useRxJS}}'rxjs'{{/useRxJS}}{{^useRxJS}}'./rxjsStub{{importFileExtension}}'{{/useRxJS}}; /** * Defines the contract for a middleware intercepting requests before diff --git a/modules/openapi-generator/src/main/resources/typescript/auth/auth.mustache b/modules/openapi-generator/src/main/resources/typescript/auth/auth.mustache index 429a2e8f5cde..4263017a2790 100644 --- a/modules/openapi-generator/src/main/resources/typescript/auth/auth.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/auth/auth.mustache @@ -1,4 +1,4 @@ -import { RequestContext } from "../http/http{{extensionForDeno}}"; +import { RequestContext } from "../http/http{{importFileExtension}}"; {{#useInversify}} import { injectable, inject, named } from "inversify"; import { AbstractTokenProvider } from "../services/configuration"; diff --git a/modules/openapi-generator/src/main/resources/typescript/configuration.mustache b/modules/openapi-generator/src/main/resources/typescript/configuration.mustache index 38f46ded384c..a281b22db0a3 100644 --- a/modules/openapi-generator/src/main/resources/typescript/configuration.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/configuration.mustache @@ -1,15 +1,15 @@ -import { HttpLibrary } from "./http/http{{extensionForDeno}}"; -import { Middleware, PromiseMiddleware, PromiseMiddlewareWrapper } from "./middleware{{extensionForDeno}}"; +import { HttpLibrary } from "./http/http{{importFileExtension}}"; +import { Middleware, PromiseMiddleware, PromiseMiddlewareWrapper } from "./middleware{{importFileExtension}}"; {{#frameworks}} {{#fetch-api}} -import { IsomorphicFetchHttpLibrary as DefaultHttpLibrary } from "./http/isomorphic-fetch{{extensionForDeno}}"; +import { IsomorphicFetchHttpLibrary as DefaultHttpLibrary } from "./http/isomorphic-fetch{{importFileExtension}}"; {{/fetch-api}} {{#jquery}} import { JQueryHttpLibrary as DefaultHttpLibrary } from "./http/jquery"; {{/jquery}} {{/frameworks}} -import { BaseServerConfiguration, server1 } from "./servers{{extensionForDeno}}"; -import { configureAuthMethods, AuthMethods, AuthMethodsConfiguration } from "./auth/auth{{extensionForDeno}}"; +import { BaseServerConfiguration, server1 } from "./servers{{importFileExtension}}"; +import { configureAuthMethods, AuthMethods, AuthMethodsConfiguration } from "./auth/auth{{importFileExtension}}"; export interface Configuration { readonly baseServer: BaseServerConfiguration; diff --git a/modules/openapi-generator/src/main/resources/typescript/http/http.mustache b/modules/openapi-generator/src/main/resources/typescript/http/http.mustache index 52fdb8754f21..2cc4f4a12845 100644 --- a/modules/openapi-generator/src/main/resources/typescript/http/http.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/http/http.mustache @@ -12,7 +12,7 @@ import * as https from 'https'; import {{^supportsES6}}* as{{/supportsES6}} URLParse from "url-parse"; {{/deno}} {{/platforms}} -import { Observable, from } from {{#useRxJS}}'rxjs'{{/useRxJS}}{{^useRxJS}}'../rxjsStub{{extensionForDeno}}'{{/useRxJS}}; +import { Observable, from } from {{#useRxJS}}'rxjs'{{/useRxJS}}{{^useRxJS}}'../rxjsStub{{importFileExtension}}'{{/useRxJS}}; {{#platforms}} {{^deno}} diff --git a/modules/openapi-generator/src/main/resources/typescript/http/isomorphic-fetch.mustache b/modules/openapi-generator/src/main/resources/typescript/http/isomorphic-fetch.mustache index 57b1ae594f6f..1ebbe5a3a9ee 100644 --- a/modules/openapi-generator/src/main/resources/typescript/http/isomorphic-fetch.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/http/isomorphic-fetch.mustache @@ -1,5 +1,5 @@ -import {HttpLibrary, RequestContext, ResponseContext} from './http{{extensionForDeno}}'; -import { from, Observable } from {{#useRxJS}}'rxjs'{{/useRxJS}}{{^useRxJS}}'../rxjsStub{{extensionForDeno}}'{{/useRxJS}}; +import {HttpLibrary, RequestContext, ResponseContext} from './http{{importFileExtension}}'; +import { from, Observable } from {{#useRxJS}}'rxjs'{{/useRxJS}}{{^useRxJS}}'../rxjsStub{{importFileExtension}}'{{/useRxJS}}; {{#platforms}} {{#node}} import fetch from "node-fetch"; diff --git a/modules/openapi-generator/src/main/resources/typescript/http/servers.mustache b/modules/openapi-generator/src/main/resources/typescript/http/servers.mustache index d2a0a254255c..7e204c3e0270 100644 --- a/modules/openapi-generator/src/main/resources/typescript/http/servers.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/http/servers.mustache @@ -1,4 +1,4 @@ -import { RequestContext, HttpMethod } from "./http/http{{extensionForDeno}}"; +import { RequestContext, HttpMethod } from "./http/http{{importFileExtension}}"; export interface BaseServerConfiguration { makeRequestContext(endpoint: string, httpMethod: HttpMethod): RequestContext; diff --git a/modules/openapi-generator/src/main/resources/typescript/index.mustache b/modules/openapi-generator/src/main/resources/typescript/index.mustache index 24fe1285226e..24ead976ac7d 100644 --- a/modules/openapi-generator/src/main/resources/typescript/index.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/index.mustache @@ -1,41 +1,41 @@ -export * from "./http/http{{extensionForDeno}}"; -export * from "./auth/auth{{extensionForDeno}}"; -export * from "./models/all{{extensionForDeno}}"; -export { createConfiguration } from "./configuration{{extensionForDeno}}" -export{{#platforms}}{{#deno}} type{{/deno}}{{/platforms}} { Configuration } from "./configuration{{extensionForDeno}}" -export * from "./apis/exception{{extensionForDeno}}"; -export * from "./servers{{extensionForDeno}}"; -export { RequiredError } from "./apis/baseapi{{extensionForDeno}}"; +export * from "./http/http{{importFileExtension}}"; +export * from "./auth/auth{{importFileExtension}}"; +export * from "./models/all{{importFileExtension}}"; +export { createConfiguration } from "./configuration{{importFileExtension}}" +export{{#platforms}}{{#deno}} type{{/deno}}{{/platforms}} { Configuration } from "./configuration{{importFileExtension}}" +export * from "./apis/exception{{importFileExtension}}"; +export * from "./servers{{importFileExtension}}"; +export { RequiredError } from "./apis/baseapi{{importFileExtension}}"; {{#useRxJS}} -export { Middleware } from './middleware{{extensionForDeno}}'; +export { Middleware } from './middleware{{importFileExtension}}'; {{/useRxJS}} {{^useRxJS}} -export{{#platforms}}{{#deno}} type{{/deno}}{{/platforms}} { PromiseMiddleware as Middleware } from './middleware{{extensionForDeno}}'; +export{{#platforms}}{{#deno}} type{{/deno}}{{/platforms}} { PromiseMiddleware as Middleware } from './middleware{{importFileExtension}}'; {{/useRxJS}} {{#useObjectParameters}} -export { {{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}{{classname}}{{operationIdCamelCase}}Request, {{/operation}}Object{{classname}} as {{classname}}{{^-last}}, {{/-last}} {{/operations}}{{/apis}}{{/apiInfo}}} from './types/ObjectParamAPI{{extensionForDeno}}'; +export { {{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}{{classname}}{{operationIdCamelCase}}Request, {{/operation}}Object{{classname}} as {{classname}}{{^-last}}, {{/-last}} {{/operations}}{{/apis}}{{/apiInfo}}} from './types/ObjectParamAPI{{importFileExtension}}'; {{/useObjectParameters}} {{^useObjectParameters}} {{#useRxJS}} -export { {{#apiInfo}}{{#apis}}{{#operations}}Observable{{classname}} as {{classname}}{{^-last}}, {{/-last}} {{/operations}}{{/apis}}{{/apiInfo}}} from './types/ObservableAPI{{extensionForDeno}}'; +export { {{#apiInfo}}{{#apis}}{{#operations}}Observable{{classname}} as {{classname}}{{^-last}}, {{/-last}} {{/operations}}{{/apis}}{{/apiInfo}}} from './types/ObservableAPI{{importFileExtension}}'; {{/useRxJS}} {{^useRxJS}} -export { {{#apiInfo}}{{#apis}}{{#operations}}Promise{{classname}} as {{classname}}{{^-last}}, {{/-last}} {{/operations}}{{/apis}}{{/apiInfo}}} from './types/PromiseAPI{{extensionForDeno}}'; +export { {{#apiInfo}}{{#apis}}{{#operations}}Promise{{classname}} as {{classname}}{{^-last}}, {{/-last}} {{/operations}}{{/apis}}{{/apiInfo}}} from './types/PromiseAPI{{importFileExtension}}'; {{/useRxJS}} {{/useObjectParameters}} {{#useInversify}} -export * from "./services/index{{extensionForDeno}}"; +export * from "./services/index{{importFileExtension}}"; {{#useObjectParameters}} export { {{#apiInfo}}{{#apis}}{{#operations}}AbstractObject{{classname}} as Abstract{{classname}}{{^-last}}, {{/-last}} {{/operations}}{{/apis}}{{/apiInfo}}} from './services/ObjectParamAPI'; {{/useObjectParameters}} {{^useObjectParameters}} {{#useRxJS}} -export { {{#apiInfo}}{{#apis}}{{#operations}}AbstractObservable{{classname}} as Abstract{{classname}}{{^-last}}, {{/-last}} {{/operations}}{{/apis}}{{/apiInfo}}} from './services/ObservableAPI{{extensionForDeno}}'; +export { {{#apiInfo}}{{#apis}}{{#operations}}AbstractObservable{{classname}} as Abstract{{classname}}{{^-last}}, {{/-last}} {{/operations}}{{/apis}}{{/apiInfo}}} from './services/ObservableAPI{{importFileExtension}}'; {{/useRxJS}} {{^useRxJS}} -export { {{#apiInfo}}{{#apis}}{{#operations}}AbstractPromise{{classname}} as Abstract{{classname}}{{^-last}}, {{/-last}} {{/operations}}{{/apis}}{{/apiInfo}}} from './services/PromiseAPI{{extensionForDeno}}'; +export { {{#apiInfo}}{{#apis}}{{#operations}}AbstractPromise{{classname}} as Abstract{{classname}}{{^-last}}, {{/-last}} {{/operations}}{{/apis}}{{/apiInfo}}} from './services/PromiseAPI{{importFileExtension}}'; {{/useRxJS}} {{/useObjectParameters}} {{/useInversify}} diff --git a/modules/openapi-generator/src/main/resources/typescript/model/ObjectSerializer.mustache b/modules/openapi-generator/src/main/resources/typescript/model/ObjectSerializer.mustache index 2109b58507ed..4af2dc8a237e 100644 --- a/modules/openapi-generator/src/main/resources/typescript/model/ObjectSerializer.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/model/ObjectSerializer.mustache @@ -1,12 +1,12 @@ {{#models}} {{#model}} -export * from '{{{ importPath }}}{{extensionForDeno}}'; +export * from '{{{ importPath }}}{{importFileExtension}}'; {{/model}} {{/models}} {{#models}} {{#model}} -import { {{classname}}{{#hasEnums}}{{#vars}}{{#isEnum}}, {{classname}}{{enumName}} {{/isEnum}} {{/vars}}{{/hasEnums}} } from '{{{ importPath }}}{{extensionForDeno}}'; +import { {{classname}}{{#hasEnums}}{{#vars}}{{#isEnum}}, {{classname}}{{enumName}} {{/isEnum}} {{/vars}}{{/hasEnums}} } from '{{{ importPath }}}{{importFileExtension}}'; {{/model}} {{/models}} diff --git a/modules/openapi-generator/src/main/resources/typescript/model/model.mustache b/modules/openapi-generator/src/main/resources/typescript/model/model.mustache index f7a5d8aa6839..bff4adc5f799 100644 --- a/modules/openapi-generator/src/main/resources/typescript/model/model.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/model/model.mustache @@ -2,9 +2,9 @@ {{#models}} {{#model}} {{#tsImports}} -import { {{classname}} } from '{{filename}}{{extensionForDeno}}'; +import { {{classname}} } from '{{filename}}{{importFileExtension}}'; {{/tsImports}} -import { HttpFile } from '../http/http{{extensionForDeno}}'; +import { HttpFile } from '../http/http{{importFileExtension}}'; {{#description}} /** diff --git a/modules/openapi-generator/src/main/resources/typescript/model/models_all.mustache b/modules/openapi-generator/src/main/resources/typescript/model/models_all.mustache index 99adf56f71be..5d93be1dad82 100644 --- a/modules/openapi-generator/src/main/resources/typescript/model/models_all.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/model/models_all.mustache @@ -1,5 +1,5 @@ {{#models}} {{#model}} -export * from '{{{ importPath }}}{{extensionForDeno}}' +export * from '{{{ importPath }}}{{importFileExtension}}' {{/model}} {{/models}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/typescript/types/ObjectParamAPI.mustache b/modules/openapi-generator/src/main/resources/typescript/types/ObjectParamAPI.mustache index 41969c178c11..0b6fde74ce66 100644 --- a/modules/openapi-generator/src/main/resources/typescript/types/ObjectParamAPI.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/types/ObjectParamAPI.mustache @@ -1,20 +1,20 @@ -import { ResponseContext, RequestContext, HttpFile } from '../http/http{{extensionForDeno}}'; -import { Configuration} from '../configuration{{extensionForDeno}}' +import { ResponseContext, RequestContext, HttpFile } from '../http/http{{importFileExtension}}'; +import { Configuration} from '../configuration{{importFileExtension}}' {{#useRxJS}} import { Observable } from 'rxjs'; {{/useRxJS}} {{#models}} {{#model}} -import { {{{ classname }}} } from '{{{ importPath }}}{{extensionForDeno}}'; +import { {{{ classname }}} } from '{{{ importPath }}}{{importFileExtension}}'; {{/model}} {{/models}} {{#apiInfo}} {{#apis}} {{#operations}} -import { Observable{{classname}} } from "./ObservableAPI{{extensionForDeno}}"; -import { {{classname}}RequestFactory, {{classname}}ResponseProcessor} from "../apis/{{classname}}{{extensionForDeno}}"; +import { Observable{{classname}} } from "./ObservableAPI{{importFileExtension}}"; +import { {{classname}}RequestFactory, {{classname}}ResponseProcessor} from "../apis/{{classname}}{{importFileExtension}}"; {{#operation}} export interface {{classname}}{{operationIdCamelCase}}Request { diff --git a/modules/openapi-generator/src/main/resources/typescript/types/ObservableAPI.mustache b/modules/openapi-generator/src/main/resources/typescript/types/ObservableAPI.mustache index 60160493758f..038e9a5bc4f8 100644 --- a/modules/openapi-generator/src/main/resources/typescript/types/ObservableAPI.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/types/ObservableAPI.mustache @@ -1,23 +1,23 @@ -import { ResponseContext, RequestContext, HttpFile } from '../http/http{{extensionForDeno}}'; -import { Configuration} from '../configuration{{extensionForDeno}}' -import { Observable, of, from } from {{#useRxJS}}'rxjs'{{/useRxJS}}{{^useRxJS}}'../rxjsStub{{extensionForDeno}}'{{/useRxJS}}; -import {mergeMap, map} from {{#useRxJS}}'rxjs/operators'{{/useRxJS}}{{^useRxJS}}'../rxjsStub{{extensionForDeno}}'{{/useRxJS}}; +import { ResponseContext, RequestContext, HttpFile } from '../http/http{{importFileExtension}}'; +import { Configuration} from '../configuration{{importFileExtension}}' +import { Observable, of, from } from {{#useRxJS}}'rxjs'{{/useRxJS}}{{^useRxJS}}'../rxjsStub{{importFileExtension}}'{{/useRxJS}}; +import {mergeMap, map} from {{#useRxJS}}'rxjs/operators'{{/useRxJS}}{{^useRxJS}}'../rxjsStub{{importFileExtension}}'{{/useRxJS}}; {{#useInversify}} import { injectable, inject, optional } from "inversify"; -import { AbstractConfiguration } from "../services/configuration{{extensionForDeno}}"; +import { AbstractConfiguration } from "../services/configuration{{importFileExtension}}"; {{/useInversify}} {{#models}} {{#model}} -import { {{{ classname }}} } from '{{{ importPath }}}{{extensionForDeno}}'; +import { {{{ classname }}} } from '{{{ importPath }}}{{importFileExtension}}'; {{/model}} {{/models}} {{#apiInfo}} {{#apis}} {{#operations}} -import { {{classname}}RequestFactory, {{classname}}ResponseProcessor} from "../apis/{{classname}}{{extensionForDeno}}"; +import { {{classname}}RequestFactory, {{classname}}ResponseProcessor} from "../apis/{{classname}}{{importFileExtension}}"; {{#useInversify}} -import { Abstract{{classname}}RequestFactory, Abstract{{classname}}ResponseProcessor } from "../apis/{{classname}}.service{{extensionForDeno}}"; +import { Abstract{{classname}}RequestFactory, Abstract{{classname}}ResponseProcessor } from "../apis/{{classname}}.service{{importFileExtension}}"; @injectable() {{/useInversify}} diff --git a/modules/openapi-generator/src/main/resources/typescript/types/PromiseAPI.mustache b/modules/openapi-generator/src/main/resources/typescript/types/PromiseAPI.mustache index 058757c48df8..85d43fab9b3d 100644 --- a/modules/openapi-generator/src/main/resources/typescript/types/PromiseAPI.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/types/PromiseAPI.mustache @@ -1,5 +1,5 @@ -import { ResponseContext, RequestContext, HttpFile } from '../http/http{{extensionForDeno}}'; -import { Configuration} from '../configuration{{extensionForDeno}}' +import { ResponseContext, RequestContext, HttpFile } from '../http/http{{importFileExtension}}'; +import { Configuration} from '../configuration{{importFileExtension}}' {{#useInversify}} import { injectable, inject, optional } from "inversify"; import { AbstractConfiguration } from "../services/configuration"; @@ -7,15 +7,15 @@ import { AbstractConfiguration } from "../services/configuration"; {{#models}} {{#model}} -import { {{{ classname }}} } from '{{{ importPath }}}{{extensionForDeno}}'; +import { {{{ classname }}} } from '{{{ importPath }}}{{importFileExtension}}'; {{/model}} {{/models}} {{#apiInfo}} {{#apis}} -import { Observable{{classname}} } from './ObservableAPI{{extensionForDeno}}'; +import { Observable{{classname}} } from './ObservableAPI{{importFileExtension}}'; {{#operations}} -import { {{classname}}RequestFactory, {{classname}}ResponseProcessor} from "../apis/{{classname}}{{extensionForDeno}}"; +import { {{classname}}RequestFactory, {{classname}}ResponseProcessor} from "../apis/{{classname}}{{importFileExtension}}"; {{#useInversify}} import { Abstract{{classname}}RequestFactory, Abstract{{classname}}ResponseProcessor } from "../apis/{{classname}}.service"; From 4c172ebfbecfb04ab810140194d37338ca77487c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dan=20Michael=20O=2E=20Hegg=C3=B8?= Date: Tue, 27 Dec 2022 19:26:50 +0100 Subject: [PATCH 2/4] Add importFileExtension option to typescript generator --- docs/generators/typescript.md | 1 + .../codegen/languages/TypeScriptClientCodegen.java | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/docs/generators/typescript.md b/docs/generators/typescript.md index 2a0df3ca3ab4..5ca85fe0c8c9 100644 --- a/docs/generators/typescript.md +++ b/docs/generators/typescript.md @@ -24,6 +24,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |enumUnknownDefaultCase|If the server adds new enum cases, that are unknown by an old spec/client, the client will fail to parse the network response.With this option enabled, each enum will have a new case, 'unknown_default_open_api', so that when the server sends an enum case that is not known by the client/spec, they can safely fallback to this case.|
**false**
No changes to the enum's are made, this is the default option.
**true**
With this option enabled, each enum will have a new case, 'unknown_default_open_api', so that when the enum case sent by the server is not known by the client/spec, can safely be decoded to this case.
|false| |fileContentDataType|Specifies the type to use for the content of a file - i.e. Blob (Browser, Deno) / Buffer (node)| |Buffer| |framework|Specify the framework which should be used in the client code.|
**fetch-api**
fetch-api
**jquery**
jquery
|fetch-api| +|importFileExtension|The file extension to use for imports. Setting a value may be required when using Node.js ECMAScript module resolution.| |'.ts' for Deno, blank otherwise| |legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C#have this enabled by default).|
**true**
The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.
**false**
The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing.
|true| |modelPropertyNaming|Naming convention for the property: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name| |camelCase| |npmName|The name under which you want to publish generated npm package. Required to generate a full package| |null| diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java index 5c88a0f26f41..bfd6c20a630f 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java @@ -73,6 +73,8 @@ public class TypeScriptClientCodegen extends DefaultCodegen implements CodegenCo private static final String PLATFORM_SWITCH = "platform"; private static final String PLATFORM_SWITCH_DESC = "Specifies the platform the code should run on. The default is 'node' for the 'request' framework and 'browser' otherwise."; private static final String[] PLATFORMS = { "browser", "node", "deno" }; + private static final String IMPORT_FILE_EXTENSION_SWITCH = "importFileExension"; + private static final String IMPORT_FILE_EXTENSION_SWITCH_DESC = "The file extension to use for imports. The default is '.ts' when 'platform' is 'deno' and blank otherwise."; private static final String FILE_CONTENT_DATA_TYPE= "fileContentDataType"; private static final String FILE_CONTENT_DATA_TYPE_DESC = "Specifies the type to use for the content of a file - i.e. Blob (Browser, Deno) / Buffer (node)"; private static final String USE_RXJS_SWITCH = "useRxJS"; @@ -198,6 +200,7 @@ public TypeScriptClientCodegen() { cliOptions.add(new CliOption(TypeScriptClientCodegen.USE_RXJS_SWITCH, TypeScriptClientCodegen.USE_RXJS_SWITCH_DESC).defaultValue("false")); cliOptions.add(new CliOption(TypeScriptClientCodegen.USE_OBJECT_PARAMS_SWITCH, TypeScriptClientCodegen.USE_OBJECT_PARAMS_DESC).defaultValue("false")); cliOptions.add(new CliOption(TypeScriptClientCodegen.USE_INVERSIFY_SWITCH, TypeScriptClientCodegen.USE_INVERSIFY_SWITCH_DESC).defaultValue("false")); + cliOptions.add(new CliOption(TypeScriptClientCodegen.IMPORT_FILE_EXTENSION_SWITCH, TypeScriptClientCodegen.IMPORT_FILE_EXTENSION_SWITCH_DESC)); CliOption frameworkOption = new CliOption(TypeScriptClientCodegen.FRAMEWORK_SWITCH, TypeScriptClientCodegen.FRAMEWORK_SWITCH_DESC); for (String option: TypeScriptClientCodegen.FRAMEWORKS) { @@ -835,8 +838,9 @@ public void processOpts() { supportingFiles.add(new SupportingFile("tsconfig.mustache", "", "tsconfig.json")); } - if ("deno".equals(propPlatform)) { - additionalProperties.put("importFileExtension", ".ts"); + Object fileExtension = additionalProperties.get(IMPORT_FILE_EXTENSION_SWITCH); + if (fileExtension == null && "deno".equals(propPlatform)) { + additionalProperties.put(IMPORT_FILE_EXTENSION_SWITCH, ".ts"); } final boolean useRxJS = convertPropertyToBooleanAndWriteBack(USE_RXJS_SWITCH); From 1cd3d1355fc0b4a1e43f49681fbc864ffcaae7f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dan=20Michael=20O=2E=20Hegg=C3=B8?= Date: Tue, 3 Jan 2023 15:46:59 +0100 Subject: [PATCH 3/4] Fix typo, update docs --- docs/generators/typescript.md | 2 +- .../openapitools/codegen/languages/TypeScriptClientCodegen.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/generators/typescript.md b/docs/generators/typescript.md index 5ca85fe0c8c9..9130234bf524 100644 --- a/docs/generators/typescript.md +++ b/docs/generators/typescript.md @@ -24,7 +24,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |enumUnknownDefaultCase|If the server adds new enum cases, that are unknown by an old spec/client, the client will fail to parse the network response.With this option enabled, each enum will have a new case, 'unknown_default_open_api', so that when the server sends an enum case that is not known by the client/spec, they can safely fallback to this case.|
**false**
No changes to the enum's are made, this is the default option.
**true**
With this option enabled, each enum will have a new case, 'unknown_default_open_api', so that when the enum case sent by the server is not known by the client/spec, can safely be decoded to this case.
|false| |fileContentDataType|Specifies the type to use for the content of a file - i.e. Blob (Browser, Deno) / Buffer (node)| |Buffer| |framework|Specify the framework which should be used in the client code.|
**fetch-api**
fetch-api
**jquery**
jquery
|fetch-api| -|importFileExtension|The file extension to use for imports. Setting a value may be required when using Node.js ECMAScript module resolution.| |'.ts' for Deno, blank otherwise| +|importFileExension|The file extension to use for imports. The default is '.ts' when 'platform' is 'deno' and blank otherwise.| |null| |legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C#have this enabled by default).|
**true**
The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.
**false**
The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing.
|true| |modelPropertyNaming|Naming convention for the property: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name| |camelCase| |npmName|The name under which you want to publish generated npm package. Required to generate a full package| |null| diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java index bfd6c20a630f..20ccc0e88858 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java @@ -73,7 +73,7 @@ public class TypeScriptClientCodegen extends DefaultCodegen implements CodegenCo private static final String PLATFORM_SWITCH = "platform"; private static final String PLATFORM_SWITCH_DESC = "Specifies the platform the code should run on. The default is 'node' for the 'request' framework and 'browser' otherwise."; private static final String[] PLATFORMS = { "browser", "node", "deno" }; - private static final String IMPORT_FILE_EXTENSION_SWITCH = "importFileExension"; + private static final String IMPORT_FILE_EXTENSION_SWITCH = "importFileExtension"; private static final String IMPORT_FILE_EXTENSION_SWITCH_DESC = "The file extension to use for imports. The default is '.ts' when 'platform' is 'deno' and blank otherwise."; private static final String FILE_CONTENT_DATA_TYPE= "fileContentDataType"; private static final String FILE_CONTENT_DATA_TYPE_DESC = "Specifies the type to use for the content of a file - i.e. Blob (Browser, Deno) / Buffer (node)"; From cd4fcba998eef8e7d173a1e03f0aa1b8b634876f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dan=20Michael=20O=2E=20Hegg=C3=B8?= Date: Tue, 3 Jan 2023 16:14:19 +0100 Subject: [PATCH 4/4] Update docstring --- docs/generators/typescript.md | 2 +- .../openapitools/codegen/languages/TypeScriptClientCodegen.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/generators/typescript.md b/docs/generators/typescript.md index 9130234bf524..b0dead39be55 100644 --- a/docs/generators/typescript.md +++ b/docs/generators/typescript.md @@ -24,7 +24,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |enumUnknownDefaultCase|If the server adds new enum cases, that are unknown by an old spec/client, the client will fail to parse the network response.With this option enabled, each enum will have a new case, 'unknown_default_open_api', so that when the server sends an enum case that is not known by the client/spec, they can safely fallback to this case.|
**false**
No changes to the enum's are made, this is the default option.
**true**
With this option enabled, each enum will have a new case, 'unknown_default_open_api', so that when the enum case sent by the server is not known by the client/spec, can safely be decoded to this case.
|false| |fileContentDataType|Specifies the type to use for the content of a file - i.e. Blob (Browser, Deno) / Buffer (node)| |Buffer| |framework|Specify the framework which should be used in the client code.|
**fetch-api**
fetch-api
**jquery**
jquery
|fetch-api| -|importFileExension|The file extension to use for imports. The default is '.ts' when 'platform' is 'deno' and blank otherwise.| |null| +|importFileExtension|File extension to use with relative imports. Set it to '.js' or '.mjs' when using [ESM](https://nodejs.org/api/esm.html). Defaults to '.ts' when 'platform' is set to 'deno'.| |null| |legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C#have this enabled by default).|
**true**
The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.
**false**
The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing.
|true| |modelPropertyNaming|Naming convention for the property: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name| |camelCase| |npmName|The name under which you want to publish generated npm package. Required to generate a full package| |null| diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java index 20ccc0e88858..b6c868f89685 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java @@ -74,7 +74,7 @@ public class TypeScriptClientCodegen extends DefaultCodegen implements CodegenCo private static final String PLATFORM_SWITCH_DESC = "Specifies the platform the code should run on. The default is 'node' for the 'request' framework and 'browser' otherwise."; private static final String[] PLATFORMS = { "browser", "node", "deno" }; private static final String IMPORT_FILE_EXTENSION_SWITCH = "importFileExtension"; - private static final String IMPORT_FILE_EXTENSION_SWITCH_DESC = "The file extension to use for imports. The default is '.ts' when 'platform' is 'deno' and blank otherwise."; + private static final String IMPORT_FILE_EXTENSION_SWITCH_DESC = "File extension to use with relative imports. Set it to '.js' or '.mjs' when using [ESM](https://nodejs.org/api/esm.html). Defaults to '.ts' when 'platform' is set to 'deno'."; private static final String FILE_CONTENT_DATA_TYPE= "fileContentDataType"; private static final String FILE_CONTENT_DATA_TYPE_DESC = "Specifies the type to use for the content of a file - i.e. Blob (Browser, Deno) / Buffer (node)"; private static final String USE_RXJS_SWITCH = "useRxJS";