From d01a60cb1441b467858c8becf056c2fcf956ef7b Mon Sep 17 00:00:00 2001 From: wing328 Date: Thu, 1 Feb 2018 19:20:35 +0800 Subject: [PATCH] update ts petstore files --- .../.swagger-codegen/VERSION | 2 +- .../typescript-angular/README.md | 171 ++++++++++++++++++ .../typescript-angular/api.module.ts | 15 +- .../typescript-angular/model/modelReturn.ts | 22 +++ .../.swagger-codegen/VERSION | 2 +- .../typescript-angular2/README.md | 171 ++++++++++++++++++ .../typescript-angular2/api.module.ts | 26 ++- .../typescript-angular2/api/fake.service.ts | 48 +++-- .../typescript-angular2/configuration.ts | 53 ++++++ .../typescript-angular2/git_push.sh | 2 +- .../typescript-angular2/model/ModelReturn.ts | 8 +- .../default/.swagger-codegen/VERSION | 2 +- .../default/model/apiResponse.ts | 21 +++ .../npm/.swagger-codegen/VERSION | 2 +- .../typescript-angular-v2/npm/api.module.ts | 10 +- .../npm/model/apiResponse.ts | 21 +++ .../typescript-angular-v2/npm/tsconfig.json | 2 +- .../with-interfaces/.swagger-codegen/VERSION | 2 +- .../with-interfaces/README.md | 18 +- .../with-interfaces/model/category.ts | 20 ++ .../with-interfaces/model/order.ts | 35 ++++ .../with-interfaces/model/pet.ts | 37 ++++ .../with-interfaces/model/tag.ts | 20 ++ .../with-interfaces/model/user.ts | 29 +++ .../npm/.swagger-codegen/VERSION | 2 +- .../typescript-angular-v4.3/npm/tsconfig.json | 2 +- .../npm/.swagger-codegen/VERSION | 2 +- .../typescript-angular-v4/npm/tsconfig.json | 2 +- 28 files changed, 691 insertions(+), 56 deletions(-) create mode 100644 samples/client/petstore-security-test/typescript-angular/README.md create mode 100644 samples/client/petstore-security-test/typescript-angular/model/modelReturn.ts create mode 100644 samples/client/petstore-security-test/typescript-angular2/README.md create mode 100644 samples/client/petstore/typescript-angular-v2/default/model/apiResponse.ts create mode 100644 samples/client/petstore/typescript-angular-v2/npm/model/apiResponse.ts create mode 100644 samples/client/petstore/typescript-angular-v2/with-interfaces/model/category.ts create mode 100644 samples/client/petstore/typescript-angular-v2/with-interfaces/model/order.ts create mode 100644 samples/client/petstore/typescript-angular-v2/with-interfaces/model/pet.ts create mode 100644 samples/client/petstore/typescript-angular-v2/with-interfaces/model/tag.ts create mode 100644 samples/client/petstore/typescript-angular-v2/with-interfaces/model/user.ts diff --git a/samples/client/petstore-security-test/typescript-angular/.swagger-codegen/VERSION b/samples/client/petstore-security-test/typescript-angular/.swagger-codegen/VERSION index cc6612c36e0..855ff9501eb 100644 --- a/samples/client/petstore-security-test/typescript-angular/.swagger-codegen/VERSION +++ b/samples/client/petstore-security-test/typescript-angular/.swagger-codegen/VERSION @@ -1 +1 @@ -2.3.0 \ No newline at end of file +2.4.0-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore-security-test/typescript-angular/README.md b/samples/client/petstore-security-test/typescript-angular/README.md new file mode 100644 index 00000000000..f679bcb1320 --- /dev/null +++ b/samples/client/petstore-security-test/typescript-angular/README.md @@ -0,0 +1,171 @@ +## @ + +### 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 @ --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 @ +``` + +In your Angular project: + + +``` +// without configuring providers +import { ApiModule } from ''; +import { HttpClientModule } from '@angular/common/http'; + + +@NgModule({ + imports: [ + ApiModule, + // make sure to import the HttpClientModule in the AppModule only, + // see https://github.com/angular/angular/issues/20575 + HttpClientModule + ], + declarations: [ AppComponent ], + providers: [], + bootstrap: [ AppComponent ] +}) +export class AppModule {} +``` + +``` +// configuring providers +import { ApiModule, Configuration, ConfigurationParameters } from ''; + +export function apiConfigFactory (): Configuration => { + const params: ConfigurationParameters = { + // set configuration parameters here. + } + return new Configuration(params); +} + +@NgModule({ + imports: [ ApiModule.forRoot(apiConfigFactory) ], + declarations: [ AppComponent ], + providers: [], + bootstrap: [ AppComponent ] +}) +export class AppModule {} +``` + +``` +import { DefaultApi } from ''; + +export class AppComponent { + constructor(private apiGateway: DefaultApi) { } +} +``` + +Note: The ApiModule is restricted to being instantiated once app wide. +This is to ensure that all services are treated as singletons. + +#### Using multiple swagger files / APIs / ApiModules +In order to use multiple `ApiModules` generated from different swagger files, +you can create an alias name when importing the modules +in order to avoid naming conflicts: +``` +import { ApiModule } from 'my-api-path'; +import { ApiModule as OtherApiModule } from 'my-other-api-path'; +import { HttpClientModule } from '@angular/common/http'; + + +@NgModule({ + imports: [ + ApiModule, + OtherApiModule, + // make sure to import the HttpClientModule in the AppModule only, + // see https://github.com/angular/angular/issues/20575 + HttpClientModule + ] +}) +export class AppModule { + +} +``` + + +### 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 ''; + +bootstrap(AppComponent, [ + { provide: BASE_PATH, useValue: 'https://your-web-service.com' }, +]); +``` +or + +``` +import { BASE_PATH } from ''; + +@NgModule({ + imports: [], + declarations: [ AppComponent ], + providers: [ provide: BASE_PATH, useValue: 'https://your-web-service.com' ], + bootstrap: [ AppComponent ] +}) +export class AppModule {} +``` + + +#### 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 ''; +import { environment } from '../environments/environment'; + +@NgModule({ + declarations: [ + AppComponent + ], + imports: [ ], + providers: [{ provide: BASE_PATH, useValue: environment.API_BASE_PATH }], + bootstrap: [ AppComponent ] +}) +export class AppModule { } +``` \ No newline at end of file diff --git a/samples/client/petstore-security-test/typescript-angular/api.module.ts b/samples/client/petstore-security-test/typescript-angular/api.module.ts index 77fac0cd707..a95cda25231 100644 --- a/samples/client/petstore-security-test/typescript-angular/api.module.ts +++ b/samples/client/petstore-security-test/typescript-angular/api.module.ts @@ -1,12 +1,12 @@ import { NgModule, ModuleWithProviders, SkipSelf, Optional } from '@angular/core'; -import { CommonModule } from '@angular/common'; -import { HttpClientModule } from '@angular/common/http'; import { Configuration } from './configuration'; +import { HttpClient } from '@angular/common/http'; + import { FakeService } from './api/fake.service'; @NgModule({ - imports: [ CommonModule, HttpClientModule ], + imports: [], declarations: [], exports: [], providers: [ @@ -20,9 +20,14 @@ export class ApiModule { } } - constructor( @Optional() @SkipSelf() parentModule: ApiModule) { + constructor( @Optional() @SkipSelf() parentModule: ApiModule, + @Optional() http: HttpClient) { if (parentModule) { - throw new Error('ApiModule is already loaded. Import your base AppModule only.'); + throw new Error('ApiModule is already loaded. Import in your base AppModule only.'); + } + if (!http) { + throw new Error('You need to import the HttpClientModule in your AppModule! \n' + + 'See also https://github.com/angular/angular/issues/20575'); } } } diff --git a/samples/client/petstore-security-test/typescript-angular/model/modelReturn.ts b/samples/client/petstore-security-test/typescript-angular/model/modelReturn.ts new file mode 100644 index 00000000000..515aa6eff6a --- /dev/null +++ b/samples/client/petstore-security-test/typescript-angular/model/modelReturn.ts @@ -0,0 +1,22 @@ +/** + * Swagger Petstore *_/ ' \" =end -- \\r\\n \\n \\r + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end -- + * + * OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r + * Contact: apiteam@swagger.io *_/ ' \" =end -- \\r\\n \\n \\r + * + * 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. + */ + + +/** + * Model for testing reserved words *_/ ' \" =end -- \\r\\n \\n \\r + */ +export interface ModelReturn { + /** + * property description *_/ ' \" =end -- \\r\\n \\n \\r + */ + _return?: number; +} diff --git a/samples/client/petstore-security-test/typescript-angular2/.swagger-codegen/VERSION b/samples/client/petstore-security-test/typescript-angular2/.swagger-codegen/VERSION index f9f7450d135..855ff9501eb 100644 --- a/samples/client/petstore-security-test/typescript-angular2/.swagger-codegen/VERSION +++ b/samples/client/petstore-security-test/typescript-angular2/.swagger-codegen/VERSION @@ -1 +1 @@ -2.3.0-SNAPSHOT \ No newline at end of file +2.4.0-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore-security-test/typescript-angular2/README.md b/samples/client/petstore-security-test/typescript-angular2/README.md new file mode 100644 index 00000000000..f679bcb1320 --- /dev/null +++ b/samples/client/petstore-security-test/typescript-angular2/README.md @@ -0,0 +1,171 @@ +## @ + +### 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 @ --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 @ +``` + +In your Angular project: + + +``` +// without configuring providers +import { ApiModule } from ''; +import { HttpClientModule } from '@angular/common/http'; + + +@NgModule({ + imports: [ + ApiModule, + // make sure to import the HttpClientModule in the AppModule only, + // see https://github.com/angular/angular/issues/20575 + HttpClientModule + ], + declarations: [ AppComponent ], + providers: [], + bootstrap: [ AppComponent ] +}) +export class AppModule {} +``` + +``` +// configuring providers +import { ApiModule, Configuration, ConfigurationParameters } from ''; + +export function apiConfigFactory (): Configuration => { + const params: ConfigurationParameters = { + // set configuration parameters here. + } + return new Configuration(params); +} + +@NgModule({ + imports: [ ApiModule.forRoot(apiConfigFactory) ], + declarations: [ AppComponent ], + providers: [], + bootstrap: [ AppComponent ] +}) +export class AppModule {} +``` + +``` +import { DefaultApi } from ''; + +export class AppComponent { + constructor(private apiGateway: DefaultApi) { } +} +``` + +Note: The ApiModule is restricted to being instantiated once app wide. +This is to ensure that all services are treated as singletons. + +#### Using multiple swagger files / APIs / ApiModules +In order to use multiple `ApiModules` generated from different swagger files, +you can create an alias name when importing the modules +in order to avoid naming conflicts: +``` +import { ApiModule } from 'my-api-path'; +import { ApiModule as OtherApiModule } from 'my-other-api-path'; +import { HttpClientModule } from '@angular/common/http'; + + +@NgModule({ + imports: [ + ApiModule, + OtherApiModule, + // make sure to import the HttpClientModule in the AppModule only, + // see https://github.com/angular/angular/issues/20575 + HttpClientModule + ] +}) +export class AppModule { + +} +``` + + +### 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 ''; + +bootstrap(AppComponent, [ + { provide: BASE_PATH, useValue: 'https://your-web-service.com' }, +]); +``` +or + +``` +import { BASE_PATH } from ''; + +@NgModule({ + imports: [], + declarations: [ AppComponent ], + providers: [ provide: BASE_PATH, useValue: 'https://your-web-service.com' ], + bootstrap: [ AppComponent ] +}) +export class AppModule {} +``` + + +#### 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 ''; +import { environment } from '../environments/environment'; + +@NgModule({ + declarations: [ + AppComponent + ], + imports: [ ], + providers: [{ provide: BASE_PATH, useValue: environment.API_BASE_PATH }], + bootstrap: [ AppComponent ] +}) +export class AppModule { } +``` \ No newline at end of file diff --git a/samples/client/petstore-security-test/typescript-angular2/api.module.ts b/samples/client/petstore-security-test/typescript-angular2/api.module.ts index c3bde487bc4..a95cda25231 100644 --- a/samples/client/petstore-security-test/typescript-angular2/api.module.ts +++ b/samples/client/petstore-security-test/typescript-angular2/api.module.ts @@ -1,21 +1,33 @@ -import { NgModule, ModuleWithProviders } from '@angular/core'; -import { CommonModule } from '@angular/common'; -import { HttpModule } from '@angular/http'; +import { NgModule, ModuleWithProviders, SkipSelf, Optional } from '@angular/core'; import { Configuration } from './configuration'; +import { HttpClient } from '@angular/common/http'; + import { FakeService } from './api/fake.service'; @NgModule({ - imports: [ CommonModule, HttpModule ], + imports: [], declarations: [], exports: [], - providers: [ FakeService ] + providers: [ + FakeService ] }) export class ApiModule { - public static forConfig(configurationFactory: () => Configuration): ModuleWithProviders { + public static forRoot(configurationFactory: () => Configuration): ModuleWithProviders { return { ngModule: ApiModule, - providers: [ {provide: Configuration, useFactory: configurationFactory}] + providers: [ { provide: Configuration, useFactory: configurationFactory } ] + } + } + + constructor( @Optional() @SkipSelf() parentModule: ApiModule, + @Optional() http: HttpClient) { + if (parentModule) { + throw new Error('ApiModule is already loaded. Import in your base AppModule only.'); + } + if (!http) { + throw new Error('You need to import the HttpClientModule in your AppModule! \n' + + 'See also https://github.com/angular/angular/issues/20575'); } } } diff --git a/samples/client/petstore-security-test/typescript-angular2/api/fake.service.ts b/samples/client/petstore-security-test/typescript-angular2/api/fake.service.ts index ec51d332251..d0047d78bee 100644 --- a/samples/client/petstore-security-test/typescript-angular2/api/fake.service.ts +++ b/samples/client/petstore-security-test/typescript-angular2/api/fake.service.ts @@ -9,19 +9,18 @@ * 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'; -import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http'; +import { HttpClient, HttpHeaders, HttpParams, + HttpResponse, HttpEvent } from '@angular/common/http'; +import { CustomHttpUrlEncodingCodec } from '../encoder'; import { Observable } from 'rxjs/Observable'; -import '../rxjs-operators'; import { BASE_PATH, COLLECTION_FORMATS } from '../variables'; import { Configuration } from '../configuration'; -import { CustomHttpUrlEncodingCodec } from '../encoder'; @Injectable() @@ -56,21 +55,36 @@ export class FakeService { } - /** * To test code injection *_/ ' \" =end -- \\r\\n \\n \\r * - * @param test code inject * ' " =end rn n r To test code injection *_/ ' \" =end -- \\r\\n \\n \\r + * @param testCodeInjectEndRnNR To test code injection *_/ ' \" =end -- \\r\\n \\n \\r + * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. + * @param reportProgress flag to report request and response progress. */ - public testCodeInjectEndRnNR(test code inject * ' " =end rn n r?: string): Observable<{}> { + public testCodeInjectEndRnNR(testCodeInjectEndRnNR?: string, observe?: 'body', reportProgress?: boolean): Observable; + public testCodeInjectEndRnNR(testCodeInjectEndRnNR?: string, observe?: 'response', reportProgress?: boolean): Observable>; + public testCodeInjectEndRnNR(testCodeInjectEndRnNR?: string, observe?: 'events', reportProgress?: boolean): Observable>; + public testCodeInjectEndRnNR(testCodeInjectEndRnNR?: string, observe: any = 'body', reportProgress: boolean = false ): Observable { let headers = this.defaultHeaders; + // to determine the Accept header + let httpHeaderAccepts: string[] = [ + 'application/json', + '*_/ =end -- ' + ]; + let httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts); + if (httpHeaderAcceptSelected != undefined) { + headers = headers.set("Accept", httpHeaderAcceptSelected); + } + // to determine the Content-Type header let consumes: string[] = [ 'application/json', '*_/ =end -- ' ]; + const canConsumeForm = this.canConsumeForm(consumes); let formParams: { append(param: string, value: any): void; }; @@ -82,17 +96,19 @@ export class FakeService { formParams = new HttpParams({encoder: new CustomHttpUrlEncodingCodec()}); } - - - if (test code inject * ' " =end rn n r !== undefined) { - formParams = formParams.append('test code inject */ ' " =end -- \r\n \n \r', test code inject * ' " =end rn n r) || formParams; + if (testCodeInjectEndRnNR !== undefined) { + formParams = formParams.append('test code inject */ ' " =end -- \r\n \n \r', testCodeInjectEndRnNR) || formParams; } - return this.httpClient.put(`${this.basePath}/fake`, - convertFormParamsToString ? formParams.toString() : formParams, { - headers: headers, - withCredentials: this.configuration.withCredentials, - }); + return this.httpClient.put(`${this.basePath}/fake`, + convertFormParamsToString ? formParams.toString() : formParams, + { + withCredentials: this.configuration.withCredentials, + headers: headers, + observe: observe, + reportProgress: reportProgress + } + ); } } diff --git a/samples/client/petstore-security-test/typescript-angular2/configuration.ts b/samples/client/petstore-security-test/typescript-angular2/configuration.ts index 005c3a26df3..2ee1824f5f7 100644 --- a/samples/client/petstore-security-test/typescript-angular2/configuration.ts +++ b/samples/client/petstore-security-test/typescript-angular2/configuration.ts @@ -23,4 +23,57 @@ export class Configuration { this.basePath = configurationParameters.basePath; this.withCredentials = configurationParameters.withCredentials; } + + /** + * Select the correct content-type to use for a request. + * Uses {@link Configuration#isJsonMime} to determine the correct content-type. + * If no content type is found return the first found type if the contentTypes is not empty + * @param {string[]} contentTypes - the array of content types that are available for selection + * @returns {string} the selected content-type or undefined if no selection could be made. + */ + public selectHeaderContentType (contentTypes: string[]): string | undefined { + if (contentTypes.length == 0) { + return undefined; + } + + let type = contentTypes.find(x => this.isJsonMime(x)); + if (type === undefined) { + return contentTypes[0]; + } + return type; + } + + /** + * Select the correct accept content-type to use for a request. + * Uses {@link Configuration#isJsonMime} to determine the correct accept content-type. + * If no content type is found return the first found type if the contentTypes is not empty + * @param {string[]} accepts - the array of content types that are available for selection. + * @returns {string} the selected content-type or undefined if no selection could be made. + */ + public selectHeaderAccept(accepts: string[]): string | undefined { + if (accepts.length == 0) { + return undefined; + } + + let type = accepts.find(x => this.isJsonMime(x)); + if (type === undefined) { + return accepts[0]; + } + return type; + } + + /** + * Check if the given MIME is a JSON MIME. + * JSON MIME examples: + * application/json + * application/json; charset=UTF8 + * APPLICATION/JSON + * application/vnd.company+json + * @param {string} mime - MIME (Multipurpose Internet Mail Extensions) + * @return {boolean} True if the given MIME is JSON, false otherwise. + */ + public isJsonMime(mime: string): boolean { + const jsonMime: RegExp = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i'); + return mime != null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json'); + } } diff --git a/samples/client/petstore-security-test/typescript-angular2/git_push.sh b/samples/client/petstore-security-test/typescript-angular2/git_push.sh index ed374619b13..ae01b182ae9 100644 --- a/samples/client/petstore-security-test/typescript-angular2/git_push.sh +++ b/samples/client/petstore-security-test/typescript-angular2/git_push.sh @@ -36,7 +36,7 @@ git_remote=`git remote` if [ "$git_remote" = "" ]; then # git remote not defined if [ "$GIT_TOKEN" = "" ]; then - echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git crediential in your environment." + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git else git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git diff --git a/samples/client/petstore-security-test/typescript-angular2/model/ModelReturn.ts b/samples/client/petstore-security-test/typescript-angular2/model/ModelReturn.ts index e2360156a9d..515aa6eff6a 100644 --- a/samples/client/petstore-security-test/typescript-angular2/model/ModelReturn.ts +++ b/samples/client/petstore-security-test/typescript-angular2/model/ModelReturn.ts @@ -11,16 +11,12 @@ */ - /** * Model for testing reserved words *_/ ' \" =end -- \\r\\n \\n \\r */ -export interface ModelReturn { +export interface ModelReturn { /** * property description *_/ ' \" =end -- \\r\\n \\n \\r */ - return?: number; - + _return?: number; } - - diff --git a/samples/client/petstore/typescript-angular-v2/default/.swagger-codegen/VERSION b/samples/client/petstore/typescript-angular-v2/default/.swagger-codegen/VERSION index 2bf1c1ccf36..855ff9501eb 100644 --- a/samples/client/petstore/typescript-angular-v2/default/.swagger-codegen/VERSION +++ b/samples/client/petstore/typescript-angular-v2/default/.swagger-codegen/VERSION @@ -1 +1 @@ -2.3.1 +2.4.0-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/typescript-angular-v2/default/model/apiResponse.ts b/samples/client/petstore/typescript-angular-v2/default/model/apiResponse.ts new file mode 100644 index 00000000000..af5590c3d85 --- /dev/null +++ b/samples/client/petstore/typescript-angular-v2/default/model/apiResponse.ts @@ -0,0 +1,21 @@ +/** + * Swagger Petstore + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * 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. + */ + + +/** + * 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/.swagger-codegen/VERSION b/samples/client/petstore/typescript-angular-v2/npm/.swagger-codegen/VERSION index 2bf1c1ccf36..855ff9501eb 100644 --- a/samples/client/petstore/typescript-angular-v2/npm/.swagger-codegen/VERSION +++ b/samples/client/petstore/typescript-angular-v2/npm/.swagger-codegen/VERSION @@ -1 +1 @@ -2.3.1 +2.4.0-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/typescript-angular-v2/npm/api.module.ts b/samples/client/petstore/typescript-angular-v2/npm/api.module.ts index e192f195ab4..1504d60e630 100644 --- a/samples/client/petstore/typescript-angular-v2/npm/api.module.ts +++ b/samples/client/petstore/typescript-angular-v2/npm/api.module.ts @@ -1,7 +1,8 @@ import { NgModule, ModuleWithProviders, SkipSelf, Optional } from '@angular/core'; -import { CommonModule } from '@angular/common'; import { Configuration } from './configuration'; +import { Http } from '@angular/http'; + import { PetService } from './api/pet.service'; import { StoreService } from './api/store.service'; import { UserService } from './api/user.service'; @@ -23,9 +24,14 @@ export class ApiModule { } } - constructor( @Optional() @SkipSelf() parentModule: ApiModule) { + constructor( @Optional() @SkipSelf() parentModule: ApiModule, + @Optional() http: Http) { if (parentModule) { throw new Error('ApiModule is already loaded. Import in your base AppModule only.'); } + if (!http) { + throw new Error('You need to import the HttpModule in your AppModule! \n' + + 'See also https://github.com/angular/angular/issues/20575'); + } } } diff --git a/samples/client/petstore/typescript-angular-v2/npm/model/apiResponse.ts b/samples/client/petstore/typescript-angular-v2/npm/model/apiResponse.ts new file mode 100644 index 00000000000..af5590c3d85 --- /dev/null +++ b/samples/client/petstore/typescript-angular-v2/npm/model/apiResponse.ts @@ -0,0 +1,21 @@ +/** + * Swagger Petstore + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * 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. + */ + + +/** + * 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/tsconfig.json b/samples/client/petstore/typescript-angular-v2/npm/tsconfig.json index a6e9096bbf7..498ee01e9dd 100644 --- a/samples/client/petstore/typescript-angular-v2/npm/tsconfig.json +++ b/samples/client/petstore/typescript-angular-v2/npm/tsconfig.json @@ -5,7 +5,7 @@ "noImplicitAny": false, "suppressImplicitAnyIndexErrors": true, "target": "es5", - "module": "es6", + "module": "commonjs", "moduleResolution": "node", "removeComments": true, "sourceMap": true, diff --git a/samples/client/petstore/typescript-angular-v2/with-interfaces/.swagger-codegen/VERSION b/samples/client/petstore/typescript-angular-v2/with-interfaces/.swagger-codegen/VERSION index 2bf1c1ccf36..855ff9501eb 100644 --- a/samples/client/petstore/typescript-angular-v2/with-interfaces/.swagger-codegen/VERSION +++ b/samples/client/petstore/typescript-angular-v2/with-interfaces/.swagger-codegen/VERSION @@ -1 +1 @@ -2.3.1 +2.4.0-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/typescript-angular-v2/with-interfaces/README.md b/samples/client/petstore/typescript-angular-v2/with-interfaces/README.md index 507613134c5..d1eaaa92928 100644 --- a/samples/client/petstore/typescript-angular-v2/with-interfaces/README.md +++ b/samples/client/petstore/typescript-angular-v2/with-interfaces/README.md @@ -1,4 +1,4 @@ -## @swagger/angular2-typescript-petstore@0.0.1 +## @ ### Building @@ -19,7 +19,7 @@ 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 +npm install @ --save ``` _unPublished (not recommended):_ @@ -37,7 +37,7 @@ npm link In your project: ``` -npm link @swagger/angular2-typescript-petstore@0.0.1 +npm link @ ``` In your Angular project: @@ -45,7 +45,7 @@ In your Angular project: ``` // without configuring providers -import { ApiModule } from '@swagger/angular2-typescript-petstore'; +import { ApiModule } from ''; import { HttpModule } from '@angular/http'; @@ -63,7 +63,7 @@ export class AppModule {} ``` // configuring providers -import { ApiModule, Configuration, ConfigurationParameters } from '@swagger/angular2-typescript-petstore'; +import { ApiModule, Configuration, ConfigurationParameters } from ''; export function apiConfigFactory (): Configuration => { const params: ConfigurationParameters = { @@ -82,7 +82,7 @@ export class AppModule {} ``` ``` -import { DefaultApi } from '@swagger/angular2-typescript-petstore'; +import { DefaultApi } from ''; export class AppComponent { constructor(private apiGateway: DefaultApi) { } @@ -119,7 +119,7 @@ export class AppModule { If different than the generated base path, during app bootstrap, you can provide the base path to your service. ``` -import { BASE_PATH } from '@swagger/angular2-typescript-petstore'; +import { BASE_PATH } from ''; bootstrap(AppComponent, [ { provide: BASE_PATH, useValue: 'https://your-web-service.com' }, @@ -128,7 +128,7 @@ bootstrap(AppComponent, [ or ``` -import { BASE_PATH } from '@swagger/angular2-typescript-petstore'; +import { BASE_PATH } from ''; @NgModule({ imports: [], @@ -152,7 +152,7 @@ export const environment = { In the src/app/app.module.ts: ``` -import { BASE_PATH } from '@swagger/angular2-typescript-petstore'; +import { BASE_PATH } from ''; import { environment } from '../environments/environment'; @NgModule({ 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 new file mode 100644 index 00000000000..093bd438a38 --- /dev/null +++ b/samples/client/petstore/typescript-angular-v2/with-interfaces/model/category.ts @@ -0,0 +1,20 @@ +/** + * Swagger Petstore + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * 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. + */ + + +/** + * 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 new file mode 100644 index 00000000000..6a1e1fd6bcf --- /dev/null +++ b/samples/client/petstore/typescript-angular-v2/with-interfaces/model/order.ts @@ -0,0 +1,35 @@ +/** + * Swagger Petstore + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * 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. + */ + + +/** + * 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 new file mode 100644 index 00000000000..b8b659008af --- /dev/null +++ b/samples/client/petstore/typescript-angular-v2/with-interfaces/model/pet.ts @@ -0,0 +1,37 @@ +/** + * Swagger Petstore + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * 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. + */ +import { Category } from './category'; +import { Tag } from './tag'; + + +/** + * A pet for sale in the pet store + */ +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 new file mode 100644 index 00000000000..e35232df691 --- /dev/null +++ b/samples/client/petstore/typescript-angular-v2/with-interfaces/model/tag.ts @@ -0,0 +1,20 @@ +/** + * Swagger Petstore + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * 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. + */ + + +/** + * 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 new file mode 100644 index 00000000000..e8788de129c --- /dev/null +++ b/samples/client/petstore/typescript-angular-v2/with-interfaces/model/user.ts @@ -0,0 +1,29 @@ +/** + * Swagger Petstore + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * 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. + */ + + +/** + * 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.3/npm/.swagger-codegen/VERSION b/samples/client/petstore/typescript-angular-v4.3/npm/.swagger-codegen/VERSION index 2bf1c1ccf36..855ff9501eb 100644 --- a/samples/client/petstore/typescript-angular-v4.3/npm/.swagger-codegen/VERSION +++ b/samples/client/petstore/typescript-angular-v4.3/npm/.swagger-codegen/VERSION @@ -1 +1 @@ -2.3.1 +2.4.0-SNAPSHOT \ No newline at end of file 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..498ee01e9dd 100644 --- a/samples/client/petstore/typescript-angular-v4.3/npm/tsconfig.json +++ b/samples/client/petstore/typescript-angular-v4.3/npm/tsconfig.json @@ -5,7 +5,7 @@ "noImplicitAny": false, "suppressImplicitAnyIndexErrors": true, "target": "es5", - "module": "es6", + "module": "commonjs", "moduleResolution": "node", "removeComments": true, "sourceMap": true, diff --git a/samples/client/petstore/typescript-angular-v4/npm/.swagger-codegen/VERSION b/samples/client/petstore/typescript-angular-v4/npm/.swagger-codegen/VERSION index 2bf1c1ccf36..855ff9501eb 100644 --- a/samples/client/petstore/typescript-angular-v4/npm/.swagger-codegen/VERSION +++ b/samples/client/petstore/typescript-angular-v4/npm/.swagger-codegen/VERSION @@ -1 +1 @@ -2.3.1 +2.4.0-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/typescript-angular-v4/npm/tsconfig.json b/samples/client/petstore/typescript-angular-v4/npm/tsconfig.json index a6e9096bbf7..498ee01e9dd 100644 --- a/samples/client/petstore/typescript-angular-v4/npm/tsconfig.json +++ b/samples/client/petstore/typescript-angular-v4/npm/tsconfig.json @@ -5,7 +5,7 @@ "noImplicitAny": false, "suppressImplicitAnyIndexErrors": true, "target": "es5", - "module": "es6", + "module": "commonjs", "moduleResolution": "node", "removeComments": true, "sourceMap": true,