From 45eb5fffc01bdc99ebdfef64f6f9a72e8f3875cd Mon Sep 17 00:00:00 2001 From: wing328 Date: Tue, 4 Jul 2017 01:00:35 +0800 Subject: [PATCH] add ngVersion option --- bin/typescript-angular2-petstore-all.sh | 6 +- ...typescript-angular2-petstore-interfaces.sh | 2 +- bin/typescript-angular2-petstore-with-npm.sh | 2 +- bin/typescript-angular2-petstore.sh | 2 +- bin/typescript-angular4-petstore-with-npm.sh | 31 + .../TypeScriptAngular2ClientCodegen.java | 30 +- .../typescript-angular2/package.mustache | 18 +- .../with-interfaces/api/pet.service.ts | 99 +-- .../api/pet.serviceInterface.ts | 20 +- .../with-interfaces/api/store.service.ts | 31 +- .../api/store.serviceInterface.ts | 8 +- .../with-interfaces/api/user.service.ts | 80 ++- .../api/user.serviceInterface.ts | 14 +- .../with-interfaces/model/Category.ts | 7 +- .../with-interfaces/model/Order.ts | 7 +- .../with-interfaces/model/Pet.ts | 7 +- .../with-interfaces/model/Tag.ts | 7 +- .../with-interfaces/model/User.ts | 7 +- .../with-interfaces/model/apiResponse.ts | 25 + .../with-interfaces/model/models.ts | 1 + .../typescript-angular4/npm/.gitignore | 4 + .../npm/.swagger-codegen-ignore | 23 + .../npm/.swagger-codegen/VERSION | 1 + .../typescript-angular4/npm/README.md | 98 +++ .../typescript-angular4/npm/api.module.ts | 23 + .../typescript-angular4/npm/api/api.ts | 7 + .../npm/api/pet.service.ts | 637 ++++++++++++++++++ .../npm/api/store.service.ts | 291 ++++++++ .../npm/api/user.service.ts | 529 +++++++++++++++ .../typescript-angular4/npm/configuration.ts | 26 + .../typescript-angular4/npm/git_push.sh | 52 ++ .../petstore/typescript-angular4/npm/index.ts | 5 + .../npm/model/apiResponse.ts | 25 + .../typescript-angular4/npm/model/category.ts | 23 + .../typescript-angular4/npm/model/models.ts | 6 + .../typescript-angular4/npm/model/order.ts | 41 ++ .../typescript-angular4/npm/model/pet.ts | 43 ++ .../typescript-angular4/npm/model/tag.ts | 23 + .../typescript-angular4/npm/model/user.ts | 38 ++ .../typescript-angular4/npm/package.json | 40 ++ .../typescript-angular4/npm/rxjs-operators.ts | 11 + .../typescript-angular4/npm/tsconfig.json | 25 + .../typescript-angular4/npm/typings.json | 5 + .../typescript-angular4/npm/variables.ts | 9 + 44 files changed, 2252 insertions(+), 137 deletions(-) create mode 100755 bin/typescript-angular4-petstore-with-npm.sh create mode 100644 samples/client/petstore/typescript-angular2/with-interfaces/model/apiResponse.ts create mode 100644 samples/client/petstore/typescript-angular4/npm/.gitignore create mode 100644 samples/client/petstore/typescript-angular4/npm/.swagger-codegen-ignore create mode 100644 samples/client/petstore/typescript-angular4/npm/.swagger-codegen/VERSION create mode 100644 samples/client/petstore/typescript-angular4/npm/README.md create mode 100644 samples/client/petstore/typescript-angular4/npm/api.module.ts create mode 100644 samples/client/petstore/typescript-angular4/npm/api/api.ts create mode 100644 samples/client/petstore/typescript-angular4/npm/api/pet.service.ts create mode 100644 samples/client/petstore/typescript-angular4/npm/api/store.service.ts create mode 100644 samples/client/petstore/typescript-angular4/npm/api/user.service.ts create mode 100644 samples/client/petstore/typescript-angular4/npm/configuration.ts create mode 100644 samples/client/petstore/typescript-angular4/npm/git_push.sh create mode 100644 samples/client/petstore/typescript-angular4/npm/index.ts create mode 100644 samples/client/petstore/typescript-angular4/npm/model/apiResponse.ts create mode 100644 samples/client/petstore/typescript-angular4/npm/model/category.ts create mode 100644 samples/client/petstore/typescript-angular4/npm/model/models.ts create mode 100644 samples/client/petstore/typescript-angular4/npm/model/order.ts create mode 100644 samples/client/petstore/typescript-angular4/npm/model/pet.ts create mode 100644 samples/client/petstore/typescript-angular4/npm/model/tag.ts create mode 100644 samples/client/petstore/typescript-angular4/npm/model/user.ts create mode 100644 samples/client/petstore/typescript-angular4/npm/package.json create mode 100644 samples/client/petstore/typescript-angular4/npm/rxjs-operators.ts create mode 100644 samples/client/petstore/typescript-angular4/npm/tsconfig.json create mode 100644 samples/client/petstore/typescript-angular4/npm/typings.json create mode 100644 samples/client/petstore/typescript-angular4/npm/variables.ts diff --git a/bin/typescript-angular2-petstore-all.sh b/bin/typescript-angular2-petstore-all.sh index 0a4ee7080d5..bf83c8473ca 100755 --- a/bin/typescript-angular2-petstore-all.sh +++ b/bin/typescript-angular2-petstore-all.sh @@ -28,13 +28,13 @@ fi export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" echo "Typescript Petstore API client (default)" -ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l typescript-angular2 -o samples/client/petstore/typescript-angular2/default" +ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l typescript-angular2 -o samples/client/petstore/typescript-angular2/default --additional-properties ngVersion=2" java $JAVA_OPTS -jar $executable $ags echo "Typescript Petstore API client (npm setting)" -ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l typescript-angular2 -c bin/typescript-petstore-npm.json -o samples/client/petstore/typescript-angular2/npm" +ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l typescript-angular2 -c bin/typescript-petstore-npm.json -o samples/client/petstore/typescript-angular2/npm --additional-properties ngVersion=2" 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.json -l typescript-angular2 -o samples/client/petstore/typescript-angular2/with-interfaces -D withInterfaces=true" +ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l typescript-angular2 -o samples/client/petstore/typescript-angular2/with-interfaces -D withInterfaces=true --additional-properties ngVersion=2" java $JAVA_OPTS -jar $executable $ags diff --git a/bin/typescript-angular2-petstore-interfaces.sh b/bin/typescript-angular2-petstore-interfaces.sh index 12b3228a619..bd61ab0c27f 100755 --- a/bin/typescript-angular2-petstore-interfaces.sh +++ b/bin/typescript-angular2-petstore-interfaces.sh @@ -26,6 +26,6 @@ fi # if you've executed sbt assembly previously it will use that instead. export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" -ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l typescript-angular2 -o samples/client/petstore/typescript-angular2/with-interfaces -D withInterfaces=true" +ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l typescript-angular2 -o samples/client/petstore/typescript-angular2/with-interfaces -D withInterfaces=true --additional-properties ngVersion=2" java $JAVA_OPTS -jar $executable $ags diff --git a/bin/typescript-angular2-petstore-with-npm.sh b/bin/typescript-angular2-petstore-with-npm.sh index 305a3e0b39d..5615ed53d5e 100755 --- a/bin/typescript-angular2-petstore-with-npm.sh +++ b/bin/typescript-angular2-petstore-with-npm.sh @@ -26,6 +26,6 @@ fi # if you've executed sbt assembly previously it will use that instead. export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" -ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l typescript-angular2 -c bin/typescript-petstore-npm.json -o samples/client/petstore/typescript-angular2/npm" +ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l typescript-angular2 -c bin/typescript-petstore-npm.json -o samples/client/petstore/typescript-angular2/npm --additional-properties ngVersion=2" java $JAVA_OPTS -jar $executable $ags diff --git a/bin/typescript-angular2-petstore.sh b/bin/typescript-angular2-petstore.sh index f26dd0f668f..87e283d51d8 100755 --- a/bin/typescript-angular2-petstore.sh +++ b/bin/typescript-angular2-petstore.sh @@ -26,6 +26,6 @@ fi # if you've executed sbt assembly previously it will use that instead. export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" -ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l typescript-angular2 -o samples/client/petstore/typescript-angular2/default" +ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l typescript-angular2 -o samples/client/petstore/typescript-angular2/default --additional-properties ngVersion=2" java $JAVA_OPTS -jar $executable $ags diff --git a/bin/typescript-angular4-petstore-with-npm.sh b/bin/typescript-angular4-petstore-with-npm.sh new file mode 100755 index 00000000000..877d3e0a19f --- /dev/null +++ b/bin/typescript-angular4-petstore-with-npm.sh @@ -0,0 +1,31 @@ +#!/bin/sh + +SCRIPT="$0" + +while [ -h "$SCRIPT" ] ; do + ls=`ls -ld "$SCRIPT"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + SCRIPT="$link" + else + SCRIPT=`dirname "$SCRIPT"`/"$link" + fi +done + +if [ ! -d "${APP_DIR}" ]; then + APP_DIR=`dirname "$SCRIPT"`/.. + APP_DIR=`cd "${APP_DIR}"; pwd` +fi + +executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar" + +if [ ! -f "$executable" ] +then + mvn clean package +fi + +# if you've executed sbt assembly previously it will use that instead. +export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" +ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l typescript-angular2 -c bin/typescript-petstore-npm.json -o samples/client/petstore/typescript-angular4/npm --additional-properties ngVersion=4" + +java $JAVA_OPTS -jar $executable $ags diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/TypeScriptAngular2ClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/TypeScriptAngular2ClientCodegen.java index f83a36be6eb..f81108a8972 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/TypeScriptAngular2ClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/TypeScriptAngular2ClientCodegen.java @@ -33,12 +33,14 @@ public class TypeScriptAngular2ClientCodegen extends AbstractTypeScriptClientCod public static final String INJECTION_TOKEN = "injectionToken"; public static final String INJECTION_TOKEN_IMPORT = "injectionTokenImport"; public static final String WITH_INTERFACES = "withInterfaces"; + public static final String NG_VERSION = "ngVersion"; protected String npmName = null; protected String npmVersion = "1.0.0"; protected String npmRepository = null; protected String injectionToken = "InjectionToken"; protected String injectionTokenImport = "InjectionToken"; + protected String ngVersion = "4"; public TypeScriptAngular2ClientCodegen() { super(); @@ -59,6 +61,7 @@ public class TypeScriptAngular2ClientCodegen extends AbstractTypeScriptClientCod this.cliOptions.add(new CliOption(SNAPSHOT, "When setting this property to true the version will be suffixed with -SNAPSHOT.yyyyMMddHHmm", BooleanProperty.TYPE).defaultValue(Boolean.FALSE.toString())); this.cliOptions.add(new CliOption(USE_OPAQUE_TOKEN, "When setting this property to true, OpaqueToken is used instead of InjectionToken", BooleanProperty.TYPE).defaultValue(Boolean.FALSE.toString())); this.cliOptions.add(new CliOption(WITH_INTERFACES, "Setting this property to true will generate interfaces next to the default class implementations.", BooleanProperty.TYPE).defaultValue(Boolean.FALSE.toString())); + this.cliOptions.add(new CliOption(NG_VERSION, "The version of Angular (2 or 4). Default is '4'")); } @Override @@ -74,7 +77,7 @@ public class TypeScriptAngular2ClientCodegen extends AbstractTypeScriptClientCod @Override public String getHelp() { - return "Generates a TypeScript Angular2 client library."; + return "Generates a TypeScript Angular (2.x or 4.x) client library."; } @Override @@ -106,6 +109,23 @@ public class TypeScriptAngular2ClientCodegen extends AbstractTypeScriptClientCod apiTemplateFiles.put("apiInterface.mustache", "Interface.ts"); } } + + // determine NG version + if (additionalProperties.containsKey(NG_VERSION)) { + if ("2".equals(additionalProperties.get(NG_VERSION).toString())) { + additionalProperties.put("isNg2x", true); + setNgVersion("2"); + } else if ("4".equals(additionalProperties.get(NG_VERSION).toString())) { + additionalProperties.put("isNg4x", true); + setNgVersion("4"); + } else { + throw new IllegalArgumentException("Invalid ngVersion, which must be either '2' or '4'"); + } + } else { + // default to 4 + additionalProperties.put("isNg4x", true); + setNgVersion("4"); + } } private void addNpmPackageGeneration() { @@ -307,6 +327,14 @@ public class TypeScriptAngular2ClientCodegen extends AbstractTypeScriptClientCod return modelPackage() + "/" + toModelFilename(name); } + public String getNgVersion() { + return ngVersion; + } + + public void setNgVersion(String ngVersion) { + this.ngVersion = ngVersion; + } + public String getNpmName() { return npmName; } diff --git a/modules/swagger-codegen/src/main/resources/typescript-angular2/package.mustache b/modules/swagger-codegen/src/main/resources/typescript-angular2/package.mustache index b9d16d974eb..c8441855488 100644 --- a/modules/swagger-codegen/src/main/resources/typescript-angular2/package.mustache +++ b/modules/swagger-codegen/src/main/resources/typescript-angular2/package.mustache @@ -14,21 +14,21 @@ "postinstall": "npm run build" }, "peerDependencies": { - "@angular/core": "^2.2.2", - "@angular/http": "^2.2.2", - "@angular/common": "^2.2.2", - "@angular/compiler": "^2.2.2", + "@angular/core": "{{#isNg2x}}^2.2.2{{/isNg2x}}{{#isNg4x}}^4.2.5{{/isNg4x}}", + "@angular/http": "{{#isNg2x}}^2.2.2{{/isNg2x}}{{#isNg4x}}^4.2.5{{/isNg4x}}", + "@angular/common": "{{#isNg2x}}^2.2.2{{/isNg2x}}{{#isNg4x}}^4.2.5{{/isNg4x}}", + "@angular/compiler": "{{#isNg2x}}^2.2.2{{/isNg2x}}{{#isNg4x}}^4.2.5{{/isNg4x}}", "core-js": "^2.4.0", "reflect-metadata": "^0.1.3", "rxjs": "^5.1.0", "zone.js": "^0.7.6" }, "devDependencies": { - "@angular/core": "^2.2.2", - "@angular/http": "^2.2.2", - "@angular/common": "^2.2.2", - "@angular/compiler": "^2.2.2", - "@angular/platform-browser": "^2.2.2", + "@angular/core": "{{#isNg2x}}^2.2.2{{/isNg2x}}{{#isNg4x}}^4.2.5{{/isNg4x}}", + "@angular/http": "{{#isNg2x}}^2.2.2{{/isNg2x}}{{#isNg4x}}^4.2.5{{/isNg4x}}", + "@angular/common": "{{#isNg2x}}^2.2.2{{/isNg2x}}{{#isNg4x}}^4.2.5{{/isNg4x}}", + "@angular/compiler": "{{#isNg2x}}^2.2.2{{/isNg2x}}{{#isNg4x}}^4.2.5{{/isNg4x}}", + "@angular/platform-browser": "{{#isNg2x}}^2.2.2{{/isNg2x}}{{#isNg4x}}^4.2.5{{/isNg4x}}", "reflect-metadata": "^0.1.3", "rxjs": "5.1.0", "zone.js": "^0.7.6", diff --git a/samples/client/petstore/typescript-angular2/with-interfaces/api/pet.service.ts b/samples/client/petstore/typescript-angular2/with-interfaces/api/pet.service.ts index 5bc5d2aa437..5198ead65e0 100644 --- a/samples/client/petstore/typescript-angular2/with-interfaces/api/pet.service.ts +++ b/samples/client/petstore/typescript-angular2/with-interfaces/api/pet.service.ts @@ -1,9 +1,9 @@ /** * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters + * 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@wordnik.com + * Contact: apiteam@swagger.io * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git @@ -20,6 +20,7 @@ import { Response, ResponseContentType } from '@angular/http import { Observable } from 'rxjs/Observable'; import '../rxjs-operators'; +import { ApiResponse } from '../model/apiResponse'; import { Pet } from '../model/pet'; import { BASE_PATH, COLLECTION_FORMATS } from '../variables'; @@ -78,7 +79,7 @@ export class PetService implements PetServiceInterface { * * @param body Pet object that needs to be added to the store */ - public addPet(body?: Pet, extraHttpRequestParams?: any): Observable<{}> { + public addPet(body: Pet, extraHttpRequestParams?: any): Observable<{}> { return this.addPetWithHttpInfo(body, extraHttpRequestParams) .map((response: Response) => { if (response.status === 204) { @@ -111,7 +112,7 @@ export class PetService implements PetServiceInterface { * Multiple status values can be provided with comma separated strings * @param status Status values that need to be considered for filter */ - public findPetsByStatus(status?: Array, extraHttpRequestParams?: any): Observable> { + public findPetsByStatus(status: Array, extraHttpRequestParams?: any): Observable> { return this.findPetsByStatusWithHttpInfo(status, extraHttpRequestParams) .map((response: Response) => { if (response.status === 204) { @@ -127,7 +128,7 @@ export class PetService implements PetServiceInterface { * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. * @param tags Tags to filter by */ - public findPetsByTags(tags?: Array, extraHttpRequestParams?: any): Observable> { + public findPetsByTags(tags: Array, extraHttpRequestParams?: any): Observable> { return this.findPetsByTagsWithHttpInfo(tags, extraHttpRequestParams) .map((response: Response) => { if (response.status === 204) { @@ -140,8 +141,8 @@ export class PetService implements PetServiceInterface { /** * Find pet by ID - * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions - * @param petId ID of pet that needs to be fetched + * Returns a single pet + * @param petId ID of pet to return */ public getPetById(petId: number, extraHttpRequestParams?: any): Observable { return this.getPetByIdWithHttpInfo(petId, extraHttpRequestParams) @@ -159,7 +160,7 @@ export class PetService implements PetServiceInterface { * * @param body Pet object that needs to be added to the store */ - public updatePet(body?: Pet, extraHttpRequestParams?: any): Observable<{}> { + public updatePet(body: Pet, extraHttpRequestParams?: any): Observable<{}> { return this.updatePetWithHttpInfo(body, extraHttpRequestParams) .map((response: Response) => { if (response.status === 204) { @@ -177,7 +178,7 @@ export class PetService implements PetServiceInterface { * @param name Updated name of the pet * @param status Updated status of the pet */ - public updatePetWithForm(petId: string, name?: string, status?: string, extraHttpRequestParams?: any): Observable<{}> { + public updatePetWithForm(petId: number, name?: string, status?: string, extraHttpRequestParams?: any): Observable<{}> { return this.updatePetWithFormWithHttpInfo(petId, name, status, extraHttpRequestParams) .map((response: Response) => { if (response.status === 204) { @@ -195,7 +196,7 @@ export class PetService implements PetServiceInterface { * @param additionalMetadata Additional data to pass to server * @param file file to upload */ - public uploadFile(petId: number, additionalMetadata?: string, file?: Blob, extraHttpRequestParams?: any): Observable<{}> { + public uploadFile(petId: number, additionalMetadata?: string, file?: Blob, extraHttpRequestParams?: any): Observable { return this.uploadFileWithHttpInfo(petId, additionalMetadata, file, extraHttpRequestParams) .map((response: Response) => { if (response.status === 204) { @@ -212,17 +213,21 @@ export class PetService implements PetServiceInterface { * * @param body Pet object that needs to be added to the store */ - public addPetWithHttpInfo(body?: Pet, extraHttpRequestParams?: any): Observable { + public addPetWithHttpInfo(body: Pet, extraHttpRequestParams?: any): Observable { const path = this.basePath + '/pet'; let queryParameters = new URLSearchParams(); let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new Error('Required parameter body was null or undefined when calling addPet.'); + } // to determine the Accept header let produces: string[] = [ - 'application/json', - 'application/xml' + 'application/xml', + 'application/json' ]; // authentication (petstore_auth) required @@ -276,8 +281,8 @@ export class PetService implements PetServiceInterface { // to determine the Accept header let produces: string[] = [ - 'application/json', - 'application/xml' + 'application/xml', + 'application/json' ]; // authentication (petstore_auth) required @@ -309,23 +314,25 @@ export class PetService implements PetServiceInterface { * Multiple status values can be provided with comma separated strings * @param status Status values that need to be considered for filter */ - public findPetsByStatusWithHttpInfo(status?: Array, extraHttpRequestParams?: any): Observable { + public findPetsByStatusWithHttpInfo(status: Array, extraHttpRequestParams?: any): Observable { const path = this.basePath + '/pet/findByStatus'; let queryParameters = new URLSearchParams(); let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 + // verify required parameter 'status' is not null or undefined + if (status === null || status === undefined) { + throw new Error('Required parameter status was null or undefined when calling findPetsByStatus.'); + } if (status) { - status.forEach((element) => { - queryParameters.append('status', element); - }) + queryParameters.set('status', status.join(COLLECTION_FORMATS['csv'])); } // to determine the Accept header let produces: string[] = [ - 'application/json', - 'application/xml' + 'application/xml', + 'application/json' ]; // authentication (petstore_auth) required @@ -357,23 +364,25 @@ export class PetService implements PetServiceInterface { * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. * @param tags Tags to filter by */ - public findPetsByTagsWithHttpInfo(tags?: Array, extraHttpRequestParams?: any): Observable { + public findPetsByTagsWithHttpInfo(tags: Array, extraHttpRequestParams?: any): Observable { const path = this.basePath + '/pet/findByTags'; let queryParameters = new URLSearchParams(); let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 + // verify required parameter 'tags' is not null or undefined + if (tags === null || tags === undefined) { + throw new Error('Required parameter tags was null or undefined when calling findPetsByTags.'); + } if (tags) { - tags.forEach((element) => { - queryParameters.append('tags', element); - }) + queryParameters.set('tags', tags.join(COLLECTION_FORMATS['csv'])); } // to determine the Accept header let produces: string[] = [ - 'application/json', - 'application/xml' + 'application/xml', + 'application/json' ]; // authentication (petstore_auth) required @@ -402,8 +411,8 @@ export class PetService implements PetServiceInterface { /** * Find pet by ID - * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions - * @param petId ID of pet that needs to be fetched + * Returns a single pet + * @param petId ID of pet to return */ public getPetByIdWithHttpInfo(petId: number, extraHttpRequestParams?: any): Observable { const path = this.basePath + '/pet/${petId}' @@ -419,8 +428,8 @@ export class PetService implements PetServiceInterface { // to determine the Accept header let produces: string[] = [ - 'application/json', - 'application/xml' + 'application/xml', + 'application/json' ]; // authentication (api_key) required @@ -428,15 +437,6 @@ export class PetService implements PetServiceInterface { headers.set('api_key', this.configuration.apiKeys["api_key"]); } - // authentication (petstore_auth) required - // oauth required - if (this.configuration.accessToken) { - let accessToken = typeof this.configuration.accessToken === 'function' - ? this.configuration.accessToken() - : this.configuration.accessToken; - headers.set('Authorization', 'Bearer ' + accessToken); - } - let requestOptions: RequestOptionsArgs = new RequestOptions({ method: RequestMethod.Get, @@ -457,17 +457,21 @@ export class PetService implements PetServiceInterface { * * @param body Pet object that needs to be added to the store */ - public updatePetWithHttpInfo(body?: Pet, extraHttpRequestParams?: any): Observable { + public updatePetWithHttpInfo(body: Pet, extraHttpRequestParams?: any): Observable { const path = this.basePath + '/pet'; let queryParameters = new URLSearchParams(); let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new Error('Required parameter body was null or undefined when calling updatePet.'); + } // to determine the Accept header let produces: string[] = [ - 'application/json', - 'application/xml' + 'application/xml', + 'application/json' ]; // authentication (petstore_auth) required @@ -504,7 +508,7 @@ export class PetService implements PetServiceInterface { * @param name Updated name of the pet * @param status Updated status of the pet */ - public updatePetWithFormWithHttpInfo(petId: string, name?: string, status?: string, extraHttpRequestParams?: any): Observable { + public updatePetWithFormWithHttpInfo(petId: number, name?: string, status?: string, extraHttpRequestParams?: any): Observable { const path = this.basePath + '/pet/${petId}' .replace('${' + 'petId' + '}', String(petId)); @@ -527,8 +531,8 @@ export class PetService implements PetServiceInterface { // to determine the Accept header let produces: string[] = [ - 'application/json', - 'application/xml' + 'application/xml', + 'application/json' ]; // authentication (petstore_auth) required @@ -595,8 +599,7 @@ export class PetService implements PetServiceInterface { // to determine the Accept header let produces: string[] = [ - 'application/json', - 'application/xml' + 'application/json' ]; // authentication (petstore_auth) required diff --git a/samples/client/petstore/typescript-angular2/with-interfaces/api/pet.serviceInterface.ts b/samples/client/petstore/typescript-angular2/with-interfaces/api/pet.serviceInterface.ts index 6aa9ddfd5ee..5ee39b3ab69 100644 --- a/samples/client/petstore/typescript-angular2/with-interfaces/api/pet.serviceInterface.ts +++ b/samples/client/petstore/typescript-angular2/with-interfaces/api/pet.serviceInterface.ts @@ -1,9 +1,9 @@ /** * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters + * 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@wordnik.com + * Contact: apiteam@swagger.io * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git @@ -28,7 +28,7 @@ export interface PetServiceInterface { * * @param body Pet object that needs to be added to the store */ - addPet(body?: Pet, extraHttpRequestParams?: any): Observable<{}>; + addPet(body: Pet, extraHttpRequestParams?: any): Observable<{}>; /** * Deletes a pet @@ -43,19 +43,19 @@ export interface PetServiceInterface { * Multiple status values can be provided with comma separated strings * @param status Status values that need to be considered for filter */ - findPetsByStatus(status?: Array, extraHttpRequestParams?: any): Observable>; + findPetsByStatus(status: Array, extraHttpRequestParams?: any): Observable>; /** * Finds Pets by tags * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. * @param tags Tags to filter by */ - findPetsByTags(tags?: Array, extraHttpRequestParams?: any): Observable>; + findPetsByTags(tags: Array, extraHttpRequestParams?: any): Observable>; /** * Find pet by ID - * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions - * @param petId ID of pet that needs to be fetched + * Returns a single pet + * @param petId ID of pet to return */ getPetById(petId: number, extraHttpRequestParams?: any): Observable; @@ -64,7 +64,7 @@ export interface PetServiceInterface { * * @param body Pet object that needs to be added to the store */ - updatePet(body?: Pet, extraHttpRequestParams?: any): Observable<{}>; + updatePet(body: Pet, extraHttpRequestParams?: any): Observable<{}>; /** * Updates a pet in the store with form data @@ -73,7 +73,7 @@ export interface PetServiceInterface { * @param name Updated name of the pet * @param status Updated status of the pet */ - updatePetWithForm(petId: string, name?: string, status?: string, extraHttpRequestParams?: any): Observable<{}>; + updatePetWithForm(petId: number, name?: string, status?: string, extraHttpRequestParams?: any): Observable<{}>; /** * uploads an image @@ -82,6 +82,6 @@ export interface PetServiceInterface { * @param additionalMetadata Additional data to pass to server * @param file file to upload */ - uploadFile(petId: number, additionalMetadata?: string, file?: Blob, extraHttpRequestParams?: any): Observable<{}>; + uploadFile(petId: number, additionalMetadata?: string, file?: Blob, extraHttpRequestParams?: any): Observable; } diff --git a/samples/client/petstore/typescript-angular2/with-interfaces/api/store.service.ts b/samples/client/petstore/typescript-angular2/with-interfaces/api/store.service.ts index ba50bbc9997..811e2ea5574 100644 --- a/samples/client/petstore/typescript-angular2/with-interfaces/api/store.service.ts +++ b/samples/client/petstore/typescript-angular2/with-interfaces/api/store.service.ts @@ -1,9 +1,9 @@ /** * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters + * 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@wordnik.com + * Contact: apiteam@swagger.io * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git @@ -109,7 +109,7 @@ export class StoreService implements StoreServiceInterface { * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions * @param orderId ID of pet that needs to be fetched */ - public getOrderById(orderId: string, extraHttpRequestParams?: any): Observable { + public getOrderById(orderId: number, extraHttpRequestParams?: any): Observable { return this.getOrderByIdWithHttpInfo(orderId, extraHttpRequestParams) .map((response: Response) => { if (response.status === 204) { @@ -125,7 +125,7 @@ export class StoreService implements StoreServiceInterface { * * @param body order placed for purchasing the pet */ - public placeOrder(body?: Order, extraHttpRequestParams?: any): Observable { + public placeOrder(body: Order, extraHttpRequestParams?: any): Observable { return this.placeOrderWithHttpInfo(body, extraHttpRequestParams) .map((response: Response) => { if (response.status === 204) { @@ -156,8 +156,8 @@ export class StoreService implements StoreServiceInterface { // to determine the Accept header let produces: string[] = [ - 'application/json', - 'application/xml' + 'application/xml', + 'application/json' ]; @@ -188,8 +188,7 @@ export class StoreService implements StoreServiceInterface { // to determine the Accept header let produces: string[] = [ - 'application/json', - 'application/xml' + 'application/json' ]; // authentication (api_key) required @@ -217,7 +216,7 @@ export class StoreService implements StoreServiceInterface { * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions * @param orderId ID of pet that needs to be fetched */ - public getOrderByIdWithHttpInfo(orderId: string, extraHttpRequestParams?: any): Observable { + public getOrderByIdWithHttpInfo(orderId: number, extraHttpRequestParams?: any): Observable { const path = this.basePath + '/store/order/${orderId}' .replace('${' + 'orderId' + '}', String(orderId)); @@ -231,8 +230,8 @@ export class StoreService implements StoreServiceInterface { // to determine the Accept header let produces: string[] = [ - 'application/json', - 'application/xml' + 'application/xml', + 'application/json' ]; @@ -255,17 +254,21 @@ export class StoreService implements StoreServiceInterface { * * @param body order placed for purchasing the pet */ - public placeOrderWithHttpInfo(body?: Order, extraHttpRequestParams?: any): Observable { + public placeOrderWithHttpInfo(body: Order, extraHttpRequestParams?: any): Observable { const path = this.basePath + '/store/order'; let queryParameters = new URLSearchParams(); let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new Error('Required parameter body was null or undefined when calling placeOrder.'); + } // to determine the Accept header let produces: string[] = [ - 'application/json', - 'application/xml' + 'application/xml', + 'application/json' ]; diff --git a/samples/client/petstore/typescript-angular2/with-interfaces/api/store.serviceInterface.ts b/samples/client/petstore/typescript-angular2/with-interfaces/api/store.serviceInterface.ts index e08c0dc354b..a40dcc47b83 100644 --- a/samples/client/petstore/typescript-angular2/with-interfaces/api/store.serviceInterface.ts +++ b/samples/client/petstore/typescript-angular2/with-interfaces/api/store.serviceInterface.ts @@ -1,9 +1,9 @@ /** * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters + * 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@wordnik.com + * Contact: apiteam@swagger.io * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git @@ -41,13 +41,13 @@ export interface StoreServiceInterface { * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions * @param orderId ID of pet that needs to be fetched */ - getOrderById(orderId: string, extraHttpRequestParams?: any): Observable; + getOrderById(orderId: number, extraHttpRequestParams?: any): Observable; /** * Place an order for a pet * * @param body order placed for purchasing the pet */ - placeOrder(body?: Order, extraHttpRequestParams?: any): Observable; + placeOrder(body: Order, extraHttpRequestParams?: any): Observable; } diff --git a/samples/client/petstore/typescript-angular2/with-interfaces/api/user.service.ts b/samples/client/petstore/typescript-angular2/with-interfaces/api/user.service.ts index 20f0c1338b2..03ab33592f6 100644 --- a/samples/client/petstore/typescript-angular2/with-interfaces/api/user.service.ts +++ b/samples/client/petstore/typescript-angular2/with-interfaces/api/user.service.ts @@ -1,9 +1,9 @@ /** * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters + * 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@wordnik.com + * Contact: apiteam@swagger.io * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git @@ -78,7 +78,7 @@ export class UserService implements UserServiceInterface { * This can only be done by the logged in user. * @param body Created user object */ - public createUser(body?: User, extraHttpRequestParams?: any): Observable<{}> { + public createUser(body: User, extraHttpRequestParams?: any): Observable<{}> { return this.createUserWithHttpInfo(body, extraHttpRequestParams) .map((response: Response) => { if (response.status === 204) { @@ -94,7 +94,7 @@ export class UserService implements UserServiceInterface { * * @param body List of user object */ - public createUsersWithArrayInput(body?: Array, extraHttpRequestParams?: any): Observable<{}> { + public createUsersWithArrayInput(body: Array, extraHttpRequestParams?: any): Observable<{}> { return this.createUsersWithArrayInputWithHttpInfo(body, extraHttpRequestParams) .map((response: Response) => { if (response.status === 204) { @@ -110,7 +110,7 @@ export class UserService implements UserServiceInterface { * * @param body List of user object */ - public createUsersWithListInput(body?: Array, extraHttpRequestParams?: any): Observable<{}> { + public createUsersWithListInput(body: Array, extraHttpRequestParams?: any): Observable<{}> { return this.createUsersWithListInputWithHttpInfo(body, extraHttpRequestParams) .map((response: Response) => { if (response.status === 204) { @@ -159,7 +159,7 @@ export class UserService implements UserServiceInterface { * @param username The user name for login * @param password The password for login in clear text */ - public loginUser(username?: string, password?: string, extraHttpRequestParams?: any): Observable { + public loginUser(username: string, password: string, extraHttpRequestParams?: any): Observable { return this.loginUserWithHttpInfo(username, password, extraHttpRequestParams) .map((response: Response) => { if (response.status === 204) { @@ -191,7 +191,7 @@ export class UserService implements UserServiceInterface { * @param username name that need to be deleted * @param body Updated user object */ - public updateUser(username: string, body?: User, extraHttpRequestParams?: any): Observable<{}> { + public updateUser(username: string, body: User, extraHttpRequestParams?: any): Observable<{}> { return this.updateUserWithHttpInfo(username, body, extraHttpRequestParams) .map((response: Response) => { if (response.status === 204) { @@ -208,17 +208,21 @@ export class UserService implements UserServiceInterface { * This can only be done by the logged in user. * @param body Created user object */ - public createUserWithHttpInfo(body?: User, extraHttpRequestParams?: any): Observable { + public createUserWithHttpInfo(body: User, extraHttpRequestParams?: any): Observable { const path = this.basePath + '/user'; let queryParameters = new URLSearchParams(); let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new Error('Required parameter body was null or undefined when calling createUser.'); + } // to determine the Accept header let produces: string[] = [ - 'application/json', - 'application/xml' + 'application/xml', + 'application/json' ]; @@ -244,17 +248,21 @@ export class UserService implements UserServiceInterface { * * @param body List of user object */ - public createUsersWithArrayInputWithHttpInfo(body?: Array, extraHttpRequestParams?: any): Observable { + public createUsersWithArrayInputWithHttpInfo(body: Array, extraHttpRequestParams?: any): Observable { const path = this.basePath + '/user/createWithArray'; let queryParameters = new URLSearchParams(); let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new Error('Required parameter body was null or undefined when calling createUsersWithArrayInput.'); + } // to determine the Accept header let produces: string[] = [ - 'application/json', - 'application/xml' + 'application/xml', + 'application/json' ]; @@ -280,17 +288,21 @@ export class UserService implements UserServiceInterface { * * @param body List of user object */ - public createUsersWithListInputWithHttpInfo(body?: Array, extraHttpRequestParams?: any): Observable { + public createUsersWithListInputWithHttpInfo(body: Array, extraHttpRequestParams?: any): Observable { const path = this.basePath + '/user/createWithList'; let queryParameters = new URLSearchParams(); let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new Error('Required parameter body was null or undefined when calling createUsersWithListInput.'); + } // to determine the Accept header let produces: string[] = [ - 'application/json', - 'application/xml' + 'application/xml', + 'application/json' ]; @@ -330,8 +342,8 @@ export class UserService implements UserServiceInterface { // to determine the Accept header let produces: string[] = [ - 'application/json', - 'application/xml' + 'application/xml', + 'application/json' ]; @@ -368,8 +380,8 @@ export class UserService implements UserServiceInterface { // to determine the Accept header let produces: string[] = [ - 'application/json', - 'application/xml' + 'application/xml', + 'application/json' ]; @@ -393,12 +405,20 @@ export class UserService implements UserServiceInterface { * @param username The user name for login * @param password The password for login in clear text */ - public loginUserWithHttpInfo(username?: string, password?: string, extraHttpRequestParams?: any): Observable { + public loginUserWithHttpInfo(username: string, password: string, extraHttpRequestParams?: any): Observable { const path = this.basePath + '/user/login'; let queryParameters = new URLSearchParams(); let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 + // verify required parameter 'username' is not null or undefined + if (username === null || username === undefined) { + throw new Error('Required parameter username was null or undefined when calling loginUser.'); + } + // verify required parameter 'password' is not null or undefined + if (password === null || password === undefined) { + throw new Error('Required parameter password was null or undefined when calling loginUser.'); + } if (username !== undefined) { queryParameters.set('username', username); } @@ -410,8 +430,8 @@ export class UserService implements UserServiceInterface { // to determine the Accept header let produces: string[] = [ - 'application/json', - 'application/xml' + 'application/xml', + 'application/json' ]; @@ -442,8 +462,8 @@ export class UserService implements UserServiceInterface { // to determine the Accept header let produces: string[] = [ - 'application/json', - 'application/xml' + 'application/xml', + 'application/json' ]; @@ -467,7 +487,7 @@ export class UserService implements UserServiceInterface { * @param username name that need to be deleted * @param body Updated user object */ - public updateUserWithHttpInfo(username: string, body?: User, extraHttpRequestParams?: any): Observable { + public updateUserWithHttpInfo(username: string, body: User, extraHttpRequestParams?: any): Observable { const path = this.basePath + '/user/${username}' .replace('${' + 'username' + '}', String(username)); @@ -478,11 +498,15 @@ export class UserService implements UserServiceInterface { if (username === null || username === undefined) { throw new Error('Required parameter username was null or undefined when calling updateUser.'); } + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new Error('Required parameter body was null or undefined when calling updateUser.'); + } // to determine the Accept header let produces: string[] = [ - 'application/json', - 'application/xml' + 'application/xml', + 'application/json' ]; diff --git a/samples/client/petstore/typescript-angular2/with-interfaces/api/user.serviceInterface.ts b/samples/client/petstore/typescript-angular2/with-interfaces/api/user.serviceInterface.ts index 8bce8ce3033..3cab3a9c64b 100644 --- a/samples/client/petstore/typescript-angular2/with-interfaces/api/user.serviceInterface.ts +++ b/samples/client/petstore/typescript-angular2/with-interfaces/api/user.serviceInterface.ts @@ -1,9 +1,9 @@ /** * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters + * 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@wordnik.com + * Contact: apiteam@swagger.io * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git @@ -28,21 +28,21 @@ export interface UserServiceInterface { * This can only be done by the logged in user. * @param body Created user object */ - createUser(body?: User, extraHttpRequestParams?: any): Observable<{}>; + createUser(body: User, extraHttpRequestParams?: any): Observable<{}>; /** * Creates list of users with given input array * * @param body List of user object */ - createUsersWithArrayInput(body?: Array, extraHttpRequestParams?: any): Observable<{}>; + createUsersWithArrayInput(body: Array, extraHttpRequestParams?: any): Observable<{}>; /** * Creates list of users with given input array * * @param body List of user object */ - createUsersWithListInput(body?: Array, extraHttpRequestParams?: any): Observable<{}>; + createUsersWithListInput(body: Array, extraHttpRequestParams?: any): Observable<{}>; /** * Delete user @@ -64,7 +64,7 @@ export interface UserServiceInterface { * @param username The user name for login * @param password The password for login in clear text */ - loginUser(username?: string, password?: string, extraHttpRequestParams?: any): Observable; + loginUser(username: string, password: string, extraHttpRequestParams?: any): Observable; /** * Logs out current logged in user session @@ -78,6 +78,6 @@ export interface UserServiceInterface { * @param username name that need to be deleted * @param body Updated user object */ - updateUser(username: string, body?: User, extraHttpRequestParams?: any): Observable<{}>; + updateUser(username: string, body: User, extraHttpRequestParams?: any): Observable<{}>; } diff --git a/samples/client/petstore/typescript-angular2/with-interfaces/model/Category.ts b/samples/client/petstore/typescript-angular2/with-interfaces/model/Category.ts index 202faef0d43..d09f8d7b265 100644 --- a/samples/client/petstore/typescript-angular2/with-interfaces/model/Category.ts +++ b/samples/client/petstore/typescript-angular2/with-interfaces/model/Category.ts @@ -1,9 +1,9 @@ /** * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters + * 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@wordnik.com + * Contact: apiteam@swagger.io * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git @@ -12,6 +12,9 @@ +/** + * A category for a pet + */ export interface Category { id?: number; diff --git a/samples/client/petstore/typescript-angular2/with-interfaces/model/Order.ts b/samples/client/petstore/typescript-angular2/with-interfaces/model/Order.ts index 7e2cb037074..402a86689c8 100644 --- a/samples/client/petstore/typescript-angular2/with-interfaces/model/Order.ts +++ b/samples/client/petstore/typescript-angular2/with-interfaces/model/Order.ts @@ -1,9 +1,9 @@ /** * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters + * 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@wordnik.com + * Contact: apiteam@swagger.io * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git @@ -12,6 +12,9 @@ +/** + * An order for a pets from the pet store + */ export interface Order { id?: number; diff --git a/samples/client/petstore/typescript-angular2/with-interfaces/model/Pet.ts b/samples/client/petstore/typescript-angular2/with-interfaces/model/Pet.ts index 7a429abf483..0d6137d02cf 100644 --- a/samples/client/petstore/typescript-angular2/with-interfaces/model/Pet.ts +++ b/samples/client/petstore/typescript-angular2/with-interfaces/model/Pet.ts @@ -1,9 +1,9 @@ /** * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters + * 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@wordnik.com + * Contact: apiteam@swagger.io * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git @@ -14,6 +14,9 @@ import { Category } from './category'; import { Tag } from './tag'; +/** + * A pet for sale in the pet store + */ export interface Pet { id?: number; diff --git a/samples/client/petstore/typescript-angular2/with-interfaces/model/Tag.ts b/samples/client/petstore/typescript-angular2/with-interfaces/model/Tag.ts index 56cbe04b7a3..3ed1eeff8f3 100644 --- a/samples/client/petstore/typescript-angular2/with-interfaces/model/Tag.ts +++ b/samples/client/petstore/typescript-angular2/with-interfaces/model/Tag.ts @@ -1,9 +1,9 @@ /** * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters + * 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@wordnik.com + * Contact: apiteam@swagger.io * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git @@ -12,6 +12,9 @@ +/** + * A tag for a pet + */ export interface Tag { id?: number; diff --git a/samples/client/petstore/typescript-angular2/with-interfaces/model/User.ts b/samples/client/petstore/typescript-angular2/with-interfaces/model/User.ts index 202adb58c73..f4914ae2608 100644 --- a/samples/client/petstore/typescript-angular2/with-interfaces/model/User.ts +++ b/samples/client/petstore/typescript-angular2/with-interfaces/model/User.ts @@ -1,9 +1,9 @@ /** * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters + * 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@wordnik.com + * Contact: apiteam@swagger.io * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git @@ -12,6 +12,9 @@ +/** + * A User who is purchasing from the pet store + */ export interface User { id?: number; diff --git a/samples/client/petstore/typescript-angular2/with-interfaces/model/apiResponse.ts b/samples/client/petstore/typescript-angular2/with-interfaces/model/apiResponse.ts new file mode 100644 index 00000000000..3af781cf580 --- /dev/null +++ b/samples/client/petstore/typescript-angular2/with-interfaces/model/apiResponse.ts @@ -0,0 +1,25 @@ +/** + * 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-angular2/with-interfaces/model/models.ts b/samples/client/petstore/typescript-angular2/with-interfaces/model/models.ts index 1f152369d80..8607c5dabd0 100644 --- a/samples/client/petstore/typescript-angular2/with-interfaces/model/models.ts +++ b/samples/client/petstore/typescript-angular2/with-interfaces/model/models.ts @@ -1,3 +1,4 @@ +export * from './apiResponse'; export * from './category'; export * from './order'; export * from './pet'; diff --git a/samples/client/petstore/typescript-angular4/npm/.gitignore b/samples/client/petstore/typescript-angular4/npm/.gitignore new file mode 100644 index 00000000000..149b5765472 --- /dev/null +++ b/samples/client/petstore/typescript-angular4/npm/.gitignore @@ -0,0 +1,4 @@ +wwwroot/*.js +node_modules +typings +dist diff --git a/samples/client/petstore/typescript-angular4/npm/.swagger-codegen-ignore b/samples/client/petstore/typescript-angular4/npm/.swagger-codegen-ignore new file mode 100644 index 00000000000..c5fa491b4c5 --- /dev/null +++ b/samples/client/petstore/typescript-angular4/npm/.swagger-codegen-ignore @@ -0,0 +1,23 @@ +# Swagger Codegen Ignore +# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md diff --git a/samples/client/petstore/typescript-angular4/npm/.swagger-codegen/VERSION b/samples/client/petstore/typescript-angular4/npm/.swagger-codegen/VERSION new file mode 100644 index 00000000000..f9f7450d135 --- /dev/null +++ b/samples/client/petstore/typescript-angular4/npm/.swagger-codegen/VERSION @@ -0,0 +1 @@ +2.3.0-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/typescript-angular4/npm/README.md b/samples/client/petstore/typescript-angular4/npm/README.md new file mode 100644 index 00000000000..038fd51491c --- /dev/null +++ b/samples/client/petstore/typescript-angular4/npm/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-angular4/npm/api.module.ts b/samples/client/petstore/typescript-angular4/npm/api.module.ts new file mode 100644 index 00000000000..dcce0dbd628 --- /dev/null +++ b/samples/client/petstore/typescript-angular4/npm/api.module.ts @@ -0,0 +1,23 @@ +import { NgModule, ModuleWithProviders } from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { HttpModule } from '@angular/http'; +import { Configuration } from './configuration'; + +import { PetService } from './api/pet.service'; +import { StoreService } from './api/store.service'; +import { UserService } from './api/user.service'; + +@NgModule({ + imports: [ CommonModule, HttpModule ], + declarations: [], + exports: [], + providers: [ PetService, StoreService, UserService ] +}) +export class ApiModule { + public static forConfig(configurationFactory: () => Configuration): ModuleWithProviders { + return { + ngModule: ApiModule, + providers: [ {provide: Configuration, useFactory: configurationFactory}] + } + } +} diff --git a/samples/client/petstore/typescript-angular4/npm/api/api.ts b/samples/client/petstore/typescript-angular4/npm/api/api.ts new file mode 100644 index 00000000000..8e44b64083d --- /dev/null +++ b/samples/client/petstore/typescript-angular4/npm/api/api.ts @@ -0,0 +1,7 @@ +export * from './pet.service'; +import { PetService } from './pet.service'; +export * from './store.service'; +import { StoreService } from './store.service'; +export * from './user.service'; +import { UserService } from './user.service'; +export const APIS = [PetService, StoreService, UserService]; diff --git a/samples/client/petstore/typescript-angular4/npm/api/pet.service.ts b/samples/client/petstore/typescript-angular4/npm/api/pet.service.ts new file mode 100644 index 00000000000..0303ca70d3a --- /dev/null +++ b/samples/client/petstore/typescript-angular4/npm/api/pet.service.ts @@ -0,0 +1,637 @@ +/** + * 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. + */ + +/* tslint:disable:no-unused-variable member-ordering */ + +import { Inject, Injectable, Optional } from '@angular/core'; +import { Http, Headers, URLSearchParams } from '@angular/http'; +import { RequestMethod, RequestOptions, RequestOptionsArgs } from '@angular/http'; +import { Response, ResponseContentType } from '@angular/http'; + +import { Observable } from 'rxjs/Observable'; +import '../rxjs-operators'; + +import { ApiResponse } from '../model/apiResponse'; +import { Pet } from '../model/pet'; + +import { BASE_PATH, COLLECTION_FORMATS } from '../variables'; +import { Configuration } from '../configuration'; + + +@Injectable() +export class PetService { + + protected basePath = 'http://petstore.swagger.io/v2'; + public defaultHeaders: Headers = new Headers(); + public configuration: Configuration = new Configuration(); + + constructor(protected http: Http, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) { + if (basePath) { + this.basePath = basePath; + } + if (configuration) { + this.configuration = configuration; + this.basePath = basePath || configuration.basePath || this.basePath; + } + } + + /** + * + * Extends object by coping non-existing properties. + * @param objA object to be extended + * @param objB source object + */ + private extendObj(objA: T1, objB: T2) { + for(let key in objB){ + if(objB.hasOwnProperty(key)){ + (objA as any)[key] = (objB as any)[key]; + } + } + return objA; + } + + /** + * @param consumes string[] mime-types + * @return true: consumes contains 'multipart/form-data', false: otherwise + */ + private canConsumeForm(consumes: string[]): boolean { + const form = 'multipart/form-data'; + for (let consume of consumes) { + if (form === consume) { + return true; + } + } + return false; + } + + /** + * Add a new pet to the store + * + * @param body Pet object that needs to be added to the store + */ + public addPet(body: Pet, extraHttpRequestParams?: any): Observable<{}> { + return this.addPetWithHttpInfo(body, extraHttpRequestParams) + .map((response: Response) => { + if (response.status === 204) { + return undefined; + } else { + return response.json() || {}; + } + }); + } + + /** + * Deletes a pet + * + * @param petId Pet id to delete + * @param apiKey + */ + public deletePet(petId: number, apiKey?: string, extraHttpRequestParams?: any): Observable<{}> { + return this.deletePetWithHttpInfo(petId, apiKey, extraHttpRequestParams) + .map((response: Response) => { + if (response.status === 204) { + return undefined; + } else { + return response.json() || {}; + } + }); + } + + /** + * Finds Pets by status + * Multiple status values can be provided with comma separated strings + * @param status Status values that need to be considered for filter + */ + public findPetsByStatus(status: Array, extraHttpRequestParams?: any): Observable> { + return this.findPetsByStatusWithHttpInfo(status, extraHttpRequestParams) + .map((response: Response) => { + if (response.status === 204) { + return undefined; + } else { + return response.json() || {}; + } + }); + } + + /** + * Finds Pets by tags + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * @param tags Tags to filter by + */ + public findPetsByTags(tags: Array, extraHttpRequestParams?: any): Observable> { + return this.findPetsByTagsWithHttpInfo(tags, extraHttpRequestParams) + .map((response: Response) => { + if (response.status === 204) { + return undefined; + } else { + return response.json() || {}; + } + }); + } + + /** + * Find pet by ID + * Returns a single pet + * @param petId ID of pet to return + */ + public getPetById(petId: number, extraHttpRequestParams?: any): Observable { + return this.getPetByIdWithHttpInfo(petId, extraHttpRequestParams) + .map((response: Response) => { + if (response.status === 204) { + return undefined; + } else { + return response.json() || {}; + } + }); + } + + /** + * Update an existing pet + * + * @param body Pet object that needs to be added to the store + */ + public updatePet(body: Pet, extraHttpRequestParams?: any): Observable<{}> { + return this.updatePetWithHttpInfo(body, extraHttpRequestParams) + .map((response: Response) => { + if (response.status === 204) { + return undefined; + } else { + return response.json() || {}; + } + }); + } + + /** + * Updates a pet in the store with form data + * + * @param petId ID of pet that needs to be updated + * @param name Updated name of the pet + * @param status Updated status of the pet + */ + public updatePetWithForm(petId: number, name?: string, status?: string, extraHttpRequestParams?: any): Observable<{}> { + return this.updatePetWithFormWithHttpInfo(petId, name, status, extraHttpRequestParams) + .map((response: Response) => { + if (response.status === 204) { + return undefined; + } else { + return response.json() || {}; + } + }); + } + + /** + * uploads an image + * + * @param petId ID of pet to update + * @param additionalMetadata Additional data to pass to server + * @param file file to upload + */ + public uploadFile(petId: number, additionalMetadata?: string, file?: Blob, extraHttpRequestParams?: any): Observable { + return this.uploadFileWithHttpInfo(petId, additionalMetadata, file, extraHttpRequestParams) + .map((response: Response) => { + if (response.status === 204) { + return undefined; + } else { + return response.json() || {}; + } + }); + } + + + /** + * Add a new pet to the store + * + * @param body Pet object that needs to be added to the store + */ + public addPetWithHttpInfo(body: Pet, extraHttpRequestParams?: any): Observable { + const path = this.basePath + '/pet'; + + let queryParameters = new URLSearchParams(); + let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 + + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new Error('Required parameter body was null or undefined when calling addPet.'); + } + + // to determine the Accept header + let produces: string[] = [ + 'application/xml', + 'application/json' + ]; + + // authentication (petstore_auth) required + // oauth required + if (this.configuration.accessToken) { + let accessToken = typeof this.configuration.accessToken === 'function' + ? this.configuration.accessToken() + : this.configuration.accessToken; + headers.set('Authorization', 'Bearer ' + accessToken); + } + + + headers.set('Content-Type', 'application/json'); + + let requestOptions: RequestOptionsArgs = new RequestOptions({ + method: RequestMethod.Post, + headers: headers, + body: body == null ? '' : JSON.stringify(body), // https://github.com/angular/angular/issues/10612 + search: queryParameters, + withCredentials:this.configuration.withCredentials + }); + // https://github.com/swagger-api/swagger-codegen/issues/4037 + if (extraHttpRequestParams) { + requestOptions = (Object).assign(requestOptions, extraHttpRequestParams); + } + + return this.http.request(path, requestOptions); + } + + /** + * Deletes a pet + * + * @param petId Pet id to delete + * @param apiKey + */ + public deletePetWithHttpInfo(petId: number, apiKey?: string, extraHttpRequestParams?: any): Observable { + const path = this.basePath + '/pet/${petId}' + .replace('${' + 'petId' + '}', String(petId)); + + let queryParameters = new URLSearchParams(); + let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 + + // verify required parameter 'petId' is not null or undefined + if (petId === null || petId === undefined) { + throw new Error('Required parameter petId was null or undefined when calling deletePet.'); + } + if (apiKey !== undefined && apiKey !== null) { + headers.set('api_key', String(apiKey)); + } + + + // to determine the Accept header + let produces: string[] = [ + 'application/xml', + 'application/json' + ]; + + // authentication (petstore_auth) required + // oauth required + if (this.configuration.accessToken) { + let accessToken = typeof this.configuration.accessToken === 'function' + ? this.configuration.accessToken() + : this.configuration.accessToken; + headers.set('Authorization', 'Bearer ' + accessToken); + } + + + let requestOptions: RequestOptionsArgs = new RequestOptions({ + method: RequestMethod.Delete, + headers: headers, + search: queryParameters, + withCredentials:this.configuration.withCredentials + }); + // https://github.com/swagger-api/swagger-codegen/issues/4037 + if (extraHttpRequestParams) { + requestOptions = (Object).assign(requestOptions, extraHttpRequestParams); + } + + return this.http.request(path, requestOptions); + } + + /** + * Finds Pets by status + * Multiple status values can be provided with comma separated strings + * @param status Status values that need to be considered for filter + */ + public findPetsByStatusWithHttpInfo(status: Array, extraHttpRequestParams?: any): Observable { + const path = this.basePath + '/pet/findByStatus'; + + let queryParameters = new URLSearchParams(); + let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 + + // verify required parameter 'status' is not null or undefined + if (status === null || status === undefined) { + throw new Error('Required parameter status was null or undefined when calling findPetsByStatus.'); + } + if (status) { + queryParameters.set('status', status.join(COLLECTION_FORMATS['csv'])); + } + + + // to determine the Accept header + let produces: string[] = [ + 'application/xml', + 'application/json' + ]; + + // authentication (petstore_auth) required + // oauth required + if (this.configuration.accessToken) { + let accessToken = typeof this.configuration.accessToken === 'function' + ? this.configuration.accessToken() + : this.configuration.accessToken; + headers.set('Authorization', 'Bearer ' + accessToken); + } + + + let requestOptions: RequestOptionsArgs = new RequestOptions({ + method: RequestMethod.Get, + headers: headers, + search: queryParameters, + withCredentials:this.configuration.withCredentials + }); + // https://github.com/swagger-api/swagger-codegen/issues/4037 + if (extraHttpRequestParams) { + requestOptions = (Object).assign(requestOptions, extraHttpRequestParams); + } + + return this.http.request(path, requestOptions); + } + + /** + * Finds Pets by tags + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * @param tags Tags to filter by + */ + public findPetsByTagsWithHttpInfo(tags: Array, extraHttpRequestParams?: any): Observable { + const path = this.basePath + '/pet/findByTags'; + + let queryParameters = new URLSearchParams(); + let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 + + // verify required parameter 'tags' is not null or undefined + if (tags === null || tags === undefined) { + throw new Error('Required parameter tags was null or undefined when calling findPetsByTags.'); + } + if (tags) { + queryParameters.set('tags', tags.join(COLLECTION_FORMATS['csv'])); + } + + + // to determine the Accept header + let produces: string[] = [ + 'application/xml', + 'application/json' + ]; + + // authentication (petstore_auth) required + // oauth required + if (this.configuration.accessToken) { + let accessToken = typeof this.configuration.accessToken === 'function' + ? this.configuration.accessToken() + : this.configuration.accessToken; + headers.set('Authorization', 'Bearer ' + accessToken); + } + + + let requestOptions: RequestOptionsArgs = new RequestOptions({ + method: RequestMethod.Get, + headers: headers, + search: queryParameters, + withCredentials:this.configuration.withCredentials + }); + // https://github.com/swagger-api/swagger-codegen/issues/4037 + if (extraHttpRequestParams) { + requestOptions = (Object).assign(requestOptions, extraHttpRequestParams); + } + + return this.http.request(path, requestOptions); + } + + /** + * Find pet by ID + * Returns a single pet + * @param petId ID of pet to return + */ + public getPetByIdWithHttpInfo(petId: number, extraHttpRequestParams?: any): Observable { + const path = this.basePath + '/pet/${petId}' + .replace('${' + 'petId' + '}', String(petId)); + + let queryParameters = new URLSearchParams(); + let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 + + // verify required parameter 'petId' is not null or undefined + if (petId === null || petId === undefined) { + throw new Error('Required parameter petId was null or undefined when calling getPetById.'); + } + + // to determine the Accept header + let produces: string[] = [ + 'application/xml', + 'application/json' + ]; + + // authentication (api_key) required + if (this.configuration.apiKeys["api_key"]) { + headers.set('api_key', this.configuration.apiKeys["api_key"]); + } + + + let requestOptions: RequestOptionsArgs = new RequestOptions({ + method: RequestMethod.Get, + headers: headers, + search: queryParameters, + withCredentials:this.configuration.withCredentials + }); + // https://github.com/swagger-api/swagger-codegen/issues/4037 + if (extraHttpRequestParams) { + requestOptions = (Object).assign(requestOptions, extraHttpRequestParams); + } + + return this.http.request(path, requestOptions); + } + + /** + * Update an existing pet + * + * @param body Pet object that needs to be added to the store + */ + public updatePetWithHttpInfo(body: Pet, extraHttpRequestParams?: any): Observable { + const path = this.basePath + '/pet'; + + let queryParameters = new URLSearchParams(); + let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 + + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new Error('Required parameter body was null or undefined when calling updatePet.'); + } + + // to determine the Accept header + let produces: string[] = [ + 'application/xml', + 'application/json' + ]; + + // authentication (petstore_auth) required + // oauth required + if (this.configuration.accessToken) { + let accessToken = typeof this.configuration.accessToken === 'function' + ? this.configuration.accessToken() + : this.configuration.accessToken; + headers.set('Authorization', 'Bearer ' + accessToken); + } + + + headers.set('Content-Type', 'application/json'); + + let requestOptions: RequestOptionsArgs = new RequestOptions({ + method: RequestMethod.Put, + headers: headers, + body: body == null ? '' : JSON.stringify(body), // https://github.com/angular/angular/issues/10612 + search: queryParameters, + withCredentials:this.configuration.withCredentials + }); + // https://github.com/swagger-api/swagger-codegen/issues/4037 + if (extraHttpRequestParams) { + requestOptions = (Object).assign(requestOptions, extraHttpRequestParams); + } + + return this.http.request(path, requestOptions); + } + + /** + * Updates a pet in the store with form data + * + * @param petId ID of pet that needs to be updated + * @param name Updated name of the pet + * @param status Updated status of the pet + */ + public updatePetWithFormWithHttpInfo(petId: number, name?: string, status?: string, extraHttpRequestParams?: any): Observable { + const path = this.basePath + '/pet/${petId}' + .replace('${' + 'petId' + '}', String(petId)); + + let queryParameters = new URLSearchParams(); + let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 + + // verify required parameter 'petId' is not null or undefined + if (petId === null || petId === undefined) { + throw new Error('Required parameter petId was null or undefined when calling updatePetWithForm.'); + } + // to determine the Content-Type header + let consumes: string[] = [ + 'application/x-www-form-urlencoded' + ]; + let canConsumeForm = this.canConsumeForm(consumes); + let useForm = false; + let formParams = new (useForm ? FormData : URLSearchParams as any)() as { + set(param: string, value: any): void; + }; + + // to determine the Accept header + let produces: string[] = [ + 'application/xml', + 'application/json' + ]; + + // authentication (petstore_auth) required + // oauth required + if (this.configuration.accessToken) { + let accessToken = typeof this.configuration.accessToken === 'function' + ? this.configuration.accessToken() + : this.configuration.accessToken; + headers.set('Authorization', 'Bearer ' + accessToken); + } + + + if (name !== undefined) { + formParams.set('name', name); + } + + if (status !== undefined) { + formParams.set('status', status); + } + + let requestOptions: RequestOptionsArgs = new RequestOptions({ + method: RequestMethod.Post, + headers: headers, + body: formParams.toString(), + search: queryParameters, + withCredentials:this.configuration.withCredentials + }); + // https://github.com/swagger-api/swagger-codegen/issues/4037 + if (extraHttpRequestParams) { + requestOptions = (Object).assign(requestOptions, extraHttpRequestParams); + } + + return this.http.request(path, requestOptions); + } + + /** + * uploads an image + * + * @param petId ID of pet to update + * @param additionalMetadata Additional data to pass to server + * @param file file to upload + */ + public uploadFileWithHttpInfo(petId: number, additionalMetadata?: string, file?: Blob, extraHttpRequestParams?: any): Observable { + const path = this.basePath + '/pet/${petId}/uploadImage' + .replace('${' + 'petId' + '}', String(petId)); + + let queryParameters = new URLSearchParams(); + let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 + + // verify required parameter 'petId' is not null or undefined + if (petId === null || petId === undefined) { + throw new Error('Required parameter petId was null or undefined when calling uploadFile.'); + } + // to determine the Content-Type header + let consumes: string[] = [ + 'multipart/form-data' + ]; + let canConsumeForm = this.canConsumeForm(consumes); + let useForm = false; + useForm = canConsumeForm; + let formParams = new (useForm ? FormData : URLSearchParams as any)() as { + set(param: string, value: any): void; + }; + + // to determine the Accept header + let produces: string[] = [ + 'application/json' + ]; + + // authentication (petstore_auth) required + // oauth required + if (this.configuration.accessToken) { + let accessToken = typeof this.configuration.accessToken === 'function' + ? this.configuration.accessToken() + : this.configuration.accessToken; + headers.set('Authorization', 'Bearer ' + accessToken); + } + + + if (additionalMetadata !== undefined) { + formParams.set('additionalMetadata', additionalMetadata); + } + + if (file !== undefined) { + formParams.set('file', file); + } + + let requestOptions: RequestOptionsArgs = new RequestOptions({ + method: RequestMethod.Post, + headers: headers, + body: formParams.toString(), + search: queryParameters, + withCredentials:this.configuration.withCredentials + }); + // https://github.com/swagger-api/swagger-codegen/issues/4037 + if (extraHttpRequestParams) { + requestOptions = (Object).assign(requestOptions, extraHttpRequestParams); + } + + return this.http.request(path, requestOptions); + } + +} diff --git a/samples/client/petstore/typescript-angular4/npm/api/store.service.ts b/samples/client/petstore/typescript-angular4/npm/api/store.service.ts new file mode 100644 index 00000000000..877c8df7e08 --- /dev/null +++ b/samples/client/petstore/typescript-angular4/npm/api/store.service.ts @@ -0,0 +1,291 @@ +/** + * 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. + */ + +/* tslint:disable:no-unused-variable member-ordering */ + +import { Inject, Injectable, Optional } from '@angular/core'; +import { Http, Headers, URLSearchParams } from '@angular/http'; +import { RequestMethod, RequestOptions, RequestOptionsArgs } from '@angular/http'; +import { Response, ResponseContentType } from '@angular/http'; + +import { Observable } from 'rxjs/Observable'; +import '../rxjs-operators'; + +import { Order } from '../model/order'; + +import { BASE_PATH, COLLECTION_FORMATS } from '../variables'; +import { Configuration } from '../configuration'; + + +@Injectable() +export class StoreService { + + protected basePath = 'http://petstore.swagger.io/v2'; + public defaultHeaders: Headers = new Headers(); + public configuration: Configuration = new Configuration(); + + constructor(protected http: Http, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) { + if (basePath) { + this.basePath = basePath; + } + if (configuration) { + this.configuration = configuration; + this.basePath = basePath || configuration.basePath || this.basePath; + } + } + + /** + * + * Extends object by coping non-existing properties. + * @param objA object to be extended + * @param objB source object + */ + private extendObj(objA: T1, objB: T2) { + for(let key in objB){ + if(objB.hasOwnProperty(key)){ + (objA as any)[key] = (objB as any)[key]; + } + } + return objA; + } + + /** + * @param consumes string[] mime-types + * @return true: consumes contains 'multipart/form-data', false: otherwise + */ + private canConsumeForm(consumes: string[]): boolean { + const form = 'multipart/form-data'; + for (let consume of consumes) { + if (form === consume) { + return true; + } + } + return false; + } + + /** + * Delete purchase order by ID + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * @param orderId ID of the order that needs to be deleted + */ + public deleteOrder(orderId: string, extraHttpRequestParams?: any): Observable<{}> { + return this.deleteOrderWithHttpInfo(orderId, extraHttpRequestParams) + .map((response: Response) => { + if (response.status === 204) { + return undefined; + } else { + return response.json() || {}; + } + }); + } + + /** + * Returns pet inventories by status + * Returns a map of status codes to quantities + */ + public getInventory(extraHttpRequestParams?: any): Observable<{ [key: string]: number; }> { + return this.getInventoryWithHttpInfo(extraHttpRequestParams) + .map((response: Response) => { + if (response.status === 204) { + return undefined; + } else { + return response.json() || {}; + } + }); + } + + /** + * Find purchase order by ID + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + * @param orderId ID of pet that needs to be fetched + */ + public getOrderById(orderId: number, extraHttpRequestParams?: any): Observable { + return this.getOrderByIdWithHttpInfo(orderId, extraHttpRequestParams) + .map((response: Response) => { + if (response.status === 204) { + return undefined; + } else { + return response.json() || {}; + } + }); + } + + /** + * Place an order for a pet + * + * @param body order placed for purchasing the pet + */ + public placeOrder(body: Order, extraHttpRequestParams?: any): Observable { + return this.placeOrderWithHttpInfo(body, extraHttpRequestParams) + .map((response: Response) => { + if (response.status === 204) { + return undefined; + } else { + return response.json() || {}; + } + }); + } + + + /** + * Delete purchase order by ID + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * @param orderId ID of the order that needs to be deleted + */ + public deleteOrderWithHttpInfo(orderId: string, extraHttpRequestParams?: any): Observable { + const path = this.basePath + '/store/order/${orderId}' + .replace('${' + 'orderId' + '}', String(orderId)); + + let queryParameters = new URLSearchParams(); + let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 + + // verify required parameter 'orderId' is not null or undefined + if (orderId === null || orderId === undefined) { + throw new Error('Required parameter orderId was null or undefined when calling deleteOrder.'); + } + + // to determine the Accept header + let produces: string[] = [ + 'application/xml', + 'application/json' + ]; + + + let requestOptions: RequestOptionsArgs = new RequestOptions({ + method: RequestMethod.Delete, + headers: headers, + search: queryParameters, + withCredentials:this.configuration.withCredentials + }); + // https://github.com/swagger-api/swagger-codegen/issues/4037 + if (extraHttpRequestParams) { + requestOptions = (Object).assign(requestOptions, extraHttpRequestParams); + } + + return this.http.request(path, requestOptions); + } + + /** + * Returns pet inventories by status + * Returns a map of status codes to quantities + */ + public getInventoryWithHttpInfo(extraHttpRequestParams?: any): Observable { + const path = this.basePath + '/store/inventory'; + + let queryParameters = new URLSearchParams(); + let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 + + + // to determine the Accept header + let produces: string[] = [ + 'application/json' + ]; + + // authentication (api_key) required + if (this.configuration.apiKeys["api_key"]) { + headers.set('api_key', this.configuration.apiKeys["api_key"]); + } + + + let requestOptions: RequestOptionsArgs = new RequestOptions({ + method: RequestMethod.Get, + headers: headers, + search: queryParameters, + withCredentials:this.configuration.withCredentials + }); + // https://github.com/swagger-api/swagger-codegen/issues/4037 + if (extraHttpRequestParams) { + requestOptions = (Object).assign(requestOptions, extraHttpRequestParams); + } + + return this.http.request(path, requestOptions); + } + + /** + * Find purchase order by ID + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + * @param orderId ID of pet that needs to be fetched + */ + public getOrderByIdWithHttpInfo(orderId: number, extraHttpRequestParams?: any): Observable { + const path = this.basePath + '/store/order/${orderId}' + .replace('${' + 'orderId' + '}', String(orderId)); + + let queryParameters = new URLSearchParams(); + let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 + + // verify required parameter 'orderId' is not null or undefined + if (orderId === null || orderId === undefined) { + throw new Error('Required parameter orderId was null or undefined when calling getOrderById.'); + } + + // to determine the Accept header + let produces: string[] = [ + 'application/xml', + 'application/json' + ]; + + + let requestOptions: RequestOptionsArgs = new RequestOptions({ + method: RequestMethod.Get, + headers: headers, + search: queryParameters, + withCredentials:this.configuration.withCredentials + }); + // https://github.com/swagger-api/swagger-codegen/issues/4037 + if (extraHttpRequestParams) { + requestOptions = (Object).assign(requestOptions, extraHttpRequestParams); + } + + return this.http.request(path, requestOptions); + } + + /** + * Place an order for a pet + * + * @param body order placed for purchasing the pet + */ + public placeOrderWithHttpInfo(body: Order, extraHttpRequestParams?: any): Observable { + const path = this.basePath + '/store/order'; + + let queryParameters = new URLSearchParams(); + let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 + + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new Error('Required parameter body was null or undefined when calling placeOrder.'); + } + + // to determine the Accept header + let produces: string[] = [ + 'application/xml', + 'application/json' + ]; + + + headers.set('Content-Type', 'application/json'); + + let requestOptions: RequestOptionsArgs = new RequestOptions({ + method: RequestMethod.Post, + headers: headers, + body: body == null ? '' : JSON.stringify(body), // https://github.com/angular/angular/issues/10612 + search: queryParameters, + withCredentials:this.configuration.withCredentials + }); + // https://github.com/swagger-api/swagger-codegen/issues/4037 + if (extraHttpRequestParams) { + requestOptions = (Object).assign(requestOptions, extraHttpRequestParams); + } + + return this.http.request(path, requestOptions); + } + +} diff --git a/samples/client/petstore/typescript-angular4/npm/api/user.service.ts b/samples/client/petstore/typescript-angular4/npm/api/user.service.ts new file mode 100644 index 00000000000..5a5761dcdd3 --- /dev/null +++ b/samples/client/petstore/typescript-angular4/npm/api/user.service.ts @@ -0,0 +1,529 @@ +/** + * 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. + */ + +/* tslint:disable:no-unused-variable member-ordering */ + +import { Inject, Injectable, Optional } from '@angular/core'; +import { Http, Headers, URLSearchParams } from '@angular/http'; +import { RequestMethod, RequestOptions, RequestOptionsArgs } from '@angular/http'; +import { Response, ResponseContentType } from '@angular/http'; + +import { Observable } from 'rxjs/Observable'; +import '../rxjs-operators'; + +import { User } from '../model/user'; + +import { BASE_PATH, COLLECTION_FORMATS } from '../variables'; +import { Configuration } from '../configuration'; + + +@Injectable() +export class UserService { + + protected basePath = 'http://petstore.swagger.io/v2'; + public defaultHeaders: Headers = new Headers(); + public configuration: Configuration = new Configuration(); + + constructor(protected http: Http, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) { + if (basePath) { + this.basePath = basePath; + } + if (configuration) { + this.configuration = configuration; + this.basePath = basePath || configuration.basePath || this.basePath; + } + } + + /** + * + * Extends object by coping non-existing properties. + * @param objA object to be extended + * @param objB source object + */ + private extendObj(objA: T1, objB: T2) { + for(let key in objB){ + if(objB.hasOwnProperty(key)){ + (objA as any)[key] = (objB as any)[key]; + } + } + return objA; + } + + /** + * @param consumes string[] mime-types + * @return true: consumes contains 'multipart/form-data', false: otherwise + */ + private canConsumeForm(consumes: string[]): boolean { + const form = 'multipart/form-data'; + for (let consume of consumes) { + if (form === consume) { + return true; + } + } + return false; + } + + /** + * Create user + * This can only be done by the logged in user. + * @param body Created user object + */ + public createUser(body: User, extraHttpRequestParams?: any): Observable<{}> { + return this.createUserWithHttpInfo(body, extraHttpRequestParams) + .map((response: Response) => { + if (response.status === 204) { + return undefined; + } else { + return response.json() || {}; + } + }); + } + + /** + * Creates list of users with given input array + * + * @param body List of user object + */ + public createUsersWithArrayInput(body: Array, extraHttpRequestParams?: any): Observable<{}> { + return this.createUsersWithArrayInputWithHttpInfo(body, extraHttpRequestParams) + .map((response: Response) => { + if (response.status === 204) { + return undefined; + } else { + return response.json() || {}; + } + }); + } + + /** + * Creates list of users with given input array + * + * @param body List of user object + */ + public createUsersWithListInput(body: Array, extraHttpRequestParams?: any): Observable<{}> { + return this.createUsersWithListInputWithHttpInfo(body, extraHttpRequestParams) + .map((response: Response) => { + if (response.status === 204) { + return undefined; + } else { + return response.json() || {}; + } + }); + } + + /** + * Delete user + * This can only be done by the logged in user. + * @param username The name that needs to be deleted + */ + public deleteUser(username: string, extraHttpRequestParams?: any): Observable<{}> { + return this.deleteUserWithHttpInfo(username, extraHttpRequestParams) + .map((response: Response) => { + if (response.status === 204) { + return undefined; + } else { + return response.json() || {}; + } + }); + } + + /** + * Get user by user name + * + * @param username The name that needs to be fetched. Use user1 for testing. + */ + public getUserByName(username: string, extraHttpRequestParams?: any): Observable { + return this.getUserByNameWithHttpInfo(username, extraHttpRequestParams) + .map((response: Response) => { + if (response.status === 204) { + return undefined; + } else { + return response.json() || {}; + } + }); + } + + /** + * Logs user into the system + * + * @param username The user name for login + * @param password The password for login in clear text + */ + public loginUser(username: string, password: string, extraHttpRequestParams?: any): Observable { + return this.loginUserWithHttpInfo(username, password, extraHttpRequestParams) + .map((response: Response) => { + if (response.status === 204) { + return undefined; + } else { + return response.json() || {}; + } + }); + } + + /** + * Logs out current logged in user session + * + */ + public logoutUser(extraHttpRequestParams?: any): Observable<{}> { + return this.logoutUserWithHttpInfo(extraHttpRequestParams) + .map((response: Response) => { + if (response.status === 204) { + return undefined; + } else { + return response.json() || {}; + } + }); + } + + /** + * Updated user + * This can only be done by the logged in user. + * @param username name that need to be deleted + * @param body Updated user object + */ + public updateUser(username: string, body: User, extraHttpRequestParams?: any): Observable<{}> { + return this.updateUserWithHttpInfo(username, body, extraHttpRequestParams) + .map((response: Response) => { + if (response.status === 204) { + return undefined; + } else { + return response.json() || {}; + } + }); + } + + + /** + * Create user + * This can only be done by the logged in user. + * @param body Created user object + */ + public createUserWithHttpInfo(body: User, extraHttpRequestParams?: any): Observable { + const path = this.basePath + '/user'; + + let queryParameters = new URLSearchParams(); + let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 + + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new Error('Required parameter body was null or undefined when calling createUser.'); + } + + // to determine the Accept header + let produces: string[] = [ + 'application/xml', + 'application/json' + ]; + + + headers.set('Content-Type', 'application/json'); + + let requestOptions: RequestOptionsArgs = new RequestOptions({ + method: RequestMethod.Post, + headers: headers, + body: body == null ? '' : JSON.stringify(body), // https://github.com/angular/angular/issues/10612 + search: queryParameters, + withCredentials:this.configuration.withCredentials + }); + // https://github.com/swagger-api/swagger-codegen/issues/4037 + if (extraHttpRequestParams) { + requestOptions = (Object).assign(requestOptions, extraHttpRequestParams); + } + + return this.http.request(path, requestOptions); + } + + /** + * Creates list of users with given input array + * + * @param body List of user object + */ + public createUsersWithArrayInputWithHttpInfo(body: Array, extraHttpRequestParams?: any): Observable { + const path = this.basePath + '/user/createWithArray'; + + let queryParameters = new URLSearchParams(); + let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 + + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new Error('Required parameter body was null or undefined when calling createUsersWithArrayInput.'); + } + + // to determine the Accept header + let produces: string[] = [ + 'application/xml', + 'application/json' + ]; + + + headers.set('Content-Type', 'application/json'); + + let requestOptions: RequestOptionsArgs = new RequestOptions({ + method: RequestMethod.Post, + headers: headers, + body: body == null ? '' : JSON.stringify(body), // https://github.com/angular/angular/issues/10612 + search: queryParameters, + withCredentials:this.configuration.withCredentials + }); + // https://github.com/swagger-api/swagger-codegen/issues/4037 + if (extraHttpRequestParams) { + requestOptions = (Object).assign(requestOptions, extraHttpRequestParams); + } + + return this.http.request(path, requestOptions); + } + + /** + * Creates list of users with given input array + * + * @param body List of user object + */ + public createUsersWithListInputWithHttpInfo(body: Array, extraHttpRequestParams?: any): Observable { + const path = this.basePath + '/user/createWithList'; + + let queryParameters = new URLSearchParams(); + let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 + + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new Error('Required parameter body was null or undefined when calling createUsersWithListInput.'); + } + + // to determine the Accept header + let produces: string[] = [ + 'application/xml', + 'application/json' + ]; + + + headers.set('Content-Type', 'application/json'); + + let requestOptions: RequestOptionsArgs = new RequestOptions({ + method: RequestMethod.Post, + headers: headers, + body: body == null ? '' : JSON.stringify(body), // https://github.com/angular/angular/issues/10612 + search: queryParameters, + withCredentials:this.configuration.withCredentials + }); + // https://github.com/swagger-api/swagger-codegen/issues/4037 + if (extraHttpRequestParams) { + requestOptions = (Object).assign(requestOptions, extraHttpRequestParams); + } + + return this.http.request(path, requestOptions); + } + + /** + * Delete user + * This can only be done by the logged in user. + * @param username The name that needs to be deleted + */ + public deleteUserWithHttpInfo(username: string, extraHttpRequestParams?: any): Observable { + const path = this.basePath + '/user/${username}' + .replace('${' + 'username' + '}', String(username)); + + let queryParameters = new URLSearchParams(); + let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 + + // verify required parameter 'username' is not null or undefined + if (username === null || username === undefined) { + throw new Error('Required parameter username was null or undefined when calling deleteUser.'); + } + + // to determine the Accept header + let produces: string[] = [ + 'application/xml', + 'application/json' + ]; + + + let requestOptions: RequestOptionsArgs = new RequestOptions({ + method: RequestMethod.Delete, + headers: headers, + search: queryParameters, + withCredentials:this.configuration.withCredentials + }); + // https://github.com/swagger-api/swagger-codegen/issues/4037 + if (extraHttpRequestParams) { + requestOptions = (Object).assign(requestOptions, extraHttpRequestParams); + } + + return this.http.request(path, requestOptions); + } + + /** + * Get user by user name + * + * @param username The name that needs to be fetched. Use user1 for testing. + */ + public getUserByNameWithHttpInfo(username: string, extraHttpRequestParams?: any): Observable { + const path = this.basePath + '/user/${username}' + .replace('${' + 'username' + '}', String(username)); + + let queryParameters = new URLSearchParams(); + let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 + + // verify required parameter 'username' is not null or undefined + if (username === null || username === undefined) { + throw new Error('Required parameter username was null or undefined when calling getUserByName.'); + } + + // to determine the Accept header + let produces: string[] = [ + 'application/xml', + 'application/json' + ]; + + + let requestOptions: RequestOptionsArgs = new RequestOptions({ + method: RequestMethod.Get, + headers: headers, + search: queryParameters, + withCredentials:this.configuration.withCredentials + }); + // https://github.com/swagger-api/swagger-codegen/issues/4037 + if (extraHttpRequestParams) { + requestOptions = (Object).assign(requestOptions, extraHttpRequestParams); + } + + return this.http.request(path, requestOptions); + } + + /** + * Logs user into the system + * + * @param username The user name for login + * @param password The password for login in clear text + */ + public loginUserWithHttpInfo(username: string, password: string, extraHttpRequestParams?: any): Observable { + const path = this.basePath + '/user/login'; + + let queryParameters = new URLSearchParams(); + let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 + + // verify required parameter 'username' is not null or undefined + if (username === null || username === undefined) { + throw new Error('Required parameter username was null or undefined when calling loginUser.'); + } + // verify required parameter 'password' is not null or undefined + if (password === null || password === undefined) { + throw new Error('Required parameter password was null or undefined when calling loginUser.'); + } + if (username !== undefined) { + queryParameters.set('username', username); + } + + if (password !== undefined) { + queryParameters.set('password', password); + } + + + // to determine the Accept header + let produces: string[] = [ + 'application/xml', + 'application/json' + ]; + + + let requestOptions: RequestOptionsArgs = new RequestOptions({ + method: RequestMethod.Get, + headers: headers, + search: queryParameters, + withCredentials:this.configuration.withCredentials + }); + // https://github.com/swagger-api/swagger-codegen/issues/4037 + if (extraHttpRequestParams) { + requestOptions = (Object).assign(requestOptions, extraHttpRequestParams); + } + + return this.http.request(path, requestOptions); + } + + /** + * Logs out current logged in user session + * + */ + public logoutUserWithHttpInfo(extraHttpRequestParams?: any): Observable { + const path = this.basePath + '/user/logout'; + + let queryParameters = new URLSearchParams(); + let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 + + + // to determine the Accept header + let produces: string[] = [ + 'application/xml', + 'application/json' + ]; + + + let requestOptions: RequestOptionsArgs = new RequestOptions({ + method: RequestMethod.Get, + headers: headers, + search: queryParameters, + withCredentials:this.configuration.withCredentials + }); + // https://github.com/swagger-api/swagger-codegen/issues/4037 + if (extraHttpRequestParams) { + requestOptions = (Object).assign(requestOptions, extraHttpRequestParams); + } + + return this.http.request(path, requestOptions); + } + + /** + * Updated user + * This can only be done by the logged in user. + * @param username name that need to be deleted + * @param body Updated user object + */ + public updateUserWithHttpInfo(username: string, body: User, extraHttpRequestParams?: any): Observable { + const path = this.basePath + '/user/${username}' + .replace('${' + 'username' + '}', String(username)); + + let queryParameters = new URLSearchParams(); + let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 + + // verify required parameter 'username' is not null or undefined + if (username === null || username === undefined) { + throw new Error('Required parameter username was null or undefined when calling updateUser.'); + } + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new Error('Required parameter body was null or undefined when calling updateUser.'); + } + + // to determine the Accept header + let produces: string[] = [ + 'application/xml', + 'application/json' + ]; + + + headers.set('Content-Type', 'application/json'); + + let requestOptions: RequestOptionsArgs = new RequestOptions({ + method: RequestMethod.Put, + headers: headers, + body: body == null ? '' : JSON.stringify(body), // https://github.com/angular/angular/issues/10612 + search: queryParameters, + withCredentials:this.configuration.withCredentials + }); + // https://github.com/swagger-api/swagger-codegen/issues/4037 + if (extraHttpRequestParams) { + requestOptions = (Object).assign(requestOptions, extraHttpRequestParams); + } + + return this.http.request(path, requestOptions); + } + +} diff --git a/samples/client/petstore/typescript-angular4/npm/configuration.ts b/samples/client/petstore/typescript-angular4/npm/configuration.ts new file mode 100644 index 00000000000..0eed43fd575 --- /dev/null +++ b/samples/client/petstore/typescript-angular4/npm/configuration.ts @@ -0,0 +1,26 @@ +export interface ConfigurationParameters { + apiKeys?: {[ key: string ]: string}; + username?: string; + password?: string; + accessToken?: string; + basePath?: string; + withCredentials?: boolean; +} + +export class Configuration { + apiKeys: {[ key: string ]: string}; + username: string; + password: string; + accessToken: string | (() => string); + basePath: string; + withCredentials: boolean; + + constructor(configurationParameters: ConfigurationParameters = {}) { + this.apiKeys = configurationParameters.apiKeys; + this.username = configurationParameters.username; + this.password = configurationParameters.password; + this.accessToken = configurationParameters.accessToken; + this.basePath = configurationParameters.basePath; + this.withCredentials = configurationParameters.withCredentials; + } +} diff --git a/samples/client/petstore/typescript-angular4/npm/git_push.sh b/samples/client/petstore/typescript-angular4/npm/git_push.sh new file mode 100644 index 00000000000..ed374619b13 --- /dev/null +++ b/samples/client/petstore/typescript-angular4/npm/git_push.sh @@ -0,0 +1,52 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 + +if [ "$git_user_id" = "" ]; then + git_user_id="GIT_USER_ID" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="GIT_REPO_ID" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="Minor update" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +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." + 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 + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' + diff --git a/samples/client/petstore/typescript-angular4/npm/index.ts b/samples/client/petstore/typescript-angular4/npm/index.ts new file mode 100644 index 00000000000..c312b70fa3e --- /dev/null +++ b/samples/client/petstore/typescript-angular4/npm/index.ts @@ -0,0 +1,5 @@ +export * from './api/api'; +export * from './model/models'; +export * from './variables'; +export * from './configuration'; +export * from './api.module'; \ No newline at end of file diff --git a/samples/client/petstore/typescript-angular4/npm/model/apiResponse.ts b/samples/client/petstore/typescript-angular4/npm/model/apiResponse.ts new file mode 100644 index 00000000000..3af781cf580 --- /dev/null +++ b/samples/client/petstore/typescript-angular4/npm/model/apiResponse.ts @@ -0,0 +1,25 @@ +/** + * 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-angular4/npm/model/category.ts b/samples/client/petstore/typescript-angular4/npm/model/category.ts new file mode 100644 index 00000000000..d09f8d7b265 --- /dev/null +++ b/samples/client/petstore/typescript-angular4/npm/model/category.ts @@ -0,0 +1,23 @@ +/** + * 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-angular4/npm/model/models.ts b/samples/client/petstore/typescript-angular4/npm/model/models.ts new file mode 100644 index 00000000000..8607c5dabd0 --- /dev/null +++ b/samples/client/petstore/typescript-angular4/npm/model/models.ts @@ -0,0 +1,6 @@ +export * from './apiResponse'; +export * from './category'; +export * from './order'; +export * from './pet'; +export * from './tag'; +export * from './user'; diff --git a/samples/client/petstore/typescript-angular4/npm/model/order.ts b/samples/client/petstore/typescript-angular4/npm/model/order.ts new file mode 100644 index 00000000000..402a86689c8 --- /dev/null +++ b/samples/client/petstore/typescript-angular4/npm/model/order.ts @@ -0,0 +1,41 @@ +/** + * 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 enum StatusEnum { + Placed = 'placed', + Approved = 'approved', + Delivered = 'delivered' + } +} diff --git a/samples/client/petstore/typescript-angular4/npm/model/pet.ts b/samples/client/petstore/typescript-angular4/npm/model/pet.ts new file mode 100644 index 00000000000..0d6137d02cf --- /dev/null +++ b/samples/client/petstore/typescript-angular4/npm/model/pet.ts @@ -0,0 +1,43 @@ +/** + * 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 enum StatusEnum { + Available = 'available', + Pending = 'pending', + Sold = 'sold' + } +} diff --git a/samples/client/petstore/typescript-angular4/npm/model/tag.ts b/samples/client/petstore/typescript-angular4/npm/model/tag.ts new file mode 100644 index 00000000000..3ed1eeff8f3 --- /dev/null +++ b/samples/client/petstore/typescript-angular4/npm/model/tag.ts @@ -0,0 +1,23 @@ +/** + * 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-angular4/npm/model/user.ts b/samples/client/petstore/typescript-angular4/npm/model/user.ts new file mode 100644 index 00000000000..f4914ae2608 --- /dev/null +++ b/samples/client/petstore/typescript-angular4/npm/model/user.ts @@ -0,0 +1,38 @@ +/** + * 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-angular4/npm/package.json b/samples/client/petstore/typescript-angular4/npm/package.json new file mode 100644 index 00000000000..c4961bcc48a --- /dev/null +++ b/samples/client/petstore/typescript-angular4/npm/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": "^4.2.5", + "@angular/http": "^4.2.5", + "@angular/common": "^4.2.5", + "@angular/compiler": "^4.2.5", + "core-js": "^2.4.0", + "reflect-metadata": "^0.1.3", + "rxjs": "^5.1.0", + "zone.js": "^0.7.6" + }, + "devDependencies": { + "@angular/core": "^4.2.5", + "@angular/http": "^4.2.5", + "@angular/common": "^4.2.5", + "@angular/compiler": "^4.2.5", + "@angular/platform-browser": "^4.2.5", + "reflect-metadata": "^0.1.3", + "rxjs": "5.1.0", + "zone.js": "^0.7.6", + "typescript": "^2.1.5" + }, + "publishConfig":{ + "registry":"https://skimdb.npmjs.com/registry" + } +} diff --git a/samples/client/petstore/typescript-angular4/npm/rxjs-operators.ts b/samples/client/petstore/typescript-angular4/npm/rxjs-operators.ts new file mode 100644 index 00000000000..5659cd0694f --- /dev/null +++ b/samples/client/petstore/typescript-angular4/npm/rxjs-operators.ts @@ -0,0 +1,11 @@ +// RxJS imports according to https://angular.io/docs/ts/latest/guide/server-communication.html#!#rxjs + +// See node_module/rxjs/Rxjs.js +// Import just the rxjs statics and operators we need for THIS app. + +// Statics +import 'rxjs/add/observable/throw'; + +// Operators +import 'rxjs/add/operator/catch'; +import 'rxjs/add/operator/map'; diff --git a/samples/client/petstore/typescript-angular4/npm/tsconfig.json b/samples/client/petstore/typescript-angular4/npm/tsconfig.json new file mode 100644 index 00000000000..a6e9096bbf7 --- /dev/null +++ b/samples/client/petstore/typescript-angular4/npm/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-angular4/npm/typings.json b/samples/client/petstore/typescript-angular4/npm/typings.json new file mode 100644 index 00000000000..507c40e5cbe --- /dev/null +++ b/samples/client/petstore/typescript-angular4/npm/typings.json @@ -0,0 +1,5 @@ +{ + "globalDependencies": { + "core-js": "registry:dt/core-js#0.0.0+20160725163759" + } +} diff --git a/samples/client/petstore/typescript-angular4/npm/variables.ts b/samples/client/petstore/typescript-angular4/npm/variables.ts new file mode 100644 index 00000000000..6fe58549f39 --- /dev/null +++ b/samples/client/petstore/typescript-angular4/npm/variables.ts @@ -0,0 +1,9 @@ +import { InjectionToken } from '@angular/core'; + +export const BASE_PATH = new InjectionToken('basePath'); +export const COLLECTION_FORMATS = { + 'csv': ',', + 'tsv': ' ', + 'ssv': ' ', + 'pipes': '|' +}