Skip to content

Commit 5344a02

Browse files
authored
Multiple enhancements to typescript fetch generator (#145)
1 parent 1e59649 commit 5344a02

File tree

15 files changed

+1252
-893
lines changed

15 files changed

+1252
-893
lines changed

modules/openapi-generator/src/main/java/org/openapitools/codegen/CodegenProperty.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public class CodegenProperty implements Cloneable {
5454
public boolean exclusiveMinimum;
5555
public boolean exclusiveMaximum;
5656
public boolean hasMore, required, secondaryParam;
57-
public boolean hasMoreNonReadOnly; // for model constructor, true if next properyt is not readonly
57+
public boolean hasMoreNonReadOnly; // for model constructor, true if next property is not readonly
5858
public boolean isPrimitiveType, isContainer, isNotContainer;
5959
public boolean isString, isNumeric, isInteger, isLong, isNumber, isFloat, isDouble, isByteArray, isBinary, isFile, isBoolean, isDate, isDateTime, isUuid;
6060
public boolean isListContainer, isMapContainer;

modules/openapi-generator/src/main/resources/typescript-fetch/api.mustache

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export interface FetchArgs {
4444
* @class BaseAPI
4545
*/
4646
export class BaseAPI {
47-
protected configuration: Configuration;
47+
protected configuration: Configuration | undefined;
4848
4949
constructor(configuration?: Configuration, protected basePath: string = BASE_PATH, protected fetch: FetchAPI = portableFetch) {
5050
if (configuration) {
@@ -61,7 +61,7 @@ export class BaseAPI {
6161
* @extends {Error}
6262
*/
6363
export class RequiredError extends Error {
64-
name: "RequiredError"
64+
name: "RequiredError" = "RequiredError";
6565
constructor(public field: string, msg?: string) {
6666
super(msg);
6767
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
export enum {{classname}} {
77
{{#allowableValues}}
88
{{#enumVars}}
9-
{{{name}}} = <any> {{{value}}}{{^-last}},{{/-last}}
9+
{{{name}}} = {{{value}}}{{^-last}},{{/-last}}
1010
{{/enumVars}}
1111
{{/allowableValues}}
1212
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export namespace {{classname}} {
3232
export enum {{enumName}} {
3333
{{#allowableValues}}
3434
{{#enumVars}}
35-
{{{name}}} = <any> {{{value}}}{{^-last}},{{/-last}}
35+
{{{name}}} = {{{value}}}{{^-last}},{{/-last}}
3636
{{/enumVars}}
3737
{{/allowableValues}}
3838
}

modules/openapi-generator/src/main/resources/typescript-fetch/package.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
},
2323
"devDependencies": {
2424
"@types/node": "^8.0.9",
25-
"typescript": "^2.0"
25+
"typescript": "^2.4"
2626
}{{#npmRepository}},{{/npmRepository}}
2727
{{#npmRepository}}
2828
"publishConfig":{

samples/client/petstore/typescript-fetch/builds/default/api.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export interface FetchArgs {
5555
* @class BaseAPI
5656
*/
5757
export class BaseAPI {
58-
protected configuration: Configuration;
58+
protected configuration: Configuration | undefined;
5959

6060
constructor(configuration?: Configuration, protected basePath: string = BASE_PATH, protected fetch: FetchAPI = portableFetch) {
6161
if (configuration) {
@@ -72,7 +72,7 @@ export class BaseAPI {
7272
* @extends {Error}
7373
*/
7474
export class RequiredError extends Error {
75-
name: "RequiredError"
75+
name: "RequiredError" = "RequiredError";
7676
constructor(public field: string, msg?: string) {
7777
super(msg);
7878
}
@@ -178,9 +178,9 @@ export namespace Order {
178178
* @enum {string}
179179
*/
180180
export enum StatusEnum {
181-
Placed = <any> 'placed',
182-
Approved = <any> 'approved',
183-
Delivered = <any> 'delivered'
181+
Placed = 'placed',
182+
Approved = 'approved',
183+
Delivered = 'delivered'
184184
}
185185
}
186186

@@ -238,9 +238,9 @@ export namespace Pet {
238238
* @enum {string}
239239
*/
240240
export enum StatusEnum {
241-
Available = <any> 'available',
242-
Pending = <any> 'pending',
243-
Sold = <any> 'sold'
241+
Available = 'available',
242+
Pending = 'pending',
243+
Sold = 'sold'
244244
}
245245
}
246246

samples/client/petstore/typescript-fetch/builds/es6-target/api.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export interface FetchArgs {
5555
* @class BaseAPI
5656
*/
5757
export class BaseAPI {
58-
protected configuration: Configuration;
58+
protected configuration: Configuration | undefined;
5959

6060
constructor(configuration?: Configuration, protected basePath: string = BASE_PATH, protected fetch: FetchAPI = portableFetch) {
6161
if (configuration) {
@@ -72,7 +72,7 @@ export class BaseAPI {
7272
* @extends {Error}
7373
*/
7474
export class RequiredError extends Error {
75-
name: "RequiredError"
75+
name: "RequiredError" = "RequiredError";
7676
constructor(public field: string, msg?: string) {
7777
super(msg);
7878
}
@@ -178,9 +178,9 @@ export namespace Order {
178178
* @enum {string}
179179
*/
180180
export enum StatusEnum {
181-
Placed = <any> 'placed',
182-
Approved = <any> 'approved',
183-
Delivered = <any> 'delivered'
181+
Placed = 'placed',
182+
Approved = 'approved',
183+
Delivered = 'delivered'
184184
}
185185
}
186186

@@ -238,9 +238,9 @@ export namespace Pet {
238238
* @enum {string}
239239
*/
240240
export enum StatusEnum {
241-
Available = <any> 'available',
242-
Pending = <any> 'pending',
243-
Sold = <any> 'sold'
241+
Available = 'available',
242+
Pending = 'pending',
243+
Sold = 'sold'
244244
}
245245
}
246246

samples/client/petstore/typescript-fetch/builds/es6-target/package-lock.json

Lines changed: 0 additions & 69 deletions
This file was deleted.

samples/client/petstore/typescript-fetch/builds/es6-target/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
},
2323
"devDependencies": {
2424
"@types/node": "^8.0.9",
25-
"typescript": "^2.0"
25+
"typescript": "^2.4"
2626
},
2727
"publishConfig":{
2828
"registry":"https://skimdb.npmjs.com/registry"

samples/client/petstore/typescript-fetch/builds/with-interfaces/api.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export interface FetchArgs {
5555
* @class BaseAPI
5656
*/
5757
export class BaseAPI {
58-
protected configuration: Configuration;
58+
protected configuration: Configuration | undefined;
5959

6060
constructor(configuration?: Configuration, protected basePath: string = BASE_PATH, protected fetch: FetchAPI = portableFetch) {
6161
if (configuration) {
@@ -72,7 +72,7 @@ export class BaseAPI {
7272
* @extends {Error}
7373
*/
7474
export class RequiredError extends Error {
75-
name: "RequiredError"
75+
name: "RequiredError" = "RequiredError";
7676
constructor(public field: string, msg?: string) {
7777
super(msg);
7878
}
@@ -178,9 +178,9 @@ export namespace Order {
178178
* @enum {string}
179179
*/
180180
export enum StatusEnum {
181-
Placed = <any> 'placed',
182-
Approved = <any> 'approved',
183-
Delivered = <any> 'delivered'
181+
Placed = 'placed',
182+
Approved = 'approved',
183+
Delivered = 'delivered'
184184
}
185185
}
186186

@@ -238,9 +238,9 @@ export namespace Pet {
238238
* @enum {string}
239239
*/
240240
export enum StatusEnum {
241-
Available = <any> 'available',
242-
Pending = <any> 'pending',
243-
Sold = <any> 'sold'
241+
Available = 'available',
242+
Pending = 'pending',
243+
Sold = 'sold'
244244
}
245245
}
246246

0 commit comments

Comments
 (0)