[Typscript][Fetch] add configuration to support authentication (#4008)

* add configuration to typescript fetch

* fix issues reported by the CI

* fix header parameters in ts fetch client

* add new configuration file for ts fetch

* skip if check for configuration in ts fetch

* Fix `this.configuration` issue in paramsCreator

* update ts fetch samples

* Fix typescript fetch tests to work with Configuration

* Add dictionary to store apikeys (#8)

* Add dictionary to store apikeys

* Type apikey with expected params rather than Dictionary - typescript-fetch

* Update test samples to new typescript-fetch api

* Fix tests for typesript-fetch api

* update typescript sample using petstore.yaml
This commit is contained in:
wing328 2016-10-20 18:38:32 +08:00 committed by GitHub
parent c73e499c5d
commit 9036dfdb3a
14 changed files with 881 additions and 315 deletions

View File

@ -26,6 +26,6 @@ fi
# if you've executed sbt assembly previously it will use that instead. # 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" 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-fetch -c bin/typescript-fetch-petstore-target-es6.json -o samples/client/petstore/typescript-fetch/builds/es6-target" ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l typescript-fetch -c bin/typescript-fetch-petstore-target-es6.json -o samples/client/petstore/typescript-fetch/builds/es6-target"
java $JAVA_OPTS -jar $executable $ags java $JAVA_OPTS -jar $executable $ags

View File

@ -26,6 +26,6 @@ fi
# if you've executed sbt assembly previously it will use that instead. # 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" 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-fetch -c bin/typescript-fetch-petstore-with-npm-version.json -o samples/client/petstore/typescript-fetch/builds/with-npm-version" ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l typescript-fetch -c bin/typescript-fetch-petstore-with-npm-version.json -o samples/client/petstore/typescript-fetch/builds/with-npm-version"
java $JAVA_OPTS -jar $executable $ags java $JAVA_OPTS -jar $executable $ags

View File

@ -26,6 +26,6 @@ fi
# if you've executed sbt assembly previously it will use that instead. # 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" 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-fetch -o samples/client/petstore/typescript-fetch/builds/default" ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l typescript-fetch -o samples/client/petstore/typescript-fetch/builds/default"
java $JAVA_OPTS -jar $executable $ags java $JAVA_OPTS -jar $executable $ags

View File

@ -41,6 +41,7 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
supportingFiles.add(new SupportingFile("typings.json.mustache", "", "typings.json")); supportingFiles.add(new SupportingFile("typings.json.mustache", "", "typings.json"));
supportingFiles.add(new SupportingFile("tsconfig.json.mustache", "", "tsconfig.json")); supportingFiles.add(new SupportingFile("tsconfig.json.mustache", "", "tsconfig.json"));
supportingFiles.add(new SupportingFile("gitignore", "", ".gitignore")); supportingFiles.add(new SupportingFile("gitignore", "", ".gitignore"));
supportingFiles.add(new SupportingFile("configuration.mustache", "", "configuration.ts"));
if(additionalProperties.containsKey(NPM_NAME)) { if(additionalProperties.containsKey(NPM_NAME)) {
this.setNpmName(additionalProperties.get(NPM_NAME).toString()); this.setNpmName(additionalProperties.get(NPM_NAME).toString());

View File

@ -7,6 +7,8 @@ import * as isomorphicFetch from "isomorphic-fetch";
import * as assign from "core-js/library/fn/object/assign"; import * as assign from "core-js/library/fn/object/assign";
{{/supportsES6}} {{/supportsES6}}
import { Configuration } from './configuration';
interface Dictionary<T> { [index: string]: T; } interface Dictionary<T> { [index: string]: T; }
export interface FetchAPI { (url: string, init?: any): Promise<any>; } export interface FetchAPI { (url: string, init?: any): Promise<any>; }
@ -20,11 +22,14 @@ export interface FetchArgs {
export class BaseAPI { export class BaseAPI {
basePath: string; basePath: string;
fetch: FetchAPI; fetch: FetchAPI;
public configuration: Configuration;
constructor(fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) { constructor(fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH, configuration: Configuration = new Configuration()) {
this.basePath = basePath; this.basePath = basePath;
this.fetch = fetch; this.fetch = fetch;
this.configuration = configuration;
} }
} }
{{#models}} {{#models}}
@ -70,7 +75,7 @@ export const {{classname}}FetchParamCreactor = {
* {{notes}}{{/notes}}{{#allParams}} * {{notes}}{{/notes}}{{#allParams}}
* @param {{paramName}} {{description}}{{/allParams}} * @param {{paramName}} {{description}}{{/allParams}}
*/ */
{{nickname}}({{#hasParams}}params: { {{#allParams}} {{paramName}}{{^required}}?{{/required}}: {{{dataType}}};{{/allParams}} }{{/hasParams}}): FetchArgs { {{nickname}}({{#hasParams}}params: { {{#allParams}} {{paramName}}{{^required}}?{{/required}}: {{{dataType}}};{{/allParams}} }{{/hasParams}}{{#hasAuthMethods}}{{#hasParams}}, {{/hasParams}}configuration: Configuration{{/hasAuthMethods}}): FetchArgs {
{{#allParams}} {{#allParams}}
{{#required}} {{#required}}
// verify required parameter "{{paramName}}" is set // verify required parameter "{{paramName}}" is set
@ -112,6 +117,42 @@ export const {{classname}}FetchParamCreactor = {
fetchOptions.headers = contentTypeHeader; fetchOptions.headers = contentTypeHeader;
} }
{{/hasHeaderParams}} {{/hasHeaderParams}}
{{#authMethods}}
// authentication ({{name}}) required
{{#isApiKey}}
{{#isKeyInHeader}}
if (configuration.apiKey && configuration.apiKey.{{keyParamName}}) {
fetchOptions.headers = {{#supportsES6}}Object.{{/supportsES6}}assign({
'{{keyParamName}}': configuration.apiKey.{{keyParamName}},
}, contentTypeHeader);
}
{{/isKeyInHeader}}
{{#isKeyInQuery}}
if (configuration.apiKey && configuration.apiKey.{{keyParamName}}) {
urlObj.query = {{#supportsES6}}Object.{{/supportsES6}}assign({}, urlObj.query, {
'{{keyParamName}}': configuration.apiKey.{{keyParamName}},
});
}
{{/isKeyInQuery}}
{{/isApiKey}}
{{#isBasic}}
// http basic authentication required
if (configuration.username || configuration.password) {
fetchOptions.headers = {{#supportsES6}}Object.{{/supportsES6}}assign({
'Authorization': 'Basic ' + btoa(configuration.username + ':' + configuration.password),
}, contentTypeHeader);
}
{{/isBasic}}
{{#isOAuth}}
// oauth required
if (configuration.accessToken) {
fetchOptions.headers = {{#supportsES6}}Object.{{/supportsES6}}assign({
'Authorization': 'Bearer ' + configuration.accessToken,
}, contentTypeHeader);
}
{{/isOAuth}}
{{/authMethods}}
return { return {
url: url.format(urlObj), url: url.format(urlObj),
options: fetchOptions, options: fetchOptions,
@ -131,8 +172,8 @@ export const {{classname}}Fp = {
* {{notes}}{{/notes}}{{#allParams}} * {{notes}}{{/notes}}{{#allParams}}
* @param {{paramName}} {{description}}{{/allParams}} * @param {{paramName}} {{description}}{{/allParams}}
*/ */
{{nickname}}({{#hasParams}}params: { {{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}; {{/allParams}} }{{/hasParams}}): (fetch: FetchAPI, basePath?: string) => Promise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}any{{/returnType}}> { {{nickname}}({{#hasParams}}params: { {{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}; {{/allParams}} }{{/hasParams}}{{#hasAuthMethods}}{{#hasParams}}, {{/hasParams}}configuration: Configuration{{/hasAuthMethods}}): (fetch: FetchAPI, basePath?: string) => Promise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}any{{/returnType}}> {
const fetchArgs = {{classname}}FetchParamCreactor.{{nickname}}({{#hasParams}}params{{/hasParams}}); const fetchArgs = {{classname}}FetchParamCreactor.{{nickname}}({{#hasParams}}params{{/hasParams}}{{#hasAuthMethods}}{{#hasParams}}, {{/hasParams}}configuration{{/hasAuthMethods}});
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
if (response.status >= 200 && response.status < 300) { if (response.status >= 200 && response.status < 300) {
@ -158,7 +199,7 @@ export class {{classname}} extends BaseAPI {
* @param {{paramName}} {{description}}{{/allParams}} * @param {{paramName}} {{description}}{{/allParams}}
*/ */
{{nickname}}({{#hasParams}}params: { {{#allParams}} {{paramName}}{{^required}}?{{/required}}: {{{dataType}}};{{/allParams}} }{{/hasParams}}) { {{nickname}}({{#hasParams}}params: { {{#allParams}} {{paramName}}{{^required}}?{{/required}}: {{{dataType}}};{{/allParams}} }{{/hasParams}}) {
return {{classname}}Fp.{{nickname}}({{#hasParams}}params{{/hasParams}})(this.fetch, this.basePath); return {{classname}}Fp.{{nickname}}({{#hasParams}}params{{/hasParams}}{{#hasAuthMethods}}{{#hasParams}}, {{/hasParams}}this.configuration{{/hasAuthMethods}})(this.fetch, this.basePath);
} }
{{/operation}} {{/operation}}
}; };
@ -175,8 +216,8 @@ export const {{classname}}Factory = function (fetch?: FetchAPI, basePath?: strin
* {{notes}}{{/notes}}{{#allParams}} * {{notes}}{{/notes}}{{#allParams}}
* @param {{paramName}} {{description}}{{/allParams}} * @param {{paramName}} {{description}}{{/allParams}}
*/ */
{{nickname}}({{#hasParams}}params: { {{#allParams}} {{paramName}}{{^required}}?{{/required}}: {{{dataType}}};{{/allParams}} }{{/hasParams}}) { {{nickname}}({{#hasParams}}params: { {{#allParams}} {{paramName}}{{^required}}?{{/required}}: {{{dataType}}};{{/allParams}} }{{/hasParams}}{{#hasAuthMethods}}{{#hasParams}}, {{/hasParams}}configuration: Configuration{{/hasAuthMethods}}) {
return {{classname}}Fp.{{nickname}}({{#hasParams}}params{{/hasParams}})(fetch, basePath); return {{classname}}Fp.{{nickname}}({{#hasParams}}params{{/hasParams}}{{#hasAuthMethods}}{{#hasParams}}, {{/hasParams}}configuration{{/hasAuthMethods}})(fetch, basePath);
}, },
{{/operation}} {{/operation}}
} }

View File

@ -0,0 +1,12 @@
export class Configuration {
apiKey: {
{{#authMethods}}
{{#isApiKey}}
{{keyParamName}}: string;
{{/isApiKey}}
{{/authMethods}}
};
username: string;
password: string;
accessToken: string;
}

View File

@ -1,9 +1,9 @@
/** /**
* Swagger Petstore * Swagger Petstore
* This is a sample server Petstore server. You can find out more about Swagger at <a href=\"http://swagger.io\">http://swagger.io</a> 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 * 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. * NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git * https://github.com/swagger-api/swagger-codegen.git
@ -28,6 +28,8 @@ import * as url from "url";
import * as isomorphicFetch from "isomorphic-fetch"; import * as isomorphicFetch from "isomorphic-fetch";
import * as assign from "core-js/library/fn/object/assign"; import * as assign from "core-js/library/fn/object/assign";
import { Configuration } from './configuration';
interface Dictionary<T> { [index: string]: T; } interface Dictionary<T> { [index: string]: T; }
export interface FetchAPI { (url: string, init?: any): Promise<any>; } export interface FetchAPI { (url: string, init?: any): Promise<any>; }
@ -41,18 +43,36 @@ export interface FetchArgs {
export class BaseAPI { export class BaseAPI {
basePath: string; basePath: string;
fetch: FetchAPI; fetch: FetchAPI;
public configuration: Configuration;
constructor(fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) { constructor(fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH, configuration: Configuration = new Configuration()) {
this.basePath = basePath; this.basePath = basePath;
this.fetch = fetch; this.fetch = fetch;
} this.configuration = configuration;
} }
}
/**
* Describes the result of uploading an image resource
*/
export interface ApiResponse {
"code"?: number;
"type"?: string;
"message"?: string;
}
/**
* A category for a pet
*/
export interface Category { export interface Category {
"id"?: number; "id"?: number;
"name"?: string; "name"?: string;
} }
/**
* An order for a pets from the pet store
*/
export interface Order { export interface Order {
"id"?: number; "id"?: number;
"petId"?: number; "petId"?: number;
@ -66,6 +86,9 @@ export interface Order {
} }
export type OrderStatusEnum = "placed" | "approved" | "delivered"; export type OrderStatusEnum = "placed" | "approved" | "delivered";
/**
* A pet for sale in the pet store
*/
export interface Pet { export interface Pet {
"id"?: number; "id"?: number;
"category"?: Category; "category"?: Category;
@ -79,11 +102,17 @@ export interface Pet {
} }
export type PetStatusEnum = "available" | "pending" | "sold"; export type PetStatusEnum = "available" | "pending" | "sold";
/**
* A tag for a pet
*/
export interface Tag { export interface Tag {
"id"?: number; "id"?: number;
"name"?: string; "name"?: string;
} }
/**
* A User who is purchasing from the pet store
*/
export interface User { export interface User {
"id"?: number; "id"?: number;
"username"?: string; "username"?: string;
@ -109,7 +138,11 @@ export const PetApiFetchParamCreactor = {
* *
* @param body Pet object that needs to be added to the store * @param body Pet object that needs to be added to the store
*/ */
addPet(params: { body?: Pet; }): FetchArgs { addPet(params: { body: Pet; }, configuration: Configuration): FetchArgs {
// verify required parameter "body" is set
if (params["body"] == null) {
throw new Error("Missing required parameter body when calling addPet");
}
const baseUrl = `/pet`; const baseUrl = `/pet`;
let urlObj = url.parse(baseUrl, true); let urlObj = url.parse(baseUrl, true);
let fetchOptions: RequestInit = { method: "POST" }; let fetchOptions: RequestInit = { method: "POST" };
@ -122,6 +155,14 @@ export const PetApiFetchParamCreactor = {
if (contentTypeHeader) { if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader; fetchOptions.headers = contentTypeHeader;
} }
// authentication (petstore_auth) required
// oauth required
if (configuration.accessToken) {
fetchOptions.headers = assign({
'Authorization': 'Bearer ' + configuration.accessToken,
}, contentTypeHeader);
}
return { return {
url: url.format(urlObj), url: url.format(urlObj),
options: fetchOptions, options: fetchOptions,
@ -133,7 +174,7 @@ export const PetApiFetchParamCreactor = {
* @param petId Pet id to delete * @param petId Pet id to delete
* @param apiKey * @param apiKey
*/ */
deletePet(params: { petId: number; apiKey?: string; }): FetchArgs { deletePet(params: { petId: number; apiKey?: string; }, configuration: Configuration): FetchArgs {
// verify required parameter "petId" is set // verify required parameter "petId" is set
if (params["petId"] == null) { if (params["petId"] == null) {
throw new Error("Missing required parameter petId when calling deletePet"); throw new Error("Missing required parameter petId when calling deletePet");
@ -147,6 +188,14 @@ export const PetApiFetchParamCreactor = {
fetchOptions.headers = assign({ fetchOptions.headers = assign({
"api_key": params.apiKey, "api_key": params.apiKey,
}, contentTypeHeader); }, contentTypeHeader);
// authentication (petstore_auth) required
// oauth required
if (configuration.accessToken) {
fetchOptions.headers = assign({
'Authorization': 'Bearer ' + configuration.accessToken,
}, contentTypeHeader);
}
return { return {
url: url.format(urlObj), url: url.format(urlObj),
options: fetchOptions, options: fetchOptions,
@ -157,7 +206,11 @@ export const PetApiFetchParamCreactor = {
* Multiple status values can be provided with comma separated strings * Multiple status values can be provided with comma separated strings
* @param status Status values that need to be considered for filter * @param status Status values that need to be considered for filter
*/ */
findPetsByStatus(params: { status?: Array<string>; }): FetchArgs { findPetsByStatus(params: { status: Array<string>; }, configuration: Configuration): FetchArgs {
// verify required parameter "status" is set
if (params["status"] == null) {
throw new Error("Missing required parameter status when calling findPetsByStatus");
}
const baseUrl = `/pet/findByStatus`; const baseUrl = `/pet/findByStatus`;
let urlObj = url.parse(baseUrl, true); let urlObj = url.parse(baseUrl, true);
urlObj.query = assign({}, urlObj.query, { urlObj.query = assign({}, urlObj.query, {
@ -169,6 +222,14 @@ export const PetApiFetchParamCreactor = {
if (contentTypeHeader) { if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader; fetchOptions.headers = contentTypeHeader;
} }
// authentication (petstore_auth) required
// oauth required
if (configuration.accessToken) {
fetchOptions.headers = assign({
'Authorization': 'Bearer ' + configuration.accessToken,
}, contentTypeHeader);
}
return { return {
url: url.format(urlObj), url: url.format(urlObj),
options: fetchOptions, options: fetchOptions,
@ -179,7 +240,11 @@ export const PetApiFetchParamCreactor = {
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
* @param tags Tags to filter by * @param tags Tags to filter by
*/ */
findPetsByTags(params: { tags?: Array<string>; }): FetchArgs { findPetsByTags(params: { tags: Array<string>; }, configuration: Configuration): FetchArgs {
// verify required parameter "tags" is set
if (params["tags"] == null) {
throw new Error("Missing required parameter tags when calling findPetsByTags");
}
const baseUrl = `/pet/findByTags`; const baseUrl = `/pet/findByTags`;
let urlObj = url.parse(baseUrl, true); let urlObj = url.parse(baseUrl, true);
urlObj.query = assign({}, urlObj.query, { urlObj.query = assign({}, urlObj.query, {
@ -191,6 +256,14 @@ export const PetApiFetchParamCreactor = {
if (contentTypeHeader) { if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader; fetchOptions.headers = contentTypeHeader;
} }
// authentication (petstore_auth) required
// oauth required
if (configuration.accessToken) {
fetchOptions.headers = assign({
'Authorization': 'Bearer ' + configuration.accessToken,
}, contentTypeHeader);
}
return { return {
url: url.format(urlObj), url: url.format(urlObj),
options: fetchOptions, options: fetchOptions,
@ -198,10 +271,10 @@ export const PetApiFetchParamCreactor = {
}, },
/** /**
* Find pet by ID * Find pet by ID
* Returns a pet when ID &lt; 10. ID &gt; 10 or nonintegers will simulate API error conditions * Returns a single pet
* @param petId ID of pet that needs to be fetched * @param petId ID of pet to return
*/ */
getPetById(params: { petId: number; }): FetchArgs { getPetById(params: { petId: number; }, configuration: Configuration): FetchArgs {
// verify required parameter "petId" is set // verify required parameter "petId" is set
if (params["petId"] == null) { if (params["petId"] == null) {
throw new Error("Missing required parameter petId when calling getPetById"); throw new Error("Missing required parameter petId when calling getPetById");
@ -215,6 +288,13 @@ export const PetApiFetchParamCreactor = {
if (contentTypeHeader) { if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader; fetchOptions.headers = contentTypeHeader;
} }
// authentication (api_key) required
if (configuration.apiKey && configuration.apiKey.api_key) {
fetchOptions.headers = assign({
'api_key': configuration.apiKey.api_key,
}, contentTypeHeader);
}
return { return {
url: url.format(urlObj), url: url.format(urlObj),
options: fetchOptions, options: fetchOptions,
@ -225,7 +305,11 @@ export const PetApiFetchParamCreactor = {
* *
* @param body Pet object that needs to be added to the store * @param body Pet object that needs to be added to the store
*/ */
updatePet(params: { body?: Pet; }): FetchArgs { updatePet(params: { body: Pet; }, configuration: Configuration): FetchArgs {
// verify required parameter "body" is set
if (params["body"] == null) {
throw new Error("Missing required parameter body when calling updatePet");
}
const baseUrl = `/pet`; const baseUrl = `/pet`;
let urlObj = url.parse(baseUrl, true); let urlObj = url.parse(baseUrl, true);
let fetchOptions: RequestInit = { method: "PUT" }; let fetchOptions: RequestInit = { method: "PUT" };
@ -238,6 +322,14 @@ export const PetApiFetchParamCreactor = {
if (contentTypeHeader) { if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader; fetchOptions.headers = contentTypeHeader;
} }
// authentication (petstore_auth) required
// oauth required
if (configuration.accessToken) {
fetchOptions.headers = assign({
'Authorization': 'Bearer ' + configuration.accessToken,
}, contentTypeHeader);
}
return { return {
url: url.format(urlObj), url: url.format(urlObj),
options: fetchOptions, options: fetchOptions,
@ -250,7 +342,7 @@ export const PetApiFetchParamCreactor = {
* @param name Updated name of the pet * @param name Updated name of the pet
* @param status Updated status of the pet * @param status Updated status of the pet
*/ */
updatePetWithForm(params: { petId: string; name?: string; status?: string; }): FetchArgs { updatePetWithForm(params: { petId: number; name?: string; status?: string; }, configuration: Configuration): FetchArgs {
// verify required parameter "petId" is set // verify required parameter "petId" is set
if (params["petId"] == null) { if (params["petId"] == null) {
throw new Error("Missing required parameter petId when calling updatePetWithForm"); throw new Error("Missing required parameter petId when calling updatePetWithForm");
@ -269,6 +361,14 @@ export const PetApiFetchParamCreactor = {
if (contentTypeHeader) { if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader; fetchOptions.headers = contentTypeHeader;
} }
// authentication (petstore_auth) required
// oauth required
if (configuration.accessToken) {
fetchOptions.headers = assign({
'Authorization': 'Bearer ' + configuration.accessToken,
}, contentTypeHeader);
}
return { return {
url: url.format(urlObj), url: url.format(urlObj),
options: fetchOptions, options: fetchOptions,
@ -281,7 +381,7 @@ export const PetApiFetchParamCreactor = {
* @param additionalMetadata Additional data to pass to server * @param additionalMetadata Additional data to pass to server
* @param file file to upload * @param file file to upload
*/ */
uploadFile(params: { petId: number; additionalMetadata?: string; file?: any; }): FetchArgs { uploadFile(params: { petId: number; additionalMetadata?: string; file?: any; }, configuration: Configuration): FetchArgs {
// verify required parameter "petId" is set // verify required parameter "petId" is set
if (params["petId"] == null) { if (params["petId"] == null) {
throw new Error("Missing required parameter petId when calling uploadFile"); throw new Error("Missing required parameter petId when calling uploadFile");
@ -300,6 +400,14 @@ export const PetApiFetchParamCreactor = {
if (contentTypeHeader) { if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader; fetchOptions.headers = contentTypeHeader;
} }
// authentication (petstore_auth) required
// oauth required
if (configuration.accessToken) {
fetchOptions.headers = assign({
'Authorization': 'Bearer ' + configuration.accessToken,
}, contentTypeHeader);
}
return { return {
url: url.format(urlObj), url: url.format(urlObj),
options: fetchOptions, options: fetchOptions,
@ -316,8 +424,8 @@ export const PetApiFp = {
* *
* @param body Pet object that needs to be added to the store * @param body Pet object that needs to be added to the store
*/ */
addPet(params: { body?: Pet; }): (fetch: FetchAPI, basePath?: string) => Promise<any> { addPet(params: { body: Pet; }, configuration: Configuration): (fetch: FetchAPI, basePath?: string) => Promise<any> {
const fetchArgs = PetApiFetchParamCreactor.addPet(params); const fetchArgs = PetApiFetchParamCreactor.addPet(params, configuration);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
if (response.status >= 200 && response.status < 300) { if (response.status >= 200 && response.status < 300) {
@ -334,8 +442,8 @@ export const PetApiFp = {
* @param petId Pet id to delete * @param petId Pet id to delete
* @param apiKey * @param apiKey
*/ */
deletePet(params: { petId: number; apiKey?: string; }): (fetch: FetchAPI, basePath?: string) => Promise<any> { deletePet(params: { petId: number; apiKey?: string; }, configuration: Configuration): (fetch: FetchAPI, basePath?: string) => Promise<any> {
const fetchArgs = PetApiFetchParamCreactor.deletePet(params); const fetchArgs = PetApiFetchParamCreactor.deletePet(params, configuration);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
if (response.status >= 200 && response.status < 300) { if (response.status >= 200 && response.status < 300) {
@ -351,8 +459,8 @@ export const PetApiFp = {
* Multiple status values can be provided with comma separated strings * Multiple status values can be provided with comma separated strings
* @param status Status values that need to be considered for filter * @param status Status values that need to be considered for filter
*/ */
findPetsByStatus(params: { status?: Array<string>; }): (fetch: FetchAPI, basePath?: string) => Promise<Array<Pet>> { findPetsByStatus(params: { status: Array<string>; }, configuration: Configuration): (fetch: FetchAPI, basePath?: string) => Promise<Array<Pet>> {
const fetchArgs = PetApiFetchParamCreactor.findPetsByStatus(params); const fetchArgs = PetApiFetchParamCreactor.findPetsByStatus(params, configuration);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
if (response.status >= 200 && response.status < 300) { if (response.status >= 200 && response.status < 300) {
@ -368,8 +476,8 @@ export const PetApiFp = {
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
* @param tags Tags to filter by * @param tags Tags to filter by
*/ */
findPetsByTags(params: { tags?: Array<string>; }): (fetch: FetchAPI, basePath?: string) => Promise<Array<Pet>> { findPetsByTags(params: { tags: Array<string>; }, configuration: Configuration): (fetch: FetchAPI, basePath?: string) => Promise<Array<Pet>> {
const fetchArgs = PetApiFetchParamCreactor.findPetsByTags(params); const fetchArgs = PetApiFetchParamCreactor.findPetsByTags(params, configuration);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
if (response.status >= 200 && response.status < 300) { if (response.status >= 200 && response.status < 300) {
@ -382,11 +490,11 @@ export const PetApiFp = {
}, },
/** /**
* Find pet by ID * Find pet by ID
* Returns a pet when ID &lt; 10. ID &gt; 10 or nonintegers will simulate API error conditions * Returns a single pet
* @param petId ID of pet that needs to be fetched * @param petId ID of pet to return
*/ */
getPetById(params: { petId: number; }): (fetch: FetchAPI, basePath?: string) => Promise<Pet> { getPetById(params: { petId: number; }, configuration: Configuration): (fetch: FetchAPI, basePath?: string) => Promise<Pet> {
const fetchArgs = PetApiFetchParamCreactor.getPetById(params); const fetchArgs = PetApiFetchParamCreactor.getPetById(params, configuration);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
if (response.status >= 200 && response.status < 300) { if (response.status >= 200 && response.status < 300) {
@ -402,8 +510,8 @@ export const PetApiFp = {
* *
* @param body Pet object that needs to be added to the store * @param body Pet object that needs to be added to the store
*/ */
updatePet(params: { body?: Pet; }): (fetch: FetchAPI, basePath?: string) => Promise<any> { updatePet(params: { body: Pet; }, configuration: Configuration): (fetch: FetchAPI, basePath?: string) => Promise<any> {
const fetchArgs = PetApiFetchParamCreactor.updatePet(params); const fetchArgs = PetApiFetchParamCreactor.updatePet(params, configuration);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
if (response.status >= 200 && response.status < 300) { if (response.status >= 200 && response.status < 300) {
@ -421,8 +529,8 @@ export const PetApiFp = {
* @param name Updated name of the pet * @param name Updated name of the pet
* @param status Updated status of the pet * @param status Updated status of the pet
*/ */
updatePetWithForm(params: { petId: string; name?: string; status?: string; }): (fetch: FetchAPI, basePath?: string) => Promise<any> { updatePetWithForm(params: { petId: number; name?: string; status?: string; }, configuration: Configuration): (fetch: FetchAPI, basePath?: string) => Promise<any> {
const fetchArgs = PetApiFetchParamCreactor.updatePetWithForm(params); const fetchArgs = PetApiFetchParamCreactor.updatePetWithForm(params, configuration);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
if (response.status >= 200 && response.status < 300) { if (response.status >= 200 && response.status < 300) {
@ -440,12 +548,12 @@ export const PetApiFp = {
* @param additionalMetadata Additional data to pass to server * @param additionalMetadata Additional data to pass to server
* @param file file to upload * @param file file to upload
*/ */
uploadFile(params: { petId: number; additionalMetadata?: string; file?: any; }): (fetch: FetchAPI, basePath?: string) => Promise<any> { uploadFile(params: { petId: number; additionalMetadata?: string; file?: any; }, configuration: Configuration): (fetch: FetchAPI, basePath?: string) => Promise<ApiResponse> {
const fetchArgs = PetApiFetchParamCreactor.uploadFile(params); const fetchArgs = PetApiFetchParamCreactor.uploadFile(params, configuration);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
if (response.status >= 200 && response.status < 300) { if (response.status >= 200 && response.status < 300) {
return response; return response.json();
} else { } else {
throw response; throw response;
} }
@ -463,8 +571,8 @@ export class PetApi extends BaseAPI {
* *
* @param body Pet object that needs to be added to the store * @param body Pet object that needs to be added to the store
*/ */
addPet(params: { body?: Pet; }) { addPet(params: { body: Pet; }) {
return PetApiFp.addPet(params)(this.fetch, this.basePath); return PetApiFp.addPet(params, this.configuration)(this.fetch, this.basePath);
} }
/** /**
* Deletes a pet * Deletes a pet
@ -473,39 +581,39 @@ export class PetApi extends BaseAPI {
* @param apiKey * @param apiKey
*/ */
deletePet(params: { petId: number; apiKey?: string; }) { deletePet(params: { petId: number; apiKey?: string; }) {
return PetApiFp.deletePet(params)(this.fetch, this.basePath); return PetApiFp.deletePet(params, this.configuration)(this.fetch, this.basePath);
} }
/** /**
* Finds Pets by status * Finds Pets by status
* Multiple status values can be provided with comma separated strings * Multiple status values can be provided with comma separated strings
* @param status Status values that need to be considered for filter * @param status Status values that need to be considered for filter
*/ */
findPetsByStatus(params: { status?: Array<string>; }) { findPetsByStatus(params: { status: Array<string>; }) {
return PetApiFp.findPetsByStatus(params)(this.fetch, this.basePath); return PetApiFp.findPetsByStatus(params, this.configuration)(this.fetch, this.basePath);
} }
/** /**
* Finds Pets by tags * Finds Pets by tags
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
* @param tags Tags to filter by * @param tags Tags to filter by
*/ */
findPetsByTags(params: { tags?: Array<string>; }) { findPetsByTags(params: { tags: Array<string>; }) {
return PetApiFp.findPetsByTags(params)(this.fetch, this.basePath); return PetApiFp.findPetsByTags(params, this.configuration)(this.fetch, this.basePath);
} }
/** /**
* Find pet by ID * Find pet by ID
* Returns a pet when ID &lt; 10. ID &gt; 10 or nonintegers will simulate API error conditions * Returns a single pet
* @param petId ID of pet that needs to be fetched * @param petId ID of pet to return
*/ */
getPetById(params: { petId: number; }) { getPetById(params: { petId: number; }) {
return PetApiFp.getPetById(params)(this.fetch, this.basePath); return PetApiFp.getPetById(params, this.configuration)(this.fetch, this.basePath);
} }
/** /**
* Update an existing pet * Update an existing pet
* *
* @param body Pet object that needs to be added to the store * @param body Pet object that needs to be added to the store
*/ */
updatePet(params: { body?: Pet; }) { updatePet(params: { body: Pet; }) {
return PetApiFp.updatePet(params)(this.fetch, this.basePath); return PetApiFp.updatePet(params, this.configuration)(this.fetch, this.basePath);
} }
/** /**
* Updates a pet in the store with form data * Updates a pet in the store with form data
@ -514,8 +622,8 @@ export class PetApi extends BaseAPI {
* @param name Updated name of the pet * @param name Updated name of the pet
* @param status Updated status of the pet * @param status Updated status of the pet
*/ */
updatePetWithForm(params: { petId: string; name?: string; status?: string; }) { updatePetWithForm(params: { petId: number; name?: string; status?: string; }) {
return PetApiFp.updatePetWithForm(params)(this.fetch, this.basePath); return PetApiFp.updatePetWithForm(params, this.configuration)(this.fetch, this.basePath);
} }
/** /**
* uploads an image * uploads an image
@ -525,7 +633,7 @@ export class PetApi extends BaseAPI {
* @param file file to upload * @param file file to upload
*/ */
uploadFile(params: { petId: number; additionalMetadata?: string; file?: any; }) { uploadFile(params: { petId: number; additionalMetadata?: string; file?: any; }) {
return PetApiFp.uploadFile(params)(this.fetch, this.basePath); return PetApiFp.uploadFile(params, this.configuration)(this.fetch, this.basePath);
} }
}; };
@ -539,8 +647,8 @@ export const PetApiFactory = function (fetch?: FetchAPI, basePath?: string) {
* *
* @param body Pet object that needs to be added to the store * @param body Pet object that needs to be added to the store
*/ */
addPet(params: { body?: Pet; }) { addPet(params: { body: Pet; }, configuration: Configuration) {
return PetApiFp.addPet(params)(fetch, basePath); return PetApiFp.addPet(params, configuration)(fetch, basePath);
}, },
/** /**
* Deletes a pet * Deletes a pet
@ -548,40 +656,40 @@ export const PetApiFactory = function (fetch?: FetchAPI, basePath?: string) {
* @param petId Pet id to delete * @param petId Pet id to delete
* @param apiKey * @param apiKey
*/ */
deletePet(params: { petId: number; apiKey?: string; }) { deletePet(params: { petId: number; apiKey?: string; }, configuration: Configuration) {
return PetApiFp.deletePet(params)(fetch, basePath); return PetApiFp.deletePet(params, configuration)(fetch, basePath);
}, },
/** /**
* Finds Pets by status * Finds Pets by status
* Multiple status values can be provided with comma separated strings * Multiple status values can be provided with comma separated strings
* @param status Status values that need to be considered for filter * @param status Status values that need to be considered for filter
*/ */
findPetsByStatus(params: { status?: Array<string>; }) { findPetsByStatus(params: { status: Array<string>; }, configuration: Configuration) {
return PetApiFp.findPetsByStatus(params)(fetch, basePath); return PetApiFp.findPetsByStatus(params, configuration)(fetch, basePath);
}, },
/** /**
* Finds Pets by tags * Finds Pets by tags
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
* @param tags Tags to filter by * @param tags Tags to filter by
*/ */
findPetsByTags(params: { tags?: Array<string>; }) { findPetsByTags(params: { tags: Array<string>; }, configuration: Configuration) {
return PetApiFp.findPetsByTags(params)(fetch, basePath); return PetApiFp.findPetsByTags(params, configuration)(fetch, basePath);
}, },
/** /**
* Find pet by ID * Find pet by ID
* Returns a pet when ID &lt; 10. ID &gt; 10 or nonintegers will simulate API error conditions * Returns a single pet
* @param petId ID of pet that needs to be fetched * @param petId ID of pet to return
*/ */
getPetById(params: { petId: number; }) { getPetById(params: { petId: number; }, configuration: Configuration) {
return PetApiFp.getPetById(params)(fetch, basePath); return PetApiFp.getPetById(params, configuration)(fetch, basePath);
}, },
/** /**
* Update an existing pet * Update an existing pet
* *
* @param body Pet object that needs to be added to the store * @param body Pet object that needs to be added to the store
*/ */
updatePet(params: { body?: Pet; }) { updatePet(params: { body: Pet; }, configuration: Configuration) {
return PetApiFp.updatePet(params)(fetch, basePath); return PetApiFp.updatePet(params, configuration)(fetch, basePath);
}, },
/** /**
* Updates a pet in the store with form data * Updates a pet in the store with form data
@ -590,8 +698,8 @@ export const PetApiFactory = function (fetch?: FetchAPI, basePath?: string) {
* @param name Updated name of the pet * @param name Updated name of the pet
* @param status Updated status of the pet * @param status Updated status of the pet
*/ */
updatePetWithForm(params: { petId: string; name?: string; status?: string; }) { updatePetWithForm(params: { petId: number; name?: string; status?: string; }, configuration: Configuration) {
return PetApiFp.updatePetWithForm(params)(fetch, basePath); return PetApiFp.updatePetWithForm(params, configuration)(fetch, basePath);
}, },
/** /**
* uploads an image * uploads an image
@ -600,8 +708,8 @@ export const PetApiFactory = function (fetch?: FetchAPI, basePath?: string) {
* @param additionalMetadata Additional data to pass to server * @param additionalMetadata Additional data to pass to server
* @param file file to upload * @param file file to upload
*/ */
uploadFile(params: { petId: number; additionalMetadata?: string; file?: any; }) { uploadFile(params: { petId: number; additionalMetadata?: string; file?: any; }, configuration: Configuration) {
return PetApiFp.uploadFile(params)(fetch, basePath); return PetApiFp.uploadFile(params, configuration)(fetch, basePath);
}, },
} }
}; };
@ -630,6 +738,7 @@ export const StoreApiFetchParamCreactor = {
if (contentTypeHeader) { if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader; fetchOptions.headers = contentTypeHeader;
} }
return { return {
url: url.format(urlObj), url: url.format(urlObj),
options: fetchOptions, options: fetchOptions,
@ -639,7 +748,7 @@ export const StoreApiFetchParamCreactor = {
* Returns pet inventories by status * Returns pet inventories by status
* Returns a map of status codes to quantities * Returns a map of status codes to quantities
*/ */
getInventory(): FetchArgs { getInventory(configuration: Configuration): FetchArgs {
const baseUrl = `/store/inventory`; const baseUrl = `/store/inventory`;
let urlObj = url.parse(baseUrl, true); let urlObj = url.parse(baseUrl, true);
let fetchOptions: RequestInit = { method: "GET" }; let fetchOptions: RequestInit = { method: "GET" };
@ -648,6 +757,13 @@ export const StoreApiFetchParamCreactor = {
if (contentTypeHeader) { if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader; fetchOptions.headers = contentTypeHeader;
} }
// authentication (api_key) required
if (configuration.apiKey && configuration.apiKey.api_key) {
fetchOptions.headers = assign({
'api_key': configuration.apiKey.api_key,
}, contentTypeHeader);
}
return { return {
url: url.format(urlObj), url: url.format(urlObj),
options: fetchOptions, options: fetchOptions,
@ -658,7 +774,7 @@ export const StoreApiFetchParamCreactor = {
* For valid response try integer IDs with value &lt;&#x3D; 5 or &gt; 10. Other values will generated exceptions * For valid response try integer IDs with value &lt;&#x3D; 5 or &gt; 10. Other values will generated exceptions
* @param orderId ID of pet that needs to be fetched * @param orderId ID of pet that needs to be fetched
*/ */
getOrderById(params: { orderId: string; }): FetchArgs { getOrderById(params: { orderId: number; }): FetchArgs {
// verify required parameter "orderId" is set // verify required parameter "orderId" is set
if (params["orderId"] == null) { if (params["orderId"] == null) {
throw new Error("Missing required parameter orderId when calling getOrderById"); throw new Error("Missing required parameter orderId when calling getOrderById");
@ -672,6 +788,7 @@ export const StoreApiFetchParamCreactor = {
if (contentTypeHeader) { if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader; fetchOptions.headers = contentTypeHeader;
} }
return { return {
url: url.format(urlObj), url: url.format(urlObj),
options: fetchOptions, options: fetchOptions,
@ -682,7 +799,11 @@ export const StoreApiFetchParamCreactor = {
* *
* @param body order placed for purchasing the pet * @param body order placed for purchasing the pet
*/ */
placeOrder(params: { body?: Order; }): FetchArgs { placeOrder(params: { body: Order; }): FetchArgs {
// verify required parameter "body" is set
if (params["body"] == null) {
throw new Error("Missing required parameter body when calling placeOrder");
}
const baseUrl = `/store/order`; const baseUrl = `/store/order`;
let urlObj = url.parse(baseUrl, true); let urlObj = url.parse(baseUrl, true);
let fetchOptions: RequestInit = { method: "POST" }; let fetchOptions: RequestInit = { method: "POST" };
@ -695,6 +816,7 @@ export const StoreApiFetchParamCreactor = {
if (contentTypeHeader) { if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader; fetchOptions.headers = contentTypeHeader;
} }
return { return {
url: url.format(urlObj), url: url.format(urlObj),
options: fetchOptions, options: fetchOptions,
@ -727,8 +849,8 @@ export const StoreApiFp = {
* Returns pet inventories by status * Returns pet inventories by status
* Returns a map of status codes to quantities * Returns a map of status codes to quantities
*/ */
getInventory(): (fetch: FetchAPI, basePath?: string) => Promise<{ [key: string]: number; }> { getInventory(configuration: Configuration): (fetch: FetchAPI, basePath?: string) => Promise<{ [key: string]: number; }> {
const fetchArgs = StoreApiFetchParamCreactor.getInventory(); const fetchArgs = StoreApiFetchParamCreactor.getInventory(configuration);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
if (response.status >= 200 && response.status < 300) { if (response.status >= 200 && response.status < 300) {
@ -744,7 +866,7 @@ export const StoreApiFp = {
* For valid response try integer IDs with value &lt;&#x3D; 5 or &gt; 10. Other values will generated exceptions * For valid response try integer IDs with value &lt;&#x3D; 5 or &gt; 10. Other values will generated exceptions
* @param orderId ID of pet that needs to be fetched * @param orderId ID of pet that needs to be fetched
*/ */
getOrderById(params: { orderId: string; }): (fetch: FetchAPI, basePath?: string) => Promise<Order> { getOrderById(params: { orderId: number; }): (fetch: FetchAPI, basePath?: string) => Promise<Order> {
const fetchArgs = StoreApiFetchParamCreactor.getOrderById(params); const fetchArgs = StoreApiFetchParamCreactor.getOrderById(params);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
@ -761,7 +883,7 @@ export const StoreApiFp = {
* *
* @param body order placed for purchasing the pet * @param body order placed for purchasing the pet
*/ */
placeOrder(params: { body?: Order; }): (fetch: FetchAPI, basePath?: string) => Promise<Order> { placeOrder(params: { body: Order; }): (fetch: FetchAPI, basePath?: string) => Promise<Order> {
const fetchArgs = StoreApiFetchParamCreactor.placeOrder(params); const fetchArgs = StoreApiFetchParamCreactor.placeOrder(params);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
@ -792,14 +914,14 @@ export class StoreApi extends BaseAPI {
* Returns a map of status codes to quantities * Returns a map of status codes to quantities
*/ */
getInventory() { getInventory() {
return StoreApiFp.getInventory()(this.fetch, this.basePath); return StoreApiFp.getInventory(this.configuration)(this.fetch, this.basePath);
} }
/** /**
* Find purchase order by ID * Find purchase order by ID
* For valid response try integer IDs with value &lt;&#x3D; 5 or &gt; 10. Other values will generated exceptions * For valid response try integer IDs with value &lt;&#x3D; 5 or &gt; 10. Other values will generated exceptions
* @param orderId ID of pet that needs to be fetched * @param orderId ID of pet that needs to be fetched
*/ */
getOrderById(params: { orderId: string; }) { getOrderById(params: { orderId: number; }) {
return StoreApiFp.getOrderById(params)(this.fetch, this.basePath); return StoreApiFp.getOrderById(params)(this.fetch, this.basePath);
} }
/** /**
@ -807,7 +929,7 @@ export class StoreApi extends BaseAPI {
* *
* @param body order placed for purchasing the pet * @param body order placed for purchasing the pet
*/ */
placeOrder(params: { body?: Order; }) { placeOrder(params: { body: Order; }) {
return StoreApiFp.placeOrder(params)(this.fetch, this.basePath); return StoreApiFp.placeOrder(params)(this.fetch, this.basePath);
} }
}; };
@ -829,15 +951,15 @@ export const StoreApiFactory = function (fetch?: FetchAPI, basePath?: string) {
* Returns pet inventories by status * Returns pet inventories by status
* Returns a map of status codes to quantities * Returns a map of status codes to quantities
*/ */
getInventory() { getInventory(configuration: Configuration) {
return StoreApiFp.getInventory()(fetch, basePath); return StoreApiFp.getInventory(configuration)(fetch, basePath);
}, },
/** /**
* Find purchase order by ID * Find purchase order by ID
* For valid response try integer IDs with value &lt;&#x3D; 5 or &gt; 10. Other values will generated exceptions * For valid response try integer IDs with value &lt;&#x3D; 5 or &gt; 10. Other values will generated exceptions
* @param orderId ID of pet that needs to be fetched * @param orderId ID of pet that needs to be fetched
*/ */
getOrderById(params: { orderId: string; }) { getOrderById(params: { orderId: number; }) {
return StoreApiFp.getOrderById(params)(fetch, basePath); return StoreApiFp.getOrderById(params)(fetch, basePath);
}, },
/** /**
@ -845,7 +967,7 @@ export const StoreApiFactory = function (fetch?: FetchAPI, basePath?: string) {
* *
* @param body order placed for purchasing the pet * @param body order placed for purchasing the pet
*/ */
placeOrder(params: { body?: Order; }) { placeOrder(params: { body: Order; }) {
return StoreApiFp.placeOrder(params)(fetch, basePath); return StoreApiFp.placeOrder(params)(fetch, basePath);
}, },
} }
@ -861,7 +983,11 @@ export const UserApiFetchParamCreactor = {
* This can only be done by the logged in user. * This can only be done by the logged in user.
* @param body Created user object * @param body Created user object
*/ */
createUser(params: { body?: User; }): FetchArgs { createUser(params: { body: User; }): FetchArgs {
// verify required parameter "body" is set
if (params["body"] == null) {
throw new Error("Missing required parameter body when calling createUser");
}
const baseUrl = `/user`; const baseUrl = `/user`;
let urlObj = url.parse(baseUrl, true); let urlObj = url.parse(baseUrl, true);
let fetchOptions: RequestInit = { method: "POST" }; let fetchOptions: RequestInit = { method: "POST" };
@ -874,6 +1000,7 @@ export const UserApiFetchParamCreactor = {
if (contentTypeHeader) { if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader; fetchOptions.headers = contentTypeHeader;
} }
return { return {
url: url.format(urlObj), url: url.format(urlObj),
options: fetchOptions, options: fetchOptions,
@ -884,7 +1011,11 @@ export const UserApiFetchParamCreactor = {
* *
* @param body List of user object * @param body List of user object
*/ */
createUsersWithArrayInput(params: { body?: Array<User>; }): FetchArgs { createUsersWithArrayInput(params: { body: Array<User>; }): FetchArgs {
// verify required parameter "body" is set
if (params["body"] == null) {
throw new Error("Missing required parameter body when calling createUsersWithArrayInput");
}
const baseUrl = `/user/createWithArray`; const baseUrl = `/user/createWithArray`;
let urlObj = url.parse(baseUrl, true); let urlObj = url.parse(baseUrl, true);
let fetchOptions: RequestInit = { method: "POST" }; let fetchOptions: RequestInit = { method: "POST" };
@ -897,6 +1028,7 @@ export const UserApiFetchParamCreactor = {
if (contentTypeHeader) { if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader; fetchOptions.headers = contentTypeHeader;
} }
return { return {
url: url.format(urlObj), url: url.format(urlObj),
options: fetchOptions, options: fetchOptions,
@ -907,7 +1039,11 @@ export const UserApiFetchParamCreactor = {
* *
* @param body List of user object * @param body List of user object
*/ */
createUsersWithListInput(params: { body?: Array<User>; }): FetchArgs { createUsersWithListInput(params: { body: Array<User>; }): FetchArgs {
// verify required parameter "body" is set
if (params["body"] == null) {
throw new Error("Missing required parameter body when calling createUsersWithListInput");
}
const baseUrl = `/user/createWithList`; const baseUrl = `/user/createWithList`;
let urlObj = url.parse(baseUrl, true); let urlObj = url.parse(baseUrl, true);
let fetchOptions: RequestInit = { method: "POST" }; let fetchOptions: RequestInit = { method: "POST" };
@ -920,6 +1056,7 @@ export const UserApiFetchParamCreactor = {
if (contentTypeHeader) { if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader; fetchOptions.headers = contentTypeHeader;
} }
return { return {
url: url.format(urlObj), url: url.format(urlObj),
options: fetchOptions, options: fetchOptions,
@ -944,6 +1081,7 @@ export const UserApiFetchParamCreactor = {
if (contentTypeHeader) { if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader; fetchOptions.headers = contentTypeHeader;
} }
return { return {
url: url.format(urlObj), url: url.format(urlObj),
options: fetchOptions, options: fetchOptions,
@ -968,6 +1106,7 @@ export const UserApiFetchParamCreactor = {
if (contentTypeHeader) { if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader; fetchOptions.headers = contentTypeHeader;
} }
return { return {
url: url.format(urlObj), url: url.format(urlObj),
options: fetchOptions, options: fetchOptions,
@ -979,7 +1118,15 @@ export const UserApiFetchParamCreactor = {
* @param username The user name for login * @param username The user name for login
* @param password The password for login in clear text * @param password The password for login in clear text
*/ */
loginUser(params: { username?: string; password?: string; }): FetchArgs { loginUser(params: { username: string; password: string; }): FetchArgs {
// verify required parameter "username" is set
if (params["username"] == null) {
throw new Error("Missing required parameter username when calling loginUser");
}
// verify required parameter "password" is set
if (params["password"] == null) {
throw new Error("Missing required parameter password when calling loginUser");
}
const baseUrl = `/user/login`; const baseUrl = `/user/login`;
let urlObj = url.parse(baseUrl, true); let urlObj = url.parse(baseUrl, true);
urlObj.query = assign({}, urlObj.query, { urlObj.query = assign({}, urlObj.query, {
@ -992,6 +1139,7 @@ export const UserApiFetchParamCreactor = {
if (contentTypeHeader) { if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader; fetchOptions.headers = contentTypeHeader;
} }
return { return {
url: url.format(urlObj), url: url.format(urlObj),
options: fetchOptions, options: fetchOptions,
@ -1010,6 +1158,7 @@ export const UserApiFetchParamCreactor = {
if (contentTypeHeader) { if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader; fetchOptions.headers = contentTypeHeader;
} }
return { return {
url: url.format(urlObj), url: url.format(urlObj),
options: fetchOptions, options: fetchOptions,
@ -1021,11 +1170,15 @@ export const UserApiFetchParamCreactor = {
* @param username name that need to be deleted * @param username name that need to be deleted
* @param body Updated user object * @param body Updated user object
*/ */
updateUser(params: { username: string; body?: User; }): FetchArgs { updateUser(params: { username: string; body: User; }): FetchArgs {
// verify required parameter "username" is set // verify required parameter "username" is set
if (params["username"] == null) { if (params["username"] == null) {
throw new Error("Missing required parameter username when calling updateUser"); throw new Error("Missing required parameter username when calling updateUser");
} }
// verify required parameter "body" is set
if (params["body"] == null) {
throw new Error("Missing required parameter body when calling updateUser");
}
const baseUrl = `/user/{username}` const baseUrl = `/user/{username}`
.replace(`{${"username"}}`, `${ params.username }`); .replace(`{${"username"}}`, `${ params.username }`);
let urlObj = url.parse(baseUrl, true); let urlObj = url.parse(baseUrl, true);
@ -1039,6 +1192,7 @@ export const UserApiFetchParamCreactor = {
if (contentTypeHeader) { if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader; fetchOptions.headers = contentTypeHeader;
} }
return { return {
url: url.format(urlObj), url: url.format(urlObj),
options: fetchOptions, options: fetchOptions,
@ -1055,7 +1209,7 @@ export const UserApiFp = {
* This can only be done by the logged in user. * This can only be done by the logged in user.
* @param body Created user object * @param body Created user object
*/ */
createUser(params: { body?: User; }): (fetch: FetchAPI, basePath?: string) => Promise<any> { createUser(params: { body: User; }): (fetch: FetchAPI, basePath?: string) => Promise<any> {
const fetchArgs = UserApiFetchParamCreactor.createUser(params); const fetchArgs = UserApiFetchParamCreactor.createUser(params);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
@ -1072,7 +1226,7 @@ export const UserApiFp = {
* *
* @param body List of user object * @param body List of user object
*/ */
createUsersWithArrayInput(params: { body?: Array<User>; }): (fetch: FetchAPI, basePath?: string) => Promise<any> { createUsersWithArrayInput(params: { body: Array<User>; }): (fetch: FetchAPI, basePath?: string) => Promise<any> {
const fetchArgs = UserApiFetchParamCreactor.createUsersWithArrayInput(params); const fetchArgs = UserApiFetchParamCreactor.createUsersWithArrayInput(params);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
@ -1089,7 +1243,7 @@ export const UserApiFp = {
* *
* @param body List of user object * @param body List of user object
*/ */
createUsersWithListInput(params: { body?: Array<User>; }): (fetch: FetchAPI, basePath?: string) => Promise<any> { createUsersWithListInput(params: { body: Array<User>; }): (fetch: FetchAPI, basePath?: string) => Promise<any> {
const fetchArgs = UserApiFetchParamCreactor.createUsersWithListInput(params); const fetchArgs = UserApiFetchParamCreactor.createUsersWithListInput(params);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
@ -1141,7 +1295,7 @@ export const UserApiFp = {
* @param username The user name for login * @param username The user name for login
* @param password The password for login in clear text * @param password The password for login in clear text
*/ */
loginUser(params: { username?: string; password?: string; }): (fetch: FetchAPI, basePath?: string) => Promise<string> { loginUser(params: { username: string; password: string; }): (fetch: FetchAPI, basePath?: string) => Promise<string> {
const fetchArgs = UserApiFetchParamCreactor.loginUser(params); const fetchArgs = UserApiFetchParamCreactor.loginUser(params);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
@ -1175,7 +1329,7 @@ export const UserApiFp = {
* @param username name that need to be deleted * @param username name that need to be deleted
* @param body Updated user object * @param body Updated user object
*/ */
updateUser(params: { username: string; body?: User; }): (fetch: FetchAPI, basePath?: string) => Promise<any> { updateUser(params: { username: string; body: User; }): (fetch: FetchAPI, basePath?: string) => Promise<any> {
const fetchArgs = UserApiFetchParamCreactor.updateUser(params); const fetchArgs = UserApiFetchParamCreactor.updateUser(params);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
@ -1198,7 +1352,7 @@ export class UserApi extends BaseAPI {
* This can only be done by the logged in user. * This can only be done by the logged in user.
* @param body Created user object * @param body Created user object
*/ */
createUser(params: { body?: User; }) { createUser(params: { body: User; }) {
return UserApiFp.createUser(params)(this.fetch, this.basePath); return UserApiFp.createUser(params)(this.fetch, this.basePath);
} }
/** /**
@ -1206,7 +1360,7 @@ export class UserApi extends BaseAPI {
* *
* @param body List of user object * @param body List of user object
*/ */
createUsersWithArrayInput(params: { body?: Array<User>; }) { createUsersWithArrayInput(params: { body: Array<User>; }) {
return UserApiFp.createUsersWithArrayInput(params)(this.fetch, this.basePath); return UserApiFp.createUsersWithArrayInput(params)(this.fetch, this.basePath);
} }
/** /**
@ -1214,7 +1368,7 @@ export class UserApi extends BaseAPI {
* *
* @param body List of user object * @param body List of user object
*/ */
createUsersWithListInput(params: { body?: Array<User>; }) { createUsersWithListInput(params: { body: Array<User>; }) {
return UserApiFp.createUsersWithListInput(params)(this.fetch, this.basePath); return UserApiFp.createUsersWithListInput(params)(this.fetch, this.basePath);
} }
/** /**
@ -1239,7 +1393,7 @@ export class UserApi extends BaseAPI {
* @param username The user name for login * @param username The user name for login
* @param password The password for login in clear text * @param password The password for login in clear text
*/ */
loginUser(params: { username?: string; password?: string; }) { loginUser(params: { username: string; password: string; }) {
return UserApiFp.loginUser(params)(this.fetch, this.basePath); return UserApiFp.loginUser(params)(this.fetch, this.basePath);
} }
/** /**
@ -1255,7 +1409,7 @@ export class UserApi extends BaseAPI {
* @param username name that need to be deleted * @param username name that need to be deleted
* @param body Updated user object * @param body Updated user object
*/ */
updateUser(params: { username: string; body?: User; }) { updateUser(params: { username: string; body: User; }) {
return UserApiFp.updateUser(params)(this.fetch, this.basePath); return UserApiFp.updateUser(params)(this.fetch, this.basePath);
} }
}; };
@ -1270,7 +1424,7 @@ export const UserApiFactory = function (fetch?: FetchAPI, basePath?: string) {
* This can only be done by the logged in user. * This can only be done by the logged in user.
* @param body Created user object * @param body Created user object
*/ */
createUser(params: { body?: User; }) { createUser(params: { body: User; }) {
return UserApiFp.createUser(params)(fetch, basePath); return UserApiFp.createUser(params)(fetch, basePath);
}, },
/** /**
@ -1278,7 +1432,7 @@ export const UserApiFactory = function (fetch?: FetchAPI, basePath?: string) {
* *
* @param body List of user object * @param body List of user object
*/ */
createUsersWithArrayInput(params: { body?: Array<User>; }) { createUsersWithArrayInput(params: { body: Array<User>; }) {
return UserApiFp.createUsersWithArrayInput(params)(fetch, basePath); return UserApiFp.createUsersWithArrayInput(params)(fetch, basePath);
}, },
/** /**
@ -1286,7 +1440,7 @@ export const UserApiFactory = function (fetch?: FetchAPI, basePath?: string) {
* *
* @param body List of user object * @param body List of user object
*/ */
createUsersWithListInput(params: { body?: Array<User>; }) { createUsersWithListInput(params: { body: Array<User>; }) {
return UserApiFp.createUsersWithListInput(params)(fetch, basePath); return UserApiFp.createUsersWithListInput(params)(fetch, basePath);
}, },
/** /**
@ -1311,7 +1465,7 @@ export const UserApiFactory = function (fetch?: FetchAPI, basePath?: string) {
* @param username The user name for login * @param username The user name for login
* @param password The password for login in clear text * @param password The password for login in clear text
*/ */
loginUser(params: { username?: string; password?: string; }) { loginUser(params: { username: string; password: string; }) {
return UserApiFp.loginUser(params)(fetch, basePath); return UserApiFp.loginUser(params)(fetch, basePath);
}, },
/** /**
@ -1327,7 +1481,7 @@ export const UserApiFactory = function (fetch?: FetchAPI, basePath?: string) {
* @param username name that need to be deleted * @param username name that need to be deleted
* @param body Updated user object * @param body Updated user object
*/ */
updateUser(params: { username: string; body?: User; }) { updateUser(params: { username: string; body: User; }) {
return UserApiFp.updateUser(params)(fetch, basePath); return UserApiFp.updateUser(params)(fetch, basePath);
}, },
} }

View File

@ -0,0 +1,8 @@
export class Configuration {
apiKey: {
api_key: string;
};
username: string;
password: string;
accessToken: string;
}

View File

@ -1,9 +1,9 @@
/** /**
* Swagger Petstore * Swagger Petstore
* This is a sample server Petstore server. You can find out more about Swagger at <a href=\"http://swagger.io\">http://swagger.io</a> 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 * 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. * NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git * https://github.com/swagger-api/swagger-codegen.git
@ -27,6 +27,8 @@ import * as url from "url";
import * as isomorphicFetch from "isomorphic-fetch"; import * as isomorphicFetch from "isomorphic-fetch";
import { Configuration } from './configuration';
interface Dictionary<T> { [index: string]: T; } interface Dictionary<T> { [index: string]: T; }
export interface FetchAPI { (url: string, init?: any): Promise<any>; } export interface FetchAPI { (url: string, init?: any): Promise<any>; }
@ -40,18 +42,36 @@ export interface FetchArgs {
export class BaseAPI { export class BaseAPI {
basePath: string; basePath: string;
fetch: FetchAPI; fetch: FetchAPI;
public configuration: Configuration;
constructor(fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) { constructor(fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH, configuration: Configuration = new Configuration()) {
this.basePath = basePath; this.basePath = basePath;
this.fetch = fetch; this.fetch = fetch;
} this.configuration = configuration;
} }
}
/**
* Describes the result of uploading an image resource
*/
export interface ApiResponse {
"code"?: number;
"type"?: string;
"message"?: string;
}
/**
* A category for a pet
*/
export interface Category { export interface Category {
"id"?: number; "id"?: number;
"name"?: string; "name"?: string;
} }
/**
* An order for a pets from the pet store
*/
export interface Order { export interface Order {
"id"?: number; "id"?: number;
"petId"?: number; "petId"?: number;
@ -65,6 +85,9 @@ export interface Order {
} }
export type OrderStatusEnum = "placed" | "approved" | "delivered"; export type OrderStatusEnum = "placed" | "approved" | "delivered";
/**
* A pet for sale in the pet store
*/
export interface Pet { export interface Pet {
"id"?: number; "id"?: number;
"category"?: Category; "category"?: Category;
@ -78,11 +101,17 @@ export interface Pet {
} }
export type PetStatusEnum = "available" | "pending" | "sold"; export type PetStatusEnum = "available" | "pending" | "sold";
/**
* A tag for a pet
*/
export interface Tag { export interface Tag {
"id"?: number; "id"?: number;
"name"?: string; "name"?: string;
} }
/**
* A User who is purchasing from the pet store
*/
export interface User { export interface User {
"id"?: number; "id"?: number;
"username"?: string; "username"?: string;
@ -108,7 +137,11 @@ export const PetApiFetchParamCreactor = {
* *
* @param body Pet object that needs to be added to the store * @param body Pet object that needs to be added to the store
*/ */
addPet(params: { body?: Pet; }): FetchArgs { addPet(params: { body: Pet; }, configuration: Configuration): FetchArgs {
// verify required parameter "body" is set
if (params["body"] == null) {
throw new Error("Missing required parameter body when calling addPet");
}
const baseUrl = `/pet`; const baseUrl = `/pet`;
let urlObj = url.parse(baseUrl, true); let urlObj = url.parse(baseUrl, true);
let fetchOptions: RequestInit = { method: "POST" }; let fetchOptions: RequestInit = { method: "POST" };
@ -121,6 +154,14 @@ export const PetApiFetchParamCreactor = {
if (contentTypeHeader) { if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader; fetchOptions.headers = contentTypeHeader;
} }
// authentication (petstore_auth) required
// oauth required
if (configuration.accessToken) {
fetchOptions.headers = Object.assign({
'Authorization': 'Bearer ' + configuration.accessToken,
}, contentTypeHeader);
}
return { return {
url: url.format(urlObj), url: url.format(urlObj),
options: fetchOptions, options: fetchOptions,
@ -132,7 +173,7 @@ export const PetApiFetchParamCreactor = {
* @param petId Pet id to delete * @param petId Pet id to delete
* @param apiKey * @param apiKey
*/ */
deletePet(params: { petId: number; apiKey?: string; }): FetchArgs { deletePet(params: { petId: number; apiKey?: string; }, configuration: Configuration): FetchArgs {
// verify required parameter "petId" is set // verify required parameter "petId" is set
if (params["petId"] == null) { if (params["petId"] == null) {
throw new Error("Missing required parameter petId when calling deletePet"); throw new Error("Missing required parameter petId when calling deletePet");
@ -146,6 +187,14 @@ export const PetApiFetchParamCreactor = {
fetchOptions.headers = Object.assign({ fetchOptions.headers = Object.assign({
"api_key": params.apiKey, "api_key": params.apiKey,
}, contentTypeHeader); }, contentTypeHeader);
// authentication (petstore_auth) required
// oauth required
if (configuration.accessToken) {
fetchOptions.headers = Object.assign({
'Authorization': 'Bearer ' + configuration.accessToken,
}, contentTypeHeader);
}
return { return {
url: url.format(urlObj), url: url.format(urlObj),
options: fetchOptions, options: fetchOptions,
@ -156,7 +205,11 @@ export const PetApiFetchParamCreactor = {
* Multiple status values can be provided with comma separated strings * Multiple status values can be provided with comma separated strings
* @param status Status values that need to be considered for filter * @param status Status values that need to be considered for filter
*/ */
findPetsByStatus(params: { status?: Array<string>; }): FetchArgs { findPetsByStatus(params: { status: Array<string>; }, configuration: Configuration): FetchArgs {
// verify required parameter "status" is set
if (params["status"] == null) {
throw new Error("Missing required parameter status when calling findPetsByStatus");
}
const baseUrl = `/pet/findByStatus`; const baseUrl = `/pet/findByStatus`;
let urlObj = url.parse(baseUrl, true); let urlObj = url.parse(baseUrl, true);
urlObj.query = Object.assign({}, urlObj.query, { urlObj.query = Object.assign({}, urlObj.query, {
@ -168,6 +221,14 @@ export const PetApiFetchParamCreactor = {
if (contentTypeHeader) { if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader; fetchOptions.headers = contentTypeHeader;
} }
// authentication (petstore_auth) required
// oauth required
if (configuration.accessToken) {
fetchOptions.headers = Object.assign({
'Authorization': 'Bearer ' + configuration.accessToken,
}, contentTypeHeader);
}
return { return {
url: url.format(urlObj), url: url.format(urlObj),
options: fetchOptions, options: fetchOptions,
@ -178,7 +239,11 @@ export const PetApiFetchParamCreactor = {
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
* @param tags Tags to filter by * @param tags Tags to filter by
*/ */
findPetsByTags(params: { tags?: Array<string>; }): FetchArgs { findPetsByTags(params: { tags: Array<string>; }, configuration: Configuration): FetchArgs {
// verify required parameter "tags" is set
if (params["tags"] == null) {
throw new Error("Missing required parameter tags when calling findPetsByTags");
}
const baseUrl = `/pet/findByTags`; const baseUrl = `/pet/findByTags`;
let urlObj = url.parse(baseUrl, true); let urlObj = url.parse(baseUrl, true);
urlObj.query = Object.assign({}, urlObj.query, { urlObj.query = Object.assign({}, urlObj.query, {
@ -190,6 +255,14 @@ export const PetApiFetchParamCreactor = {
if (contentTypeHeader) { if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader; fetchOptions.headers = contentTypeHeader;
} }
// authentication (petstore_auth) required
// oauth required
if (configuration.accessToken) {
fetchOptions.headers = Object.assign({
'Authorization': 'Bearer ' + configuration.accessToken,
}, contentTypeHeader);
}
return { return {
url: url.format(urlObj), url: url.format(urlObj),
options: fetchOptions, options: fetchOptions,
@ -197,10 +270,10 @@ export const PetApiFetchParamCreactor = {
}, },
/** /**
* Find pet by ID * Find pet by ID
* Returns a pet when ID &lt; 10. ID &gt; 10 or nonintegers will simulate API error conditions * Returns a single pet
* @param petId ID of pet that needs to be fetched * @param petId ID of pet to return
*/ */
getPetById(params: { petId: number; }): FetchArgs { getPetById(params: { petId: number; }, configuration: Configuration): FetchArgs {
// verify required parameter "petId" is set // verify required parameter "petId" is set
if (params["petId"] == null) { if (params["petId"] == null) {
throw new Error("Missing required parameter petId when calling getPetById"); throw new Error("Missing required parameter petId when calling getPetById");
@ -214,6 +287,13 @@ export const PetApiFetchParamCreactor = {
if (contentTypeHeader) { if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader; fetchOptions.headers = contentTypeHeader;
} }
// authentication (api_key) required
if (configuration.apiKey && configuration.apiKey.api_key) {
fetchOptions.headers = Object.assign({
'api_key': configuration.apiKey.api_key,
}, contentTypeHeader);
}
return { return {
url: url.format(urlObj), url: url.format(urlObj),
options: fetchOptions, options: fetchOptions,
@ -224,7 +304,11 @@ export const PetApiFetchParamCreactor = {
* *
* @param body Pet object that needs to be added to the store * @param body Pet object that needs to be added to the store
*/ */
updatePet(params: { body?: Pet; }): FetchArgs { updatePet(params: { body: Pet; }, configuration: Configuration): FetchArgs {
// verify required parameter "body" is set
if (params["body"] == null) {
throw new Error("Missing required parameter body when calling updatePet");
}
const baseUrl = `/pet`; const baseUrl = `/pet`;
let urlObj = url.parse(baseUrl, true); let urlObj = url.parse(baseUrl, true);
let fetchOptions: RequestInit = { method: "PUT" }; let fetchOptions: RequestInit = { method: "PUT" };
@ -237,6 +321,14 @@ export const PetApiFetchParamCreactor = {
if (contentTypeHeader) { if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader; fetchOptions.headers = contentTypeHeader;
} }
// authentication (petstore_auth) required
// oauth required
if (configuration.accessToken) {
fetchOptions.headers = Object.assign({
'Authorization': 'Bearer ' + configuration.accessToken,
}, contentTypeHeader);
}
return { return {
url: url.format(urlObj), url: url.format(urlObj),
options: fetchOptions, options: fetchOptions,
@ -249,7 +341,7 @@ export const PetApiFetchParamCreactor = {
* @param name Updated name of the pet * @param name Updated name of the pet
* @param status Updated status of the pet * @param status Updated status of the pet
*/ */
updatePetWithForm(params: { petId: string; name?: string; status?: string; }): FetchArgs { updatePetWithForm(params: { petId: number; name?: string; status?: string; }, configuration: Configuration): FetchArgs {
// verify required parameter "petId" is set // verify required parameter "petId" is set
if (params["petId"] == null) { if (params["petId"] == null) {
throw new Error("Missing required parameter petId when calling updatePetWithForm"); throw new Error("Missing required parameter petId when calling updatePetWithForm");
@ -268,6 +360,14 @@ export const PetApiFetchParamCreactor = {
if (contentTypeHeader) { if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader; fetchOptions.headers = contentTypeHeader;
} }
// authentication (petstore_auth) required
// oauth required
if (configuration.accessToken) {
fetchOptions.headers = Object.assign({
'Authorization': 'Bearer ' + configuration.accessToken,
}, contentTypeHeader);
}
return { return {
url: url.format(urlObj), url: url.format(urlObj),
options: fetchOptions, options: fetchOptions,
@ -280,7 +380,7 @@ export const PetApiFetchParamCreactor = {
* @param additionalMetadata Additional data to pass to server * @param additionalMetadata Additional data to pass to server
* @param file file to upload * @param file file to upload
*/ */
uploadFile(params: { petId: number; additionalMetadata?: string; file?: any; }): FetchArgs { uploadFile(params: { petId: number; additionalMetadata?: string; file?: any; }, configuration: Configuration): FetchArgs {
// verify required parameter "petId" is set // verify required parameter "petId" is set
if (params["petId"] == null) { if (params["petId"] == null) {
throw new Error("Missing required parameter petId when calling uploadFile"); throw new Error("Missing required parameter petId when calling uploadFile");
@ -299,6 +399,14 @@ export const PetApiFetchParamCreactor = {
if (contentTypeHeader) { if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader; fetchOptions.headers = contentTypeHeader;
} }
// authentication (petstore_auth) required
// oauth required
if (configuration.accessToken) {
fetchOptions.headers = Object.assign({
'Authorization': 'Bearer ' + configuration.accessToken,
}, contentTypeHeader);
}
return { return {
url: url.format(urlObj), url: url.format(urlObj),
options: fetchOptions, options: fetchOptions,
@ -315,8 +423,8 @@ export const PetApiFp = {
* *
* @param body Pet object that needs to be added to the store * @param body Pet object that needs to be added to the store
*/ */
addPet(params: { body?: Pet; }): (fetch: FetchAPI, basePath?: string) => Promise<any> { addPet(params: { body: Pet; }, configuration: Configuration): (fetch: FetchAPI, basePath?: string) => Promise<any> {
const fetchArgs = PetApiFetchParamCreactor.addPet(params); const fetchArgs = PetApiFetchParamCreactor.addPet(params, configuration);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
if (response.status >= 200 && response.status < 300) { if (response.status >= 200 && response.status < 300) {
@ -333,8 +441,8 @@ export const PetApiFp = {
* @param petId Pet id to delete * @param petId Pet id to delete
* @param apiKey * @param apiKey
*/ */
deletePet(params: { petId: number; apiKey?: string; }): (fetch: FetchAPI, basePath?: string) => Promise<any> { deletePet(params: { petId: number; apiKey?: string; }, configuration: Configuration): (fetch: FetchAPI, basePath?: string) => Promise<any> {
const fetchArgs = PetApiFetchParamCreactor.deletePet(params); const fetchArgs = PetApiFetchParamCreactor.deletePet(params, configuration);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
if (response.status >= 200 && response.status < 300) { if (response.status >= 200 && response.status < 300) {
@ -350,8 +458,8 @@ export const PetApiFp = {
* Multiple status values can be provided with comma separated strings * Multiple status values can be provided with comma separated strings
* @param status Status values that need to be considered for filter * @param status Status values that need to be considered for filter
*/ */
findPetsByStatus(params: { status?: Array<string>; }): (fetch: FetchAPI, basePath?: string) => Promise<Array<Pet>> { findPetsByStatus(params: { status: Array<string>; }, configuration: Configuration): (fetch: FetchAPI, basePath?: string) => Promise<Array<Pet>> {
const fetchArgs = PetApiFetchParamCreactor.findPetsByStatus(params); const fetchArgs = PetApiFetchParamCreactor.findPetsByStatus(params, configuration);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
if (response.status >= 200 && response.status < 300) { if (response.status >= 200 && response.status < 300) {
@ -367,8 +475,8 @@ export const PetApiFp = {
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
* @param tags Tags to filter by * @param tags Tags to filter by
*/ */
findPetsByTags(params: { tags?: Array<string>; }): (fetch: FetchAPI, basePath?: string) => Promise<Array<Pet>> { findPetsByTags(params: { tags: Array<string>; }, configuration: Configuration): (fetch: FetchAPI, basePath?: string) => Promise<Array<Pet>> {
const fetchArgs = PetApiFetchParamCreactor.findPetsByTags(params); const fetchArgs = PetApiFetchParamCreactor.findPetsByTags(params, configuration);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
if (response.status >= 200 && response.status < 300) { if (response.status >= 200 && response.status < 300) {
@ -381,11 +489,11 @@ export const PetApiFp = {
}, },
/** /**
* Find pet by ID * Find pet by ID
* Returns a pet when ID &lt; 10. ID &gt; 10 or nonintegers will simulate API error conditions * Returns a single pet
* @param petId ID of pet that needs to be fetched * @param petId ID of pet to return
*/ */
getPetById(params: { petId: number; }): (fetch: FetchAPI, basePath?: string) => Promise<Pet> { getPetById(params: { petId: number; }, configuration: Configuration): (fetch: FetchAPI, basePath?: string) => Promise<Pet> {
const fetchArgs = PetApiFetchParamCreactor.getPetById(params); const fetchArgs = PetApiFetchParamCreactor.getPetById(params, configuration);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
if (response.status >= 200 && response.status < 300) { if (response.status >= 200 && response.status < 300) {
@ -401,8 +509,8 @@ export const PetApiFp = {
* *
* @param body Pet object that needs to be added to the store * @param body Pet object that needs to be added to the store
*/ */
updatePet(params: { body?: Pet; }): (fetch: FetchAPI, basePath?: string) => Promise<any> { updatePet(params: { body: Pet; }, configuration: Configuration): (fetch: FetchAPI, basePath?: string) => Promise<any> {
const fetchArgs = PetApiFetchParamCreactor.updatePet(params); const fetchArgs = PetApiFetchParamCreactor.updatePet(params, configuration);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
if (response.status >= 200 && response.status < 300) { if (response.status >= 200 && response.status < 300) {
@ -420,8 +528,8 @@ export const PetApiFp = {
* @param name Updated name of the pet * @param name Updated name of the pet
* @param status Updated status of the pet * @param status Updated status of the pet
*/ */
updatePetWithForm(params: { petId: string; name?: string; status?: string; }): (fetch: FetchAPI, basePath?: string) => Promise<any> { updatePetWithForm(params: { petId: number; name?: string; status?: string; }, configuration: Configuration): (fetch: FetchAPI, basePath?: string) => Promise<any> {
const fetchArgs = PetApiFetchParamCreactor.updatePetWithForm(params); const fetchArgs = PetApiFetchParamCreactor.updatePetWithForm(params, configuration);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
if (response.status >= 200 && response.status < 300) { if (response.status >= 200 && response.status < 300) {
@ -439,12 +547,12 @@ export const PetApiFp = {
* @param additionalMetadata Additional data to pass to server * @param additionalMetadata Additional data to pass to server
* @param file file to upload * @param file file to upload
*/ */
uploadFile(params: { petId: number; additionalMetadata?: string; file?: any; }): (fetch: FetchAPI, basePath?: string) => Promise<any> { uploadFile(params: { petId: number; additionalMetadata?: string; file?: any; }, configuration: Configuration): (fetch: FetchAPI, basePath?: string) => Promise<ApiResponse> {
const fetchArgs = PetApiFetchParamCreactor.uploadFile(params); const fetchArgs = PetApiFetchParamCreactor.uploadFile(params, configuration);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
if (response.status >= 200 && response.status < 300) { if (response.status >= 200 && response.status < 300) {
return response; return response.json();
} else { } else {
throw response; throw response;
} }
@ -462,8 +570,8 @@ export class PetApi extends BaseAPI {
* *
* @param body Pet object that needs to be added to the store * @param body Pet object that needs to be added to the store
*/ */
addPet(params: { body?: Pet; }) { addPet(params: { body: Pet; }) {
return PetApiFp.addPet(params)(this.fetch, this.basePath); return PetApiFp.addPet(params, this.configuration)(this.fetch, this.basePath);
} }
/** /**
* Deletes a pet * Deletes a pet
@ -472,39 +580,39 @@ export class PetApi extends BaseAPI {
* @param apiKey * @param apiKey
*/ */
deletePet(params: { petId: number; apiKey?: string; }) { deletePet(params: { petId: number; apiKey?: string; }) {
return PetApiFp.deletePet(params)(this.fetch, this.basePath); return PetApiFp.deletePet(params, this.configuration)(this.fetch, this.basePath);
} }
/** /**
* Finds Pets by status * Finds Pets by status
* Multiple status values can be provided with comma separated strings * Multiple status values can be provided with comma separated strings
* @param status Status values that need to be considered for filter * @param status Status values that need to be considered for filter
*/ */
findPetsByStatus(params: { status?: Array<string>; }) { findPetsByStatus(params: { status: Array<string>; }) {
return PetApiFp.findPetsByStatus(params)(this.fetch, this.basePath); return PetApiFp.findPetsByStatus(params, this.configuration)(this.fetch, this.basePath);
} }
/** /**
* Finds Pets by tags * Finds Pets by tags
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
* @param tags Tags to filter by * @param tags Tags to filter by
*/ */
findPetsByTags(params: { tags?: Array<string>; }) { findPetsByTags(params: { tags: Array<string>; }) {
return PetApiFp.findPetsByTags(params)(this.fetch, this.basePath); return PetApiFp.findPetsByTags(params, this.configuration)(this.fetch, this.basePath);
} }
/** /**
* Find pet by ID * Find pet by ID
* Returns a pet when ID &lt; 10. ID &gt; 10 or nonintegers will simulate API error conditions * Returns a single pet
* @param petId ID of pet that needs to be fetched * @param petId ID of pet to return
*/ */
getPetById(params: { petId: number; }) { getPetById(params: { petId: number; }) {
return PetApiFp.getPetById(params)(this.fetch, this.basePath); return PetApiFp.getPetById(params, this.configuration)(this.fetch, this.basePath);
} }
/** /**
* Update an existing pet * Update an existing pet
* *
* @param body Pet object that needs to be added to the store * @param body Pet object that needs to be added to the store
*/ */
updatePet(params: { body?: Pet; }) { updatePet(params: { body: Pet; }) {
return PetApiFp.updatePet(params)(this.fetch, this.basePath); return PetApiFp.updatePet(params, this.configuration)(this.fetch, this.basePath);
} }
/** /**
* Updates a pet in the store with form data * Updates a pet in the store with form data
@ -513,8 +621,8 @@ export class PetApi extends BaseAPI {
* @param name Updated name of the pet * @param name Updated name of the pet
* @param status Updated status of the pet * @param status Updated status of the pet
*/ */
updatePetWithForm(params: { petId: string; name?: string; status?: string; }) { updatePetWithForm(params: { petId: number; name?: string; status?: string; }) {
return PetApiFp.updatePetWithForm(params)(this.fetch, this.basePath); return PetApiFp.updatePetWithForm(params, this.configuration)(this.fetch, this.basePath);
} }
/** /**
* uploads an image * uploads an image
@ -524,7 +632,7 @@ export class PetApi extends BaseAPI {
* @param file file to upload * @param file file to upload
*/ */
uploadFile(params: { petId: number; additionalMetadata?: string; file?: any; }) { uploadFile(params: { petId: number; additionalMetadata?: string; file?: any; }) {
return PetApiFp.uploadFile(params)(this.fetch, this.basePath); return PetApiFp.uploadFile(params, this.configuration)(this.fetch, this.basePath);
} }
}; };
@ -538,8 +646,8 @@ export const PetApiFactory = function (fetch?: FetchAPI, basePath?: string) {
* *
* @param body Pet object that needs to be added to the store * @param body Pet object that needs to be added to the store
*/ */
addPet(params: { body?: Pet; }) { addPet(params: { body: Pet; }, configuration: Configuration) {
return PetApiFp.addPet(params)(fetch, basePath); return PetApiFp.addPet(params, configuration)(fetch, basePath);
}, },
/** /**
* Deletes a pet * Deletes a pet
@ -547,40 +655,40 @@ export const PetApiFactory = function (fetch?: FetchAPI, basePath?: string) {
* @param petId Pet id to delete * @param petId Pet id to delete
* @param apiKey * @param apiKey
*/ */
deletePet(params: { petId: number; apiKey?: string; }) { deletePet(params: { petId: number; apiKey?: string; }, configuration: Configuration) {
return PetApiFp.deletePet(params)(fetch, basePath); return PetApiFp.deletePet(params, configuration)(fetch, basePath);
}, },
/** /**
* Finds Pets by status * Finds Pets by status
* Multiple status values can be provided with comma separated strings * Multiple status values can be provided with comma separated strings
* @param status Status values that need to be considered for filter * @param status Status values that need to be considered for filter
*/ */
findPetsByStatus(params: { status?: Array<string>; }) { findPetsByStatus(params: { status: Array<string>; }, configuration: Configuration) {
return PetApiFp.findPetsByStatus(params)(fetch, basePath); return PetApiFp.findPetsByStatus(params, configuration)(fetch, basePath);
}, },
/** /**
* Finds Pets by tags * Finds Pets by tags
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
* @param tags Tags to filter by * @param tags Tags to filter by
*/ */
findPetsByTags(params: { tags?: Array<string>; }) { findPetsByTags(params: { tags: Array<string>; }, configuration: Configuration) {
return PetApiFp.findPetsByTags(params)(fetch, basePath); return PetApiFp.findPetsByTags(params, configuration)(fetch, basePath);
}, },
/** /**
* Find pet by ID * Find pet by ID
* Returns a pet when ID &lt; 10. ID &gt; 10 or nonintegers will simulate API error conditions * Returns a single pet
* @param petId ID of pet that needs to be fetched * @param petId ID of pet to return
*/ */
getPetById(params: { petId: number; }) { getPetById(params: { petId: number; }, configuration: Configuration) {
return PetApiFp.getPetById(params)(fetch, basePath); return PetApiFp.getPetById(params, configuration)(fetch, basePath);
}, },
/** /**
* Update an existing pet * Update an existing pet
* *
* @param body Pet object that needs to be added to the store * @param body Pet object that needs to be added to the store
*/ */
updatePet(params: { body?: Pet; }) { updatePet(params: { body: Pet; }, configuration: Configuration) {
return PetApiFp.updatePet(params)(fetch, basePath); return PetApiFp.updatePet(params, configuration)(fetch, basePath);
}, },
/** /**
* Updates a pet in the store with form data * Updates a pet in the store with form data
@ -589,8 +697,8 @@ export const PetApiFactory = function (fetch?: FetchAPI, basePath?: string) {
* @param name Updated name of the pet * @param name Updated name of the pet
* @param status Updated status of the pet * @param status Updated status of the pet
*/ */
updatePetWithForm(params: { petId: string; name?: string; status?: string; }) { updatePetWithForm(params: { petId: number; name?: string; status?: string; }, configuration: Configuration) {
return PetApiFp.updatePetWithForm(params)(fetch, basePath); return PetApiFp.updatePetWithForm(params, configuration)(fetch, basePath);
}, },
/** /**
* uploads an image * uploads an image
@ -599,8 +707,8 @@ export const PetApiFactory = function (fetch?: FetchAPI, basePath?: string) {
* @param additionalMetadata Additional data to pass to server * @param additionalMetadata Additional data to pass to server
* @param file file to upload * @param file file to upload
*/ */
uploadFile(params: { petId: number; additionalMetadata?: string; file?: any; }) { uploadFile(params: { petId: number; additionalMetadata?: string; file?: any; }, configuration: Configuration) {
return PetApiFp.uploadFile(params)(fetch, basePath); return PetApiFp.uploadFile(params, configuration)(fetch, basePath);
}, },
} }
}; };
@ -629,6 +737,7 @@ export const StoreApiFetchParamCreactor = {
if (contentTypeHeader) { if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader; fetchOptions.headers = contentTypeHeader;
} }
return { return {
url: url.format(urlObj), url: url.format(urlObj),
options: fetchOptions, options: fetchOptions,
@ -638,7 +747,7 @@ export const StoreApiFetchParamCreactor = {
* Returns pet inventories by status * Returns pet inventories by status
* Returns a map of status codes to quantities * Returns a map of status codes to quantities
*/ */
getInventory(): FetchArgs { getInventory(configuration: Configuration): FetchArgs {
const baseUrl = `/store/inventory`; const baseUrl = `/store/inventory`;
let urlObj = url.parse(baseUrl, true); let urlObj = url.parse(baseUrl, true);
let fetchOptions: RequestInit = { method: "GET" }; let fetchOptions: RequestInit = { method: "GET" };
@ -647,6 +756,13 @@ export const StoreApiFetchParamCreactor = {
if (contentTypeHeader) { if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader; fetchOptions.headers = contentTypeHeader;
} }
// authentication (api_key) required
if (configuration.apiKey && configuration.apiKey.api_key) {
fetchOptions.headers = Object.assign({
'api_key': configuration.apiKey.api_key,
}, contentTypeHeader);
}
return { return {
url: url.format(urlObj), url: url.format(urlObj),
options: fetchOptions, options: fetchOptions,
@ -657,7 +773,7 @@ export const StoreApiFetchParamCreactor = {
* For valid response try integer IDs with value &lt;&#x3D; 5 or &gt; 10. Other values will generated exceptions * For valid response try integer IDs with value &lt;&#x3D; 5 or &gt; 10. Other values will generated exceptions
* @param orderId ID of pet that needs to be fetched * @param orderId ID of pet that needs to be fetched
*/ */
getOrderById(params: { orderId: string; }): FetchArgs { getOrderById(params: { orderId: number; }): FetchArgs {
// verify required parameter "orderId" is set // verify required parameter "orderId" is set
if (params["orderId"] == null) { if (params["orderId"] == null) {
throw new Error("Missing required parameter orderId when calling getOrderById"); throw new Error("Missing required parameter orderId when calling getOrderById");
@ -671,6 +787,7 @@ export const StoreApiFetchParamCreactor = {
if (contentTypeHeader) { if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader; fetchOptions.headers = contentTypeHeader;
} }
return { return {
url: url.format(urlObj), url: url.format(urlObj),
options: fetchOptions, options: fetchOptions,
@ -681,7 +798,11 @@ export const StoreApiFetchParamCreactor = {
* *
* @param body order placed for purchasing the pet * @param body order placed for purchasing the pet
*/ */
placeOrder(params: { body?: Order; }): FetchArgs { placeOrder(params: { body: Order; }): FetchArgs {
// verify required parameter "body" is set
if (params["body"] == null) {
throw new Error("Missing required parameter body when calling placeOrder");
}
const baseUrl = `/store/order`; const baseUrl = `/store/order`;
let urlObj = url.parse(baseUrl, true); let urlObj = url.parse(baseUrl, true);
let fetchOptions: RequestInit = { method: "POST" }; let fetchOptions: RequestInit = { method: "POST" };
@ -694,6 +815,7 @@ export const StoreApiFetchParamCreactor = {
if (contentTypeHeader) { if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader; fetchOptions.headers = contentTypeHeader;
} }
return { return {
url: url.format(urlObj), url: url.format(urlObj),
options: fetchOptions, options: fetchOptions,
@ -726,8 +848,8 @@ export const StoreApiFp = {
* Returns pet inventories by status * Returns pet inventories by status
* Returns a map of status codes to quantities * Returns a map of status codes to quantities
*/ */
getInventory(): (fetch: FetchAPI, basePath?: string) => Promise<{ [key: string]: number; }> { getInventory(configuration: Configuration): (fetch: FetchAPI, basePath?: string) => Promise<{ [key: string]: number; }> {
const fetchArgs = StoreApiFetchParamCreactor.getInventory(); const fetchArgs = StoreApiFetchParamCreactor.getInventory(configuration);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
if (response.status >= 200 && response.status < 300) { if (response.status >= 200 && response.status < 300) {
@ -743,7 +865,7 @@ export const StoreApiFp = {
* For valid response try integer IDs with value &lt;&#x3D; 5 or &gt; 10. Other values will generated exceptions * For valid response try integer IDs with value &lt;&#x3D; 5 or &gt; 10. Other values will generated exceptions
* @param orderId ID of pet that needs to be fetched * @param orderId ID of pet that needs to be fetched
*/ */
getOrderById(params: { orderId: string; }): (fetch: FetchAPI, basePath?: string) => Promise<Order> { getOrderById(params: { orderId: number; }): (fetch: FetchAPI, basePath?: string) => Promise<Order> {
const fetchArgs = StoreApiFetchParamCreactor.getOrderById(params); const fetchArgs = StoreApiFetchParamCreactor.getOrderById(params);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
@ -760,7 +882,7 @@ export const StoreApiFp = {
* *
* @param body order placed for purchasing the pet * @param body order placed for purchasing the pet
*/ */
placeOrder(params: { body?: Order; }): (fetch: FetchAPI, basePath?: string) => Promise<Order> { placeOrder(params: { body: Order; }): (fetch: FetchAPI, basePath?: string) => Promise<Order> {
const fetchArgs = StoreApiFetchParamCreactor.placeOrder(params); const fetchArgs = StoreApiFetchParamCreactor.placeOrder(params);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
@ -791,14 +913,14 @@ export class StoreApi extends BaseAPI {
* Returns a map of status codes to quantities * Returns a map of status codes to quantities
*/ */
getInventory() { getInventory() {
return StoreApiFp.getInventory()(this.fetch, this.basePath); return StoreApiFp.getInventory(this.configuration)(this.fetch, this.basePath);
} }
/** /**
* Find purchase order by ID * Find purchase order by ID
* For valid response try integer IDs with value &lt;&#x3D; 5 or &gt; 10. Other values will generated exceptions * For valid response try integer IDs with value &lt;&#x3D; 5 or &gt; 10. Other values will generated exceptions
* @param orderId ID of pet that needs to be fetched * @param orderId ID of pet that needs to be fetched
*/ */
getOrderById(params: { orderId: string; }) { getOrderById(params: { orderId: number; }) {
return StoreApiFp.getOrderById(params)(this.fetch, this.basePath); return StoreApiFp.getOrderById(params)(this.fetch, this.basePath);
} }
/** /**
@ -806,7 +928,7 @@ export class StoreApi extends BaseAPI {
* *
* @param body order placed for purchasing the pet * @param body order placed for purchasing the pet
*/ */
placeOrder(params: { body?: Order; }) { placeOrder(params: { body: Order; }) {
return StoreApiFp.placeOrder(params)(this.fetch, this.basePath); return StoreApiFp.placeOrder(params)(this.fetch, this.basePath);
} }
}; };
@ -828,15 +950,15 @@ export const StoreApiFactory = function (fetch?: FetchAPI, basePath?: string) {
* Returns pet inventories by status * Returns pet inventories by status
* Returns a map of status codes to quantities * Returns a map of status codes to quantities
*/ */
getInventory() { getInventory(configuration: Configuration) {
return StoreApiFp.getInventory()(fetch, basePath); return StoreApiFp.getInventory(configuration)(fetch, basePath);
}, },
/** /**
* Find purchase order by ID * Find purchase order by ID
* For valid response try integer IDs with value &lt;&#x3D; 5 or &gt; 10. Other values will generated exceptions * For valid response try integer IDs with value &lt;&#x3D; 5 or &gt; 10. Other values will generated exceptions
* @param orderId ID of pet that needs to be fetched * @param orderId ID of pet that needs to be fetched
*/ */
getOrderById(params: { orderId: string; }) { getOrderById(params: { orderId: number; }) {
return StoreApiFp.getOrderById(params)(fetch, basePath); return StoreApiFp.getOrderById(params)(fetch, basePath);
}, },
/** /**
@ -844,7 +966,7 @@ export const StoreApiFactory = function (fetch?: FetchAPI, basePath?: string) {
* *
* @param body order placed for purchasing the pet * @param body order placed for purchasing the pet
*/ */
placeOrder(params: { body?: Order; }) { placeOrder(params: { body: Order; }) {
return StoreApiFp.placeOrder(params)(fetch, basePath); return StoreApiFp.placeOrder(params)(fetch, basePath);
}, },
} }
@ -860,7 +982,11 @@ export const UserApiFetchParamCreactor = {
* This can only be done by the logged in user. * This can only be done by the logged in user.
* @param body Created user object * @param body Created user object
*/ */
createUser(params: { body?: User; }): FetchArgs { createUser(params: { body: User; }): FetchArgs {
// verify required parameter "body" is set
if (params["body"] == null) {
throw new Error("Missing required parameter body when calling createUser");
}
const baseUrl = `/user`; const baseUrl = `/user`;
let urlObj = url.parse(baseUrl, true); let urlObj = url.parse(baseUrl, true);
let fetchOptions: RequestInit = { method: "POST" }; let fetchOptions: RequestInit = { method: "POST" };
@ -873,6 +999,7 @@ export const UserApiFetchParamCreactor = {
if (contentTypeHeader) { if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader; fetchOptions.headers = contentTypeHeader;
} }
return { return {
url: url.format(urlObj), url: url.format(urlObj),
options: fetchOptions, options: fetchOptions,
@ -883,7 +1010,11 @@ export const UserApiFetchParamCreactor = {
* *
* @param body List of user object * @param body List of user object
*/ */
createUsersWithArrayInput(params: { body?: Array<User>; }): FetchArgs { createUsersWithArrayInput(params: { body: Array<User>; }): FetchArgs {
// verify required parameter "body" is set
if (params["body"] == null) {
throw new Error("Missing required parameter body when calling createUsersWithArrayInput");
}
const baseUrl = `/user/createWithArray`; const baseUrl = `/user/createWithArray`;
let urlObj = url.parse(baseUrl, true); let urlObj = url.parse(baseUrl, true);
let fetchOptions: RequestInit = { method: "POST" }; let fetchOptions: RequestInit = { method: "POST" };
@ -896,6 +1027,7 @@ export const UserApiFetchParamCreactor = {
if (contentTypeHeader) { if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader; fetchOptions.headers = contentTypeHeader;
} }
return { return {
url: url.format(urlObj), url: url.format(urlObj),
options: fetchOptions, options: fetchOptions,
@ -906,7 +1038,11 @@ export const UserApiFetchParamCreactor = {
* *
* @param body List of user object * @param body List of user object
*/ */
createUsersWithListInput(params: { body?: Array<User>; }): FetchArgs { createUsersWithListInput(params: { body: Array<User>; }): FetchArgs {
// verify required parameter "body" is set
if (params["body"] == null) {
throw new Error("Missing required parameter body when calling createUsersWithListInput");
}
const baseUrl = `/user/createWithList`; const baseUrl = `/user/createWithList`;
let urlObj = url.parse(baseUrl, true); let urlObj = url.parse(baseUrl, true);
let fetchOptions: RequestInit = { method: "POST" }; let fetchOptions: RequestInit = { method: "POST" };
@ -919,6 +1055,7 @@ export const UserApiFetchParamCreactor = {
if (contentTypeHeader) { if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader; fetchOptions.headers = contentTypeHeader;
} }
return { return {
url: url.format(urlObj), url: url.format(urlObj),
options: fetchOptions, options: fetchOptions,
@ -943,6 +1080,7 @@ export const UserApiFetchParamCreactor = {
if (contentTypeHeader) { if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader; fetchOptions.headers = contentTypeHeader;
} }
return { return {
url: url.format(urlObj), url: url.format(urlObj),
options: fetchOptions, options: fetchOptions,
@ -967,6 +1105,7 @@ export const UserApiFetchParamCreactor = {
if (contentTypeHeader) { if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader; fetchOptions.headers = contentTypeHeader;
} }
return { return {
url: url.format(urlObj), url: url.format(urlObj),
options: fetchOptions, options: fetchOptions,
@ -978,7 +1117,15 @@ export const UserApiFetchParamCreactor = {
* @param username The user name for login * @param username The user name for login
* @param password The password for login in clear text * @param password The password for login in clear text
*/ */
loginUser(params: { username?: string; password?: string; }): FetchArgs { loginUser(params: { username: string; password: string; }): FetchArgs {
// verify required parameter "username" is set
if (params["username"] == null) {
throw new Error("Missing required parameter username when calling loginUser");
}
// verify required parameter "password" is set
if (params["password"] == null) {
throw new Error("Missing required parameter password when calling loginUser");
}
const baseUrl = `/user/login`; const baseUrl = `/user/login`;
let urlObj = url.parse(baseUrl, true); let urlObj = url.parse(baseUrl, true);
urlObj.query = Object.assign({}, urlObj.query, { urlObj.query = Object.assign({}, urlObj.query, {
@ -991,6 +1138,7 @@ export const UserApiFetchParamCreactor = {
if (contentTypeHeader) { if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader; fetchOptions.headers = contentTypeHeader;
} }
return { return {
url: url.format(urlObj), url: url.format(urlObj),
options: fetchOptions, options: fetchOptions,
@ -1009,6 +1157,7 @@ export const UserApiFetchParamCreactor = {
if (contentTypeHeader) { if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader; fetchOptions.headers = contentTypeHeader;
} }
return { return {
url: url.format(urlObj), url: url.format(urlObj),
options: fetchOptions, options: fetchOptions,
@ -1020,11 +1169,15 @@ export const UserApiFetchParamCreactor = {
* @param username name that need to be deleted * @param username name that need to be deleted
* @param body Updated user object * @param body Updated user object
*/ */
updateUser(params: { username: string; body?: User; }): FetchArgs { updateUser(params: { username: string; body: User; }): FetchArgs {
// verify required parameter "username" is set // verify required parameter "username" is set
if (params["username"] == null) { if (params["username"] == null) {
throw new Error("Missing required parameter username when calling updateUser"); throw new Error("Missing required parameter username when calling updateUser");
} }
// verify required parameter "body" is set
if (params["body"] == null) {
throw new Error("Missing required parameter body when calling updateUser");
}
const baseUrl = `/user/{username}` const baseUrl = `/user/{username}`
.replace(`{${"username"}}`, `${ params.username }`); .replace(`{${"username"}}`, `${ params.username }`);
let urlObj = url.parse(baseUrl, true); let urlObj = url.parse(baseUrl, true);
@ -1038,6 +1191,7 @@ export const UserApiFetchParamCreactor = {
if (contentTypeHeader) { if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader; fetchOptions.headers = contentTypeHeader;
} }
return { return {
url: url.format(urlObj), url: url.format(urlObj),
options: fetchOptions, options: fetchOptions,
@ -1054,7 +1208,7 @@ export const UserApiFp = {
* This can only be done by the logged in user. * This can only be done by the logged in user.
* @param body Created user object * @param body Created user object
*/ */
createUser(params: { body?: User; }): (fetch: FetchAPI, basePath?: string) => Promise<any> { createUser(params: { body: User; }): (fetch: FetchAPI, basePath?: string) => Promise<any> {
const fetchArgs = UserApiFetchParamCreactor.createUser(params); const fetchArgs = UserApiFetchParamCreactor.createUser(params);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
@ -1071,7 +1225,7 @@ export const UserApiFp = {
* *
* @param body List of user object * @param body List of user object
*/ */
createUsersWithArrayInput(params: { body?: Array<User>; }): (fetch: FetchAPI, basePath?: string) => Promise<any> { createUsersWithArrayInput(params: { body: Array<User>; }): (fetch: FetchAPI, basePath?: string) => Promise<any> {
const fetchArgs = UserApiFetchParamCreactor.createUsersWithArrayInput(params); const fetchArgs = UserApiFetchParamCreactor.createUsersWithArrayInput(params);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
@ -1088,7 +1242,7 @@ export const UserApiFp = {
* *
* @param body List of user object * @param body List of user object
*/ */
createUsersWithListInput(params: { body?: Array<User>; }): (fetch: FetchAPI, basePath?: string) => Promise<any> { createUsersWithListInput(params: { body: Array<User>; }): (fetch: FetchAPI, basePath?: string) => Promise<any> {
const fetchArgs = UserApiFetchParamCreactor.createUsersWithListInput(params); const fetchArgs = UserApiFetchParamCreactor.createUsersWithListInput(params);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
@ -1140,7 +1294,7 @@ export const UserApiFp = {
* @param username The user name for login * @param username The user name for login
* @param password The password for login in clear text * @param password The password for login in clear text
*/ */
loginUser(params: { username?: string; password?: string; }): (fetch: FetchAPI, basePath?: string) => Promise<string> { loginUser(params: { username: string; password: string; }): (fetch: FetchAPI, basePath?: string) => Promise<string> {
const fetchArgs = UserApiFetchParamCreactor.loginUser(params); const fetchArgs = UserApiFetchParamCreactor.loginUser(params);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
@ -1174,7 +1328,7 @@ export const UserApiFp = {
* @param username name that need to be deleted * @param username name that need to be deleted
* @param body Updated user object * @param body Updated user object
*/ */
updateUser(params: { username: string; body?: User; }): (fetch: FetchAPI, basePath?: string) => Promise<any> { updateUser(params: { username: string; body: User; }): (fetch: FetchAPI, basePath?: string) => Promise<any> {
const fetchArgs = UserApiFetchParamCreactor.updateUser(params); const fetchArgs = UserApiFetchParamCreactor.updateUser(params);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
@ -1197,7 +1351,7 @@ export class UserApi extends BaseAPI {
* This can only be done by the logged in user. * This can only be done by the logged in user.
* @param body Created user object * @param body Created user object
*/ */
createUser(params: { body?: User; }) { createUser(params: { body: User; }) {
return UserApiFp.createUser(params)(this.fetch, this.basePath); return UserApiFp.createUser(params)(this.fetch, this.basePath);
} }
/** /**
@ -1205,7 +1359,7 @@ export class UserApi extends BaseAPI {
* *
* @param body List of user object * @param body List of user object
*/ */
createUsersWithArrayInput(params: { body?: Array<User>; }) { createUsersWithArrayInput(params: { body: Array<User>; }) {
return UserApiFp.createUsersWithArrayInput(params)(this.fetch, this.basePath); return UserApiFp.createUsersWithArrayInput(params)(this.fetch, this.basePath);
} }
/** /**
@ -1213,7 +1367,7 @@ export class UserApi extends BaseAPI {
* *
* @param body List of user object * @param body List of user object
*/ */
createUsersWithListInput(params: { body?: Array<User>; }) { createUsersWithListInput(params: { body: Array<User>; }) {
return UserApiFp.createUsersWithListInput(params)(this.fetch, this.basePath); return UserApiFp.createUsersWithListInput(params)(this.fetch, this.basePath);
} }
/** /**
@ -1238,7 +1392,7 @@ export class UserApi extends BaseAPI {
* @param username The user name for login * @param username The user name for login
* @param password The password for login in clear text * @param password The password for login in clear text
*/ */
loginUser(params: { username?: string; password?: string; }) { loginUser(params: { username: string; password: string; }) {
return UserApiFp.loginUser(params)(this.fetch, this.basePath); return UserApiFp.loginUser(params)(this.fetch, this.basePath);
} }
/** /**
@ -1254,7 +1408,7 @@ export class UserApi extends BaseAPI {
* @param username name that need to be deleted * @param username name that need to be deleted
* @param body Updated user object * @param body Updated user object
*/ */
updateUser(params: { username: string; body?: User; }) { updateUser(params: { username: string; body: User; }) {
return UserApiFp.updateUser(params)(this.fetch, this.basePath); return UserApiFp.updateUser(params)(this.fetch, this.basePath);
} }
}; };
@ -1269,7 +1423,7 @@ export const UserApiFactory = function (fetch?: FetchAPI, basePath?: string) {
* This can only be done by the logged in user. * This can only be done by the logged in user.
* @param body Created user object * @param body Created user object
*/ */
createUser(params: { body?: User; }) { createUser(params: { body: User; }) {
return UserApiFp.createUser(params)(fetch, basePath); return UserApiFp.createUser(params)(fetch, basePath);
}, },
/** /**
@ -1277,7 +1431,7 @@ export const UserApiFactory = function (fetch?: FetchAPI, basePath?: string) {
* *
* @param body List of user object * @param body List of user object
*/ */
createUsersWithArrayInput(params: { body?: Array<User>; }) { createUsersWithArrayInput(params: { body: Array<User>; }) {
return UserApiFp.createUsersWithArrayInput(params)(fetch, basePath); return UserApiFp.createUsersWithArrayInput(params)(fetch, basePath);
}, },
/** /**
@ -1285,7 +1439,7 @@ export const UserApiFactory = function (fetch?: FetchAPI, basePath?: string) {
* *
* @param body List of user object * @param body List of user object
*/ */
createUsersWithListInput(params: { body?: Array<User>; }) { createUsersWithListInput(params: { body: Array<User>; }) {
return UserApiFp.createUsersWithListInput(params)(fetch, basePath); return UserApiFp.createUsersWithListInput(params)(fetch, basePath);
}, },
/** /**
@ -1310,7 +1464,7 @@ export const UserApiFactory = function (fetch?: FetchAPI, basePath?: string) {
* @param username The user name for login * @param username The user name for login
* @param password The password for login in clear text * @param password The password for login in clear text
*/ */
loginUser(params: { username?: string; password?: string; }) { loginUser(params: { username: string; password: string; }) {
return UserApiFp.loginUser(params)(fetch, basePath); return UserApiFp.loginUser(params)(fetch, basePath);
}, },
/** /**
@ -1326,7 +1480,7 @@ export const UserApiFactory = function (fetch?: FetchAPI, basePath?: string) {
* @param username name that need to be deleted * @param username name that need to be deleted
* @param body Updated user object * @param body Updated user object
*/ */
updateUser(params: { username: string; body?: User; }) { updateUser(params: { username: string; body: User; }) {
return UserApiFp.updateUser(params)(fetch, basePath); return UserApiFp.updateUser(params)(fetch, basePath);
}, },
} }

View File

@ -0,0 +1,8 @@
export class Configuration {
apiKey: {
api_key: string;
};
username: string;
password: string;
accessToken: string;
}

View File

@ -1,9 +1,9 @@
/** /**
* Swagger Petstore * Swagger Petstore
* This is a sample server Petstore server. You can find out more about Swagger at <a href=\"http://swagger.io\">http://swagger.io</a> 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 * 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. * NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git * https://github.com/swagger-api/swagger-codegen.git
@ -28,6 +28,8 @@ import * as url from "url";
import * as isomorphicFetch from "isomorphic-fetch"; import * as isomorphicFetch from "isomorphic-fetch";
import * as assign from "core-js/library/fn/object/assign"; import * as assign from "core-js/library/fn/object/assign";
import { Configuration } from './configuration';
interface Dictionary<T> { [index: string]: T; } interface Dictionary<T> { [index: string]: T; }
export interface FetchAPI { (url: string, init?: any): Promise<any>; } export interface FetchAPI { (url: string, init?: any): Promise<any>; }
@ -41,18 +43,36 @@ export interface FetchArgs {
export class BaseAPI { export class BaseAPI {
basePath: string; basePath: string;
fetch: FetchAPI; fetch: FetchAPI;
public configuration: Configuration;
constructor(fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) { constructor(fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH, configuration: Configuration = new Configuration()) {
this.basePath = basePath; this.basePath = basePath;
this.fetch = fetch; this.fetch = fetch;
} this.configuration = configuration;
} }
}
/**
* Describes the result of uploading an image resource
*/
export interface ApiResponse {
"code"?: number;
"type"?: string;
"message"?: string;
}
/**
* A category for a pet
*/
export interface Category { export interface Category {
"id"?: number; "id"?: number;
"name"?: string; "name"?: string;
} }
/**
* An order for a pets from the pet store
*/
export interface Order { export interface Order {
"id"?: number; "id"?: number;
"petId"?: number; "petId"?: number;
@ -66,6 +86,9 @@ export interface Order {
} }
export type OrderStatusEnum = "placed" | "approved" | "delivered"; export type OrderStatusEnum = "placed" | "approved" | "delivered";
/**
* A pet for sale in the pet store
*/
export interface Pet { export interface Pet {
"id"?: number; "id"?: number;
"category"?: Category; "category"?: Category;
@ -79,11 +102,17 @@ export interface Pet {
} }
export type PetStatusEnum = "available" | "pending" | "sold"; export type PetStatusEnum = "available" | "pending" | "sold";
/**
* A tag for a pet
*/
export interface Tag { export interface Tag {
"id"?: number; "id"?: number;
"name"?: string; "name"?: string;
} }
/**
* A User who is purchasing from the pet store
*/
export interface User { export interface User {
"id"?: number; "id"?: number;
"username"?: string; "username"?: string;
@ -109,7 +138,11 @@ export const PetApiFetchParamCreactor = {
* *
* @param body Pet object that needs to be added to the store * @param body Pet object that needs to be added to the store
*/ */
addPet(params: { body?: Pet; }): FetchArgs { addPet(params: { body: Pet; }, configuration: Configuration): FetchArgs {
// verify required parameter "body" is set
if (params["body"] == null) {
throw new Error("Missing required parameter body when calling addPet");
}
const baseUrl = `/pet`; const baseUrl = `/pet`;
let urlObj = url.parse(baseUrl, true); let urlObj = url.parse(baseUrl, true);
let fetchOptions: RequestInit = { method: "POST" }; let fetchOptions: RequestInit = { method: "POST" };
@ -122,6 +155,14 @@ export const PetApiFetchParamCreactor = {
if (contentTypeHeader) { if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader; fetchOptions.headers = contentTypeHeader;
} }
// authentication (petstore_auth) required
// oauth required
if (configuration.accessToken) {
fetchOptions.headers = assign({
'Authorization': 'Bearer ' + configuration.accessToken,
}, contentTypeHeader);
}
return { return {
url: url.format(urlObj), url: url.format(urlObj),
options: fetchOptions, options: fetchOptions,
@ -133,7 +174,7 @@ export const PetApiFetchParamCreactor = {
* @param petId Pet id to delete * @param petId Pet id to delete
* @param apiKey * @param apiKey
*/ */
deletePet(params: { petId: number; apiKey?: string; }): FetchArgs { deletePet(params: { petId: number; apiKey?: string; }, configuration: Configuration): FetchArgs {
// verify required parameter "petId" is set // verify required parameter "petId" is set
if (params["petId"] == null) { if (params["petId"] == null) {
throw new Error("Missing required parameter petId when calling deletePet"); throw new Error("Missing required parameter petId when calling deletePet");
@ -147,6 +188,14 @@ export const PetApiFetchParamCreactor = {
fetchOptions.headers = assign({ fetchOptions.headers = assign({
"api_key": params.apiKey, "api_key": params.apiKey,
}, contentTypeHeader); }, contentTypeHeader);
// authentication (petstore_auth) required
// oauth required
if (configuration.accessToken) {
fetchOptions.headers = assign({
'Authorization': 'Bearer ' + configuration.accessToken,
}, contentTypeHeader);
}
return { return {
url: url.format(urlObj), url: url.format(urlObj),
options: fetchOptions, options: fetchOptions,
@ -157,7 +206,11 @@ export const PetApiFetchParamCreactor = {
* Multiple status values can be provided with comma separated strings * Multiple status values can be provided with comma separated strings
* @param status Status values that need to be considered for filter * @param status Status values that need to be considered for filter
*/ */
findPetsByStatus(params: { status?: Array<string>; }): FetchArgs { findPetsByStatus(params: { status: Array<string>; }, configuration: Configuration): FetchArgs {
// verify required parameter "status" is set
if (params["status"] == null) {
throw new Error("Missing required parameter status when calling findPetsByStatus");
}
const baseUrl = `/pet/findByStatus`; const baseUrl = `/pet/findByStatus`;
let urlObj = url.parse(baseUrl, true); let urlObj = url.parse(baseUrl, true);
urlObj.query = assign({}, urlObj.query, { urlObj.query = assign({}, urlObj.query, {
@ -169,6 +222,14 @@ export const PetApiFetchParamCreactor = {
if (contentTypeHeader) { if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader; fetchOptions.headers = contentTypeHeader;
} }
// authentication (petstore_auth) required
// oauth required
if (configuration.accessToken) {
fetchOptions.headers = assign({
'Authorization': 'Bearer ' + configuration.accessToken,
}, contentTypeHeader);
}
return { return {
url: url.format(urlObj), url: url.format(urlObj),
options: fetchOptions, options: fetchOptions,
@ -179,7 +240,11 @@ export const PetApiFetchParamCreactor = {
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
* @param tags Tags to filter by * @param tags Tags to filter by
*/ */
findPetsByTags(params: { tags?: Array<string>; }): FetchArgs { findPetsByTags(params: { tags: Array<string>; }, configuration: Configuration): FetchArgs {
// verify required parameter "tags" is set
if (params["tags"] == null) {
throw new Error("Missing required parameter tags when calling findPetsByTags");
}
const baseUrl = `/pet/findByTags`; const baseUrl = `/pet/findByTags`;
let urlObj = url.parse(baseUrl, true); let urlObj = url.parse(baseUrl, true);
urlObj.query = assign({}, urlObj.query, { urlObj.query = assign({}, urlObj.query, {
@ -191,6 +256,14 @@ export const PetApiFetchParamCreactor = {
if (contentTypeHeader) { if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader; fetchOptions.headers = contentTypeHeader;
} }
// authentication (petstore_auth) required
// oauth required
if (configuration.accessToken) {
fetchOptions.headers = assign({
'Authorization': 'Bearer ' + configuration.accessToken,
}, contentTypeHeader);
}
return { return {
url: url.format(urlObj), url: url.format(urlObj),
options: fetchOptions, options: fetchOptions,
@ -198,10 +271,10 @@ export const PetApiFetchParamCreactor = {
}, },
/** /**
* Find pet by ID * Find pet by ID
* Returns a pet when ID &lt; 10. ID &gt; 10 or nonintegers will simulate API error conditions * Returns a single pet
* @param petId ID of pet that needs to be fetched * @param petId ID of pet to return
*/ */
getPetById(params: { petId: number; }): FetchArgs { getPetById(params: { petId: number; }, configuration: Configuration): FetchArgs {
// verify required parameter "petId" is set // verify required parameter "petId" is set
if (params["petId"] == null) { if (params["petId"] == null) {
throw new Error("Missing required parameter petId when calling getPetById"); throw new Error("Missing required parameter petId when calling getPetById");
@ -215,6 +288,13 @@ export const PetApiFetchParamCreactor = {
if (contentTypeHeader) { if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader; fetchOptions.headers = contentTypeHeader;
} }
// authentication (api_key) required
if (configuration.apiKey && configuration.apiKey.api_key) {
fetchOptions.headers = assign({
'api_key': configuration.apiKey.api_key,
}, contentTypeHeader);
}
return { return {
url: url.format(urlObj), url: url.format(urlObj),
options: fetchOptions, options: fetchOptions,
@ -225,7 +305,11 @@ export const PetApiFetchParamCreactor = {
* *
* @param body Pet object that needs to be added to the store * @param body Pet object that needs to be added to the store
*/ */
updatePet(params: { body?: Pet; }): FetchArgs { updatePet(params: { body: Pet; }, configuration: Configuration): FetchArgs {
// verify required parameter "body" is set
if (params["body"] == null) {
throw new Error("Missing required parameter body when calling updatePet");
}
const baseUrl = `/pet`; const baseUrl = `/pet`;
let urlObj = url.parse(baseUrl, true); let urlObj = url.parse(baseUrl, true);
let fetchOptions: RequestInit = { method: "PUT" }; let fetchOptions: RequestInit = { method: "PUT" };
@ -238,6 +322,14 @@ export const PetApiFetchParamCreactor = {
if (contentTypeHeader) { if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader; fetchOptions.headers = contentTypeHeader;
} }
// authentication (petstore_auth) required
// oauth required
if (configuration.accessToken) {
fetchOptions.headers = assign({
'Authorization': 'Bearer ' + configuration.accessToken,
}, contentTypeHeader);
}
return { return {
url: url.format(urlObj), url: url.format(urlObj),
options: fetchOptions, options: fetchOptions,
@ -250,7 +342,7 @@ export const PetApiFetchParamCreactor = {
* @param name Updated name of the pet * @param name Updated name of the pet
* @param status Updated status of the pet * @param status Updated status of the pet
*/ */
updatePetWithForm(params: { petId: string; name?: string; status?: string; }): FetchArgs { updatePetWithForm(params: { petId: number; name?: string; status?: string; }, configuration: Configuration): FetchArgs {
// verify required parameter "petId" is set // verify required parameter "petId" is set
if (params["petId"] == null) { if (params["petId"] == null) {
throw new Error("Missing required parameter petId when calling updatePetWithForm"); throw new Error("Missing required parameter petId when calling updatePetWithForm");
@ -269,6 +361,14 @@ export const PetApiFetchParamCreactor = {
if (contentTypeHeader) { if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader; fetchOptions.headers = contentTypeHeader;
} }
// authentication (petstore_auth) required
// oauth required
if (configuration.accessToken) {
fetchOptions.headers = assign({
'Authorization': 'Bearer ' + configuration.accessToken,
}, contentTypeHeader);
}
return { return {
url: url.format(urlObj), url: url.format(urlObj),
options: fetchOptions, options: fetchOptions,
@ -281,7 +381,7 @@ export const PetApiFetchParamCreactor = {
* @param additionalMetadata Additional data to pass to server * @param additionalMetadata Additional data to pass to server
* @param file file to upload * @param file file to upload
*/ */
uploadFile(params: { petId: number; additionalMetadata?: string; file?: any; }): FetchArgs { uploadFile(params: { petId: number; additionalMetadata?: string; file?: any; }, configuration: Configuration): FetchArgs {
// verify required parameter "petId" is set // verify required parameter "petId" is set
if (params["petId"] == null) { if (params["petId"] == null) {
throw new Error("Missing required parameter petId when calling uploadFile"); throw new Error("Missing required parameter petId when calling uploadFile");
@ -300,6 +400,14 @@ export const PetApiFetchParamCreactor = {
if (contentTypeHeader) { if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader; fetchOptions.headers = contentTypeHeader;
} }
// authentication (petstore_auth) required
// oauth required
if (configuration.accessToken) {
fetchOptions.headers = assign({
'Authorization': 'Bearer ' + configuration.accessToken,
}, contentTypeHeader);
}
return { return {
url: url.format(urlObj), url: url.format(urlObj),
options: fetchOptions, options: fetchOptions,
@ -316,8 +424,8 @@ export const PetApiFp = {
* *
* @param body Pet object that needs to be added to the store * @param body Pet object that needs to be added to the store
*/ */
addPet(params: { body?: Pet; }): (fetch: FetchAPI, basePath?: string) => Promise<any> { addPet(params: { body: Pet; }, configuration: Configuration): (fetch: FetchAPI, basePath?: string) => Promise<any> {
const fetchArgs = PetApiFetchParamCreactor.addPet(params); const fetchArgs = PetApiFetchParamCreactor.addPet(params, configuration);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
if (response.status >= 200 && response.status < 300) { if (response.status >= 200 && response.status < 300) {
@ -334,8 +442,8 @@ export const PetApiFp = {
* @param petId Pet id to delete * @param petId Pet id to delete
* @param apiKey * @param apiKey
*/ */
deletePet(params: { petId: number; apiKey?: string; }): (fetch: FetchAPI, basePath?: string) => Promise<any> { deletePet(params: { petId: number; apiKey?: string; }, configuration: Configuration): (fetch: FetchAPI, basePath?: string) => Promise<any> {
const fetchArgs = PetApiFetchParamCreactor.deletePet(params); const fetchArgs = PetApiFetchParamCreactor.deletePet(params, configuration);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
if (response.status >= 200 && response.status < 300) { if (response.status >= 200 && response.status < 300) {
@ -351,8 +459,8 @@ export const PetApiFp = {
* Multiple status values can be provided with comma separated strings * Multiple status values can be provided with comma separated strings
* @param status Status values that need to be considered for filter * @param status Status values that need to be considered for filter
*/ */
findPetsByStatus(params: { status?: Array<string>; }): (fetch: FetchAPI, basePath?: string) => Promise<Array<Pet>> { findPetsByStatus(params: { status: Array<string>; }, configuration: Configuration): (fetch: FetchAPI, basePath?: string) => Promise<Array<Pet>> {
const fetchArgs = PetApiFetchParamCreactor.findPetsByStatus(params); const fetchArgs = PetApiFetchParamCreactor.findPetsByStatus(params, configuration);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
if (response.status >= 200 && response.status < 300) { if (response.status >= 200 && response.status < 300) {
@ -368,8 +476,8 @@ export const PetApiFp = {
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
* @param tags Tags to filter by * @param tags Tags to filter by
*/ */
findPetsByTags(params: { tags?: Array<string>; }): (fetch: FetchAPI, basePath?: string) => Promise<Array<Pet>> { findPetsByTags(params: { tags: Array<string>; }, configuration: Configuration): (fetch: FetchAPI, basePath?: string) => Promise<Array<Pet>> {
const fetchArgs = PetApiFetchParamCreactor.findPetsByTags(params); const fetchArgs = PetApiFetchParamCreactor.findPetsByTags(params, configuration);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
if (response.status >= 200 && response.status < 300) { if (response.status >= 200 && response.status < 300) {
@ -382,11 +490,11 @@ export const PetApiFp = {
}, },
/** /**
* Find pet by ID * Find pet by ID
* Returns a pet when ID &lt; 10. ID &gt; 10 or nonintegers will simulate API error conditions * Returns a single pet
* @param petId ID of pet that needs to be fetched * @param petId ID of pet to return
*/ */
getPetById(params: { petId: number; }): (fetch: FetchAPI, basePath?: string) => Promise<Pet> { getPetById(params: { petId: number; }, configuration: Configuration): (fetch: FetchAPI, basePath?: string) => Promise<Pet> {
const fetchArgs = PetApiFetchParamCreactor.getPetById(params); const fetchArgs = PetApiFetchParamCreactor.getPetById(params, configuration);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
if (response.status >= 200 && response.status < 300) { if (response.status >= 200 && response.status < 300) {
@ -402,8 +510,8 @@ export const PetApiFp = {
* *
* @param body Pet object that needs to be added to the store * @param body Pet object that needs to be added to the store
*/ */
updatePet(params: { body?: Pet; }): (fetch: FetchAPI, basePath?: string) => Promise<any> { updatePet(params: { body: Pet; }, configuration: Configuration): (fetch: FetchAPI, basePath?: string) => Promise<any> {
const fetchArgs = PetApiFetchParamCreactor.updatePet(params); const fetchArgs = PetApiFetchParamCreactor.updatePet(params, configuration);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
if (response.status >= 200 && response.status < 300) { if (response.status >= 200 && response.status < 300) {
@ -421,8 +529,8 @@ export const PetApiFp = {
* @param name Updated name of the pet * @param name Updated name of the pet
* @param status Updated status of the pet * @param status Updated status of the pet
*/ */
updatePetWithForm(params: { petId: string; name?: string; status?: string; }): (fetch: FetchAPI, basePath?: string) => Promise<any> { updatePetWithForm(params: { petId: number; name?: string; status?: string; }, configuration: Configuration): (fetch: FetchAPI, basePath?: string) => Promise<any> {
const fetchArgs = PetApiFetchParamCreactor.updatePetWithForm(params); const fetchArgs = PetApiFetchParamCreactor.updatePetWithForm(params, configuration);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
if (response.status >= 200 && response.status < 300) { if (response.status >= 200 && response.status < 300) {
@ -440,12 +548,12 @@ export const PetApiFp = {
* @param additionalMetadata Additional data to pass to server * @param additionalMetadata Additional data to pass to server
* @param file file to upload * @param file file to upload
*/ */
uploadFile(params: { petId: number; additionalMetadata?: string; file?: any; }): (fetch: FetchAPI, basePath?: string) => Promise<any> { uploadFile(params: { petId: number; additionalMetadata?: string; file?: any; }, configuration: Configuration): (fetch: FetchAPI, basePath?: string) => Promise<ApiResponse> {
const fetchArgs = PetApiFetchParamCreactor.uploadFile(params); const fetchArgs = PetApiFetchParamCreactor.uploadFile(params, configuration);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
if (response.status >= 200 && response.status < 300) { if (response.status >= 200 && response.status < 300) {
return response; return response.json();
} else { } else {
throw response; throw response;
} }
@ -463,8 +571,8 @@ export class PetApi extends BaseAPI {
* *
* @param body Pet object that needs to be added to the store * @param body Pet object that needs to be added to the store
*/ */
addPet(params: { body?: Pet; }) { addPet(params: { body: Pet; }) {
return PetApiFp.addPet(params)(this.fetch, this.basePath); return PetApiFp.addPet(params, this.configuration)(this.fetch, this.basePath);
} }
/** /**
* Deletes a pet * Deletes a pet
@ -473,39 +581,39 @@ export class PetApi extends BaseAPI {
* @param apiKey * @param apiKey
*/ */
deletePet(params: { petId: number; apiKey?: string; }) { deletePet(params: { petId: number; apiKey?: string; }) {
return PetApiFp.deletePet(params)(this.fetch, this.basePath); return PetApiFp.deletePet(params, this.configuration)(this.fetch, this.basePath);
} }
/** /**
* Finds Pets by status * Finds Pets by status
* Multiple status values can be provided with comma separated strings * Multiple status values can be provided with comma separated strings
* @param status Status values that need to be considered for filter * @param status Status values that need to be considered for filter
*/ */
findPetsByStatus(params: { status?: Array<string>; }) { findPetsByStatus(params: { status: Array<string>; }) {
return PetApiFp.findPetsByStatus(params)(this.fetch, this.basePath); return PetApiFp.findPetsByStatus(params, this.configuration)(this.fetch, this.basePath);
} }
/** /**
* Finds Pets by tags * Finds Pets by tags
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
* @param tags Tags to filter by * @param tags Tags to filter by
*/ */
findPetsByTags(params: { tags?: Array<string>; }) { findPetsByTags(params: { tags: Array<string>; }) {
return PetApiFp.findPetsByTags(params)(this.fetch, this.basePath); return PetApiFp.findPetsByTags(params, this.configuration)(this.fetch, this.basePath);
} }
/** /**
* Find pet by ID * Find pet by ID
* Returns a pet when ID &lt; 10. ID &gt; 10 or nonintegers will simulate API error conditions * Returns a single pet
* @param petId ID of pet that needs to be fetched * @param petId ID of pet to return
*/ */
getPetById(params: { petId: number; }) { getPetById(params: { petId: number; }) {
return PetApiFp.getPetById(params)(this.fetch, this.basePath); return PetApiFp.getPetById(params, this.configuration)(this.fetch, this.basePath);
} }
/** /**
* Update an existing pet * Update an existing pet
* *
* @param body Pet object that needs to be added to the store * @param body Pet object that needs to be added to the store
*/ */
updatePet(params: { body?: Pet; }) { updatePet(params: { body: Pet; }) {
return PetApiFp.updatePet(params)(this.fetch, this.basePath); return PetApiFp.updatePet(params, this.configuration)(this.fetch, this.basePath);
} }
/** /**
* Updates a pet in the store with form data * Updates a pet in the store with form data
@ -514,8 +622,8 @@ export class PetApi extends BaseAPI {
* @param name Updated name of the pet * @param name Updated name of the pet
* @param status Updated status of the pet * @param status Updated status of the pet
*/ */
updatePetWithForm(params: { petId: string; name?: string; status?: string; }) { updatePetWithForm(params: { petId: number; name?: string; status?: string; }) {
return PetApiFp.updatePetWithForm(params)(this.fetch, this.basePath); return PetApiFp.updatePetWithForm(params, this.configuration)(this.fetch, this.basePath);
} }
/** /**
* uploads an image * uploads an image
@ -525,7 +633,7 @@ export class PetApi extends BaseAPI {
* @param file file to upload * @param file file to upload
*/ */
uploadFile(params: { petId: number; additionalMetadata?: string; file?: any; }) { uploadFile(params: { petId: number; additionalMetadata?: string; file?: any; }) {
return PetApiFp.uploadFile(params)(this.fetch, this.basePath); return PetApiFp.uploadFile(params, this.configuration)(this.fetch, this.basePath);
} }
}; };
@ -539,8 +647,8 @@ export const PetApiFactory = function (fetch?: FetchAPI, basePath?: string) {
* *
* @param body Pet object that needs to be added to the store * @param body Pet object that needs to be added to the store
*/ */
addPet(params: { body?: Pet; }) { addPet(params: { body: Pet; }, configuration: Configuration) {
return PetApiFp.addPet(params)(fetch, basePath); return PetApiFp.addPet(params, configuration)(fetch, basePath);
}, },
/** /**
* Deletes a pet * Deletes a pet
@ -548,40 +656,40 @@ export const PetApiFactory = function (fetch?: FetchAPI, basePath?: string) {
* @param petId Pet id to delete * @param petId Pet id to delete
* @param apiKey * @param apiKey
*/ */
deletePet(params: { petId: number; apiKey?: string; }) { deletePet(params: { petId: number; apiKey?: string; }, configuration: Configuration) {
return PetApiFp.deletePet(params)(fetch, basePath); return PetApiFp.deletePet(params, configuration)(fetch, basePath);
}, },
/** /**
* Finds Pets by status * Finds Pets by status
* Multiple status values can be provided with comma separated strings * Multiple status values can be provided with comma separated strings
* @param status Status values that need to be considered for filter * @param status Status values that need to be considered for filter
*/ */
findPetsByStatus(params: { status?: Array<string>; }) { findPetsByStatus(params: { status: Array<string>; }, configuration: Configuration) {
return PetApiFp.findPetsByStatus(params)(fetch, basePath); return PetApiFp.findPetsByStatus(params, configuration)(fetch, basePath);
}, },
/** /**
* Finds Pets by tags * Finds Pets by tags
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
* @param tags Tags to filter by * @param tags Tags to filter by
*/ */
findPetsByTags(params: { tags?: Array<string>; }) { findPetsByTags(params: { tags: Array<string>; }, configuration: Configuration) {
return PetApiFp.findPetsByTags(params)(fetch, basePath); return PetApiFp.findPetsByTags(params, configuration)(fetch, basePath);
}, },
/** /**
* Find pet by ID * Find pet by ID
* Returns a pet when ID &lt; 10. ID &gt; 10 or nonintegers will simulate API error conditions * Returns a single pet
* @param petId ID of pet that needs to be fetched * @param petId ID of pet to return
*/ */
getPetById(params: { petId: number; }) { getPetById(params: { petId: number; }, configuration: Configuration) {
return PetApiFp.getPetById(params)(fetch, basePath); return PetApiFp.getPetById(params, configuration)(fetch, basePath);
}, },
/** /**
* Update an existing pet * Update an existing pet
* *
* @param body Pet object that needs to be added to the store * @param body Pet object that needs to be added to the store
*/ */
updatePet(params: { body?: Pet; }) { updatePet(params: { body: Pet; }, configuration: Configuration) {
return PetApiFp.updatePet(params)(fetch, basePath); return PetApiFp.updatePet(params, configuration)(fetch, basePath);
}, },
/** /**
* Updates a pet in the store with form data * Updates a pet in the store with form data
@ -590,8 +698,8 @@ export const PetApiFactory = function (fetch?: FetchAPI, basePath?: string) {
* @param name Updated name of the pet * @param name Updated name of the pet
* @param status Updated status of the pet * @param status Updated status of the pet
*/ */
updatePetWithForm(params: { petId: string; name?: string; status?: string; }) { updatePetWithForm(params: { petId: number; name?: string; status?: string; }, configuration: Configuration) {
return PetApiFp.updatePetWithForm(params)(fetch, basePath); return PetApiFp.updatePetWithForm(params, configuration)(fetch, basePath);
}, },
/** /**
* uploads an image * uploads an image
@ -600,8 +708,8 @@ export const PetApiFactory = function (fetch?: FetchAPI, basePath?: string) {
* @param additionalMetadata Additional data to pass to server * @param additionalMetadata Additional data to pass to server
* @param file file to upload * @param file file to upload
*/ */
uploadFile(params: { petId: number; additionalMetadata?: string; file?: any; }) { uploadFile(params: { petId: number; additionalMetadata?: string; file?: any; }, configuration: Configuration) {
return PetApiFp.uploadFile(params)(fetch, basePath); return PetApiFp.uploadFile(params, configuration)(fetch, basePath);
}, },
} }
}; };
@ -630,6 +738,7 @@ export const StoreApiFetchParamCreactor = {
if (contentTypeHeader) { if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader; fetchOptions.headers = contentTypeHeader;
} }
return { return {
url: url.format(urlObj), url: url.format(urlObj),
options: fetchOptions, options: fetchOptions,
@ -639,7 +748,7 @@ export const StoreApiFetchParamCreactor = {
* Returns pet inventories by status * Returns pet inventories by status
* Returns a map of status codes to quantities * Returns a map of status codes to quantities
*/ */
getInventory(): FetchArgs { getInventory(configuration: Configuration): FetchArgs {
const baseUrl = `/store/inventory`; const baseUrl = `/store/inventory`;
let urlObj = url.parse(baseUrl, true); let urlObj = url.parse(baseUrl, true);
let fetchOptions: RequestInit = { method: "GET" }; let fetchOptions: RequestInit = { method: "GET" };
@ -648,6 +757,13 @@ export const StoreApiFetchParamCreactor = {
if (contentTypeHeader) { if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader; fetchOptions.headers = contentTypeHeader;
} }
// authentication (api_key) required
if (configuration.apiKey && configuration.apiKey.api_key) {
fetchOptions.headers = assign({
'api_key': configuration.apiKey.api_key,
}, contentTypeHeader);
}
return { return {
url: url.format(urlObj), url: url.format(urlObj),
options: fetchOptions, options: fetchOptions,
@ -658,7 +774,7 @@ export const StoreApiFetchParamCreactor = {
* For valid response try integer IDs with value &lt;&#x3D; 5 or &gt; 10. Other values will generated exceptions * For valid response try integer IDs with value &lt;&#x3D; 5 or &gt; 10. Other values will generated exceptions
* @param orderId ID of pet that needs to be fetched * @param orderId ID of pet that needs to be fetched
*/ */
getOrderById(params: { orderId: string; }): FetchArgs { getOrderById(params: { orderId: number; }): FetchArgs {
// verify required parameter "orderId" is set // verify required parameter "orderId" is set
if (params["orderId"] == null) { if (params["orderId"] == null) {
throw new Error("Missing required parameter orderId when calling getOrderById"); throw new Error("Missing required parameter orderId when calling getOrderById");
@ -672,6 +788,7 @@ export const StoreApiFetchParamCreactor = {
if (contentTypeHeader) { if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader; fetchOptions.headers = contentTypeHeader;
} }
return { return {
url: url.format(urlObj), url: url.format(urlObj),
options: fetchOptions, options: fetchOptions,
@ -682,7 +799,11 @@ export const StoreApiFetchParamCreactor = {
* *
* @param body order placed for purchasing the pet * @param body order placed for purchasing the pet
*/ */
placeOrder(params: { body?: Order; }): FetchArgs { placeOrder(params: { body: Order; }): FetchArgs {
// verify required parameter "body" is set
if (params["body"] == null) {
throw new Error("Missing required parameter body when calling placeOrder");
}
const baseUrl = `/store/order`; const baseUrl = `/store/order`;
let urlObj = url.parse(baseUrl, true); let urlObj = url.parse(baseUrl, true);
let fetchOptions: RequestInit = { method: "POST" }; let fetchOptions: RequestInit = { method: "POST" };
@ -695,6 +816,7 @@ export const StoreApiFetchParamCreactor = {
if (contentTypeHeader) { if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader; fetchOptions.headers = contentTypeHeader;
} }
return { return {
url: url.format(urlObj), url: url.format(urlObj),
options: fetchOptions, options: fetchOptions,
@ -727,8 +849,8 @@ export const StoreApiFp = {
* Returns pet inventories by status * Returns pet inventories by status
* Returns a map of status codes to quantities * Returns a map of status codes to quantities
*/ */
getInventory(): (fetch: FetchAPI, basePath?: string) => Promise<{ [key: string]: number; }> { getInventory(configuration: Configuration): (fetch: FetchAPI, basePath?: string) => Promise<{ [key: string]: number; }> {
const fetchArgs = StoreApiFetchParamCreactor.getInventory(); const fetchArgs = StoreApiFetchParamCreactor.getInventory(configuration);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
if (response.status >= 200 && response.status < 300) { if (response.status >= 200 && response.status < 300) {
@ -744,7 +866,7 @@ export const StoreApiFp = {
* For valid response try integer IDs with value &lt;&#x3D; 5 or &gt; 10. Other values will generated exceptions * For valid response try integer IDs with value &lt;&#x3D; 5 or &gt; 10. Other values will generated exceptions
* @param orderId ID of pet that needs to be fetched * @param orderId ID of pet that needs to be fetched
*/ */
getOrderById(params: { orderId: string; }): (fetch: FetchAPI, basePath?: string) => Promise<Order> { getOrderById(params: { orderId: number; }): (fetch: FetchAPI, basePath?: string) => Promise<Order> {
const fetchArgs = StoreApiFetchParamCreactor.getOrderById(params); const fetchArgs = StoreApiFetchParamCreactor.getOrderById(params);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
@ -761,7 +883,7 @@ export const StoreApiFp = {
* *
* @param body order placed for purchasing the pet * @param body order placed for purchasing the pet
*/ */
placeOrder(params: { body?: Order; }): (fetch: FetchAPI, basePath?: string) => Promise<Order> { placeOrder(params: { body: Order; }): (fetch: FetchAPI, basePath?: string) => Promise<Order> {
const fetchArgs = StoreApiFetchParamCreactor.placeOrder(params); const fetchArgs = StoreApiFetchParamCreactor.placeOrder(params);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
@ -792,14 +914,14 @@ export class StoreApi extends BaseAPI {
* Returns a map of status codes to quantities * Returns a map of status codes to quantities
*/ */
getInventory() { getInventory() {
return StoreApiFp.getInventory()(this.fetch, this.basePath); return StoreApiFp.getInventory(this.configuration)(this.fetch, this.basePath);
} }
/** /**
* Find purchase order by ID * Find purchase order by ID
* For valid response try integer IDs with value &lt;&#x3D; 5 or &gt; 10. Other values will generated exceptions * For valid response try integer IDs with value &lt;&#x3D; 5 or &gt; 10. Other values will generated exceptions
* @param orderId ID of pet that needs to be fetched * @param orderId ID of pet that needs to be fetched
*/ */
getOrderById(params: { orderId: string; }) { getOrderById(params: { orderId: number; }) {
return StoreApiFp.getOrderById(params)(this.fetch, this.basePath); return StoreApiFp.getOrderById(params)(this.fetch, this.basePath);
} }
/** /**
@ -807,7 +929,7 @@ export class StoreApi extends BaseAPI {
* *
* @param body order placed for purchasing the pet * @param body order placed for purchasing the pet
*/ */
placeOrder(params: { body?: Order; }) { placeOrder(params: { body: Order; }) {
return StoreApiFp.placeOrder(params)(this.fetch, this.basePath); return StoreApiFp.placeOrder(params)(this.fetch, this.basePath);
} }
}; };
@ -829,15 +951,15 @@ export const StoreApiFactory = function (fetch?: FetchAPI, basePath?: string) {
* Returns pet inventories by status * Returns pet inventories by status
* Returns a map of status codes to quantities * Returns a map of status codes to quantities
*/ */
getInventory() { getInventory(configuration: Configuration) {
return StoreApiFp.getInventory()(fetch, basePath); return StoreApiFp.getInventory(configuration)(fetch, basePath);
}, },
/** /**
* Find purchase order by ID * Find purchase order by ID
* For valid response try integer IDs with value &lt;&#x3D; 5 or &gt; 10. Other values will generated exceptions * For valid response try integer IDs with value &lt;&#x3D; 5 or &gt; 10. Other values will generated exceptions
* @param orderId ID of pet that needs to be fetched * @param orderId ID of pet that needs to be fetched
*/ */
getOrderById(params: { orderId: string; }) { getOrderById(params: { orderId: number; }) {
return StoreApiFp.getOrderById(params)(fetch, basePath); return StoreApiFp.getOrderById(params)(fetch, basePath);
}, },
/** /**
@ -845,7 +967,7 @@ export const StoreApiFactory = function (fetch?: FetchAPI, basePath?: string) {
* *
* @param body order placed for purchasing the pet * @param body order placed for purchasing the pet
*/ */
placeOrder(params: { body?: Order; }) { placeOrder(params: { body: Order; }) {
return StoreApiFp.placeOrder(params)(fetch, basePath); return StoreApiFp.placeOrder(params)(fetch, basePath);
}, },
} }
@ -861,7 +983,11 @@ export const UserApiFetchParamCreactor = {
* This can only be done by the logged in user. * This can only be done by the logged in user.
* @param body Created user object * @param body Created user object
*/ */
createUser(params: { body?: User; }): FetchArgs { createUser(params: { body: User; }): FetchArgs {
// verify required parameter "body" is set
if (params["body"] == null) {
throw new Error("Missing required parameter body when calling createUser");
}
const baseUrl = `/user`; const baseUrl = `/user`;
let urlObj = url.parse(baseUrl, true); let urlObj = url.parse(baseUrl, true);
let fetchOptions: RequestInit = { method: "POST" }; let fetchOptions: RequestInit = { method: "POST" };
@ -874,6 +1000,7 @@ export const UserApiFetchParamCreactor = {
if (contentTypeHeader) { if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader; fetchOptions.headers = contentTypeHeader;
} }
return { return {
url: url.format(urlObj), url: url.format(urlObj),
options: fetchOptions, options: fetchOptions,
@ -884,7 +1011,11 @@ export const UserApiFetchParamCreactor = {
* *
* @param body List of user object * @param body List of user object
*/ */
createUsersWithArrayInput(params: { body?: Array<User>; }): FetchArgs { createUsersWithArrayInput(params: { body: Array<User>; }): FetchArgs {
// verify required parameter "body" is set
if (params["body"] == null) {
throw new Error("Missing required parameter body when calling createUsersWithArrayInput");
}
const baseUrl = `/user/createWithArray`; const baseUrl = `/user/createWithArray`;
let urlObj = url.parse(baseUrl, true); let urlObj = url.parse(baseUrl, true);
let fetchOptions: RequestInit = { method: "POST" }; let fetchOptions: RequestInit = { method: "POST" };
@ -897,6 +1028,7 @@ export const UserApiFetchParamCreactor = {
if (contentTypeHeader) { if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader; fetchOptions.headers = contentTypeHeader;
} }
return { return {
url: url.format(urlObj), url: url.format(urlObj),
options: fetchOptions, options: fetchOptions,
@ -907,7 +1039,11 @@ export const UserApiFetchParamCreactor = {
* *
* @param body List of user object * @param body List of user object
*/ */
createUsersWithListInput(params: { body?: Array<User>; }): FetchArgs { createUsersWithListInput(params: { body: Array<User>; }): FetchArgs {
// verify required parameter "body" is set
if (params["body"] == null) {
throw new Error("Missing required parameter body when calling createUsersWithListInput");
}
const baseUrl = `/user/createWithList`; const baseUrl = `/user/createWithList`;
let urlObj = url.parse(baseUrl, true); let urlObj = url.parse(baseUrl, true);
let fetchOptions: RequestInit = { method: "POST" }; let fetchOptions: RequestInit = { method: "POST" };
@ -920,6 +1056,7 @@ export const UserApiFetchParamCreactor = {
if (contentTypeHeader) { if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader; fetchOptions.headers = contentTypeHeader;
} }
return { return {
url: url.format(urlObj), url: url.format(urlObj),
options: fetchOptions, options: fetchOptions,
@ -944,6 +1081,7 @@ export const UserApiFetchParamCreactor = {
if (contentTypeHeader) { if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader; fetchOptions.headers = contentTypeHeader;
} }
return { return {
url: url.format(urlObj), url: url.format(urlObj),
options: fetchOptions, options: fetchOptions,
@ -968,6 +1106,7 @@ export const UserApiFetchParamCreactor = {
if (contentTypeHeader) { if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader; fetchOptions.headers = contentTypeHeader;
} }
return { return {
url: url.format(urlObj), url: url.format(urlObj),
options: fetchOptions, options: fetchOptions,
@ -979,7 +1118,15 @@ export const UserApiFetchParamCreactor = {
* @param username The user name for login * @param username The user name for login
* @param password The password for login in clear text * @param password The password for login in clear text
*/ */
loginUser(params: { username?: string; password?: string; }): FetchArgs { loginUser(params: { username: string; password: string; }): FetchArgs {
// verify required parameter "username" is set
if (params["username"] == null) {
throw new Error("Missing required parameter username when calling loginUser");
}
// verify required parameter "password" is set
if (params["password"] == null) {
throw new Error("Missing required parameter password when calling loginUser");
}
const baseUrl = `/user/login`; const baseUrl = `/user/login`;
let urlObj = url.parse(baseUrl, true); let urlObj = url.parse(baseUrl, true);
urlObj.query = assign({}, urlObj.query, { urlObj.query = assign({}, urlObj.query, {
@ -992,6 +1139,7 @@ export const UserApiFetchParamCreactor = {
if (contentTypeHeader) { if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader; fetchOptions.headers = contentTypeHeader;
} }
return { return {
url: url.format(urlObj), url: url.format(urlObj),
options: fetchOptions, options: fetchOptions,
@ -1010,6 +1158,7 @@ export const UserApiFetchParamCreactor = {
if (contentTypeHeader) { if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader; fetchOptions.headers = contentTypeHeader;
} }
return { return {
url: url.format(urlObj), url: url.format(urlObj),
options: fetchOptions, options: fetchOptions,
@ -1021,11 +1170,15 @@ export const UserApiFetchParamCreactor = {
* @param username name that need to be deleted * @param username name that need to be deleted
* @param body Updated user object * @param body Updated user object
*/ */
updateUser(params: { username: string; body?: User; }): FetchArgs { updateUser(params: { username: string; body: User; }): FetchArgs {
// verify required parameter "username" is set // verify required parameter "username" is set
if (params["username"] == null) { if (params["username"] == null) {
throw new Error("Missing required parameter username when calling updateUser"); throw new Error("Missing required parameter username when calling updateUser");
} }
// verify required parameter "body" is set
if (params["body"] == null) {
throw new Error("Missing required parameter body when calling updateUser");
}
const baseUrl = `/user/{username}` const baseUrl = `/user/{username}`
.replace(`{${"username"}}`, `${ params.username }`); .replace(`{${"username"}}`, `${ params.username }`);
let urlObj = url.parse(baseUrl, true); let urlObj = url.parse(baseUrl, true);
@ -1039,6 +1192,7 @@ export const UserApiFetchParamCreactor = {
if (contentTypeHeader) { if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader; fetchOptions.headers = contentTypeHeader;
} }
return { return {
url: url.format(urlObj), url: url.format(urlObj),
options: fetchOptions, options: fetchOptions,
@ -1055,7 +1209,7 @@ export const UserApiFp = {
* This can only be done by the logged in user. * This can only be done by the logged in user.
* @param body Created user object * @param body Created user object
*/ */
createUser(params: { body?: User; }): (fetch: FetchAPI, basePath?: string) => Promise<any> { createUser(params: { body: User; }): (fetch: FetchAPI, basePath?: string) => Promise<any> {
const fetchArgs = UserApiFetchParamCreactor.createUser(params); const fetchArgs = UserApiFetchParamCreactor.createUser(params);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
@ -1072,7 +1226,7 @@ export const UserApiFp = {
* *
* @param body List of user object * @param body List of user object
*/ */
createUsersWithArrayInput(params: { body?: Array<User>; }): (fetch: FetchAPI, basePath?: string) => Promise<any> { createUsersWithArrayInput(params: { body: Array<User>; }): (fetch: FetchAPI, basePath?: string) => Promise<any> {
const fetchArgs = UserApiFetchParamCreactor.createUsersWithArrayInput(params); const fetchArgs = UserApiFetchParamCreactor.createUsersWithArrayInput(params);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
@ -1089,7 +1243,7 @@ export const UserApiFp = {
* *
* @param body List of user object * @param body List of user object
*/ */
createUsersWithListInput(params: { body?: Array<User>; }): (fetch: FetchAPI, basePath?: string) => Promise<any> { createUsersWithListInput(params: { body: Array<User>; }): (fetch: FetchAPI, basePath?: string) => Promise<any> {
const fetchArgs = UserApiFetchParamCreactor.createUsersWithListInput(params); const fetchArgs = UserApiFetchParamCreactor.createUsersWithListInput(params);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
@ -1141,7 +1295,7 @@ export const UserApiFp = {
* @param username The user name for login * @param username The user name for login
* @param password The password for login in clear text * @param password The password for login in clear text
*/ */
loginUser(params: { username?: string; password?: string; }): (fetch: FetchAPI, basePath?: string) => Promise<string> { loginUser(params: { username: string; password: string; }): (fetch: FetchAPI, basePath?: string) => Promise<string> {
const fetchArgs = UserApiFetchParamCreactor.loginUser(params); const fetchArgs = UserApiFetchParamCreactor.loginUser(params);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
@ -1175,7 +1329,7 @@ export const UserApiFp = {
* @param username name that need to be deleted * @param username name that need to be deleted
* @param body Updated user object * @param body Updated user object
*/ */
updateUser(params: { username: string; body?: User; }): (fetch: FetchAPI, basePath?: string) => Promise<any> { updateUser(params: { username: string; body: User; }): (fetch: FetchAPI, basePath?: string) => Promise<any> {
const fetchArgs = UserApiFetchParamCreactor.updateUser(params); const fetchArgs = UserApiFetchParamCreactor.updateUser(params);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => { return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => { return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
@ -1198,7 +1352,7 @@ export class UserApi extends BaseAPI {
* This can only be done by the logged in user. * This can only be done by the logged in user.
* @param body Created user object * @param body Created user object
*/ */
createUser(params: { body?: User; }) { createUser(params: { body: User; }) {
return UserApiFp.createUser(params)(this.fetch, this.basePath); return UserApiFp.createUser(params)(this.fetch, this.basePath);
} }
/** /**
@ -1206,7 +1360,7 @@ export class UserApi extends BaseAPI {
* *
* @param body List of user object * @param body List of user object
*/ */
createUsersWithArrayInput(params: { body?: Array<User>; }) { createUsersWithArrayInput(params: { body: Array<User>; }) {
return UserApiFp.createUsersWithArrayInput(params)(this.fetch, this.basePath); return UserApiFp.createUsersWithArrayInput(params)(this.fetch, this.basePath);
} }
/** /**
@ -1214,7 +1368,7 @@ export class UserApi extends BaseAPI {
* *
* @param body List of user object * @param body List of user object
*/ */
createUsersWithListInput(params: { body?: Array<User>; }) { createUsersWithListInput(params: { body: Array<User>; }) {
return UserApiFp.createUsersWithListInput(params)(this.fetch, this.basePath); return UserApiFp.createUsersWithListInput(params)(this.fetch, this.basePath);
} }
/** /**
@ -1239,7 +1393,7 @@ export class UserApi extends BaseAPI {
* @param username The user name for login * @param username The user name for login
* @param password The password for login in clear text * @param password The password for login in clear text
*/ */
loginUser(params: { username?: string; password?: string; }) { loginUser(params: { username: string; password: string; }) {
return UserApiFp.loginUser(params)(this.fetch, this.basePath); return UserApiFp.loginUser(params)(this.fetch, this.basePath);
} }
/** /**
@ -1255,7 +1409,7 @@ export class UserApi extends BaseAPI {
* @param username name that need to be deleted * @param username name that need to be deleted
* @param body Updated user object * @param body Updated user object
*/ */
updateUser(params: { username: string; body?: User; }) { updateUser(params: { username: string; body: User; }) {
return UserApiFp.updateUser(params)(this.fetch, this.basePath); return UserApiFp.updateUser(params)(this.fetch, this.basePath);
} }
}; };
@ -1270,7 +1424,7 @@ export const UserApiFactory = function (fetch?: FetchAPI, basePath?: string) {
* This can only be done by the logged in user. * This can only be done by the logged in user.
* @param body Created user object * @param body Created user object
*/ */
createUser(params: { body?: User; }) { createUser(params: { body: User; }) {
return UserApiFp.createUser(params)(fetch, basePath); return UserApiFp.createUser(params)(fetch, basePath);
}, },
/** /**
@ -1278,7 +1432,7 @@ export const UserApiFactory = function (fetch?: FetchAPI, basePath?: string) {
* *
* @param body List of user object * @param body List of user object
*/ */
createUsersWithArrayInput(params: { body?: Array<User>; }) { createUsersWithArrayInput(params: { body: Array<User>; }) {
return UserApiFp.createUsersWithArrayInput(params)(fetch, basePath); return UserApiFp.createUsersWithArrayInput(params)(fetch, basePath);
}, },
/** /**
@ -1286,7 +1440,7 @@ export const UserApiFactory = function (fetch?: FetchAPI, basePath?: string) {
* *
* @param body List of user object * @param body List of user object
*/ */
createUsersWithListInput(params: { body?: Array<User>; }) { createUsersWithListInput(params: { body: Array<User>; }) {
return UserApiFp.createUsersWithListInput(params)(fetch, basePath); return UserApiFp.createUsersWithListInput(params)(fetch, basePath);
}, },
/** /**
@ -1311,7 +1465,7 @@ export const UserApiFactory = function (fetch?: FetchAPI, basePath?: string) {
* @param username The user name for login * @param username The user name for login
* @param password The password for login in clear text * @param password The password for login in clear text
*/ */
loginUser(params: { username?: string; password?: string; }) { loginUser(params: { username: string; password: string; }) {
return UserApiFp.loginUser(params)(fetch, basePath); return UserApiFp.loginUser(params)(fetch, basePath);
}, },
/** /**
@ -1327,7 +1481,7 @@ export const UserApiFactory = function (fetch?: FetchAPI, basePath?: string) {
* @param username name that need to be deleted * @param username name that need to be deleted
* @param body Updated user object * @param body Updated user object
*/ */
updateUser(params: { username: string; body?: User; }) { updateUser(params: { username: string; body: User; }) {
return UserApiFp.updateUser(params)(fetch, basePath); return UserApiFp.updateUser(params)(fetch, basePath);
}, },
} }

View File

@ -0,0 +1,8 @@
export class Configuration {
apiKey: {
api_key: string;
};
username: string;
password: string;
accessToken: string;
}

View File

@ -1,25 +1,38 @@
import {expect} from 'chai'; import {expect} from 'chai';
import {PetApiFactory, Pet, Category} from 'typescript-fetch-api'; import {PetApiFactory, Pet, Category} from 'typescript-fetch-api';
import {Configuration} from 'typescript-fetch-api/dist/configuration';
let config: Configuration;
before(function() {
config = new Configuration();
config.accessToken = "foobar";
config.apiKey = {
api_key: "foobar"
};
config.username = "foo";
config.password = "bar";
});
describe('PetApiFactory', () => { describe('PetApiFactory', () => {
let fixture: Pet = createTestFixture(); let fixture: Pet = createTestFixture();
it('should add and delete Pet', () => { it('should add and delete Pet', () => {
return PetApiFactory().addPet({ body: fixture }).then(() => { return PetApiFactory().addPet({ body: fixture }, config).then(() => {
}); });
}); });
it('should get Pet by ID', () => { it('should get Pet by ID', () => {
return PetApiFactory().getPetById({ petId: fixture.id }).then((result) => { return PetApiFactory().getPetById({ petId: fixture.id }, config).then((result) => {
return expect(result).to.deep.equal(fixture); return expect(result).to.deep.equal(fixture);
}); });
}); });
it('should update Pet by ID', () => { it('should update Pet by ID', () => {
return PetApiFactory().getPetById({ petId: fixture.id }).then( (result) => { return PetApiFactory().getPetById({ petId: fixture.id }, config).then( (result) => {
result.name = 'newname'; result.name = 'newname';
return PetApiFactory().updatePet({ body: result }).then(() => { return PetApiFactory().updatePet({ body: result }, config).then(() => {
return PetApiFactory().getPetById({ petId: fixture.id }).then( (result) => { return PetApiFactory().getPetById({ petId: fixture.id }, config).then( (result) => {
return expect(result.name).to.deep.equal('newname'); return expect(result.name).to.deep.equal('newname');
}); });
}); });
@ -27,11 +40,11 @@ describe('PetApiFactory', () => {
}); });
it('should delete Pet', () => { it('should delete Pet', () => {
return PetApiFactory().deletePet({ petId: fixture.id }); return PetApiFactory().deletePet({ petId: fixture.id }, config);
}); });
it('should not contain deleted Pet', () => { it('should not contain deleted Pet', () => {
return PetApiFactory().getPetById({ petId: fixture.id }).then((result) => { return PetApiFactory().getPetById({ petId: fixture.id }, config).then((result) => {
return expect(result).to.not.exist; return expect(result).to.not.exist;
}, (err) => { }, (err) => {
return expect(err).to.exist; return expect(err).to.exist;

View File

@ -1,9 +1,22 @@
import {expect} from 'chai'; import {expect} from 'chai';
import {StoreApiFactory} from 'typescript-fetch-api'; import {StoreApiFactory} from 'typescript-fetch-api';
import {Configuration} from 'typescript-fetch-api/dist/configuration';
let config: Configuration;
before(function() {
config = new Configuration();
config.accessToken = "foobar";
config.apiKey = {
api_key: "foobar"
};
config.username = "foo";
config.password = "bar";
});
describe('StoreApiFactory', function() { describe('StoreApiFactory', function() {
it('should get inventory', function() { it('should get inventory', function() {
return StoreApiFactory().getInventory().then((result) => { return StoreApiFactory().getInventory(config).then((result) => {
expect(Object.keys(result)).to.not.be.empty; expect(Object.keys(result)).to.not.be.empty;
}); });
}); });