[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.
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

View File

@ -26,6 +26,6 @@ fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l typescript-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

View File

@ -26,6 +26,6 @@ fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l typescript-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

View File

@ -41,6 +41,7 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
supportingFiles.add(new SupportingFile("typings.json.mustache", "", "typings.json"));
supportingFiles.add(new SupportingFile("tsconfig.json.mustache", "", "tsconfig.json"));
supportingFiles.add(new SupportingFile("gitignore", "", ".gitignore"));
supportingFiles.add(new SupportingFile("configuration.mustache", "", "configuration.ts"));
if(additionalProperties.containsKey(NPM_NAME)) {
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";
{{/supportsES6}}
import { Configuration } from './configuration';
interface Dictionary<T> { [index: string]: T; }
export interface FetchAPI { (url: string, init?: any): Promise<any>; }
@ -20,11 +22,14 @@ export interface FetchArgs {
export class BaseAPI {
basePath: string;
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.fetch = fetch;
this.configuration = configuration;
}
}
{{#models}}
@ -70,7 +75,7 @@ export const {{classname}}FetchParamCreactor = {
* {{notes}}{{/notes}}{{#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}}
{{#required}}
// verify required parameter "{{paramName}}" is set
@ -112,6 +117,42 @@ export const {{classname}}FetchParamCreactor = {
fetchOptions.headers = contentTypeHeader;
}
{{/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 {
url: url.format(urlObj),
options: fetchOptions,
@ -131,8 +172,8 @@ export const {{classname}}Fp = {
* {{notes}}{{/notes}}{{#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}}> {
const fetchArgs = {{classname}}FetchParamCreactor.{{nickname}}({{#hasParams}}params{{/hasParams}});
{{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}}{{#hasAuthMethods}}{{#hasParams}}, {{/hasParams}}configuration{{/hasAuthMethods}});
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
if (response.status >= 200 && response.status < 300) {
@ -158,7 +199,7 @@ export class {{classname}} extends BaseAPI {
* @param {{paramName}} {{description}}{{/allParams}}
*/
{{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}}
};
@ -175,8 +216,8 @@ export const {{classname}}Factory = function (fetch?: FetchAPI, basePath?: strin
* {{notes}}{{/notes}}{{#allParams}}
* @param {{paramName}} {{description}}{{/allParams}}
*/
{{nickname}}({{#hasParams}}params: { {{#allParams}} {{paramName}}{{^required}}?{{/required}}: {{{dataType}}};{{/allParams}} }{{/hasParams}}) {
return {{classname}}Fp.{{nickname}}({{#hasParams}}params{{/hasParams}})(fetch, basePath);
{{nickname}}({{#hasParams}}params: { {{#allParams}} {{paramName}}{{^required}}?{{/required}}: {{{dataType}}};{{/allParams}} }{{/hasParams}}{{#hasAuthMethods}}{{#hasParams}}, {{/hasParams}}configuration: Configuration{{/hasAuthMethods}}) {
return {{classname}}Fp.{{nickname}}({{#hasParams}}params{{/hasParams}}{{#hasAuthMethods}}{{#hasParams}}, {{/hasParams}}configuration{{/hasAuthMethods}})(fetch, basePath);
},
{{/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
* 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
* Contact: apiteam@wordnik.com
* Contact: apiteam@swagger.io
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
@ -28,6 +28,8 @@ import * as url from "url";
import * as isomorphicFetch from "isomorphic-fetch";
import * as assign from "core-js/library/fn/object/assign";
import { Configuration } from './configuration';
interface Dictionary<T> { [index: string]: T; }
export interface FetchAPI { (url: string, init?: any): Promise<any>; }
@ -41,18 +43,36 @@ export interface FetchArgs {
export class BaseAPI {
basePath: string;
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.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 {
"id"?: number;
"name"?: string;
}
/**
* An order for a pets from the pet store
*/
export interface Order {
"id"?: number;
"petId"?: number;
@ -66,6 +86,9 @@ export interface Order {
}
export type OrderStatusEnum = "placed" | "approved" | "delivered";
/**
* A pet for sale in the pet store
*/
export interface Pet {
"id"?: number;
"category"?: Category;
@ -79,11 +102,17 @@ export interface Pet {
}
export type PetStatusEnum = "available" | "pending" | "sold";
/**
* A tag for a pet
*/
export interface Tag {
"id"?: number;
"name"?: string;
}
/**
* A User who is purchasing from the pet store
*/
export interface User {
"id"?: number;
"username"?: string;
@ -109,7 +138,11 @@ export const PetApiFetchParamCreactor = {
*
* @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`;
let urlObj = url.parse(baseUrl, true);
let fetchOptions: RequestInit = { method: "POST" };
@ -122,6 +155,14 @@ export const PetApiFetchParamCreactor = {
if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader;
}
// authentication (petstore_auth) required
// oauth required
if (configuration.accessToken) {
fetchOptions.headers = assign({
'Authorization': 'Bearer ' + configuration.accessToken,
}, contentTypeHeader);
}
return {
url: url.format(urlObj),
options: fetchOptions,
@ -133,7 +174,7 @@ export const PetApiFetchParamCreactor = {
* @param petId Pet id to delete
* @param apiKey
*/
deletePet(params: { petId: number; apiKey?: string; }): FetchArgs {
deletePet(params: { petId: number; apiKey?: string; }, configuration: Configuration): FetchArgs {
// verify required parameter "petId" is set
if (params["petId"] == null) {
throw new Error("Missing required parameter petId when calling deletePet");
@ -147,6 +188,14 @@ export const PetApiFetchParamCreactor = {
fetchOptions.headers = assign({
"api_key": params.apiKey,
}, contentTypeHeader);
// authentication (petstore_auth) required
// oauth required
if (configuration.accessToken) {
fetchOptions.headers = assign({
'Authorization': 'Bearer ' + configuration.accessToken,
}, contentTypeHeader);
}
return {
url: url.format(urlObj),
options: fetchOptions,
@ -157,7 +206,11 @@ export const PetApiFetchParamCreactor = {
* Multiple status values can be provided with comma separated strings
* @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`;
let urlObj = url.parse(baseUrl, true);
urlObj.query = assign({}, urlObj.query, {
@ -169,6 +222,14 @@ export const PetApiFetchParamCreactor = {
if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader;
}
// authentication (petstore_auth) required
// oauth required
if (configuration.accessToken) {
fetchOptions.headers = assign({
'Authorization': 'Bearer ' + configuration.accessToken,
}, contentTypeHeader);
}
return {
url: url.format(urlObj),
options: fetchOptions,
@ -179,7 +240,11 @@ export const PetApiFetchParamCreactor = {
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
* @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`;
let urlObj = url.parse(baseUrl, true);
urlObj.query = assign({}, urlObj.query, {
@ -191,6 +256,14 @@ export const PetApiFetchParamCreactor = {
if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader;
}
// authentication (petstore_auth) required
// oauth required
if (configuration.accessToken) {
fetchOptions.headers = assign({
'Authorization': 'Bearer ' + configuration.accessToken,
}, contentTypeHeader);
}
return {
url: url.format(urlObj),
options: fetchOptions,
@ -198,10 +271,10 @@ export const PetApiFetchParamCreactor = {
},
/**
* Find pet by ID
* Returns a pet when ID &lt; 10. ID &gt; 10 or nonintegers will simulate API error conditions
* @param petId ID of pet that needs to be fetched
* Returns a single pet
* @param petId ID of pet to return
*/
getPetById(params: { petId: number; }): FetchArgs {
getPetById(params: { petId: number; }, configuration: Configuration): FetchArgs {
// verify required parameter "petId" is set
if (params["petId"] == null) {
throw new Error("Missing required parameter petId when calling getPetById");
@ -215,6 +288,13 @@ export const PetApiFetchParamCreactor = {
if (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 {
url: url.format(urlObj),
options: fetchOptions,
@ -225,7 +305,11 @@ export const PetApiFetchParamCreactor = {
*
* @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`;
let urlObj = url.parse(baseUrl, true);
let fetchOptions: RequestInit = { method: "PUT" };
@ -238,6 +322,14 @@ export const PetApiFetchParamCreactor = {
if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader;
}
// authentication (petstore_auth) required
// oauth required
if (configuration.accessToken) {
fetchOptions.headers = assign({
'Authorization': 'Bearer ' + configuration.accessToken,
}, contentTypeHeader);
}
return {
url: url.format(urlObj),
options: fetchOptions,
@ -250,7 +342,7 @@ export const PetApiFetchParamCreactor = {
* @param name Updated name 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
if (params["petId"] == null) {
throw new Error("Missing required parameter petId when calling updatePetWithForm");
@ -269,6 +361,14 @@ export const PetApiFetchParamCreactor = {
if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader;
}
// authentication (petstore_auth) required
// oauth required
if (configuration.accessToken) {
fetchOptions.headers = assign({
'Authorization': 'Bearer ' + configuration.accessToken,
}, contentTypeHeader);
}
return {
url: url.format(urlObj),
options: fetchOptions,
@ -281,7 +381,7 @@ export const PetApiFetchParamCreactor = {
* @param additionalMetadata Additional data to pass to server
* @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
if (params["petId"] == null) {
throw new Error("Missing required parameter petId when calling uploadFile");
@ -300,6 +400,14 @@ export const PetApiFetchParamCreactor = {
if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader;
}
// authentication (petstore_auth) required
// oauth required
if (configuration.accessToken) {
fetchOptions.headers = assign({
'Authorization': 'Bearer ' + configuration.accessToken,
}, contentTypeHeader);
}
return {
url: url.format(urlObj),
options: fetchOptions,
@ -316,8 +424,8 @@ export const PetApiFp = {
*
* @param body Pet object that needs to be added to the store
*/
addPet(params: { body?: Pet; }): (fetch: FetchAPI, basePath?: string) => Promise<any> {
const fetchArgs = PetApiFetchParamCreactor.addPet(params);
addPet(params: { body: Pet; }, configuration: Configuration): (fetch: FetchAPI, basePath?: string) => Promise<any> {
const fetchArgs = PetApiFetchParamCreactor.addPet(params, configuration);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
if (response.status >= 200 && response.status < 300) {
@ -334,8 +442,8 @@ export const PetApiFp = {
* @param petId Pet id to delete
* @param apiKey
*/
deletePet(params: { petId: number; apiKey?: string; }): (fetch: FetchAPI, basePath?: string) => Promise<any> {
const fetchArgs = PetApiFetchParamCreactor.deletePet(params);
deletePet(params: { petId: number; apiKey?: string; }, configuration: Configuration): (fetch: FetchAPI, basePath?: string) => Promise<any> {
const fetchArgs = PetApiFetchParamCreactor.deletePet(params, configuration);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
if (response.status >= 200 && response.status < 300) {
@ -351,8 +459,8 @@ export const PetApiFp = {
* Multiple status values can be provided with comma separated strings
* @param status Status values that need to be considered for filter
*/
findPetsByStatus(params: { status?: Array<string>; }): (fetch: FetchAPI, basePath?: string) => Promise<Array<Pet>> {
const fetchArgs = PetApiFetchParamCreactor.findPetsByStatus(params);
findPetsByStatus(params: { status: Array<string>; }, configuration: Configuration): (fetch: FetchAPI, basePath?: string) => Promise<Array<Pet>> {
const fetchArgs = PetApiFetchParamCreactor.findPetsByStatus(params, configuration);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
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.
* @param tags Tags to filter by
*/
findPetsByTags(params: { tags?: Array<string>; }): (fetch: FetchAPI, basePath?: string) => Promise<Array<Pet>> {
const fetchArgs = PetApiFetchParamCreactor.findPetsByTags(params);
findPetsByTags(params: { tags: Array<string>; }, configuration: Configuration): (fetch: FetchAPI, basePath?: string) => Promise<Array<Pet>> {
const fetchArgs = PetApiFetchParamCreactor.findPetsByTags(params, configuration);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
if (response.status >= 200 && response.status < 300) {
@ -382,11 +490,11 @@ export const PetApiFp = {
},
/**
* Find pet by ID
* Returns a pet when ID &lt; 10. ID &gt; 10 or nonintegers will simulate API error conditions
* @param petId ID of pet that needs to be fetched
* Returns a single pet
* @param petId ID of pet to return
*/
getPetById(params: { petId: number; }): (fetch: FetchAPI, basePath?: string) => Promise<Pet> {
const fetchArgs = PetApiFetchParamCreactor.getPetById(params);
getPetById(params: { petId: number; }, configuration: Configuration): (fetch: FetchAPI, basePath?: string) => Promise<Pet> {
const fetchArgs = PetApiFetchParamCreactor.getPetById(params, configuration);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
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
*/
updatePet(params: { body?: Pet; }): (fetch: FetchAPI, basePath?: string) => Promise<any> {
const fetchArgs = PetApiFetchParamCreactor.updatePet(params);
updatePet(params: { body: Pet; }, configuration: Configuration): (fetch: FetchAPI, basePath?: string) => Promise<any> {
const fetchArgs = PetApiFetchParamCreactor.updatePet(params, configuration);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
if (response.status >= 200 && response.status < 300) {
@ -421,8 +529,8 @@ export const PetApiFp = {
* @param name Updated name of the pet
* @param status Updated status of the pet
*/
updatePetWithForm(params: { petId: string; name?: string; status?: string; }): (fetch: FetchAPI, basePath?: string) => Promise<any> {
const fetchArgs = PetApiFetchParamCreactor.updatePetWithForm(params);
updatePetWithForm(params: { petId: number; name?: string; status?: string; }, configuration: Configuration): (fetch: FetchAPI, basePath?: string) => Promise<any> {
const fetchArgs = PetApiFetchParamCreactor.updatePetWithForm(params, configuration);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
if (response.status >= 200 && response.status < 300) {
@ -440,12 +548,12 @@ export const PetApiFp = {
* @param additionalMetadata Additional data to pass to server
* @param file file to upload
*/
uploadFile(params: { petId: number; additionalMetadata?: string; file?: any; }): (fetch: FetchAPI, basePath?: string) => Promise<any> {
const fetchArgs = PetApiFetchParamCreactor.uploadFile(params);
uploadFile(params: { petId: number; additionalMetadata?: string; file?: any; }, configuration: Configuration): (fetch: FetchAPI, basePath?: string) => Promise<ApiResponse> {
const fetchArgs = PetApiFetchParamCreactor.uploadFile(params, configuration);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
if (response.status >= 200 && response.status < 300) {
return response;
return response.json();
} else {
throw response;
}
@ -463,8 +571,8 @@ export class PetApi extends BaseAPI {
*
* @param body Pet object that needs to be added to the store
*/
addPet(params: { body?: Pet; }) {
return PetApiFp.addPet(params)(this.fetch, this.basePath);
addPet(params: { body: Pet; }) {
return PetApiFp.addPet(params, this.configuration)(this.fetch, this.basePath);
}
/**
* Deletes a pet
@ -473,39 +581,39 @@ export class PetApi extends BaseAPI {
* @param apiKey
*/
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
* Multiple status values can be provided with comma separated strings
* @param status Status values that need to be considered for filter
*/
findPetsByStatus(params: { status?: Array<string>; }) {
return PetApiFp.findPetsByStatus(params)(this.fetch, this.basePath);
findPetsByStatus(params: { status: Array<string>; }) {
return PetApiFp.findPetsByStatus(params, this.configuration)(this.fetch, this.basePath);
}
/**
* Finds Pets by tags
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
* @param tags Tags to filter by
*/
findPetsByTags(params: { tags?: Array<string>; }) {
return PetApiFp.findPetsByTags(params)(this.fetch, this.basePath);
findPetsByTags(params: { tags: Array<string>; }) {
return PetApiFp.findPetsByTags(params, this.configuration)(this.fetch, this.basePath);
}
/**
* Find pet by ID
* Returns a pet when ID &lt; 10. ID &gt; 10 or nonintegers will simulate API error conditions
* @param petId ID of pet that needs to be fetched
* Returns a single pet
* @param petId ID of pet to return
*/
getPetById(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
*
* @param body Pet object that needs to be added to the store
*/
updatePet(params: { body?: Pet; }) {
return PetApiFp.updatePet(params)(this.fetch, this.basePath);
updatePet(params: { body: Pet; }) {
return PetApiFp.updatePet(params, this.configuration)(this.fetch, this.basePath);
}
/**
* 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 status Updated status of the pet
*/
updatePetWithForm(params: { petId: string; name?: string; status?: string; }) {
return PetApiFp.updatePetWithForm(params)(this.fetch, this.basePath);
updatePetWithForm(params: { petId: number; name?: string; status?: string; }) {
return PetApiFp.updatePetWithForm(params, this.configuration)(this.fetch, this.basePath);
}
/**
* uploads an image
@ -525,7 +633,7 @@ export class PetApi extends BaseAPI {
* @param file file to upload
*/
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
*/
addPet(params: { body?: Pet; }) {
return PetApiFp.addPet(params)(fetch, basePath);
addPet(params: { body: Pet; }, configuration: Configuration) {
return PetApiFp.addPet(params, configuration)(fetch, basePath);
},
/**
* Deletes a pet
@ -548,40 +656,40 @@ export const PetApiFactory = function (fetch?: FetchAPI, basePath?: string) {
* @param petId Pet id to delete
* @param apiKey
*/
deletePet(params: { petId: number; apiKey?: string; }) {
return PetApiFp.deletePet(params)(fetch, basePath);
deletePet(params: { petId: number; apiKey?: string; }, configuration: Configuration) {
return PetApiFp.deletePet(params, configuration)(fetch, basePath);
},
/**
* Finds Pets by status
* Multiple status values can be provided with comma separated strings
* @param status Status values that need to be considered for filter
*/
findPetsByStatus(params: { status?: Array<string>; }) {
return PetApiFp.findPetsByStatus(params)(fetch, basePath);
findPetsByStatus(params: { status: Array<string>; }, configuration: Configuration) {
return PetApiFp.findPetsByStatus(params, configuration)(fetch, basePath);
},
/**
* Finds Pets by tags
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
* @param tags Tags to filter by
*/
findPetsByTags(params: { tags?: Array<string>; }) {
return PetApiFp.findPetsByTags(params)(fetch, basePath);
findPetsByTags(params: { tags: Array<string>; }, configuration: Configuration) {
return PetApiFp.findPetsByTags(params, configuration)(fetch, basePath);
},
/**
* Find pet by ID
* Returns a pet when ID &lt; 10. ID &gt; 10 or nonintegers will simulate API error conditions
* @param petId ID of pet that needs to be fetched
* Returns a single pet
* @param petId ID of pet to return
*/
getPetById(params: { petId: number; }) {
return PetApiFp.getPetById(params)(fetch, basePath);
getPetById(params: { petId: number; }, configuration: Configuration) {
return PetApiFp.getPetById(params, configuration)(fetch, basePath);
},
/**
* Update an existing pet
*
* @param body Pet object that needs to be added to the store
*/
updatePet(params: { body?: Pet; }) {
return PetApiFp.updatePet(params)(fetch, basePath);
updatePet(params: { body: Pet; }, configuration: Configuration) {
return PetApiFp.updatePet(params, configuration)(fetch, basePath);
},
/**
* 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 status Updated status of the pet
*/
updatePetWithForm(params: { petId: string; name?: string; status?: string; }) {
return PetApiFp.updatePetWithForm(params)(fetch, basePath);
updatePetWithForm(params: { petId: number; name?: string; status?: string; }, configuration: Configuration) {
return PetApiFp.updatePetWithForm(params, configuration)(fetch, basePath);
},
/**
* uploads an image
@ -600,8 +708,8 @@ export const PetApiFactory = function (fetch?: FetchAPI, basePath?: string) {
* @param additionalMetadata Additional data to pass to server
* @param file file to upload
*/
uploadFile(params: { petId: number; additionalMetadata?: string; file?: any; }) {
return PetApiFp.uploadFile(params)(fetch, basePath);
uploadFile(params: { petId: number; additionalMetadata?: string; file?: any; }, configuration: Configuration) {
return PetApiFp.uploadFile(params, configuration)(fetch, basePath);
},
}
};
@ -630,6 +738,7 @@ export const StoreApiFetchParamCreactor = {
if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader;
}
return {
url: url.format(urlObj),
options: fetchOptions,
@ -639,7 +748,7 @@ export const StoreApiFetchParamCreactor = {
* Returns pet inventories by status
* Returns a map of status codes to quantities
*/
getInventory(): FetchArgs {
getInventory(configuration: Configuration): FetchArgs {
const baseUrl = `/store/inventory`;
let urlObj = url.parse(baseUrl, true);
let fetchOptions: RequestInit = { method: "GET" };
@ -648,6 +757,13 @@ export const StoreApiFetchParamCreactor = {
if (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 {
url: url.format(urlObj),
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
* @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
if (params["orderId"] == null) {
throw new Error("Missing required parameter orderId when calling getOrderById");
@ -672,6 +788,7 @@ export const StoreApiFetchParamCreactor = {
if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader;
}
return {
url: url.format(urlObj),
options: fetchOptions,
@ -682,7 +799,11 @@ export const StoreApiFetchParamCreactor = {
*
* @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`;
let urlObj = url.parse(baseUrl, true);
let fetchOptions: RequestInit = { method: "POST" };
@ -695,6 +816,7 @@ export const StoreApiFetchParamCreactor = {
if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader;
}
return {
url: url.format(urlObj),
options: fetchOptions,
@ -727,8 +849,8 @@ export const StoreApiFp = {
* Returns pet inventories by status
* Returns a map of status codes to quantities
*/
getInventory(): (fetch: FetchAPI, basePath?: string) => Promise<{ [key: string]: number; }> {
const fetchArgs = StoreApiFetchParamCreactor.getInventory();
getInventory(configuration: Configuration): (fetch: FetchAPI, basePath?: string) => Promise<{ [key: string]: number; }> {
const fetchArgs = StoreApiFetchParamCreactor.getInventory(configuration);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
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
* @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);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
@ -761,7 +883,7 @@ export const StoreApiFp = {
*
* @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);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
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
*/
getInventory() {
return StoreApiFp.getInventory()(this.fetch, this.basePath);
return StoreApiFp.getInventory(this.configuration)(this.fetch, this.basePath);
}
/**
* Find purchase order by ID
* 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
*/
getOrderById(params: { orderId: string; }) {
getOrderById(params: { orderId: number; }) {
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
*/
placeOrder(params: { body?: Order; }) {
placeOrder(params: { body: Order; }) {
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 a map of status codes to quantities
*/
getInventory() {
return StoreApiFp.getInventory()(fetch, basePath);
getInventory(configuration: Configuration) {
return StoreApiFp.getInventory(configuration)(fetch, basePath);
},
/**
* Find purchase order by ID
* 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
*/
getOrderById(params: { orderId: string; }) {
getOrderById(params: { orderId: number; }) {
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
*/
placeOrder(params: { body?: Order; }) {
placeOrder(params: { body: Order; }) {
return StoreApiFp.placeOrder(params)(fetch, basePath);
},
}
@ -861,7 +983,11 @@ export const UserApiFetchParamCreactor = {
* This can only be done by the logged in user.
* @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`;
let urlObj = url.parse(baseUrl, true);
let fetchOptions: RequestInit = { method: "POST" };
@ -874,6 +1000,7 @@ export const UserApiFetchParamCreactor = {
if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader;
}
return {
url: url.format(urlObj),
options: fetchOptions,
@ -884,7 +1011,11 @@ export const UserApiFetchParamCreactor = {
*
* @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`;
let urlObj = url.parse(baseUrl, true);
let fetchOptions: RequestInit = { method: "POST" };
@ -897,6 +1028,7 @@ export const UserApiFetchParamCreactor = {
if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader;
}
return {
url: url.format(urlObj),
options: fetchOptions,
@ -907,7 +1039,11 @@ export const UserApiFetchParamCreactor = {
*
* @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`;
let urlObj = url.parse(baseUrl, true);
let fetchOptions: RequestInit = { method: "POST" };
@ -920,6 +1056,7 @@ export const UserApiFetchParamCreactor = {
if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader;
}
return {
url: url.format(urlObj),
options: fetchOptions,
@ -944,6 +1081,7 @@ export const UserApiFetchParamCreactor = {
if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader;
}
return {
url: url.format(urlObj),
options: fetchOptions,
@ -968,6 +1106,7 @@ export const UserApiFetchParamCreactor = {
if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader;
}
return {
url: url.format(urlObj),
options: fetchOptions,
@ -979,7 +1118,15 @@ export const UserApiFetchParamCreactor = {
* @param username The user name for login
* @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`;
let urlObj = url.parse(baseUrl, true);
urlObj.query = assign({}, urlObj.query, {
@ -992,6 +1139,7 @@ export const UserApiFetchParamCreactor = {
if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader;
}
return {
url: url.format(urlObj),
options: fetchOptions,
@ -1010,6 +1158,7 @@ export const UserApiFetchParamCreactor = {
if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader;
}
return {
url: url.format(urlObj),
options: fetchOptions,
@ -1021,11 +1170,15 @@ export const UserApiFetchParamCreactor = {
* @param username name that need to be deleted
* @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
if (params["username"] == null) {
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}`
.replace(`{${"username"}}`, `${ params.username }`);
let urlObj = url.parse(baseUrl, true);
@ -1039,6 +1192,7 @@ export const UserApiFetchParamCreactor = {
if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader;
}
return {
url: url.format(urlObj),
options: fetchOptions,
@ -1055,7 +1209,7 @@ export const UserApiFp = {
* This can only be done by the logged in user.
* @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);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
@ -1072,7 +1226,7 @@ export const UserApiFp = {
*
* @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);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
@ -1089,7 +1243,7 @@ export const UserApiFp = {
*
* @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);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
@ -1141,7 +1295,7 @@ export const UserApiFp = {
* @param username The user name for login
* @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);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
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 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);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
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.
* @param body Created user object
*/
createUser(params: { body?: User; }) {
createUser(params: { body: User; }) {
return UserApiFp.createUser(params)(this.fetch, this.basePath);
}
/**
@ -1206,7 +1360,7 @@ export class UserApi extends BaseAPI {
*
* @param body List of user object
*/
createUsersWithArrayInput(params: { body?: Array<User>; }) {
createUsersWithArrayInput(params: { body: Array<User>; }) {
return UserApiFp.createUsersWithArrayInput(params)(this.fetch, this.basePath);
}
/**
@ -1214,7 +1368,7 @@ export class UserApi extends BaseAPI {
*
* @param body List of user object
*/
createUsersWithListInput(params: { body?: Array<User>; }) {
createUsersWithListInput(params: { body: Array<User>; }) {
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 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);
}
/**
@ -1255,7 +1409,7 @@ export class UserApi extends BaseAPI {
* @param username name that need to be deleted
* @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);
}
};
@ -1270,7 +1424,7 @@ export const UserApiFactory = function (fetch?: FetchAPI, basePath?: string) {
* This can only be done by the logged in user.
* @param body Created user object
*/
createUser(params: { body?: User; }) {
createUser(params: { body: User; }) {
return UserApiFp.createUser(params)(fetch, basePath);
},
/**
@ -1278,7 +1432,7 @@ export const UserApiFactory = function (fetch?: FetchAPI, basePath?: string) {
*
* @param body List of user object
*/
createUsersWithArrayInput(params: { body?: Array<User>; }) {
createUsersWithArrayInput(params: { body: Array<User>; }) {
return UserApiFp.createUsersWithArrayInput(params)(fetch, basePath);
},
/**
@ -1286,7 +1440,7 @@ export const UserApiFactory = function (fetch?: FetchAPI, basePath?: string) {
*
* @param body List of user object
*/
createUsersWithListInput(params: { body?: Array<User>; }) {
createUsersWithListInput(params: { body: Array<User>; }) {
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 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);
},
/**
@ -1327,7 +1481,7 @@ export const UserApiFactory = function (fetch?: FetchAPI, basePath?: string) {
* @param username name that need to be deleted
* @param body Updated user object
*/
updateUser(params: { username: string; body?: User; }) {
updateUser(params: { username: string; body: User; }) {
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
* 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
* Contact: apiteam@wordnik.com
* Contact: apiteam@swagger.io
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
@ -27,6 +27,8 @@ import * as url from "url";
import * as isomorphicFetch from "isomorphic-fetch";
import { Configuration } from './configuration';
interface Dictionary<T> { [index: string]: T; }
export interface FetchAPI { (url: string, init?: any): Promise<any>; }
@ -40,18 +42,36 @@ export interface FetchArgs {
export class BaseAPI {
basePath: string;
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.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 {
"id"?: number;
"name"?: string;
}
/**
* An order for a pets from the pet store
*/
export interface Order {
"id"?: number;
"petId"?: number;
@ -65,6 +85,9 @@ export interface Order {
}
export type OrderStatusEnum = "placed" | "approved" | "delivered";
/**
* A pet for sale in the pet store
*/
export interface Pet {
"id"?: number;
"category"?: Category;
@ -78,11 +101,17 @@ export interface Pet {
}
export type PetStatusEnum = "available" | "pending" | "sold";
/**
* A tag for a pet
*/
export interface Tag {
"id"?: number;
"name"?: string;
}
/**
* A User who is purchasing from the pet store
*/
export interface User {
"id"?: number;
"username"?: string;
@ -108,7 +137,11 @@ export const PetApiFetchParamCreactor = {
*
* @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`;
let urlObj = url.parse(baseUrl, true);
let fetchOptions: RequestInit = { method: "POST" };
@ -121,6 +154,14 @@ export const PetApiFetchParamCreactor = {
if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader;
}
// authentication (petstore_auth) required
// oauth required
if (configuration.accessToken) {
fetchOptions.headers = Object.assign({
'Authorization': 'Bearer ' + configuration.accessToken,
}, contentTypeHeader);
}
return {
url: url.format(urlObj),
options: fetchOptions,
@ -132,7 +173,7 @@ export const PetApiFetchParamCreactor = {
* @param petId Pet id to delete
* @param apiKey
*/
deletePet(params: { petId: number; apiKey?: string; }): FetchArgs {
deletePet(params: { petId: number; apiKey?: string; }, configuration: Configuration): FetchArgs {
// verify required parameter "petId" is set
if (params["petId"] == null) {
throw new Error("Missing required parameter petId when calling deletePet");
@ -146,6 +187,14 @@ export const PetApiFetchParamCreactor = {
fetchOptions.headers = Object.assign({
"api_key": params.apiKey,
}, contentTypeHeader);
// authentication (petstore_auth) required
// oauth required
if (configuration.accessToken) {
fetchOptions.headers = Object.assign({
'Authorization': 'Bearer ' + configuration.accessToken,
}, contentTypeHeader);
}
return {
url: url.format(urlObj),
options: fetchOptions,
@ -156,7 +205,11 @@ export const PetApiFetchParamCreactor = {
* Multiple status values can be provided with comma separated strings
* @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`;
let urlObj = url.parse(baseUrl, true);
urlObj.query = Object.assign({}, urlObj.query, {
@ -168,6 +221,14 @@ export const PetApiFetchParamCreactor = {
if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader;
}
// authentication (petstore_auth) required
// oauth required
if (configuration.accessToken) {
fetchOptions.headers = Object.assign({
'Authorization': 'Bearer ' + configuration.accessToken,
}, contentTypeHeader);
}
return {
url: url.format(urlObj),
options: fetchOptions,
@ -178,7 +239,11 @@ export const PetApiFetchParamCreactor = {
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
* @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`;
let urlObj = url.parse(baseUrl, true);
urlObj.query = Object.assign({}, urlObj.query, {
@ -190,6 +255,14 @@ export const PetApiFetchParamCreactor = {
if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader;
}
// authentication (petstore_auth) required
// oauth required
if (configuration.accessToken) {
fetchOptions.headers = Object.assign({
'Authorization': 'Bearer ' + configuration.accessToken,
}, contentTypeHeader);
}
return {
url: url.format(urlObj),
options: fetchOptions,
@ -197,10 +270,10 @@ export const PetApiFetchParamCreactor = {
},
/**
* Find pet by ID
* Returns a pet when ID &lt; 10. ID &gt; 10 or nonintegers will simulate API error conditions
* @param petId ID of pet that needs to be fetched
* Returns a single pet
* @param petId ID of pet to return
*/
getPetById(params: { petId: number; }): FetchArgs {
getPetById(params: { petId: number; }, configuration: Configuration): FetchArgs {
// verify required parameter "petId" is set
if (params["petId"] == null) {
throw new Error("Missing required parameter petId when calling getPetById");
@ -214,6 +287,13 @@ export const PetApiFetchParamCreactor = {
if (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 {
url: url.format(urlObj),
options: fetchOptions,
@ -224,7 +304,11 @@ export const PetApiFetchParamCreactor = {
*
* @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`;
let urlObj = url.parse(baseUrl, true);
let fetchOptions: RequestInit = { method: "PUT" };
@ -237,6 +321,14 @@ export const PetApiFetchParamCreactor = {
if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader;
}
// authentication (petstore_auth) required
// oauth required
if (configuration.accessToken) {
fetchOptions.headers = Object.assign({
'Authorization': 'Bearer ' + configuration.accessToken,
}, contentTypeHeader);
}
return {
url: url.format(urlObj),
options: fetchOptions,
@ -249,7 +341,7 @@ export const PetApiFetchParamCreactor = {
* @param name Updated name 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
if (params["petId"] == null) {
throw new Error("Missing required parameter petId when calling updatePetWithForm");
@ -268,6 +360,14 @@ export const PetApiFetchParamCreactor = {
if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader;
}
// authentication (petstore_auth) required
// oauth required
if (configuration.accessToken) {
fetchOptions.headers = Object.assign({
'Authorization': 'Bearer ' + configuration.accessToken,
}, contentTypeHeader);
}
return {
url: url.format(urlObj),
options: fetchOptions,
@ -280,7 +380,7 @@ export const PetApiFetchParamCreactor = {
* @param additionalMetadata Additional data to pass to server
* @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
if (params["petId"] == null) {
throw new Error("Missing required parameter petId when calling uploadFile");
@ -299,6 +399,14 @@ export const PetApiFetchParamCreactor = {
if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader;
}
// authentication (petstore_auth) required
// oauth required
if (configuration.accessToken) {
fetchOptions.headers = Object.assign({
'Authorization': 'Bearer ' + configuration.accessToken,
}, contentTypeHeader);
}
return {
url: url.format(urlObj),
options: fetchOptions,
@ -315,8 +423,8 @@ export const PetApiFp = {
*
* @param body Pet object that needs to be added to the store
*/
addPet(params: { body?: Pet; }): (fetch: FetchAPI, basePath?: string) => Promise<any> {
const fetchArgs = PetApiFetchParamCreactor.addPet(params);
addPet(params: { body: Pet; }, configuration: Configuration): (fetch: FetchAPI, basePath?: string) => Promise<any> {
const fetchArgs = PetApiFetchParamCreactor.addPet(params, configuration);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
if (response.status >= 200 && response.status < 300) {
@ -333,8 +441,8 @@ export const PetApiFp = {
* @param petId Pet id to delete
* @param apiKey
*/
deletePet(params: { petId: number; apiKey?: string; }): (fetch: FetchAPI, basePath?: string) => Promise<any> {
const fetchArgs = PetApiFetchParamCreactor.deletePet(params);
deletePet(params: { petId: number; apiKey?: string; }, configuration: Configuration): (fetch: FetchAPI, basePath?: string) => Promise<any> {
const fetchArgs = PetApiFetchParamCreactor.deletePet(params, configuration);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
if (response.status >= 200 && response.status < 300) {
@ -350,8 +458,8 @@ export const PetApiFp = {
* Multiple status values can be provided with comma separated strings
* @param status Status values that need to be considered for filter
*/
findPetsByStatus(params: { status?: Array<string>; }): (fetch: FetchAPI, basePath?: string) => Promise<Array<Pet>> {
const fetchArgs = PetApiFetchParamCreactor.findPetsByStatus(params);
findPetsByStatus(params: { status: Array<string>; }, configuration: Configuration): (fetch: FetchAPI, basePath?: string) => Promise<Array<Pet>> {
const fetchArgs = PetApiFetchParamCreactor.findPetsByStatus(params, configuration);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
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.
* @param tags Tags to filter by
*/
findPetsByTags(params: { tags?: Array<string>; }): (fetch: FetchAPI, basePath?: string) => Promise<Array<Pet>> {
const fetchArgs = PetApiFetchParamCreactor.findPetsByTags(params);
findPetsByTags(params: { tags: Array<string>; }, configuration: Configuration): (fetch: FetchAPI, basePath?: string) => Promise<Array<Pet>> {
const fetchArgs = PetApiFetchParamCreactor.findPetsByTags(params, configuration);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
if (response.status >= 200 && response.status < 300) {
@ -381,11 +489,11 @@ export const PetApiFp = {
},
/**
* Find pet by ID
* Returns a pet when ID &lt; 10. ID &gt; 10 or nonintegers will simulate API error conditions
* @param petId ID of pet that needs to be fetched
* Returns a single pet
* @param petId ID of pet to return
*/
getPetById(params: { petId: number; }): (fetch: FetchAPI, basePath?: string) => Promise<Pet> {
const fetchArgs = PetApiFetchParamCreactor.getPetById(params);
getPetById(params: { petId: number; }, configuration: Configuration): (fetch: FetchAPI, basePath?: string) => Promise<Pet> {
const fetchArgs = PetApiFetchParamCreactor.getPetById(params, configuration);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
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
*/
updatePet(params: { body?: Pet; }): (fetch: FetchAPI, basePath?: string) => Promise<any> {
const fetchArgs = PetApiFetchParamCreactor.updatePet(params);
updatePet(params: { body: Pet; }, configuration: Configuration): (fetch: FetchAPI, basePath?: string) => Promise<any> {
const fetchArgs = PetApiFetchParamCreactor.updatePet(params, configuration);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
if (response.status >= 200 && response.status < 300) {
@ -420,8 +528,8 @@ export const PetApiFp = {
* @param name Updated name of the pet
* @param status Updated status of the pet
*/
updatePetWithForm(params: { petId: string; name?: string; status?: string; }): (fetch: FetchAPI, basePath?: string) => Promise<any> {
const fetchArgs = PetApiFetchParamCreactor.updatePetWithForm(params);
updatePetWithForm(params: { petId: number; name?: string; status?: string; }, configuration: Configuration): (fetch: FetchAPI, basePath?: string) => Promise<any> {
const fetchArgs = PetApiFetchParamCreactor.updatePetWithForm(params, configuration);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
if (response.status >= 200 && response.status < 300) {
@ -439,12 +547,12 @@ export const PetApiFp = {
* @param additionalMetadata Additional data to pass to server
* @param file file to upload
*/
uploadFile(params: { petId: number; additionalMetadata?: string; file?: any; }): (fetch: FetchAPI, basePath?: string) => Promise<any> {
const fetchArgs = PetApiFetchParamCreactor.uploadFile(params);
uploadFile(params: { petId: number; additionalMetadata?: string; file?: any; }, configuration: Configuration): (fetch: FetchAPI, basePath?: string) => Promise<ApiResponse> {
const fetchArgs = PetApiFetchParamCreactor.uploadFile(params, configuration);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
if (response.status >= 200 && response.status < 300) {
return response;
return response.json();
} else {
throw response;
}
@ -462,8 +570,8 @@ export class PetApi extends BaseAPI {
*
* @param body Pet object that needs to be added to the store
*/
addPet(params: { body?: Pet; }) {
return PetApiFp.addPet(params)(this.fetch, this.basePath);
addPet(params: { body: Pet; }) {
return PetApiFp.addPet(params, this.configuration)(this.fetch, this.basePath);
}
/**
* Deletes a pet
@ -472,39 +580,39 @@ export class PetApi extends BaseAPI {
* @param apiKey
*/
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
* Multiple status values can be provided with comma separated strings
* @param status Status values that need to be considered for filter
*/
findPetsByStatus(params: { status?: Array<string>; }) {
return PetApiFp.findPetsByStatus(params)(this.fetch, this.basePath);
findPetsByStatus(params: { status: Array<string>; }) {
return PetApiFp.findPetsByStatus(params, this.configuration)(this.fetch, this.basePath);
}
/**
* Finds Pets by tags
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
* @param tags Tags to filter by
*/
findPetsByTags(params: { tags?: Array<string>; }) {
return PetApiFp.findPetsByTags(params)(this.fetch, this.basePath);
findPetsByTags(params: { tags: Array<string>; }) {
return PetApiFp.findPetsByTags(params, this.configuration)(this.fetch, this.basePath);
}
/**
* Find pet by ID
* Returns a pet when ID &lt; 10. ID &gt; 10 or nonintegers will simulate API error conditions
* @param petId ID of pet that needs to be fetched
* Returns a single pet
* @param petId ID of pet to return
*/
getPetById(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
*
* @param body Pet object that needs to be added to the store
*/
updatePet(params: { body?: Pet; }) {
return PetApiFp.updatePet(params)(this.fetch, this.basePath);
updatePet(params: { body: Pet; }) {
return PetApiFp.updatePet(params, this.configuration)(this.fetch, this.basePath);
}
/**
* 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 status Updated status of the pet
*/
updatePetWithForm(params: { petId: string; name?: string; status?: string; }) {
return PetApiFp.updatePetWithForm(params)(this.fetch, this.basePath);
updatePetWithForm(params: { petId: number; name?: string; status?: string; }) {
return PetApiFp.updatePetWithForm(params, this.configuration)(this.fetch, this.basePath);
}
/**
* uploads an image
@ -524,7 +632,7 @@ export class PetApi extends BaseAPI {
* @param file file to upload
*/
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
*/
addPet(params: { body?: Pet; }) {
return PetApiFp.addPet(params)(fetch, basePath);
addPet(params: { body: Pet; }, configuration: Configuration) {
return PetApiFp.addPet(params, configuration)(fetch, basePath);
},
/**
* Deletes a pet
@ -547,40 +655,40 @@ export const PetApiFactory = function (fetch?: FetchAPI, basePath?: string) {
* @param petId Pet id to delete
* @param apiKey
*/
deletePet(params: { petId: number; apiKey?: string; }) {
return PetApiFp.deletePet(params)(fetch, basePath);
deletePet(params: { petId: number; apiKey?: string; }, configuration: Configuration) {
return PetApiFp.deletePet(params, configuration)(fetch, basePath);
},
/**
* Finds Pets by status
* Multiple status values can be provided with comma separated strings
* @param status Status values that need to be considered for filter
*/
findPetsByStatus(params: { status?: Array<string>; }) {
return PetApiFp.findPetsByStatus(params)(fetch, basePath);
findPetsByStatus(params: { status: Array<string>; }, configuration: Configuration) {
return PetApiFp.findPetsByStatus(params, configuration)(fetch, basePath);
},
/**
* Finds Pets by tags
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
* @param tags Tags to filter by
*/
findPetsByTags(params: { tags?: Array<string>; }) {
return PetApiFp.findPetsByTags(params)(fetch, basePath);
findPetsByTags(params: { tags: Array<string>; }, configuration: Configuration) {
return PetApiFp.findPetsByTags(params, configuration)(fetch, basePath);
},
/**
* Find pet by ID
* Returns a pet when ID &lt; 10. ID &gt; 10 or nonintegers will simulate API error conditions
* @param petId ID of pet that needs to be fetched
* Returns a single pet
* @param petId ID of pet to return
*/
getPetById(params: { petId: number; }) {
return PetApiFp.getPetById(params)(fetch, basePath);
getPetById(params: { petId: number; }, configuration: Configuration) {
return PetApiFp.getPetById(params, configuration)(fetch, basePath);
},
/**
* Update an existing pet
*
* @param body Pet object that needs to be added to the store
*/
updatePet(params: { body?: Pet; }) {
return PetApiFp.updatePet(params)(fetch, basePath);
updatePet(params: { body: Pet; }, configuration: Configuration) {
return PetApiFp.updatePet(params, configuration)(fetch, basePath);
},
/**
* 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 status Updated status of the pet
*/
updatePetWithForm(params: { petId: string; name?: string; status?: string; }) {
return PetApiFp.updatePetWithForm(params)(fetch, basePath);
updatePetWithForm(params: { petId: number; name?: string; status?: string; }, configuration: Configuration) {
return PetApiFp.updatePetWithForm(params, configuration)(fetch, basePath);
},
/**
* uploads an image
@ -599,8 +707,8 @@ export const PetApiFactory = function (fetch?: FetchAPI, basePath?: string) {
* @param additionalMetadata Additional data to pass to server
* @param file file to upload
*/
uploadFile(params: { petId: number; additionalMetadata?: string; file?: any; }) {
return PetApiFp.uploadFile(params)(fetch, basePath);
uploadFile(params: { petId: number; additionalMetadata?: string; file?: any; }, configuration: Configuration) {
return PetApiFp.uploadFile(params, configuration)(fetch, basePath);
},
}
};
@ -629,6 +737,7 @@ export const StoreApiFetchParamCreactor = {
if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader;
}
return {
url: url.format(urlObj),
options: fetchOptions,
@ -638,7 +747,7 @@ export const StoreApiFetchParamCreactor = {
* Returns pet inventories by status
* Returns a map of status codes to quantities
*/
getInventory(): FetchArgs {
getInventory(configuration: Configuration): FetchArgs {
const baseUrl = `/store/inventory`;
let urlObj = url.parse(baseUrl, true);
let fetchOptions: RequestInit = { method: "GET" };
@ -647,6 +756,13 @@ export const StoreApiFetchParamCreactor = {
if (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 {
url: url.format(urlObj),
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
* @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
if (params["orderId"] == null) {
throw new Error("Missing required parameter orderId when calling getOrderById");
@ -671,6 +787,7 @@ export const StoreApiFetchParamCreactor = {
if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader;
}
return {
url: url.format(urlObj),
options: fetchOptions,
@ -681,7 +798,11 @@ export const StoreApiFetchParamCreactor = {
*
* @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`;
let urlObj = url.parse(baseUrl, true);
let fetchOptions: RequestInit = { method: "POST" };
@ -694,6 +815,7 @@ export const StoreApiFetchParamCreactor = {
if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader;
}
return {
url: url.format(urlObj),
options: fetchOptions,
@ -726,8 +848,8 @@ export const StoreApiFp = {
* Returns pet inventories by status
* Returns a map of status codes to quantities
*/
getInventory(): (fetch: FetchAPI, basePath?: string) => Promise<{ [key: string]: number; }> {
const fetchArgs = StoreApiFetchParamCreactor.getInventory();
getInventory(configuration: Configuration): (fetch: FetchAPI, basePath?: string) => Promise<{ [key: string]: number; }> {
const fetchArgs = StoreApiFetchParamCreactor.getInventory(configuration);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
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
* @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);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
@ -760,7 +882,7 @@ export const StoreApiFp = {
*
* @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);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
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
*/
getInventory() {
return StoreApiFp.getInventory()(this.fetch, this.basePath);
return StoreApiFp.getInventory(this.configuration)(this.fetch, this.basePath);
}
/**
* Find purchase order by ID
* 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
*/
getOrderById(params: { orderId: string; }) {
getOrderById(params: { orderId: number; }) {
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
*/
placeOrder(params: { body?: Order; }) {
placeOrder(params: { body: Order; }) {
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 a map of status codes to quantities
*/
getInventory() {
return StoreApiFp.getInventory()(fetch, basePath);
getInventory(configuration: Configuration) {
return StoreApiFp.getInventory(configuration)(fetch, basePath);
},
/**
* Find purchase order by ID
* 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
*/
getOrderById(params: { orderId: string; }) {
getOrderById(params: { orderId: number; }) {
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
*/
placeOrder(params: { body?: Order; }) {
placeOrder(params: { body: Order; }) {
return StoreApiFp.placeOrder(params)(fetch, basePath);
},
}
@ -860,7 +982,11 @@ export const UserApiFetchParamCreactor = {
* This can only be done by the logged in user.
* @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`;
let urlObj = url.parse(baseUrl, true);
let fetchOptions: RequestInit = { method: "POST" };
@ -873,6 +999,7 @@ export const UserApiFetchParamCreactor = {
if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader;
}
return {
url: url.format(urlObj),
options: fetchOptions,
@ -883,7 +1010,11 @@ export const UserApiFetchParamCreactor = {
*
* @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`;
let urlObj = url.parse(baseUrl, true);
let fetchOptions: RequestInit = { method: "POST" };
@ -896,6 +1027,7 @@ export const UserApiFetchParamCreactor = {
if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader;
}
return {
url: url.format(urlObj),
options: fetchOptions,
@ -906,7 +1038,11 @@ export const UserApiFetchParamCreactor = {
*
* @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`;
let urlObj = url.parse(baseUrl, true);
let fetchOptions: RequestInit = { method: "POST" };
@ -919,6 +1055,7 @@ export const UserApiFetchParamCreactor = {
if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader;
}
return {
url: url.format(urlObj),
options: fetchOptions,
@ -943,6 +1080,7 @@ export const UserApiFetchParamCreactor = {
if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader;
}
return {
url: url.format(urlObj),
options: fetchOptions,
@ -967,6 +1105,7 @@ export const UserApiFetchParamCreactor = {
if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader;
}
return {
url: url.format(urlObj),
options: fetchOptions,
@ -978,7 +1117,15 @@ export const UserApiFetchParamCreactor = {
* @param username The user name for login
* @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`;
let urlObj = url.parse(baseUrl, true);
urlObj.query = Object.assign({}, urlObj.query, {
@ -991,6 +1138,7 @@ export const UserApiFetchParamCreactor = {
if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader;
}
return {
url: url.format(urlObj),
options: fetchOptions,
@ -1009,6 +1157,7 @@ export const UserApiFetchParamCreactor = {
if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader;
}
return {
url: url.format(urlObj),
options: fetchOptions,
@ -1020,11 +1169,15 @@ export const UserApiFetchParamCreactor = {
* @param username name that need to be deleted
* @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
if (params["username"] == null) {
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}`
.replace(`{${"username"}}`, `${ params.username }`);
let urlObj = url.parse(baseUrl, true);
@ -1038,6 +1191,7 @@ export const UserApiFetchParamCreactor = {
if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader;
}
return {
url: url.format(urlObj),
options: fetchOptions,
@ -1054,7 +1208,7 @@ export const UserApiFp = {
* This can only be done by the logged in user.
* @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);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
@ -1071,7 +1225,7 @@ export const UserApiFp = {
*
* @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);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
@ -1088,7 +1242,7 @@ export const UserApiFp = {
*
* @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);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
@ -1140,7 +1294,7 @@ export const UserApiFp = {
* @param username The user name for login
* @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);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
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 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);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
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.
* @param body Created user object
*/
createUser(params: { body?: User; }) {
createUser(params: { body: User; }) {
return UserApiFp.createUser(params)(this.fetch, this.basePath);
}
/**
@ -1205,7 +1359,7 @@ export class UserApi extends BaseAPI {
*
* @param body List of user object
*/
createUsersWithArrayInput(params: { body?: Array<User>; }) {
createUsersWithArrayInput(params: { body: Array<User>; }) {
return UserApiFp.createUsersWithArrayInput(params)(this.fetch, this.basePath);
}
/**
@ -1213,7 +1367,7 @@ export class UserApi extends BaseAPI {
*
* @param body List of user object
*/
createUsersWithListInput(params: { body?: Array<User>; }) {
createUsersWithListInput(params: { body: Array<User>; }) {
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 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);
}
/**
@ -1254,7 +1408,7 @@ export class UserApi extends BaseAPI {
* @param username name that need to be deleted
* @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);
}
};
@ -1269,7 +1423,7 @@ export const UserApiFactory = function (fetch?: FetchAPI, basePath?: string) {
* This can only be done by the logged in user.
* @param body Created user object
*/
createUser(params: { body?: User; }) {
createUser(params: { body: User; }) {
return UserApiFp.createUser(params)(fetch, basePath);
},
/**
@ -1277,7 +1431,7 @@ export const UserApiFactory = function (fetch?: FetchAPI, basePath?: string) {
*
* @param body List of user object
*/
createUsersWithArrayInput(params: { body?: Array<User>; }) {
createUsersWithArrayInput(params: { body: Array<User>; }) {
return UserApiFp.createUsersWithArrayInput(params)(fetch, basePath);
},
/**
@ -1285,7 +1439,7 @@ export const UserApiFactory = function (fetch?: FetchAPI, basePath?: string) {
*
* @param body List of user object
*/
createUsersWithListInput(params: { body?: Array<User>; }) {
createUsersWithListInput(params: { body: Array<User>; }) {
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 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);
},
/**
@ -1326,7 +1480,7 @@ export const UserApiFactory = function (fetch?: FetchAPI, basePath?: string) {
* @param username name that need to be deleted
* @param body Updated user object
*/
updateUser(params: { username: string; body?: User; }) {
updateUser(params: { username: string; body: User; }) {
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
* 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
* Contact: apiteam@wordnik.com
* Contact: apiteam@swagger.io
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
@ -28,6 +28,8 @@ import * as url from "url";
import * as isomorphicFetch from "isomorphic-fetch";
import * as assign from "core-js/library/fn/object/assign";
import { Configuration } from './configuration';
interface Dictionary<T> { [index: string]: T; }
export interface FetchAPI { (url: string, init?: any): Promise<any>; }
@ -41,18 +43,36 @@ export interface FetchArgs {
export class BaseAPI {
basePath: string;
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.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 {
"id"?: number;
"name"?: string;
}
/**
* An order for a pets from the pet store
*/
export interface Order {
"id"?: number;
"petId"?: number;
@ -66,6 +86,9 @@ export interface Order {
}
export type OrderStatusEnum = "placed" | "approved" | "delivered";
/**
* A pet for sale in the pet store
*/
export interface Pet {
"id"?: number;
"category"?: Category;
@ -79,11 +102,17 @@ export interface Pet {
}
export type PetStatusEnum = "available" | "pending" | "sold";
/**
* A tag for a pet
*/
export interface Tag {
"id"?: number;
"name"?: string;
}
/**
* A User who is purchasing from the pet store
*/
export interface User {
"id"?: number;
"username"?: string;
@ -109,7 +138,11 @@ export const PetApiFetchParamCreactor = {
*
* @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`;
let urlObj = url.parse(baseUrl, true);
let fetchOptions: RequestInit = { method: "POST" };
@ -122,6 +155,14 @@ export const PetApiFetchParamCreactor = {
if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader;
}
// authentication (petstore_auth) required
// oauth required
if (configuration.accessToken) {
fetchOptions.headers = assign({
'Authorization': 'Bearer ' + configuration.accessToken,
}, contentTypeHeader);
}
return {
url: url.format(urlObj),
options: fetchOptions,
@ -133,7 +174,7 @@ export const PetApiFetchParamCreactor = {
* @param petId Pet id to delete
* @param apiKey
*/
deletePet(params: { petId: number; apiKey?: string; }): FetchArgs {
deletePet(params: { petId: number; apiKey?: string; }, configuration: Configuration): FetchArgs {
// verify required parameter "petId" is set
if (params["petId"] == null) {
throw new Error("Missing required parameter petId when calling deletePet");
@ -147,6 +188,14 @@ export const PetApiFetchParamCreactor = {
fetchOptions.headers = assign({
"api_key": params.apiKey,
}, contentTypeHeader);
// authentication (petstore_auth) required
// oauth required
if (configuration.accessToken) {
fetchOptions.headers = assign({
'Authorization': 'Bearer ' + configuration.accessToken,
}, contentTypeHeader);
}
return {
url: url.format(urlObj),
options: fetchOptions,
@ -157,7 +206,11 @@ export const PetApiFetchParamCreactor = {
* Multiple status values can be provided with comma separated strings
* @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`;
let urlObj = url.parse(baseUrl, true);
urlObj.query = assign({}, urlObj.query, {
@ -169,6 +222,14 @@ export const PetApiFetchParamCreactor = {
if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader;
}
// authentication (petstore_auth) required
// oauth required
if (configuration.accessToken) {
fetchOptions.headers = assign({
'Authorization': 'Bearer ' + configuration.accessToken,
}, contentTypeHeader);
}
return {
url: url.format(urlObj),
options: fetchOptions,
@ -179,7 +240,11 @@ export const PetApiFetchParamCreactor = {
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
* @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`;
let urlObj = url.parse(baseUrl, true);
urlObj.query = assign({}, urlObj.query, {
@ -191,6 +256,14 @@ export const PetApiFetchParamCreactor = {
if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader;
}
// authentication (petstore_auth) required
// oauth required
if (configuration.accessToken) {
fetchOptions.headers = assign({
'Authorization': 'Bearer ' + configuration.accessToken,
}, contentTypeHeader);
}
return {
url: url.format(urlObj),
options: fetchOptions,
@ -198,10 +271,10 @@ export const PetApiFetchParamCreactor = {
},
/**
* Find pet by ID
* Returns a pet when ID &lt; 10. ID &gt; 10 or nonintegers will simulate API error conditions
* @param petId ID of pet that needs to be fetched
* Returns a single pet
* @param petId ID of pet to return
*/
getPetById(params: { petId: number; }): FetchArgs {
getPetById(params: { petId: number; }, configuration: Configuration): FetchArgs {
// verify required parameter "petId" is set
if (params["petId"] == null) {
throw new Error("Missing required parameter petId when calling getPetById");
@ -215,6 +288,13 @@ export const PetApiFetchParamCreactor = {
if (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 {
url: url.format(urlObj),
options: fetchOptions,
@ -225,7 +305,11 @@ export const PetApiFetchParamCreactor = {
*
* @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`;
let urlObj = url.parse(baseUrl, true);
let fetchOptions: RequestInit = { method: "PUT" };
@ -238,6 +322,14 @@ export const PetApiFetchParamCreactor = {
if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader;
}
// authentication (petstore_auth) required
// oauth required
if (configuration.accessToken) {
fetchOptions.headers = assign({
'Authorization': 'Bearer ' + configuration.accessToken,
}, contentTypeHeader);
}
return {
url: url.format(urlObj),
options: fetchOptions,
@ -250,7 +342,7 @@ export const PetApiFetchParamCreactor = {
* @param name Updated name 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
if (params["petId"] == null) {
throw new Error("Missing required parameter petId when calling updatePetWithForm");
@ -269,6 +361,14 @@ export const PetApiFetchParamCreactor = {
if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader;
}
// authentication (petstore_auth) required
// oauth required
if (configuration.accessToken) {
fetchOptions.headers = assign({
'Authorization': 'Bearer ' + configuration.accessToken,
}, contentTypeHeader);
}
return {
url: url.format(urlObj),
options: fetchOptions,
@ -281,7 +381,7 @@ export const PetApiFetchParamCreactor = {
* @param additionalMetadata Additional data to pass to server
* @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
if (params["petId"] == null) {
throw new Error("Missing required parameter petId when calling uploadFile");
@ -300,6 +400,14 @@ export const PetApiFetchParamCreactor = {
if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader;
}
// authentication (petstore_auth) required
// oauth required
if (configuration.accessToken) {
fetchOptions.headers = assign({
'Authorization': 'Bearer ' + configuration.accessToken,
}, contentTypeHeader);
}
return {
url: url.format(urlObj),
options: fetchOptions,
@ -316,8 +424,8 @@ export const PetApiFp = {
*
* @param body Pet object that needs to be added to the store
*/
addPet(params: { body?: Pet; }): (fetch: FetchAPI, basePath?: string) => Promise<any> {
const fetchArgs = PetApiFetchParamCreactor.addPet(params);
addPet(params: { body: Pet; }, configuration: Configuration): (fetch: FetchAPI, basePath?: string) => Promise<any> {
const fetchArgs = PetApiFetchParamCreactor.addPet(params, configuration);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
if (response.status >= 200 && response.status < 300) {
@ -334,8 +442,8 @@ export const PetApiFp = {
* @param petId Pet id to delete
* @param apiKey
*/
deletePet(params: { petId: number; apiKey?: string; }): (fetch: FetchAPI, basePath?: string) => Promise<any> {
const fetchArgs = PetApiFetchParamCreactor.deletePet(params);
deletePet(params: { petId: number; apiKey?: string; }, configuration: Configuration): (fetch: FetchAPI, basePath?: string) => Promise<any> {
const fetchArgs = PetApiFetchParamCreactor.deletePet(params, configuration);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
if (response.status >= 200 && response.status < 300) {
@ -351,8 +459,8 @@ export const PetApiFp = {
* Multiple status values can be provided with comma separated strings
* @param status Status values that need to be considered for filter
*/
findPetsByStatus(params: { status?: Array<string>; }): (fetch: FetchAPI, basePath?: string) => Promise<Array<Pet>> {
const fetchArgs = PetApiFetchParamCreactor.findPetsByStatus(params);
findPetsByStatus(params: { status: Array<string>; }, configuration: Configuration): (fetch: FetchAPI, basePath?: string) => Promise<Array<Pet>> {
const fetchArgs = PetApiFetchParamCreactor.findPetsByStatus(params, configuration);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
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.
* @param tags Tags to filter by
*/
findPetsByTags(params: { tags?: Array<string>; }): (fetch: FetchAPI, basePath?: string) => Promise<Array<Pet>> {
const fetchArgs = PetApiFetchParamCreactor.findPetsByTags(params);
findPetsByTags(params: { tags: Array<string>; }, configuration: Configuration): (fetch: FetchAPI, basePath?: string) => Promise<Array<Pet>> {
const fetchArgs = PetApiFetchParamCreactor.findPetsByTags(params, configuration);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
if (response.status >= 200 && response.status < 300) {
@ -382,11 +490,11 @@ export const PetApiFp = {
},
/**
* Find pet by ID
* Returns a pet when ID &lt; 10. ID &gt; 10 or nonintegers will simulate API error conditions
* @param petId ID of pet that needs to be fetched
* Returns a single pet
* @param petId ID of pet to return
*/
getPetById(params: { petId: number; }): (fetch: FetchAPI, basePath?: string) => Promise<Pet> {
const fetchArgs = PetApiFetchParamCreactor.getPetById(params);
getPetById(params: { petId: number; }, configuration: Configuration): (fetch: FetchAPI, basePath?: string) => Promise<Pet> {
const fetchArgs = PetApiFetchParamCreactor.getPetById(params, configuration);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
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
*/
updatePet(params: { body?: Pet; }): (fetch: FetchAPI, basePath?: string) => Promise<any> {
const fetchArgs = PetApiFetchParamCreactor.updatePet(params);
updatePet(params: { body: Pet; }, configuration: Configuration): (fetch: FetchAPI, basePath?: string) => Promise<any> {
const fetchArgs = PetApiFetchParamCreactor.updatePet(params, configuration);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
if (response.status >= 200 && response.status < 300) {
@ -421,8 +529,8 @@ export const PetApiFp = {
* @param name Updated name of the pet
* @param status Updated status of the pet
*/
updatePetWithForm(params: { petId: string; name?: string; status?: string; }): (fetch: FetchAPI, basePath?: string) => Promise<any> {
const fetchArgs = PetApiFetchParamCreactor.updatePetWithForm(params);
updatePetWithForm(params: { petId: number; name?: string; status?: string; }, configuration: Configuration): (fetch: FetchAPI, basePath?: string) => Promise<any> {
const fetchArgs = PetApiFetchParamCreactor.updatePetWithForm(params, configuration);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
if (response.status >= 200 && response.status < 300) {
@ -440,12 +548,12 @@ export const PetApiFp = {
* @param additionalMetadata Additional data to pass to server
* @param file file to upload
*/
uploadFile(params: { petId: number; additionalMetadata?: string; file?: any; }): (fetch: FetchAPI, basePath?: string) => Promise<any> {
const fetchArgs = PetApiFetchParamCreactor.uploadFile(params);
uploadFile(params: { petId: number; additionalMetadata?: string; file?: any; }, configuration: Configuration): (fetch: FetchAPI, basePath?: string) => Promise<ApiResponse> {
const fetchArgs = PetApiFetchParamCreactor.uploadFile(params, configuration);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
if (response.status >= 200 && response.status < 300) {
return response;
return response.json();
} else {
throw response;
}
@ -463,8 +571,8 @@ export class PetApi extends BaseAPI {
*
* @param body Pet object that needs to be added to the store
*/
addPet(params: { body?: Pet; }) {
return PetApiFp.addPet(params)(this.fetch, this.basePath);
addPet(params: { body: Pet; }) {
return PetApiFp.addPet(params, this.configuration)(this.fetch, this.basePath);
}
/**
* Deletes a pet
@ -473,39 +581,39 @@ export class PetApi extends BaseAPI {
* @param apiKey
*/
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
* Multiple status values can be provided with comma separated strings
* @param status Status values that need to be considered for filter
*/
findPetsByStatus(params: { status?: Array<string>; }) {
return PetApiFp.findPetsByStatus(params)(this.fetch, this.basePath);
findPetsByStatus(params: { status: Array<string>; }) {
return PetApiFp.findPetsByStatus(params, this.configuration)(this.fetch, this.basePath);
}
/**
* Finds Pets by tags
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
* @param tags Tags to filter by
*/
findPetsByTags(params: { tags?: Array<string>; }) {
return PetApiFp.findPetsByTags(params)(this.fetch, this.basePath);
findPetsByTags(params: { tags: Array<string>; }) {
return PetApiFp.findPetsByTags(params, this.configuration)(this.fetch, this.basePath);
}
/**
* Find pet by ID
* Returns a pet when ID &lt; 10. ID &gt; 10 or nonintegers will simulate API error conditions
* @param petId ID of pet that needs to be fetched
* Returns a single pet
* @param petId ID of pet to return
*/
getPetById(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
*
* @param body Pet object that needs to be added to the store
*/
updatePet(params: { body?: Pet; }) {
return PetApiFp.updatePet(params)(this.fetch, this.basePath);
updatePet(params: { body: Pet; }) {
return PetApiFp.updatePet(params, this.configuration)(this.fetch, this.basePath);
}
/**
* 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 status Updated status of the pet
*/
updatePetWithForm(params: { petId: string; name?: string; status?: string; }) {
return PetApiFp.updatePetWithForm(params)(this.fetch, this.basePath);
updatePetWithForm(params: { petId: number; name?: string; status?: string; }) {
return PetApiFp.updatePetWithForm(params, this.configuration)(this.fetch, this.basePath);
}
/**
* uploads an image
@ -525,7 +633,7 @@ export class PetApi extends BaseAPI {
* @param file file to upload
*/
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
*/
addPet(params: { body?: Pet; }) {
return PetApiFp.addPet(params)(fetch, basePath);
addPet(params: { body: Pet; }, configuration: Configuration) {
return PetApiFp.addPet(params, configuration)(fetch, basePath);
},
/**
* Deletes a pet
@ -548,40 +656,40 @@ export const PetApiFactory = function (fetch?: FetchAPI, basePath?: string) {
* @param petId Pet id to delete
* @param apiKey
*/
deletePet(params: { petId: number; apiKey?: string; }) {
return PetApiFp.deletePet(params)(fetch, basePath);
deletePet(params: { petId: number; apiKey?: string; }, configuration: Configuration) {
return PetApiFp.deletePet(params, configuration)(fetch, basePath);
},
/**
* Finds Pets by status
* Multiple status values can be provided with comma separated strings
* @param status Status values that need to be considered for filter
*/
findPetsByStatus(params: { status?: Array<string>; }) {
return PetApiFp.findPetsByStatus(params)(fetch, basePath);
findPetsByStatus(params: { status: Array<string>; }, configuration: Configuration) {
return PetApiFp.findPetsByStatus(params, configuration)(fetch, basePath);
},
/**
* Finds Pets by tags
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
* @param tags Tags to filter by
*/
findPetsByTags(params: { tags?: Array<string>; }) {
return PetApiFp.findPetsByTags(params)(fetch, basePath);
findPetsByTags(params: { tags: Array<string>; }, configuration: Configuration) {
return PetApiFp.findPetsByTags(params, configuration)(fetch, basePath);
},
/**
* Find pet by ID
* Returns a pet when ID &lt; 10. ID &gt; 10 or nonintegers will simulate API error conditions
* @param petId ID of pet that needs to be fetched
* Returns a single pet
* @param petId ID of pet to return
*/
getPetById(params: { petId: number; }) {
return PetApiFp.getPetById(params)(fetch, basePath);
getPetById(params: { petId: number; }, configuration: Configuration) {
return PetApiFp.getPetById(params, configuration)(fetch, basePath);
},
/**
* Update an existing pet
*
* @param body Pet object that needs to be added to the store
*/
updatePet(params: { body?: Pet; }) {
return PetApiFp.updatePet(params)(fetch, basePath);
updatePet(params: { body: Pet; }, configuration: Configuration) {
return PetApiFp.updatePet(params, configuration)(fetch, basePath);
},
/**
* 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 status Updated status of the pet
*/
updatePetWithForm(params: { petId: string; name?: string; status?: string; }) {
return PetApiFp.updatePetWithForm(params)(fetch, basePath);
updatePetWithForm(params: { petId: number; name?: string; status?: string; }, configuration: Configuration) {
return PetApiFp.updatePetWithForm(params, configuration)(fetch, basePath);
},
/**
* uploads an image
@ -600,8 +708,8 @@ export const PetApiFactory = function (fetch?: FetchAPI, basePath?: string) {
* @param additionalMetadata Additional data to pass to server
* @param file file to upload
*/
uploadFile(params: { petId: number; additionalMetadata?: string; file?: any; }) {
return PetApiFp.uploadFile(params)(fetch, basePath);
uploadFile(params: { petId: number; additionalMetadata?: string; file?: any; }, configuration: Configuration) {
return PetApiFp.uploadFile(params, configuration)(fetch, basePath);
},
}
};
@ -630,6 +738,7 @@ export const StoreApiFetchParamCreactor = {
if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader;
}
return {
url: url.format(urlObj),
options: fetchOptions,
@ -639,7 +748,7 @@ export const StoreApiFetchParamCreactor = {
* Returns pet inventories by status
* Returns a map of status codes to quantities
*/
getInventory(): FetchArgs {
getInventory(configuration: Configuration): FetchArgs {
const baseUrl = `/store/inventory`;
let urlObj = url.parse(baseUrl, true);
let fetchOptions: RequestInit = { method: "GET" };
@ -648,6 +757,13 @@ export const StoreApiFetchParamCreactor = {
if (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 {
url: url.format(urlObj),
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
* @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
if (params["orderId"] == null) {
throw new Error("Missing required parameter orderId when calling getOrderById");
@ -672,6 +788,7 @@ export const StoreApiFetchParamCreactor = {
if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader;
}
return {
url: url.format(urlObj),
options: fetchOptions,
@ -682,7 +799,11 @@ export const StoreApiFetchParamCreactor = {
*
* @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`;
let urlObj = url.parse(baseUrl, true);
let fetchOptions: RequestInit = { method: "POST" };
@ -695,6 +816,7 @@ export const StoreApiFetchParamCreactor = {
if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader;
}
return {
url: url.format(urlObj),
options: fetchOptions,
@ -727,8 +849,8 @@ export const StoreApiFp = {
* Returns pet inventories by status
* Returns a map of status codes to quantities
*/
getInventory(): (fetch: FetchAPI, basePath?: string) => Promise<{ [key: string]: number; }> {
const fetchArgs = StoreApiFetchParamCreactor.getInventory();
getInventory(configuration: Configuration): (fetch: FetchAPI, basePath?: string) => Promise<{ [key: string]: number; }> {
const fetchArgs = StoreApiFetchParamCreactor.getInventory(configuration);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
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
* @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);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
@ -761,7 +883,7 @@ export const StoreApiFp = {
*
* @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);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
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
*/
getInventory() {
return StoreApiFp.getInventory()(this.fetch, this.basePath);
return StoreApiFp.getInventory(this.configuration)(this.fetch, this.basePath);
}
/**
* Find purchase order by ID
* 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
*/
getOrderById(params: { orderId: string; }) {
getOrderById(params: { orderId: number; }) {
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
*/
placeOrder(params: { body?: Order; }) {
placeOrder(params: { body: Order; }) {
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 a map of status codes to quantities
*/
getInventory() {
return StoreApiFp.getInventory()(fetch, basePath);
getInventory(configuration: Configuration) {
return StoreApiFp.getInventory(configuration)(fetch, basePath);
},
/**
* Find purchase order by ID
* 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
*/
getOrderById(params: { orderId: string; }) {
getOrderById(params: { orderId: number; }) {
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
*/
placeOrder(params: { body?: Order; }) {
placeOrder(params: { body: Order; }) {
return StoreApiFp.placeOrder(params)(fetch, basePath);
},
}
@ -861,7 +983,11 @@ export const UserApiFetchParamCreactor = {
* This can only be done by the logged in user.
* @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`;
let urlObj = url.parse(baseUrl, true);
let fetchOptions: RequestInit = { method: "POST" };
@ -874,6 +1000,7 @@ export const UserApiFetchParamCreactor = {
if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader;
}
return {
url: url.format(urlObj),
options: fetchOptions,
@ -884,7 +1011,11 @@ export const UserApiFetchParamCreactor = {
*
* @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`;
let urlObj = url.parse(baseUrl, true);
let fetchOptions: RequestInit = { method: "POST" };
@ -897,6 +1028,7 @@ export const UserApiFetchParamCreactor = {
if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader;
}
return {
url: url.format(urlObj),
options: fetchOptions,
@ -907,7 +1039,11 @@ export const UserApiFetchParamCreactor = {
*
* @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`;
let urlObj = url.parse(baseUrl, true);
let fetchOptions: RequestInit = { method: "POST" };
@ -920,6 +1056,7 @@ export const UserApiFetchParamCreactor = {
if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader;
}
return {
url: url.format(urlObj),
options: fetchOptions,
@ -944,6 +1081,7 @@ export const UserApiFetchParamCreactor = {
if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader;
}
return {
url: url.format(urlObj),
options: fetchOptions,
@ -968,6 +1106,7 @@ export const UserApiFetchParamCreactor = {
if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader;
}
return {
url: url.format(urlObj),
options: fetchOptions,
@ -979,7 +1118,15 @@ export const UserApiFetchParamCreactor = {
* @param username The user name for login
* @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`;
let urlObj = url.parse(baseUrl, true);
urlObj.query = assign({}, urlObj.query, {
@ -992,6 +1139,7 @@ export const UserApiFetchParamCreactor = {
if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader;
}
return {
url: url.format(urlObj),
options: fetchOptions,
@ -1010,6 +1158,7 @@ export const UserApiFetchParamCreactor = {
if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader;
}
return {
url: url.format(urlObj),
options: fetchOptions,
@ -1021,11 +1170,15 @@ export const UserApiFetchParamCreactor = {
* @param username name that need to be deleted
* @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
if (params["username"] == null) {
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}`
.replace(`{${"username"}}`, `${ params.username }`);
let urlObj = url.parse(baseUrl, true);
@ -1039,6 +1192,7 @@ export const UserApiFetchParamCreactor = {
if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader;
}
return {
url: url.format(urlObj),
options: fetchOptions,
@ -1055,7 +1209,7 @@ export const UserApiFp = {
* This can only be done by the logged in user.
* @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);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
@ -1072,7 +1226,7 @@ export const UserApiFp = {
*
* @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);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
@ -1089,7 +1243,7 @@ export const UserApiFp = {
*
* @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);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
return fetch(basePath + fetchArgs.url, fetchArgs.options).then((response) => {
@ -1141,7 +1295,7 @@ export const UserApiFp = {
* @param username The user name for login
* @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);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
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 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);
return (fetch: FetchAPI = isomorphicFetch, basePath: string = BASE_PATH) => {
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.
* @param body Created user object
*/
createUser(params: { body?: User; }) {
createUser(params: { body: User; }) {
return UserApiFp.createUser(params)(this.fetch, this.basePath);
}
/**
@ -1206,7 +1360,7 @@ export class UserApi extends BaseAPI {
*
* @param body List of user object
*/
createUsersWithArrayInput(params: { body?: Array<User>; }) {
createUsersWithArrayInput(params: { body: Array<User>; }) {
return UserApiFp.createUsersWithArrayInput(params)(this.fetch, this.basePath);
}
/**
@ -1214,7 +1368,7 @@ export class UserApi extends BaseAPI {
*
* @param body List of user object
*/
createUsersWithListInput(params: { body?: Array<User>; }) {
createUsersWithListInput(params: { body: Array<User>; }) {
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 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);
}
/**
@ -1255,7 +1409,7 @@ export class UserApi extends BaseAPI {
* @param username name that need to be deleted
* @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);
}
};
@ -1270,7 +1424,7 @@ export const UserApiFactory = function (fetch?: FetchAPI, basePath?: string) {
* This can only be done by the logged in user.
* @param body Created user object
*/
createUser(params: { body?: User; }) {
createUser(params: { body: User; }) {
return UserApiFp.createUser(params)(fetch, basePath);
},
/**
@ -1278,7 +1432,7 @@ export const UserApiFactory = function (fetch?: FetchAPI, basePath?: string) {
*
* @param body List of user object
*/
createUsersWithArrayInput(params: { body?: Array<User>; }) {
createUsersWithArrayInput(params: { body: Array<User>; }) {
return UserApiFp.createUsersWithArrayInput(params)(fetch, basePath);
},
/**
@ -1286,7 +1440,7 @@ export const UserApiFactory = function (fetch?: FetchAPI, basePath?: string) {
*
* @param body List of user object
*/
createUsersWithListInput(params: { body?: Array<User>; }) {
createUsersWithListInput(params: { body: Array<User>; }) {
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 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);
},
/**
@ -1327,7 +1481,7 @@ export const UserApiFactory = function (fetch?: FetchAPI, basePath?: string) {
* @param username name that need to be deleted
* @param body Updated user object
*/
updateUser(params: { username: string; body?: User; }) {
updateUser(params: { username: string; body: User; }) {
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 {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', () => {
let fixture: Pet = createTestFixture();
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', () => {
return PetApiFactory().getPetById({ petId: fixture.id }).then((result) => {
return PetApiFactory().getPetById({ petId: fixture.id }, config).then((result) => {
return expect(result).to.deep.equal(fixture);
});
});
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';
return PetApiFactory().updatePet({ body: result }).then(() => {
return PetApiFactory().getPetById({ petId: fixture.id }).then( (result) => {
return PetApiFactory().updatePet({ body: result }, config).then(() => {
return PetApiFactory().getPetById({ petId: fixture.id }, config).then( (result) => {
return expect(result.name).to.deep.equal('newname');
});
});
@ -27,11 +40,11 @@ describe('PetApiFactory', () => {
});
it('should delete Pet', () => {
return PetApiFactory().deletePet({ petId: fixture.id });
return PetApiFactory().deletePet({ petId: fixture.id }, config);
});
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;
}, (err) => {
return expect(err).to.exist;

View File

@ -1,9 +1,22 @@
import {expect} from 'chai';
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() {
it('should get inventory', function() {
return StoreApiFactory().getInventory().then((result) => {
return StoreApiFactory().getInventory(config).then((result) => {
expect(Object.keys(result)).to.not.be.empty;
});
});