From 3c6abdb0dc6defc6d46f340436ea1f986faf2c29 Mon Sep 17 00:00:00 2001 From: Sebastian Haas Date: Wed, 18 Oct 2017 14:59:29 +0200 Subject: [PATCH] Initial step towards an AOT-compatible API client. --- .../main/resources/typescript-angular/package.mustache | 6 ++++-- .../resources/typescript-angular/tsconfig.mustache | 10 +++++++--- .../typescript-angular-v4.3/npm/model/apiResponse.ts | 2 ++ .../typescript-angular-v4.3/npm/model/category.ts | 2 ++ .../typescript-angular-v4.3/npm/model/order.ts | 8 +++----- .../petstore/typescript-angular-v4.3/npm/model/pet.ts | 8 +++----- .../petstore/typescript-angular-v4.3/npm/model/tag.ts | 2 ++ .../petstore/typescript-angular-v4.3/npm/model/user.ts | 2 ++ .../petstore/typescript-angular-v4.3/npm/package.json | 8 +++++--- .../petstore/typescript-angular-v4.3/npm/tsconfig.json | 10 +++++++--- 10 files changed, 37 insertions(+), 21 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/typescript-angular/package.mustache b/modules/swagger-codegen/src/main/resources/typescript-angular/package.mustache index 9123cb8eb66..7fb33368637 100644 --- a/modules/swagger-codegen/src/main/resources/typescript-angular/package.mustache +++ b/modules/swagger-codegen/src/main/resources/typescript-angular/package.mustache @@ -8,10 +8,11 @@ ], "license": "Unlicense", "main": "dist/index.js", + "module": "dist/index.js", "typings": "dist/index.d.ts", "scripts": { - "build": "tsc --outDir dist/", - "postinstall": "npm run build" + "build": "ngc", + "prepublish": "npm run build" }, "peerDependencies": { "@angular/core": "^{{ngVersion}}", @@ -28,6 +29,7 @@ "@angular/http": "^{{ngVersion}}", "@angular/common": "^{{ngVersion}}", "@angular/compiler": "^{{ngVersion}}", + "@angular/compiler-cli": "^{{ngVersion}}", "@angular/platform-browser": "^{{ngVersion}}", "reflect-metadata": "^0.1.3", "rxjs": "^5.4.0", diff --git a/modules/swagger-codegen/src/main/resources/typescript-angular/tsconfig.mustache b/modules/swagger-codegen/src/main/resources/typescript-angular/tsconfig.mustache index a6e9096bbf7..ce83e26c6e9 100644 --- a/modules/swagger-codegen/src/main/resources/typescript-angular/tsconfig.mustache +++ b/modules/swagger-codegen/src/main/resources/typescript-angular/tsconfig.mustache @@ -5,14 +5,14 @@ "noImplicitAny": false, "suppressImplicitAnyIndexErrors": true, "target": "es5", - "module": "es6", + "module": "es2015", "moduleResolution": "node", "removeComments": true, "sourceMap": true, "outDir": "./dist", "noLib": false, "declaration": true, - "lib": [ "es6", "dom" ] + "lib": [ "es2015", "dom" ] }, "exclude": [ "node_modules", @@ -21,5 +21,9 @@ "filesGlob": [ "./model/*.ts", "./api/*.ts" - ] + ], + "angularCompilerOptions": { + "genDir": "dist", + "skipTemplateCodegen": true + } } diff --git a/samples/client/petstore/typescript-angular-v4.3/npm/model/apiResponse.ts b/samples/client/petstore/typescript-angular-v4.3/npm/model/apiResponse.ts index 3af781cf580..e79fabe8c8c 100644 --- a/samples/client/petstore/typescript-angular-v4.3/npm/model/apiResponse.ts +++ b/samples/client/petstore/typescript-angular-v4.3/npm/model/apiResponse.ts @@ -23,3 +23,5 @@ export interface ApiResponse { message?: string; } + + diff --git a/samples/client/petstore/typescript-angular-v4.3/npm/model/category.ts b/samples/client/petstore/typescript-angular-v4.3/npm/model/category.ts index d09f8d7b265..56608731f95 100644 --- a/samples/client/petstore/typescript-angular-v4.3/npm/model/category.ts +++ b/samples/client/petstore/typescript-angular-v4.3/npm/model/category.ts @@ -21,3 +21,5 @@ export interface Category { name?: string; } + + diff --git a/samples/client/petstore/typescript-angular-v4.3/npm/model/order.ts b/samples/client/petstore/typescript-angular-v4.3/npm/model/order.ts index 402a86689c8..84b59f1b09a 100644 --- a/samples/client/petstore/typescript-angular-v4.3/npm/model/order.ts +++ b/samples/client/petstore/typescript-angular-v4.3/npm/model/order.ts @@ -33,9 +33,7 @@ export interface Order { } export namespace Order { - export enum StatusEnum { - Placed = 'placed', - Approved = 'approved', - Delivered = 'delivered' - } + export type StatusEnum = 'placed' | 'approved' | 'delivered'; } + + diff --git a/samples/client/petstore/typescript-angular-v4.3/npm/model/pet.ts b/samples/client/petstore/typescript-angular-v4.3/npm/model/pet.ts index 0d6137d02cf..c0fc942934c 100644 --- a/samples/client/petstore/typescript-angular-v4.3/npm/model/pet.ts +++ b/samples/client/petstore/typescript-angular-v4.3/npm/model/pet.ts @@ -35,9 +35,7 @@ export interface Pet { } export namespace Pet { - export enum StatusEnum { - Available = 'available', - Pending = 'pending', - Sold = 'sold' - } + export type StatusEnum = 'available' | 'pending' | 'sold'; } + + diff --git a/samples/client/petstore/typescript-angular-v4.3/npm/model/tag.ts b/samples/client/petstore/typescript-angular-v4.3/npm/model/tag.ts index 3ed1eeff8f3..dbfa473f538 100644 --- a/samples/client/petstore/typescript-angular-v4.3/npm/model/tag.ts +++ b/samples/client/petstore/typescript-angular-v4.3/npm/model/tag.ts @@ -21,3 +21,5 @@ export interface Tag { name?: string; } + + diff --git a/samples/client/petstore/typescript-angular-v4.3/npm/model/user.ts b/samples/client/petstore/typescript-angular-v4.3/npm/model/user.ts index f4914ae2608..4dfad607c51 100644 --- a/samples/client/petstore/typescript-angular-v4.3/npm/model/user.ts +++ b/samples/client/petstore/typescript-angular-v4.3/npm/model/user.ts @@ -36,3 +36,5 @@ export interface User { userStatus?: number; } + + diff --git a/samples/client/petstore/typescript-angular-v4.3/npm/package.json b/samples/client/petstore/typescript-angular-v4.3/npm/package.json index 40157c62927..77c0e7354fd 100644 --- a/samples/client/petstore/typescript-angular-v4.3/npm/package.json +++ b/samples/client/petstore/typescript-angular-v4.3/npm/package.json @@ -8,10 +8,11 @@ ], "license": "Unlicense", "main": "dist/index.js", + "module": "dist/index.js", "typings": "dist/index.d.ts", "scripts": { - "build": "tsc --outDir dist/", - "postinstall": "npm run build" + "build": "ngc", + "prepublish": "npm run build" }, "peerDependencies": { "@angular/core": "^4.3.0", @@ -28,6 +29,7 @@ "@angular/http": "^4.3.0", "@angular/common": "^4.3.0", "@angular/compiler": "^4.3.0", + "@angular/compiler-cli": "^4.3.0", "@angular/platform-browser": "^4.3.0", "reflect-metadata": "^0.1.3", "rxjs": "^5.4.0", @@ -35,6 +37,6 @@ "typescript": "^2.1.5" }, "publishConfig": { - "registry":"https://skimdb.npmjs.com/registry" + "registry": "https://skimdb.npmjs.com/registry" } } diff --git a/samples/client/petstore/typescript-angular-v4.3/npm/tsconfig.json b/samples/client/petstore/typescript-angular-v4.3/npm/tsconfig.json index a6e9096bbf7..ce83e26c6e9 100644 --- a/samples/client/petstore/typescript-angular-v4.3/npm/tsconfig.json +++ b/samples/client/petstore/typescript-angular-v4.3/npm/tsconfig.json @@ -5,14 +5,14 @@ "noImplicitAny": false, "suppressImplicitAnyIndexErrors": true, "target": "es5", - "module": "es6", + "module": "es2015", "moduleResolution": "node", "removeComments": true, "sourceMap": true, "outDir": "./dist", "noLib": false, "declaration": true, - "lib": [ "es6", "dom" ] + "lib": [ "es2015", "dom" ] }, "exclude": [ "node_modules", @@ -21,5 +21,9 @@ "filesGlob": [ "./model/*.ts", "./api/*.ts" - ] + ], + "angularCompilerOptions": { + "genDir": "dist", + "skipTemplateCodegen": true + } }