From fe2cc24f4d00fdd90da7f85e7f9806a6e329e422 Mon Sep 17 00:00:00 2001 From: Tino Fuhrmann Date: Tue, 14 Aug 2018 19:38:00 +0200 Subject: [PATCH] WIP: Models & API --- .../languages/TypeScriptClientCodegen.java | 34 ++++- .../main/resources/typescript/api.mustache | 41 ++++++ .../resources/typescript/baseapi.mustache | 37 +++++ .../typescript/configuration.mustache | 1 + .../{models => }/modelEnum.mustache | 0 .../{models => }/modelGeneric.mustache | 0 .../typescript/{models => }/models.mustache | 4 +- .../typescript/builds/default/apis/PetApi.ts | 134 ++++++++++++++++++ .../builds/default/apis/StoreApi.ts | 71 ++++++++++ .../typescript/builds/default/apis/UserApi.ts | 129 +++++++++++++++++ .../builds/default/apis/apis/PetApi.ts | 96 +++++++++++++ .../builds/default/apis/apis/StoreApi.ts | 49 +++++++ .../builds/default/apis/apis/UserApi.ts | 91 ++++++++++++ .../typescript/builds/default/apis/baseapi.ts | 37 +++++ .../default/models/models/ApiResponse.ts | 30 ++++ .../builds/default/models/models/Category.ts | 24 ++++ .../builds/default/models/models/Order.ts | 64 +++++++++ .../builds/default/models/models/Pet.ts | 66 +++++++++ .../builds/default/models/models/Tag.ts | 24 ++++ .../builds/default/models/models/User.ts | 60 ++++++++ 20 files changed, 987 insertions(+), 5 deletions(-) create mode 100644 modules/openapi-generator/src/main/resources/typescript/api.mustache create mode 100644 modules/openapi-generator/src/main/resources/typescript/baseapi.mustache rename modules/openapi-generator/src/main/resources/typescript/{models => }/modelEnum.mustache (100%) rename modules/openapi-generator/src/main/resources/typescript/{models => }/modelGeneric.mustache (100%) rename modules/openapi-generator/src/main/resources/typescript/{models => }/models.mustache (79%) create mode 100644 samples/client/petstore/typescript/builds/default/apis/PetApi.ts create mode 100644 samples/client/petstore/typescript/builds/default/apis/StoreApi.ts create mode 100644 samples/client/petstore/typescript/builds/default/apis/UserApi.ts create mode 100644 samples/client/petstore/typescript/builds/default/apis/apis/PetApi.ts create mode 100644 samples/client/petstore/typescript/builds/default/apis/apis/StoreApi.ts create mode 100644 samples/client/petstore/typescript/builds/default/apis/apis/UserApi.ts create mode 100644 samples/client/petstore/typescript/builds/default/apis/baseapi.ts create mode 100644 samples/client/petstore/typescript/builds/default/models/models/ApiResponse.ts create mode 100644 samples/client/petstore/typescript/builds/default/models/models/Category.ts create mode 100644 samples/client/petstore/typescript/builds/default/models/models/Order.ts create mode 100644 samples/client/petstore/typescript/builds/default/models/models/Pet.ts create mode 100644 samples/client/petstore/typescript/builds/default/models/models/Tag.ts create mode 100644 samples/client/petstore/typescript/builds/default/models/models/User.ts diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java index 99e8893a74a..0408e69b81d 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java @@ -17,10 +17,13 @@ package org.openapitools.codegen.languages; +import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.oas.models.media.ArraySchema; import io.swagger.v3.oas.models.media.NumberSchema; import io.swagger.v3.oas.models.media.Schema; import io.swagger.v3.oas.models.parameters.Parameter; +import io.swagger.v3.oas.models.security.SecurityScheme; + import org.apache.commons.lang3.StringUtils; import org.openapitools.codegen.*; import org.openapitools.codegen.utils.ModelUtils; @@ -29,6 +32,7 @@ import org.slf4j.LoggerFactory; import java.io.File; import java.util.*; +import java.util.Map.Entry; public class TypeScriptClientCodegen extends DefaultCodegen implements CodegenConfig { private static final Logger LOGGER = LoggerFactory.getLogger(TypeScriptClientCodegen.class); @@ -128,8 +132,13 @@ public class TypeScriptClientCodegen extends DefaultCodegen implements CodegenCo supportingFiles.add(new SupportingFile("index.mustache", "index.ts")); // models - this.modelPackage = ""; - this.modelTemplateFiles.put("models/models.mustache", ".ts"); + this.setModelPackage(""); + this.modelTemplateFiles.put("models.mustache", ".ts"); + + // api + this.setApiPackage(""); + this.supportingFiles.add(new SupportingFile("baseapi.mustache", "apis", "baseapi.ts")); + this.apiTemplateFiles.put("api.mustache", ".ts"); } @@ -137,7 +146,26 @@ public class TypeScriptClientCodegen extends DefaultCodegen implements CodegenCo public CodegenType getTag() { return CodegenType.CLIENT; } - + + @Override + public Map postProcessOperations(Map operations) { + Map objs = (Map) operations.get("operations"); + + + // Add additional filename information for model imports in the apis + List> imports = (List>) operations.get("imports"); + for (Map im : imports) { + im.put("filename", ((String) im.get("import")).replace('.', '/')); + im.put("classname", getModelnameFromModelFilename(im.get("import").toString())); + } + return operations; + } + + private String getModelnameFromModelFilename(String filename) { + String name = filename.substring((modelPackage() + File.separator).length()); + return camelize(name); + } + @Override public String escapeReservedWord(String name) { if (this.reservedWordsMappings().containsKey(name)) { diff --git a/modules/openapi-generator/src/main/resources/typescript/api.mustache b/modules/openapi-generator/src/main/resources/typescript/api.mustache new file mode 100644 index 00000000000..3dd5268a4b1 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/typescript/api.mustache @@ -0,0 +1,41 @@ +// TODO: better import syntax? +import { BaseApiRequestFactory } from './baseapi'; +import { RequestContext } from '../http/http'; +{{#imports}} +import { {{classname}} } from '..{{filename}}'; +{{/imports}} + + + +{{#operations}} + +/** + * {{classname}} - interface{{#description}} + * {{&description}}{{/description}} + * @export + * @interface {{classname}} + */ +export class {{classname}}RequestFactory { + + {{#operation}} + /** + * {{¬es}} + {{#summary}} + * @summary {{&summary}} + {{/summary}} + {{#allParams}} + * @param {{=<% %>=}}{<%&dataType%>}<%={{ }}=%> {{^required}}[{{/required}}{{paramName}}{{^required}}]{{/required}} {{description}} + {{/allParams}} + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof {{classname}}Interface + */ + public {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}options?: any): RequestContext { + + + return null; + } + + {{/operation}} +} +{{/operations}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/typescript/baseapi.mustache b/modules/openapi-generator/src/main/resources/typescript/baseapi.mustache new file mode 100644 index 00000000000..fe7ee3d1511 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/typescript/baseapi.mustache @@ -0,0 +1,37 @@ +import { Configuration } from '../configuration' + +/** + * + * @export + */ +export const COLLECTION_FORMATS = { + csv: ",", + ssv: " ", + tsv: "\t", + pipes: "|", +}; + + +/** + * + * @export + * @class BaseAPI + */ +export class BaseAPIRequestFactory { + + constructor(protected configuration: Configuration) { + } +}; + +/** + * + * @export + * @class RequiredError + * @extends {Error} + */ +export class RequiredError extends Error { + name: "RequiredError" = "RequiredError"; + constructor(public field: string, msg?: string) { + super(msg); + } +} diff --git a/modules/openapi-generator/src/main/resources/typescript/configuration.mustache b/modules/openapi-generator/src/main/resources/typescript/configuration.mustache index 59f97141075..a9a25e5952d 100644 --- a/modules/openapi-generator/src/main/resources/typescript/configuration.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/configuration.mustache @@ -7,6 +7,7 @@ export interface ConfigurationParameters { baseServer?: ServerConfiguration; httpApi?: HttpLibrary; // override for fetch implementation middleware?: Middleware[]; // middleware to apply before/after fetch requests + username?: string; // parameter for basic security password?: string; // parameter for basic security apiKey?: string | ((name: string) => string); // parameter for apiKey security diff --git a/modules/openapi-generator/src/main/resources/typescript/models/modelEnum.mustache b/modules/openapi-generator/src/main/resources/typescript/modelEnum.mustache similarity index 100% rename from modules/openapi-generator/src/main/resources/typescript/models/modelEnum.mustache rename to modules/openapi-generator/src/main/resources/typescript/modelEnum.mustache diff --git a/modules/openapi-generator/src/main/resources/typescript/models/modelGeneric.mustache b/modules/openapi-generator/src/main/resources/typescript/modelGeneric.mustache similarity index 100% rename from modules/openapi-generator/src/main/resources/typescript/models/modelGeneric.mustache rename to modules/openapi-generator/src/main/resources/typescript/modelGeneric.mustache diff --git a/modules/openapi-generator/src/main/resources/typescript/models/models.mustache b/modules/openapi-generator/src/main/resources/typescript/models.mustache similarity index 79% rename from modules/openapi-generator/src/main/resources/typescript/models/models.mustache rename to modules/openapi-generator/src/main/resources/typescript/models.mustache index 0eebdc9ceb7..b39583e15a4 100644 --- a/modules/openapi-generator/src/main/resources/typescript/models/models.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/models.mustache @@ -6,10 +6,10 @@ import { {{.}} } from './{{.}}'; {{/imports}} {{#isEnum}} -{{>models/modelEnum}} +{{>modelEnum}} {{/isEnum}} {{^isEnum}} -{{>models/modelGeneric}} +{{>modelGeneric}} {{/isEnum}} {{/model}} {{/models}} \ No newline at end of file diff --git a/samples/client/petstore/typescript/builds/default/apis/PetApi.ts b/samples/client/petstore/typescript/builds/default/apis/PetApi.ts new file mode 100644 index 00000000000..2ce0fb93bd3 --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/apis/PetApi.ts @@ -0,0 +1,134 @@ +// TODO: better import syntax? +import { BaseApiRequestFactory } from './baseapi'; +import { RequestContext } from '../http/http'; +import { ApiResponse } from '../models/ApiResponse'; +import { Pet } from '../models/Pet'; + + + + +/** + * PetApi - interface + * @export + * @interface PetApi + */ +export class PetApiRequestFactory { + + /** + * + * @summary Add a new pet to the store + * @param {Pet} pet Pet object that needs to be added to the store + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof PetApiInterface + */ + public addPet(pet: Pet, options?: any): RequestContext { + + + return null; + } + + /** + * + * @summary Deletes a pet + * @param {number} petId Pet id to delete + * @param {string} [apiKey] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof PetApiInterface + */ + public deletePet(petId: number, apiKey?: string, options?: any): RequestContext { + + + return null; + } + + /** + * Multiple status values can be provided with comma separated strings + * @summary Finds Pets by status + * @param {Array<'available' | 'pending' | 'sold'>} status Status values that need to be considered for filter + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof PetApiInterface + */ + public findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options?: any): RequestContext { + + + return null; + } + + /** + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * @summary Finds Pets by tags + * @param {Array} tags Tags to filter by + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof PetApiInterface + */ + public findPetsByTags(tags: Array, options?: any): RequestContext { + + + return null; + } + + /** + * Returns a single pet + * @summary Find pet by ID + * @param {number} petId ID of pet to return + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof PetApiInterface + */ + public getPetById(petId: number, options?: any): RequestContext { + + + return null; + } + + /** + * + * @summary Update an existing pet + * @param {Pet} pet Pet object that needs to be added to the store + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof PetApiInterface + */ + public updatePet(pet: Pet, options?: any): RequestContext { + + + return null; + } + + /** + * + * @summary Updates a pet in the store with form data + * @param {number} petId ID of pet that needs to be updated + * @param {string} [name] Updated name of the pet + * @param {string} [status] Updated status of the pet + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof PetApiInterface + */ + public updatePetWithForm(petId: number, name?: string, status?: string, options?: any): RequestContext { + + + return null; + } + + /** + * + * @summary uploads an image + * @param {number} petId ID of pet to update + * @param {string} [additionalMetadata] Additional data to pass to server + * @param {any} [file] file to upload + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof PetApiInterface + */ + public uploadFile(petId: number, additionalMetadata?: string, file?: any, options?: any): RequestContext { + + + return null; + } + +} diff --git a/samples/client/petstore/typescript/builds/default/apis/StoreApi.ts b/samples/client/petstore/typescript/builds/default/apis/StoreApi.ts new file mode 100644 index 00000000000..7f5eada6f40 --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/apis/StoreApi.ts @@ -0,0 +1,71 @@ +// TODO: better import syntax? +import { BaseApiRequestFactory } from './baseapi'; +import { RequestContext } from '../http/http'; +import { Order } from '../models/Order'; + + + + +/** + * StoreApi - interface + * @export + * @interface StoreApi + */ +export class StoreApiRequestFactory { + + /** + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * @summary Delete purchase order by ID + * @param {string} orderId ID of the order that needs to be deleted + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof StoreApiInterface + */ + public deleteOrder(orderId: string, options?: any): RequestContext { + + + return null; + } + + /** + * Returns a map of status codes to quantities + * @summary Returns pet inventories by status + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof StoreApiInterface + */ + public getInventory(options?: any): RequestContext { + + + return null; + } + + /** + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + * @summary Find purchase order by ID + * @param {number} orderId ID of pet that needs to be fetched + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof StoreApiInterface + */ + public getOrderById(orderId: number, options?: any): RequestContext { + + + return null; + } + + /** + * + * @summary Place an order for a pet + * @param {Order} order order placed for purchasing the pet + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof StoreApiInterface + */ + public placeOrder(order: Order, options?: any): RequestContext { + + + return null; + } + +} diff --git a/samples/client/petstore/typescript/builds/default/apis/UserApi.ts b/samples/client/petstore/typescript/builds/default/apis/UserApi.ts new file mode 100644 index 00000000000..ec03ee79f79 --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/apis/UserApi.ts @@ -0,0 +1,129 @@ +// TODO: better import syntax? +import { BaseApiRequestFactory } from './baseapi'; +import { RequestContext } from '../http/http'; +import { User } from '../models/User'; + + + + +/** + * UserApi - interface + * @export + * @interface UserApi + */ +export class UserApiRequestFactory { + + /** + * This can only be done by the logged in user. + * @summary Create user + * @param {User} user Created user object + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof UserApiInterface + */ + public createUser(user: User, options?: any): RequestContext { + + + return null; + } + + /** + * + * @summary Creates list of users with given input array + * @param {Array} user List of user object + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof UserApiInterface + */ + public createUsersWithArrayInput(user: Array, options?: any): RequestContext { + + + return null; + } + + /** + * + * @summary Creates list of users with given input array + * @param {Array} user List of user object + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof UserApiInterface + */ + public createUsersWithListInput(user: Array, options?: any): RequestContext { + + + return null; + } + + /** + * This can only be done by the logged in user. + * @summary Delete user + * @param {string} username The name that needs to be deleted + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof UserApiInterface + */ + public deleteUser(username: string, options?: any): RequestContext { + + + return null; + } + + /** + * + * @summary Get user by user name + * @param {string} username The name that needs to be fetched. Use user1 for testing. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof UserApiInterface + */ + public getUserByName(username: string, options?: any): RequestContext { + + + return null; + } + + /** + * + * @summary Logs user into the system + * @param {string} username The user name for login + * @param {string} password The password for login in clear text + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof UserApiInterface + */ + public loginUser(username: string, password: string, options?: any): RequestContext { + + + return null; + } + + /** + * + * @summary Logs out current logged in user session + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof UserApiInterface + */ + public logoutUser(options?: any): RequestContext { + + + return null; + } + + /** + * This can only be done by the logged in user. + * @summary Updated user + * @param {string} username name that need to be deleted + * @param {User} user Updated user object + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof UserApiInterface + */ + public updateUser(username: string, user: User, options?: any): RequestContext { + + + return null; + } + +} diff --git a/samples/client/petstore/typescript/builds/default/apis/apis/PetApi.ts b/samples/client/petstore/typescript/builds/default/apis/apis/PetApi.ts new file mode 100644 index 00000000000..b9e34a1f536 --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/apis/apis/PetApi.ts @@ -0,0 +1,96 @@ +// TODO: better import syntax? + +import { ApiResponse } from '../'; +import { Pet } from '../'; +/** + * PetApi - interface + * @export + * @interface PetApi + */ +export interface PetApiInterface { + /** + * + * @summary Add a new pet to the store + * @param {Pet} pet Pet object that needs to be added to the store + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof PetApiInterface + */ + addPet(pet: Pet, options?: any): Promise<{}>; + + /** + * + * @summary Deletes a pet + * @param {number} petId Pet id to delete + * @param {string} [apiKey] + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof PetApiInterface + */ + deletePet(petId: number, apiKey?: string, options?: any): Promise<{}>; + + /** + * Multiple status values can be provided with comma separated strings + * @summary Finds Pets by status + * @param {Array<'available' | 'pending' | 'sold'>} status Status values that need to be considered for filter + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof PetApiInterface + */ + findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options?: any): Promise>; + + /** + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * @summary Finds Pets by tags + * @param {Array} tags Tags to filter by + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof PetApiInterface + */ + findPetsByTags(tags: Array, options?: any): Promise>; + + /** + * Returns a single pet + * @summary Find pet by ID + * @param {number} petId ID of pet to return + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof PetApiInterface + */ + getPetById(petId: number, options?: any): Promise; + + /** + * + * @summary Update an existing pet + * @param {Pet} pet Pet object that needs to be added to the store + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof PetApiInterface + */ + updatePet(pet: Pet, options?: any): Promise<{}>; + + /** + * + * @summary Updates a pet in the store with form data + * @param {number} petId ID of pet that needs to be updated + * @param {string} [name] Updated name of the pet + * @param {string} [status] Updated status of the pet + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof PetApiInterface + */ + updatePetWithForm(petId: number, name?: string, status?: string, options?: any): Promise<{}>; + + /** + * + * @summary uploads an image + * @param {number} petId ID of pet to update + * @param {string} [additionalMetadata] Additional data to pass to server + * @param {any} [file] file to upload + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof PetApiInterface + */ + uploadFile(petId: number, additionalMetadata?: string, file?: any, options?: any): Promise; + +} diff --git a/samples/client/petstore/typescript/builds/default/apis/apis/StoreApi.ts b/samples/client/petstore/typescript/builds/default/apis/apis/StoreApi.ts new file mode 100644 index 00000000000..d289d721768 --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/apis/apis/StoreApi.ts @@ -0,0 +1,49 @@ +// TODO: better import syntax? + +import { Order } from '../'; +/** + * StoreApi - interface + * @export + * @interface StoreApi + */ +export interface StoreApiInterface { + /** + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * @summary Delete purchase order by ID + * @param {string} orderId ID of the order that needs to be deleted + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof StoreApiInterface + */ + deleteOrder(orderId: string, options?: any): Promise<{}>; + + /** + * Returns a map of status codes to quantities + * @summary Returns pet inventories by status + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof StoreApiInterface + */ + getInventory(options?: any): Promise<{ [key: string]: number; }>; + + /** + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + * @summary Find purchase order by ID + * @param {number} orderId ID of pet that needs to be fetched + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof StoreApiInterface + */ + getOrderById(orderId: number, options?: any): Promise; + + /** + * + * @summary Place an order for a pet + * @param {Order} order order placed for purchasing the pet + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof StoreApiInterface + */ + placeOrder(order: Order, options?: any): Promise; + +} diff --git a/samples/client/petstore/typescript/builds/default/apis/apis/UserApi.ts b/samples/client/petstore/typescript/builds/default/apis/apis/UserApi.ts new file mode 100644 index 00000000000..6d763d78505 --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/apis/apis/UserApi.ts @@ -0,0 +1,91 @@ +// TODO: better import syntax? + +import { User } from '../'; +/** + * UserApi - interface + * @export + * @interface UserApi + */ +export interface UserApiInterface { + /** + * This can only be done by the logged in user. + * @summary Create user + * @param {User} user Created user object + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof UserApiInterface + */ + createUser(user: User, options?: any): Promise<{}>; + + /** + * + * @summary Creates list of users with given input array + * @param {Array} user List of user object + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof UserApiInterface + */ + createUsersWithArrayInput(user: Array, options?: any): Promise<{}>; + + /** + * + * @summary Creates list of users with given input array + * @param {Array} user List of user object + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof UserApiInterface + */ + createUsersWithListInput(user: Array, options?: any): Promise<{}>; + + /** + * This can only be done by the logged in user. + * @summary Delete user + * @param {string} username The name that needs to be deleted + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof UserApiInterface + */ + deleteUser(username: string, options?: any): Promise<{}>; + + /** + * + * @summary Get user by user name + * @param {string} username The name that needs to be fetched. Use user1 for testing. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof UserApiInterface + */ + getUserByName(username: string, options?: any): Promise; + + /** + * + * @summary Logs user into the system + * @param {string} username The user name for login + * @param {string} password The password for login in clear text + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof UserApiInterface + */ + loginUser(username: string, password: string, options?: any): Promise; + + /** + * + * @summary Logs out current logged in user session + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof UserApiInterface + */ + logoutUser(options?: any): Promise<{}>; + + /** + * This can only be done by the logged in user. + * @summary Updated user + * @param {string} username name that need to be deleted + * @param {User} user Updated user object + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof UserApiInterface + */ + updateUser(username: string, user: User, options?: any): Promise<{}>; + +} diff --git a/samples/client/petstore/typescript/builds/default/apis/baseapi.ts b/samples/client/petstore/typescript/builds/default/apis/baseapi.ts new file mode 100644 index 00000000000..fe7ee3d1511 --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/apis/baseapi.ts @@ -0,0 +1,37 @@ +import { Configuration } from '../configuration' + +/** + * + * @export + */ +export const COLLECTION_FORMATS = { + csv: ",", + ssv: " ", + tsv: "\t", + pipes: "|", +}; + + +/** + * + * @export + * @class BaseAPI + */ +export class BaseAPIRequestFactory { + + constructor(protected configuration: Configuration) { + } +}; + +/** + * + * @export + * @class RequiredError + * @extends {Error} + */ +export class RequiredError extends Error { + name: "RequiredError" = "RequiredError"; + constructor(public field: string, msg?: string) { + super(msg); + } +} diff --git a/samples/client/petstore/typescript/builds/default/models/models/ApiResponse.ts b/samples/client/petstore/typescript/builds/default/models/models/ApiResponse.ts new file mode 100644 index 00000000000..45f839a03ab --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/models/models/ApiResponse.ts @@ -0,0 +1,30 @@ +// tslint:disable +/* + TODO: LICENSE INFO +*/ +/** + * Describes the result of uploading an image resource + * @export + * @interface ApiResponse + */ +export interface ApiResponse { + /** + * + * @type {number} + * @memberof ApiResponse + */ + code?: number; + /** + * + * @type {string} + * @memberof ApiResponse + */ + type?: string; + /** + * + * @type {string} + * @memberof ApiResponse + */ + message?: string; +} + diff --git a/samples/client/petstore/typescript/builds/default/models/models/Category.ts b/samples/client/petstore/typescript/builds/default/models/models/Category.ts new file mode 100644 index 00000000000..c950f45dfcc --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/models/models/Category.ts @@ -0,0 +1,24 @@ +// tslint:disable +/* + TODO: LICENSE INFO +*/ +/** + * A category for a pet + * @export + * @interface Category + */ +export interface Category { + /** + * + * @type {number} + * @memberof Category + */ + id?: number; + /** + * + * @type {string} + * @memberof Category + */ + name?: string; +} + diff --git a/samples/client/petstore/typescript/builds/default/models/models/Order.ts b/samples/client/petstore/typescript/builds/default/models/models/Order.ts new file mode 100644 index 00000000000..d2699e865ee --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/models/models/Order.ts @@ -0,0 +1,64 @@ +// tslint:disable +/* + TODO: LICENSE INFO +*/ +/** + * An order for a pets from the pet store + * @export + * @interface Order + */ +export interface Order { + /** + * + * @type {number} + * @memberof Order + */ + id?: number; + /** + * + * @type {number} + * @memberof Order + */ + petId?: number; + /** + * + * @type {number} + * @memberof Order + */ + quantity?: number; + /** + * + * @type {Date} + * @memberof Order + */ + shipDate?: Date; + /** + * Order Status + * @type {string} + * @memberof Order + */ + status?: Order.StatusEnum; + /** + * + * @type {boolean} + * @memberof Order + */ + complete?: boolean; +} + +/** + * @export + * @namespace Order + */ +export namespace Order { + /** + * @export + * @enum {string} + */ + export enum StatusEnum { + Placed = 'placed', + Approved = 'approved', + Delivered = 'delivered' + } +} + diff --git a/samples/client/petstore/typescript/builds/default/models/models/Pet.ts b/samples/client/petstore/typescript/builds/default/models/models/Pet.ts new file mode 100644 index 00000000000..529d264a31e --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/models/models/Pet.ts @@ -0,0 +1,66 @@ +// tslint:disable +/* + TODO: LICENSE INFO +*/ +import { Category } from './Category'; +import { Tag } from './Tag'; +/** + * A pet for sale in the pet store + * @export + * @interface Pet + */ +export interface Pet { + /** + * + * @type {number} + * @memberof Pet + */ + id?: number; + /** + * + * @type {Category} + * @memberof Pet + */ + category?: Category; + /** + * + * @type {string} + * @memberof Pet + */ + name: string; + /** + * + * @type {Array} + * @memberof Pet + */ + photoUrls: Array; + /** + * + * @type {Array} + * @memberof Pet + */ + tags?: Array; + /** + * pet status in the store + * @type {string} + * @memberof Pet + */ + status?: Pet.StatusEnum; +} + +/** + * @export + * @namespace Pet + */ +export namespace Pet { + /** + * @export + * @enum {string} + */ + export enum StatusEnum { + Available = 'available', + Pending = 'pending', + Sold = 'sold' + } +} + diff --git a/samples/client/petstore/typescript/builds/default/models/models/Tag.ts b/samples/client/petstore/typescript/builds/default/models/models/Tag.ts new file mode 100644 index 00000000000..eb777b1c616 --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/models/models/Tag.ts @@ -0,0 +1,24 @@ +// tslint:disable +/* + TODO: LICENSE INFO +*/ +/** + * A tag for a pet + * @export + * @interface Tag + */ +export interface Tag { + /** + * + * @type {number} + * @memberof Tag + */ + id?: number; + /** + * + * @type {string} + * @memberof Tag + */ + name?: string; +} + diff --git a/samples/client/petstore/typescript/builds/default/models/models/User.ts b/samples/client/petstore/typescript/builds/default/models/models/User.ts new file mode 100644 index 00000000000..247a8665e8b --- /dev/null +++ b/samples/client/petstore/typescript/builds/default/models/models/User.ts @@ -0,0 +1,60 @@ +// tslint:disable +/* + TODO: LICENSE INFO +*/ +/** + * A User who is purchasing from the pet store + * @export + * @interface User + */ +export interface User { + /** + * + * @type {number} + * @memberof User + */ + id?: number; + /** + * + * @type {string} + * @memberof User + */ + username?: string; + /** + * + * @type {string} + * @memberof User + */ + firstName?: string; + /** + * + * @type {string} + * @memberof User + */ + lastName?: string; + /** + * + * @type {string} + * @memberof User + */ + email?: string; + /** + * + * @type {string} + * @memberof User + */ + password?: string; + /** + * + * @type {string} + * @memberof User + */ + phone?: string; + /** + * User Status + * @type {number} + * @memberof User + */ + userStatus?: number; +} +