From f7471add70f1cabdd597aecc304fd131016cae3e Mon Sep 17 00:00:00 2001 From: Keni Steward Date: Mon, 23 Oct 2017 22:42:03 -0400 Subject: [PATCH] Fixed spacing in model.mustache (#6788) * Added v4/v4.3 to typescript-angular-petsotre-all and renamed from angular2 to angular * refactored typescript-angular-petstore-all.sh * changed profile id for typescript-angularjs to properly have angularjs instead of just angular. * Spacing at end of model template * Corrected backwards compatible enum typing --- ....sh => typescript-angular-petstore-all.sh} | 8 ++ ...at => typescript-angular-petstore-all.bat} | 4 + .../typescript-angular/licenseInfo.mustache | 2 +- .../typescript-angular/modelEnum.mustache | 9 +- .../typescript-angular/modelGeneric.mustache | 11 ++- pom.xml | 2 +- pom.xml.bash | 2 +- pom.xml.circleci | 2 +- pom.xml.shippable | 2 +- .../default/api/pet.service.ts | 1 - .../default/api/store.service.ts | 1 - .../default/api/user.service.ts | 1 - .../default/model/ApiResponse.ts | 4 - .../default/model/category.ts | 3 - .../default/model/order.ts | 12 +-- .../default/model/pet.ts | 12 +-- .../default/model/tag.ts | 3 - .../default/model/user.ts | 9 -- .../npm/api/pet.service.ts | 1 - .../npm/api/store.service.ts | 1 - .../npm/api/user.service.ts | 1 - .../npm/model/ApiResponse.ts | 4 - .../npm/model/category.ts | 3 - .../typescript-angular-v2/npm/model/order.ts | 12 +-- .../typescript-angular-v2/npm/model/pet.ts | 12 +-- .../typescript-angular-v2/npm/model/tag.ts | 3 - .../typescript-angular-v2/npm/model/user.ts | 9 -- .../with-interfaces/README.md | 98 +++++++++++++++++++ .../with-interfaces/api/pet.service.ts | 1 - .../api/pet.serviceInterface.ts | 1 - .../with-interfaces/api/store.service.ts | 1 - .../api/store.serviceInterface.ts | 1 - .../with-interfaces/api/user.service.ts | 1 - .../api/user.serviceInterface.ts | 1 - .../with-interfaces/model/Category.ts | 3 - .../with-interfaces/model/Order.ts | 12 +-- .../with-interfaces/model/Pet.ts | 12 +-- .../with-interfaces/model/Tag.ts | 3 - .../with-interfaces/model/User.ts | 9 -- .../with-interfaces/model/apiResponse.ts | 4 - .../with-interfaces/package.json | 40 ++++++++ .../with-interfaces/tsconfig.json | 25 +++++ .../with-interfaces/typings.json | 5 + .../npm/api/pet.service.ts | 1 - .../npm/api/store.service.ts | 1 - .../npm/api/user.service.ts | 1 - .../npm/model/apiResponse.ts | 4 - .../npm/model/category.ts | 3 - .../npm/model/order.ts | 14 +-- .../typescript-angular-v4.3/npm/model/pet.ts | 14 +-- .../typescript-angular-v4.3/npm/model/tag.ts | 3 - .../typescript-angular-v4.3/npm/model/user.ts | 9 -- .../npm/api/pet.service.ts | 1 - .../npm/api/store.service.ts | 1 - .../npm/api/user.service.ts | 1 - .../npm/model/apiResponse.ts | 4 - .../npm/model/category.ts | 3 - .../typescript-angular-v4/npm/model/order.ts | 12 +-- .../typescript-angular-v4/npm/model/pet.ts | 12 +-- .../typescript-angular-v4/npm/model/tag.ts | 3 - .../typescript-angular-v4/npm/model/user.ts | 9 -- 61 files changed, 251 insertions(+), 196 deletions(-) rename bin/{typescript-angular-v2-petstore-all.sh => typescript-angular-petstore-all.sh} (68%) mode change 100755 => 100644 rename bin/windows/{typescript-angular2-petstore-all.bat => typescript-angular-petstore-all.bat} (58%) mode change 100755 => 100644 create mode 100644 samples/client/petstore/typescript-angular-v2/with-interfaces/README.md create mode 100644 samples/client/petstore/typescript-angular-v2/with-interfaces/package.json create mode 100644 samples/client/petstore/typescript-angular-v2/with-interfaces/tsconfig.json create mode 100644 samples/client/petstore/typescript-angular-v2/with-interfaces/typings.json diff --git a/bin/typescript-angular-v2-petstore-all.sh b/bin/typescript-angular-petstore-all.sh old mode 100755 new mode 100644 similarity index 68% rename from bin/typescript-angular-v2-petstore-all.sh rename to bin/typescript-angular-petstore-all.sh index ae2ae18719f..c3cdf8ba34f --- a/bin/typescript-angular-v2-petstore-all.sh +++ b/bin/typescript-angular-petstore-all.sh @@ -38,3 +38,11 @@ java $JAVA_OPTS -jar $executable $ags echo "Typescript Petstore API client (with interfaces generated)" ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l typescript-angular -o samples/client/petstore/typescript-angular-v2/with-interfaces -D withInterfaces=true --additional-properties ngVersion=2" java $JAVA_OPTS -jar $executable $ags + +echo "Typescript Petstore API client (v4 { Adding InjectionToken Over OpaqueToken })" +ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l typescript-angular -c bin/typescript-petstore-npm.json -o samples/client/petstore/typescript-angular-v4/npm --additional-properties ngVersion=4" +java $JAVA_OPTS -jar $executable $ags + +echo "Typescript Petstore API client (v4.3 { Adding HttpClientModule over HttpModule })" +ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l typescript-angular -c bin/typescript-petstore-npm.json -o samples/client/petstore/typescript-angular-v4.3/npm --additional-properties ngVersion=4.3" +java $JAVA_OPTS -jar $executable $ags diff --git a/bin/windows/typescript-angular2-petstore-all.bat b/bin/windows/typescript-angular-petstore-all.bat old mode 100755 new mode 100644 similarity index 58% rename from bin/windows/typescript-angular2-petstore-all.bat rename to bin/windows/typescript-angular-petstore-all.bat index 3d1a5179255..dff81b05a62 --- a/bin/windows/typescript-angular2-petstore-all.bat +++ b/bin/windows/typescript-angular-petstore-all.bat @@ -1,3 +1,7 @@ call .\bin\windows\typescript-angular-v2-with-npm.bat call .\bin\windows\typescript-angular-v2-interfaces.bat call .\bin\windows\typescript-angular-v2.bat +call .\bin\windows\typescript-angular-v4-with-npm.bat +call .\bin\windows\typescript-angular-v4.3-with-npm.bat + + diff --git a/modules/swagger-codegen/src/main/resources/typescript-angular/licenseInfo.mustache b/modules/swagger-codegen/src/main/resources/typescript-angular/licenseInfo.mustache index bbd8742e52a..7d61c4ee055 100644 --- a/modules/swagger-codegen/src/main/resources/typescript-angular/licenseInfo.mustache +++ b/modules/swagger-codegen/src/main/resources/typescript-angular/licenseInfo.mustache @@ -8,4 +8,4 @@ * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git * Do not edit the class manually. - */ + */ \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/typescript-angular/modelEnum.mustache b/modules/swagger-codegen/src/main/resources/typescript-angular/modelEnum.mustache index a32e859196f..aafd141aa9d 100644 --- a/modules/swagger-codegen/src/main/resources/typescript-angular/modelEnum.mustache +++ b/modules/swagger-codegen/src/main/resources/typescript-angular/modelEnum.mustache @@ -1,2 +1,9 @@ -export type {{classname}} = {{#allowableValues}}{{#enumVars}}{{{value}}}{{^-last}} | {{/-last}}{{/enumVars}}{{/allowableValues}}; +export type {{enumName}} = {{#allowableValues}}{{#enumVars}}{{{value}}}{{^-last}} | {{/-last}}{{/enumVars}}{{/allowableValues}}; +export const {{enumName}} = { +{{#allowableValues}} +{{#enumVars}} + {{name}}: {{{value}}} as {{enumName}}{{^-last}},{{/-last}} +{{/enumVars}} +{{/allowableValues}} +} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/typescript-angular/modelGeneric.mustache b/modules/swagger-codegen/src/main/resources/typescript-angular/modelGeneric.mustache index a8b3c80e364..34e35255d5a 100644 --- a/modules/swagger-codegen/src/main/resources/typescript-angular/modelGeneric.mustache +++ b/modules/swagger-codegen/src/main/resources/typescript-angular/modelGeneric.mustache @@ -10,14 +10,19 @@ export interface {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{ */ {{/description}} {{name}}{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{datatype}}}{{/isEnum}}; - {{/vars}} }{{#hasEnums}} export namespace {{classname}} { {{#vars}} {{#isEnum}} export type {{enumName}} = {{#allowableValues}}{{#enumVars}}{{{value}}}{{^-last}} | {{/-last}}{{/enumVars}}{{/allowableValues}}; + export const {{enumName}} = { + {{#allowableValues}} + {{#enumVars}} + {{name}}: {{{value}}} as {{enumName}}{{^-last}},{{/-last}} + {{/enumVars}} + {{/allowableValues}} + } {{/isEnum}} {{/vars}} -}{{/hasEnums}} - +}{{/hasEnums}} \ No newline at end of file diff --git a/pom.xml b/pom.xml index d063b8780d4..16a8e0e3578 100644 --- a/pom.xml +++ b/pom.xml @@ -685,7 +685,7 @@ - typescript-angular-client + typescript-angularjs-client env diff --git a/pom.xml.bash b/pom.xml.bash index 6d43fe6829d..02cd49a802a 100644 --- a/pom.xml.bash +++ b/pom.xml.bash @@ -685,7 +685,7 @@ - typescript-angular-client + typescript-angularjs-client env diff --git a/pom.xml.circleci b/pom.xml.circleci index d1b7b94572c..0f4f9879145 100644 --- a/pom.xml.circleci +++ b/pom.xml.circleci @@ -656,7 +656,7 @@ - typescript-angular-client + typescript-angularjs-client env diff --git a/pom.xml.shippable b/pom.xml.shippable index a73d38ae9aa..3b033834d4f 100644 --- a/pom.xml.shippable +++ b/pom.xml.shippable @@ -685,7 +685,7 @@ - typescript-angular-client + typescript-angularjs-client env diff --git a/samples/client/petstore/typescript-angular-v2/default/api/pet.service.ts b/samples/client/petstore/typescript-angular-v2/default/api/pet.service.ts index 11a1b603831..c2899427ea6 100644 --- a/samples/client/petstore/typescript-angular-v2/default/api/pet.service.ts +++ b/samples/client/petstore/typescript-angular-v2/default/api/pet.service.ts @@ -9,7 +9,6 @@ * https://github.com/swagger-api/swagger-codegen.git * Do not edit the class manually. */ - /* tslint:disable:no-unused-variable member-ordering */ import { Inject, Injectable, Optional } from '@angular/core'; diff --git a/samples/client/petstore/typescript-angular-v2/default/api/store.service.ts b/samples/client/petstore/typescript-angular-v2/default/api/store.service.ts index 393d291ba3d..24cf96b4136 100644 --- a/samples/client/petstore/typescript-angular-v2/default/api/store.service.ts +++ b/samples/client/petstore/typescript-angular-v2/default/api/store.service.ts @@ -9,7 +9,6 @@ * https://github.com/swagger-api/swagger-codegen.git * Do not edit the class manually. */ - /* tslint:disable:no-unused-variable member-ordering */ import { Inject, Injectable, Optional } from '@angular/core'; diff --git a/samples/client/petstore/typescript-angular-v2/default/api/user.service.ts b/samples/client/petstore/typescript-angular-v2/default/api/user.service.ts index f495f1f9d39..5bd7cdbac65 100644 --- a/samples/client/petstore/typescript-angular-v2/default/api/user.service.ts +++ b/samples/client/petstore/typescript-angular-v2/default/api/user.service.ts @@ -9,7 +9,6 @@ * https://github.com/swagger-api/swagger-codegen.git * Do not edit the class manually. */ - /* tslint:disable:no-unused-variable member-ordering */ import { Inject, Injectable, Optional } from '@angular/core'; diff --git a/samples/client/petstore/typescript-angular-v2/default/model/ApiResponse.ts b/samples/client/petstore/typescript-angular-v2/default/model/ApiResponse.ts index 3af781cf580..eac4208f022 100644 --- a/samples/client/petstore/typescript-angular-v2/default/model/ApiResponse.ts +++ b/samples/client/petstore/typescript-angular-v2/default/model/ApiResponse.ts @@ -11,15 +11,11 @@ */ - /** * Describes the result of uploading an image resource */ export interface ApiResponse { code?: number; - type?: string; - message?: string; - } diff --git a/samples/client/petstore/typescript-angular-v2/default/model/category.ts b/samples/client/petstore/typescript-angular-v2/default/model/category.ts index d09f8d7b265..5040d1db915 100644 --- a/samples/client/petstore/typescript-angular-v2/default/model/category.ts +++ b/samples/client/petstore/typescript-angular-v2/default/model/category.ts @@ -11,13 +11,10 @@ */ - /** * A category for a pet */ export interface Category { id?: number; - name?: string; - } diff --git a/samples/client/petstore/typescript-angular-v2/default/model/order.ts b/samples/client/petstore/typescript-angular-v2/default/model/order.ts index 4639b8c2949..33b60bb6e16 100644 --- a/samples/client/petstore/typescript-angular-v2/default/model/order.ts +++ b/samples/client/petstore/typescript-angular-v2/default/model/order.ts @@ -11,27 +11,25 @@ */ - /** * An order for a pets from the pet store */ export interface Order { id?: number; - petId?: number; - quantity?: number; - shipDate?: Date; - /** * Order Status */ status?: Order.StatusEnum; - complete?: boolean; - } export namespace Order { export type StatusEnum = 'placed' | 'approved' | 'delivered'; + export const StatusEnum = { + Placed: 'placed' as StatusEnum, + Approved: 'approved' as StatusEnum, + Delivered: 'delivered' as StatusEnum + } } diff --git a/samples/client/petstore/typescript-angular-v2/default/model/pet.ts b/samples/client/petstore/typescript-angular-v2/default/model/pet.ts index ce6c535b867..342ab5f8e75 100644 --- a/samples/client/petstore/typescript-angular-v2/default/model/pet.ts +++ b/samples/client/petstore/typescript-angular-v2/default/model/pet.ts @@ -9,7 +9,6 @@ * https://github.com/swagger-api/swagger-codegen.git * Do not edit the class manually. */ - import { Category } from './category'; import { Tag } from './tag'; @@ -19,21 +18,20 @@ import { Tag } from './tag'; */ export interface Pet { id?: number; - category?: Category; - name: string; - photoUrls: Array; - tags?: Array; - /** * pet status in the store */ status?: Pet.StatusEnum; - } export namespace Pet { export type StatusEnum = 'available' | 'pending' | 'sold'; + export const StatusEnum = { + Available: 'available' as StatusEnum, + Pending: 'pending' as StatusEnum, + Sold: 'sold' as StatusEnum + } } diff --git a/samples/client/petstore/typescript-angular-v2/default/model/tag.ts b/samples/client/petstore/typescript-angular-v2/default/model/tag.ts index 3ed1eeff8f3..c7524000357 100644 --- a/samples/client/petstore/typescript-angular-v2/default/model/tag.ts +++ b/samples/client/petstore/typescript-angular-v2/default/model/tag.ts @@ -11,13 +11,10 @@ */ - /** * A tag for a pet */ export interface Tag { id?: number; - name?: string; - } diff --git a/samples/client/petstore/typescript-angular-v2/default/model/user.ts b/samples/client/petstore/typescript-angular-v2/default/model/user.ts index f4914ae2608..a0261a6f37d 100644 --- a/samples/client/petstore/typescript-angular-v2/default/model/user.ts +++ b/samples/client/petstore/typescript-angular-v2/default/model/user.ts @@ -11,28 +11,19 @@ */ - /** * A User who is purchasing from the pet store */ export interface User { id?: number; - username?: string; - firstName?: string; - lastName?: string; - email?: string; - password?: string; - phone?: string; - /** * User Status */ userStatus?: number; - } diff --git a/samples/client/petstore/typescript-angular-v2/npm/api/pet.service.ts b/samples/client/petstore/typescript-angular-v2/npm/api/pet.service.ts index 11a1b603831..c2899427ea6 100644 --- a/samples/client/petstore/typescript-angular-v2/npm/api/pet.service.ts +++ b/samples/client/petstore/typescript-angular-v2/npm/api/pet.service.ts @@ -9,7 +9,6 @@ * https://github.com/swagger-api/swagger-codegen.git * Do not edit the class manually. */ - /* tslint:disable:no-unused-variable member-ordering */ import { Inject, Injectable, Optional } from '@angular/core'; diff --git a/samples/client/petstore/typescript-angular-v2/npm/api/store.service.ts b/samples/client/petstore/typescript-angular-v2/npm/api/store.service.ts index 393d291ba3d..24cf96b4136 100644 --- a/samples/client/petstore/typescript-angular-v2/npm/api/store.service.ts +++ b/samples/client/petstore/typescript-angular-v2/npm/api/store.service.ts @@ -9,7 +9,6 @@ * https://github.com/swagger-api/swagger-codegen.git * Do not edit the class manually. */ - /* tslint:disable:no-unused-variable member-ordering */ import { Inject, Injectable, Optional } from '@angular/core'; diff --git a/samples/client/petstore/typescript-angular-v2/npm/api/user.service.ts b/samples/client/petstore/typescript-angular-v2/npm/api/user.service.ts index f495f1f9d39..5bd7cdbac65 100644 --- a/samples/client/petstore/typescript-angular-v2/npm/api/user.service.ts +++ b/samples/client/petstore/typescript-angular-v2/npm/api/user.service.ts @@ -9,7 +9,6 @@ * https://github.com/swagger-api/swagger-codegen.git * Do not edit the class manually. */ - /* tslint:disable:no-unused-variable member-ordering */ import { Inject, Injectable, Optional } from '@angular/core'; diff --git a/samples/client/petstore/typescript-angular-v2/npm/model/ApiResponse.ts b/samples/client/petstore/typescript-angular-v2/npm/model/ApiResponse.ts index 3af781cf580..eac4208f022 100644 --- a/samples/client/petstore/typescript-angular-v2/npm/model/ApiResponse.ts +++ b/samples/client/petstore/typescript-angular-v2/npm/model/ApiResponse.ts @@ -11,15 +11,11 @@ */ - /** * Describes the result of uploading an image resource */ export interface ApiResponse { code?: number; - type?: string; - message?: string; - } diff --git a/samples/client/petstore/typescript-angular-v2/npm/model/category.ts b/samples/client/petstore/typescript-angular-v2/npm/model/category.ts index d09f8d7b265..5040d1db915 100644 --- a/samples/client/petstore/typescript-angular-v2/npm/model/category.ts +++ b/samples/client/petstore/typescript-angular-v2/npm/model/category.ts @@ -11,13 +11,10 @@ */ - /** * A category for a pet */ export interface Category { id?: number; - name?: string; - } diff --git a/samples/client/petstore/typescript-angular-v2/npm/model/order.ts b/samples/client/petstore/typescript-angular-v2/npm/model/order.ts index 4639b8c2949..33b60bb6e16 100644 --- a/samples/client/petstore/typescript-angular-v2/npm/model/order.ts +++ b/samples/client/petstore/typescript-angular-v2/npm/model/order.ts @@ -11,27 +11,25 @@ */ - /** * An order for a pets from the pet store */ export interface Order { id?: number; - petId?: number; - quantity?: number; - shipDate?: Date; - /** * Order Status */ status?: Order.StatusEnum; - complete?: boolean; - } export namespace Order { export type StatusEnum = 'placed' | 'approved' | 'delivered'; + export const StatusEnum = { + Placed: 'placed' as StatusEnum, + Approved: 'approved' as StatusEnum, + Delivered: 'delivered' as StatusEnum + } } diff --git a/samples/client/petstore/typescript-angular-v2/npm/model/pet.ts b/samples/client/petstore/typescript-angular-v2/npm/model/pet.ts index ce6c535b867..342ab5f8e75 100644 --- a/samples/client/petstore/typescript-angular-v2/npm/model/pet.ts +++ b/samples/client/petstore/typescript-angular-v2/npm/model/pet.ts @@ -9,7 +9,6 @@ * https://github.com/swagger-api/swagger-codegen.git * Do not edit the class manually. */ - import { Category } from './category'; import { Tag } from './tag'; @@ -19,21 +18,20 @@ import { Tag } from './tag'; */ export interface Pet { id?: number; - category?: Category; - name: string; - photoUrls: Array; - tags?: Array; - /** * pet status in the store */ status?: Pet.StatusEnum; - } export namespace Pet { export type StatusEnum = 'available' | 'pending' | 'sold'; + export const StatusEnum = { + Available: 'available' as StatusEnum, + Pending: 'pending' as StatusEnum, + Sold: 'sold' as StatusEnum + } } diff --git a/samples/client/petstore/typescript-angular-v2/npm/model/tag.ts b/samples/client/petstore/typescript-angular-v2/npm/model/tag.ts index 3ed1eeff8f3..c7524000357 100644 --- a/samples/client/petstore/typescript-angular-v2/npm/model/tag.ts +++ b/samples/client/petstore/typescript-angular-v2/npm/model/tag.ts @@ -11,13 +11,10 @@ */ - /** * A tag for a pet */ export interface Tag { id?: number; - name?: string; - } diff --git a/samples/client/petstore/typescript-angular-v2/npm/model/user.ts b/samples/client/petstore/typescript-angular-v2/npm/model/user.ts index f4914ae2608..a0261a6f37d 100644 --- a/samples/client/petstore/typescript-angular-v2/npm/model/user.ts +++ b/samples/client/petstore/typescript-angular-v2/npm/model/user.ts @@ -11,28 +11,19 @@ */ - /** * A User who is purchasing from the pet store */ export interface User { id?: number; - username?: string; - firstName?: string; - lastName?: string; - email?: string; - password?: string; - phone?: string; - /** * User Status */ userStatus?: number; - } diff --git a/samples/client/petstore/typescript-angular-v2/with-interfaces/README.md b/samples/client/petstore/typescript-angular-v2/with-interfaces/README.md new file mode 100644 index 00000000000..038fd51491c --- /dev/null +++ b/samples/client/petstore/typescript-angular-v2/with-interfaces/README.md @@ -0,0 +1,98 @@ +## @swagger/angular2-typescript-petstore@0.0.1 + +### Building + +To build an compile the typescript sources to javascript use: +``` +npm install +npm run build +``` + +### publishing + +First build the package than run ```npm publish``` + +### consuming + +navigate to the folder of your consuming project and run one of next commando's. + +_published:_ + +``` +npm install @swagger/angular2-typescript-petstore@0.0.1 --save +``` + +_unPublished (not recommended):_ + +``` +npm install PATH_TO_GENERATED_PACKAGE --save +``` + +_using `npm link`:_ + +In PATH_TO_GENERATED_PACKAGE: +``` +npm link +``` + +In your project: +``` +npm link @swagger/angular2-typescript-petstore@0.0.1 +``` + +In your angular2 project: + +``` +import { DefaultApi } from '@swagger/angular2-typescript-petstore/api/api'; +@NgModule({ + imports: [], + declarations: [], + exports: [], + providers: [AppModule] +}) +export class CoreModule {} +``` +``` +import { DefaultApi } from '@swagger/angular2-typescript-petstore/api/api'; + +export class AppComponent { + constructor(private apiGateway: DefaultApi) { } +} +``` + +### Set service base path +If different than the generated base path, during app bootstrap, you can provide the base path to your service. + +``` +import { BASE_PATH } from './path-to-swagger-gen-service/index'; + +bootstrap(AppComponent, [ + { provide: BASE_PATH, useValue: 'https://your-web-service.com' }, +]); +``` + +#### Using @angular/cli +First extend your `src/environments/*.ts` files by adding the corresponding base path: + +``` +export const environment = { + production: false, + API_BASE_PATH: 'http://127.0.0.1:8080' +}; +``` + +In the src/app/app.module.ts: +``` +import { BASE_PATH } from '@swagger/angular2-typescript-petstore'; +import { environment } from '../environments/environment'; + +@NgModule({ + declarations: [ + AppComponent, + ], + imports: [ ], + providers: [{ provide: BASE_PATH, useValue: useValue: environment.API_BASE_PATH }], + bootstrap: [AppComponent] +}) +export class AppModule { } +``` \ No newline at end of file diff --git a/samples/client/petstore/typescript-angular-v2/with-interfaces/api/pet.service.ts b/samples/client/petstore/typescript-angular-v2/with-interfaces/api/pet.service.ts index 8ff5eda659d..8d6285d29e1 100644 --- a/samples/client/petstore/typescript-angular-v2/with-interfaces/api/pet.service.ts +++ b/samples/client/petstore/typescript-angular-v2/with-interfaces/api/pet.service.ts @@ -9,7 +9,6 @@ * https://github.com/swagger-api/swagger-codegen.git * Do not edit the class manually. */ - /* tslint:disable:no-unused-variable member-ordering */ import { Inject, Injectable, Optional } from '@angular/core'; diff --git a/samples/client/petstore/typescript-angular-v2/with-interfaces/api/pet.serviceInterface.ts b/samples/client/petstore/typescript-angular-v2/with-interfaces/api/pet.serviceInterface.ts index 5ee39b3ab69..968ed61c846 100644 --- a/samples/client/petstore/typescript-angular-v2/with-interfaces/api/pet.serviceInterface.ts +++ b/samples/client/petstore/typescript-angular-v2/with-interfaces/api/pet.serviceInterface.ts @@ -9,7 +9,6 @@ * https://github.com/swagger-api/swagger-codegen.git * Do not edit the class manually. */ - import { Headers } from '@angular/http'; import { Observable } from 'rxjs/Observable'; diff --git a/samples/client/petstore/typescript-angular-v2/with-interfaces/api/store.service.ts b/samples/client/petstore/typescript-angular-v2/with-interfaces/api/store.service.ts index 1297e638d43..af8cc47369b 100644 --- a/samples/client/petstore/typescript-angular-v2/with-interfaces/api/store.service.ts +++ b/samples/client/petstore/typescript-angular-v2/with-interfaces/api/store.service.ts @@ -9,7 +9,6 @@ * https://github.com/swagger-api/swagger-codegen.git * Do not edit the class manually. */ - /* tslint:disable:no-unused-variable member-ordering */ import { Inject, Injectable, Optional } from '@angular/core'; diff --git a/samples/client/petstore/typescript-angular-v2/with-interfaces/api/store.serviceInterface.ts b/samples/client/petstore/typescript-angular-v2/with-interfaces/api/store.serviceInterface.ts index a40dcc47b83..f7fdf5fb0d9 100644 --- a/samples/client/petstore/typescript-angular-v2/with-interfaces/api/store.serviceInterface.ts +++ b/samples/client/petstore/typescript-angular-v2/with-interfaces/api/store.serviceInterface.ts @@ -9,7 +9,6 @@ * https://github.com/swagger-api/swagger-codegen.git * Do not edit the class manually. */ - import { Headers } from '@angular/http'; import { Observable } from 'rxjs/Observable'; diff --git a/samples/client/petstore/typescript-angular-v2/with-interfaces/api/user.service.ts b/samples/client/petstore/typescript-angular-v2/with-interfaces/api/user.service.ts index 480d00b3bb6..54752a85503 100644 --- a/samples/client/petstore/typescript-angular-v2/with-interfaces/api/user.service.ts +++ b/samples/client/petstore/typescript-angular-v2/with-interfaces/api/user.service.ts @@ -9,7 +9,6 @@ * https://github.com/swagger-api/swagger-codegen.git * Do not edit the class manually. */ - /* tslint:disable:no-unused-variable member-ordering */ import { Inject, Injectable, Optional } from '@angular/core'; diff --git a/samples/client/petstore/typescript-angular-v2/with-interfaces/api/user.serviceInterface.ts b/samples/client/petstore/typescript-angular-v2/with-interfaces/api/user.serviceInterface.ts index 3cab3a9c64b..f68e221df9a 100644 --- a/samples/client/petstore/typescript-angular-v2/with-interfaces/api/user.serviceInterface.ts +++ b/samples/client/petstore/typescript-angular-v2/with-interfaces/api/user.serviceInterface.ts @@ -9,7 +9,6 @@ * https://github.com/swagger-api/swagger-codegen.git * Do not edit the class manually. */ - import { Headers } from '@angular/http'; import { Observable } from 'rxjs/Observable'; diff --git a/samples/client/petstore/typescript-angular-v2/with-interfaces/model/Category.ts b/samples/client/petstore/typescript-angular-v2/with-interfaces/model/Category.ts index d09f8d7b265..5040d1db915 100644 --- a/samples/client/petstore/typescript-angular-v2/with-interfaces/model/Category.ts +++ b/samples/client/petstore/typescript-angular-v2/with-interfaces/model/Category.ts @@ -11,13 +11,10 @@ */ - /** * A category for a pet */ export interface Category { id?: number; - name?: string; - } diff --git a/samples/client/petstore/typescript-angular-v2/with-interfaces/model/Order.ts b/samples/client/petstore/typescript-angular-v2/with-interfaces/model/Order.ts index 4639b8c2949..33b60bb6e16 100644 --- a/samples/client/petstore/typescript-angular-v2/with-interfaces/model/Order.ts +++ b/samples/client/petstore/typescript-angular-v2/with-interfaces/model/Order.ts @@ -11,27 +11,25 @@ */ - /** * An order for a pets from the pet store */ export interface Order { id?: number; - petId?: number; - quantity?: number; - shipDate?: Date; - /** * Order Status */ status?: Order.StatusEnum; - complete?: boolean; - } export namespace Order { export type StatusEnum = 'placed' | 'approved' | 'delivered'; + export const StatusEnum = { + Placed: 'placed' as StatusEnum, + Approved: 'approved' as StatusEnum, + Delivered: 'delivered' as StatusEnum + } } diff --git a/samples/client/petstore/typescript-angular-v2/with-interfaces/model/Pet.ts b/samples/client/petstore/typescript-angular-v2/with-interfaces/model/Pet.ts index ce6c535b867..342ab5f8e75 100644 --- a/samples/client/petstore/typescript-angular-v2/with-interfaces/model/Pet.ts +++ b/samples/client/petstore/typescript-angular-v2/with-interfaces/model/Pet.ts @@ -9,7 +9,6 @@ * https://github.com/swagger-api/swagger-codegen.git * Do not edit the class manually. */ - import { Category } from './category'; import { Tag } from './tag'; @@ -19,21 +18,20 @@ import { Tag } from './tag'; */ export interface Pet { id?: number; - category?: Category; - name: string; - photoUrls: Array; - tags?: Array; - /** * pet status in the store */ status?: Pet.StatusEnum; - } export namespace Pet { export type StatusEnum = 'available' | 'pending' | 'sold'; + export const StatusEnum = { + Available: 'available' as StatusEnum, + Pending: 'pending' as StatusEnum, + Sold: 'sold' as StatusEnum + } } diff --git a/samples/client/petstore/typescript-angular-v2/with-interfaces/model/Tag.ts b/samples/client/petstore/typescript-angular-v2/with-interfaces/model/Tag.ts index 3ed1eeff8f3..c7524000357 100644 --- a/samples/client/petstore/typescript-angular-v2/with-interfaces/model/Tag.ts +++ b/samples/client/petstore/typescript-angular-v2/with-interfaces/model/Tag.ts @@ -11,13 +11,10 @@ */ - /** * A tag for a pet */ export interface Tag { id?: number; - name?: string; - } diff --git a/samples/client/petstore/typescript-angular-v2/with-interfaces/model/User.ts b/samples/client/petstore/typescript-angular-v2/with-interfaces/model/User.ts index f4914ae2608..a0261a6f37d 100644 --- a/samples/client/petstore/typescript-angular-v2/with-interfaces/model/User.ts +++ b/samples/client/petstore/typescript-angular-v2/with-interfaces/model/User.ts @@ -11,28 +11,19 @@ */ - /** * A User who is purchasing from the pet store */ export interface User { id?: number; - username?: string; - firstName?: string; - lastName?: string; - email?: string; - password?: string; - phone?: string; - /** * User Status */ userStatus?: number; - } diff --git a/samples/client/petstore/typescript-angular-v2/with-interfaces/model/apiResponse.ts b/samples/client/petstore/typescript-angular-v2/with-interfaces/model/apiResponse.ts index 3af781cf580..eac4208f022 100644 --- a/samples/client/petstore/typescript-angular-v2/with-interfaces/model/apiResponse.ts +++ b/samples/client/petstore/typescript-angular-v2/with-interfaces/model/apiResponse.ts @@ -11,15 +11,11 @@ */ - /** * Describes the result of uploading an image resource */ export interface ApiResponse { code?: number; - type?: string; - message?: string; - } diff --git a/samples/client/petstore/typescript-angular-v2/with-interfaces/package.json b/samples/client/petstore/typescript-angular-v2/with-interfaces/package.json new file mode 100644 index 00000000000..d6aee04c589 --- /dev/null +++ b/samples/client/petstore/typescript-angular-v2/with-interfaces/package.json @@ -0,0 +1,40 @@ +{ + "name": "@swagger/angular2-typescript-petstore", + "version": "0.0.1", + "description": "swagger client for @swagger/angular2-typescript-petstore", + "author": "Swagger Codegen Contributors", + "keywords": [ + "swagger-client" + ], + "license": "Unlicense", + "main": "dist/index.js", + "typings": "dist/index.d.ts", + "scripts": { + "build": "tsc --outDir dist/", + "postinstall": "npm run build" + }, + "peerDependencies": { + "@angular/core": "^2.0.0", + "@angular/http": "^2.0.0", + "@angular/common": "^2.0.0", + "@angular/compiler": "^2.0.0", + "core-js": "^2.4.0", + "reflect-metadata": "^0.1.3", + "rxjs": "^5.4.0", + "zone.js": "^0.7.6" + }, + "devDependencies": { + "@angular/core": "^2.0.0", + "@angular/http": "^2.0.0", + "@angular/common": "^2.0.0", + "@angular/compiler": "^2.0.0", + "@angular/platform-browser": "^2.0.0", + "reflect-metadata": "^0.1.3", + "rxjs": "^5.4.0", + "zone.js": "^0.7.6", + "typescript": "^2.1.5" + }, + "publishConfig": { + "registry":"https://skimdb.npmjs.com/registry" + } +} diff --git a/samples/client/petstore/typescript-angular-v2/with-interfaces/tsconfig.json b/samples/client/petstore/typescript-angular-v2/with-interfaces/tsconfig.json new file mode 100644 index 00000000000..a6e9096bbf7 --- /dev/null +++ b/samples/client/petstore/typescript-angular-v2/with-interfaces/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "noImplicitAny": false, + "suppressImplicitAnyIndexErrors": true, + "target": "es5", + "module": "es6", + "moduleResolution": "node", + "removeComments": true, + "sourceMap": true, + "outDir": "./dist", + "noLib": false, + "declaration": true, + "lib": [ "es6", "dom" ] + }, + "exclude": [ + "node_modules", + "dist" + ], + "filesGlob": [ + "./model/*.ts", + "./api/*.ts" + ] +} diff --git a/samples/client/petstore/typescript-angular-v2/with-interfaces/typings.json b/samples/client/petstore/typescript-angular-v2/with-interfaces/typings.json new file mode 100644 index 00000000000..507c40e5cbe --- /dev/null +++ b/samples/client/petstore/typescript-angular-v2/with-interfaces/typings.json @@ -0,0 +1,5 @@ +{ + "globalDependencies": { + "core-js": "registry:dt/core-js#0.0.0+20160725163759" + } +} diff --git a/samples/client/petstore/typescript-angular-v4.3/npm/api/pet.service.ts b/samples/client/petstore/typescript-angular-v4.3/npm/api/pet.service.ts index ee44df243de..16a19cdefa8 100644 --- a/samples/client/petstore/typescript-angular-v4.3/npm/api/pet.service.ts +++ b/samples/client/petstore/typescript-angular-v4.3/npm/api/pet.service.ts @@ -9,7 +9,6 @@ * https://github.com/swagger-api/swagger-codegen.git * Do not edit the class manually. */ - /* tslint:disable:no-unused-variable member-ordering */ import { Inject, Injectable, Optional } from '@angular/core'; diff --git a/samples/client/petstore/typescript-angular-v4.3/npm/api/store.service.ts b/samples/client/petstore/typescript-angular-v4.3/npm/api/store.service.ts index f0cf7dbc1cb..3b9c88fbb77 100644 --- a/samples/client/petstore/typescript-angular-v4.3/npm/api/store.service.ts +++ b/samples/client/petstore/typescript-angular-v4.3/npm/api/store.service.ts @@ -9,7 +9,6 @@ * https://github.com/swagger-api/swagger-codegen.git * Do not edit the class manually. */ - /* tslint:disable:no-unused-variable member-ordering */ import { Inject, Injectable, Optional } from '@angular/core'; diff --git a/samples/client/petstore/typescript-angular-v4.3/npm/api/user.service.ts b/samples/client/petstore/typescript-angular-v4.3/npm/api/user.service.ts index d67fb448fc3..4cf879c80cc 100644 --- a/samples/client/petstore/typescript-angular-v4.3/npm/api/user.service.ts +++ b/samples/client/petstore/typescript-angular-v4.3/npm/api/user.service.ts @@ -9,7 +9,6 @@ * https://github.com/swagger-api/swagger-codegen.git * Do not edit the class manually. */ - /* tslint:disable:no-unused-variable member-ordering */ import { Inject, Injectable, Optional } from '@angular/core'; 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 e79fabe8c8c..ac34396e0b3 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 @@ -11,17 +11,13 @@ */ - /** * Describes the result of uploading an image resource */ export interface ApiResponse { code?: number; - type?: string; - 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 56608731f95..767b4948418 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 @@ -11,15 +11,12 @@ */ - /** * A category for a pet */ export interface Category { id?: number; - 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 84b59f1b09a..33b60bb6e16 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 @@ -11,29 +11,25 @@ */ - /** * An order for a pets from the pet store */ export interface Order { id?: number; - petId?: number; - quantity?: number; - shipDate?: Date; - /** * Order Status */ status?: Order.StatusEnum; - complete?: boolean; - } export namespace Order { export type StatusEnum = 'placed' | 'approved' | 'delivered'; + export const StatusEnum = { + Placed: 'placed' as StatusEnum, + Approved: 'approved' as StatusEnum, + Delivered: 'delivered' as StatusEnum + } } - - 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 c0fc942934c..342ab5f8e75 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 @@ -9,7 +9,6 @@ * https://github.com/swagger-api/swagger-codegen.git * Do not edit the class manually. */ - import { Category } from './category'; import { Tag } from './tag'; @@ -19,23 +18,20 @@ import { Tag } from './tag'; */ export interface Pet { id?: number; - category?: Category; - name: string; - photoUrls: Array; - tags?: Array; - /** * pet status in the store */ status?: Pet.StatusEnum; - } export namespace Pet { export type StatusEnum = 'available' | 'pending' | 'sold'; + export const StatusEnum = { + Available: 'available' as StatusEnum, + Pending: 'pending' as StatusEnum, + Sold: 'sold' as StatusEnum + } } - - 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 dbfa473f538..73e4d26aa3b 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 @@ -11,15 +11,12 @@ */ - /** * A tag for a pet */ export interface Tag { id?: number; - 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 4dfad607c51..de9c1d85670 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 @@ -11,30 +11,21 @@ */ - /** * A User who is purchasing from the pet store */ export interface User { id?: number; - username?: string; - firstName?: string; - lastName?: string; - email?: string; - password?: string; - phone?: string; - /** * User Status */ userStatus?: number; - } diff --git a/samples/client/petstore/typescript-angular-v4/npm/api/pet.service.ts b/samples/client/petstore/typescript-angular-v4/npm/api/pet.service.ts index 11a1b603831..c2899427ea6 100644 --- a/samples/client/petstore/typescript-angular-v4/npm/api/pet.service.ts +++ b/samples/client/petstore/typescript-angular-v4/npm/api/pet.service.ts @@ -9,7 +9,6 @@ * https://github.com/swagger-api/swagger-codegen.git * Do not edit the class manually. */ - /* tslint:disable:no-unused-variable member-ordering */ import { Inject, Injectable, Optional } from '@angular/core'; diff --git a/samples/client/petstore/typescript-angular-v4/npm/api/store.service.ts b/samples/client/petstore/typescript-angular-v4/npm/api/store.service.ts index 393d291ba3d..24cf96b4136 100644 --- a/samples/client/petstore/typescript-angular-v4/npm/api/store.service.ts +++ b/samples/client/petstore/typescript-angular-v4/npm/api/store.service.ts @@ -9,7 +9,6 @@ * https://github.com/swagger-api/swagger-codegen.git * Do not edit the class manually. */ - /* tslint:disable:no-unused-variable member-ordering */ import { Inject, Injectable, Optional } from '@angular/core'; diff --git a/samples/client/petstore/typescript-angular-v4/npm/api/user.service.ts b/samples/client/petstore/typescript-angular-v4/npm/api/user.service.ts index f495f1f9d39..5bd7cdbac65 100644 --- a/samples/client/petstore/typescript-angular-v4/npm/api/user.service.ts +++ b/samples/client/petstore/typescript-angular-v4/npm/api/user.service.ts @@ -9,7 +9,6 @@ * https://github.com/swagger-api/swagger-codegen.git * Do not edit the class manually. */ - /* tslint:disable:no-unused-variable member-ordering */ import { Inject, Injectable, Optional } from '@angular/core'; diff --git a/samples/client/petstore/typescript-angular-v4/npm/model/apiResponse.ts b/samples/client/petstore/typescript-angular-v4/npm/model/apiResponse.ts index 3af781cf580..eac4208f022 100644 --- a/samples/client/petstore/typescript-angular-v4/npm/model/apiResponse.ts +++ b/samples/client/petstore/typescript-angular-v4/npm/model/apiResponse.ts @@ -11,15 +11,11 @@ */ - /** * Describes the result of uploading an image resource */ export interface ApiResponse { code?: number; - type?: string; - message?: string; - } diff --git a/samples/client/petstore/typescript-angular-v4/npm/model/category.ts b/samples/client/petstore/typescript-angular-v4/npm/model/category.ts index d09f8d7b265..5040d1db915 100644 --- a/samples/client/petstore/typescript-angular-v4/npm/model/category.ts +++ b/samples/client/petstore/typescript-angular-v4/npm/model/category.ts @@ -11,13 +11,10 @@ */ - /** * A category for a pet */ export interface Category { id?: number; - name?: string; - } diff --git a/samples/client/petstore/typescript-angular-v4/npm/model/order.ts b/samples/client/petstore/typescript-angular-v4/npm/model/order.ts index 4639b8c2949..33b60bb6e16 100644 --- a/samples/client/petstore/typescript-angular-v4/npm/model/order.ts +++ b/samples/client/petstore/typescript-angular-v4/npm/model/order.ts @@ -11,27 +11,25 @@ */ - /** * An order for a pets from the pet store */ export interface Order { id?: number; - petId?: number; - quantity?: number; - shipDate?: Date; - /** * Order Status */ status?: Order.StatusEnum; - complete?: boolean; - } export namespace Order { export type StatusEnum = 'placed' | 'approved' | 'delivered'; + export const StatusEnum = { + Placed: 'placed' as StatusEnum, + Approved: 'approved' as StatusEnum, + Delivered: 'delivered' as StatusEnum + } } diff --git a/samples/client/petstore/typescript-angular-v4/npm/model/pet.ts b/samples/client/petstore/typescript-angular-v4/npm/model/pet.ts index ce6c535b867..342ab5f8e75 100644 --- a/samples/client/petstore/typescript-angular-v4/npm/model/pet.ts +++ b/samples/client/petstore/typescript-angular-v4/npm/model/pet.ts @@ -9,7 +9,6 @@ * https://github.com/swagger-api/swagger-codegen.git * Do not edit the class manually. */ - import { Category } from './category'; import { Tag } from './tag'; @@ -19,21 +18,20 @@ import { Tag } from './tag'; */ export interface Pet { id?: number; - category?: Category; - name: string; - photoUrls: Array; - tags?: Array; - /** * pet status in the store */ status?: Pet.StatusEnum; - } export namespace Pet { export type StatusEnum = 'available' | 'pending' | 'sold'; + export const StatusEnum = { + Available: 'available' as StatusEnum, + Pending: 'pending' as StatusEnum, + Sold: 'sold' as StatusEnum + } } diff --git a/samples/client/petstore/typescript-angular-v4/npm/model/tag.ts b/samples/client/petstore/typescript-angular-v4/npm/model/tag.ts index 3ed1eeff8f3..c7524000357 100644 --- a/samples/client/petstore/typescript-angular-v4/npm/model/tag.ts +++ b/samples/client/petstore/typescript-angular-v4/npm/model/tag.ts @@ -11,13 +11,10 @@ */ - /** * A tag for a pet */ export interface Tag { id?: number; - name?: string; - } diff --git a/samples/client/petstore/typescript-angular-v4/npm/model/user.ts b/samples/client/petstore/typescript-angular-v4/npm/model/user.ts index f4914ae2608..a0261a6f37d 100644 --- a/samples/client/petstore/typescript-angular-v4/npm/model/user.ts +++ b/samples/client/petstore/typescript-angular-v4/npm/model/user.ts @@ -11,28 +11,19 @@ */ - /** * A User who is purchasing from the pet store */ export interface User { id?: number; - username?: string; - firstName?: string; - lastName?: string; - email?: string; - password?: string; - phone?: string; - /** * User Status */ userStatus?: number; - }