mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-05-12 12:40:53 +00:00
[typescript] Support esbuild, second attempt (#11465)
* Install correct typings for url-parse * Use es modules compat mode when es6 output is selected * Consolidate typescript sample generation naming scheme * Regenerate samples * Create new typescript sample to test esmodules in browser * Expose RequiredError type * Make browser integration tests pass locally * Remove cookie tests, because we don’t allow cross-origin cookies * Add output type to package definition * Execute new browser tests in pipeline * Install headless chromium dependencies in circle ci
This commit is contained in:
parent
edfb3e123f
commit
510f79989a
@ -15,6 +15,15 @@ commands: # a reusable command with parameters
|
|||||||
- source-v2-
|
- source-v2-
|
||||||
# Machine Setup
|
# Machine Setup
|
||||||
# If you break your build into multiple jobs with workflows, you will probably want to do the parts of this that are relevant in each
|
# If you break your build into multiple jobs with workflows, you will probably want to do the parts of this that are relevant in each
|
||||||
|
- run:
|
||||||
|
name: Install Headless Chrome dependencies
|
||||||
|
command: |
|
||||||
|
sudo apt-get update && sudo apt-get install -yq \
|
||||||
|
gconf-service libasound2 libatk1.0-0 libatk-bridge2.0-0 libc6 libcairo2 libcups2 libdbus-1-3 \
|
||||||
|
libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 \
|
||||||
|
libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 \
|
||||||
|
libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates \
|
||||||
|
fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget libgbm1
|
||||||
# The following `checkout` command checks out your code to your working directory. In 1.0 we did this implicitly. In 2.0 you can choose where in the course of a job your code should be checked out.
|
# The following `checkout` command checks out your code to your working directory. In 1.0 we did this implicitly. In 2.0 you can choose where in the course of a job your code should be checked out.
|
||||||
- checkout
|
- checkout
|
||||||
# Prepare for artifact and test results collection equivalent to how it was done on 1.0.
|
# Prepare for artifact and test results collection equivalent to how it was done on 1.0.
|
||||||
|
10
bin/configs/typescript-consolidated-browser.yaml
Normal file
10
bin/configs/typescript-consolidated-browser.yaml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
generatorName: typescript
|
||||||
|
outputDir: samples/openapi3/client/petstore/typescript/builds/browser
|
||||||
|
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
|
||||||
|
templateDir: modules/openapi-generator/src/main/resources/typescript
|
||||||
|
additionalProperties:
|
||||||
|
framework: fetch-api
|
||||||
|
npmName: ts-petstore-client
|
||||||
|
projectName: ts-petstore-client
|
||||||
|
moduleName: petstore
|
||||||
|
supportsES6: true
|
@ -4,7 +4,7 @@ import {Configuration} from '../configuration{{extensionForDeno}}';
|
|||||||
import {RequestContext, HttpMethod, ResponseContext, HttpFile} from '../http/http{{extensionForDeno}}';
|
import {RequestContext, HttpMethod, ResponseContext, HttpFile} from '../http/http{{extensionForDeno}}';
|
||||||
{{#platforms}}
|
{{#platforms}}
|
||||||
{{#node}}
|
{{#node}}
|
||||||
import * as FormData from "form-data";
|
import {{^supportsES6}}* as{{/supportsES6}} FormData from "form-data";
|
||||||
import { URLSearchParams } from 'url';
|
import { URLSearchParams } from 'url';
|
||||||
{{/node}}
|
{{/node}}
|
||||||
{{/platforms}}
|
{{/platforms}}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
// typings for btoa are incorrect
|
|
||||||
{{#platforms}}
|
{{#platforms}}
|
||||||
{{#node}}
|
{{#node}}
|
||||||
|
// typings for btoa are incorrect
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
import * as btoa from "btoa";
|
import {{^supportsES6}}* as{{/supportsES6}} btoa from "btoa";
|
||||||
{{/node}}
|
{{/node}}
|
||||||
{{/platforms}}
|
{{/platforms}}
|
||||||
import { RequestContext } from "../http/http{{extensionForDeno}}";
|
import { RequestContext } from "../http/http{{extensionForDeno}}";
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{{#platforms}}
|
{{#platforms}}
|
||||||
{{#node}}
|
{{#node}}
|
||||||
// TODO: evaluate if we can easily get rid of this library
|
// TODO: evaluate if we can easily get rid of this library
|
||||||
import * as FormData from "form-data";
|
import {{^supportsES6}}* as{{/supportsES6}} FormData from "form-data";
|
||||||
import { URLSearchParams } from 'url';
|
import { URLSearchParams } from 'url';
|
||||||
import * as http from 'http';
|
import * as http from 'http';
|
||||||
import * as https from 'https';
|
import * as https from 'https';
|
||||||
@ -9,9 +9,7 @@ import * as https from 'https';
|
|||||||
{{/platforms}}
|
{{/platforms}}
|
||||||
{{#platforms}}
|
{{#platforms}}
|
||||||
{{^deno}}
|
{{^deno}}
|
||||||
// typings of url-parse are incorrect...
|
import {{^supportsES6}}* as{{/supportsES6}} URLParse from "url-parse";
|
||||||
// @ts-ignore
|
|
||||||
import * as URLParse from "url-parse";
|
|
||||||
{{/deno}}
|
{{/deno}}
|
||||||
{{/platforms}}
|
{{/platforms}}
|
||||||
import { Observable, from } from {{#useRxJS}}'rxjs'{{/useRxJS}}{{^useRxJS}}'../rxjsStub{{extensionForDeno}}'{{/useRxJS}};
|
import { Observable, from } from {{#useRxJS}}'rxjs'{{/useRxJS}}{{^useRxJS}}'../rxjsStub{{extensionForDeno}}'{{/useRxJS}};
|
||||||
|
@ -5,6 +5,7 @@ export { createConfiguration } from "./configuration{{extensionForDeno}}"
|
|||||||
export{{#platforms}}{{#deno}} type{{/deno}}{{/platforms}} { Configuration } from "./configuration{{extensionForDeno}}"
|
export{{#platforms}}{{#deno}} type{{/deno}}{{/platforms}} { Configuration } from "./configuration{{extensionForDeno}}"
|
||||||
export * from "./apis/exception{{extensionForDeno}}";
|
export * from "./apis/exception{{extensionForDeno}}";
|
||||||
export * from "./servers{{extensionForDeno}}";
|
export * from "./servers{{extensionForDeno}}";
|
||||||
|
export { RequiredError } from "./apis/baseapi{{extensionForDeno}}";
|
||||||
|
|
||||||
{{#useRxJS}}
|
{{#useRxJS}}
|
||||||
export { Middleware } from './middleware{{extensionForDeno}}';
|
export { Middleware } from './middleware{{extensionForDeno}}';
|
||||||
|
@ -11,6 +11,16 @@
|
|||||||
],
|
],
|
||||||
"license": "Unlicense",
|
"license": "Unlicense",
|
||||||
"main": "./dist/index.js",
|
"main": "./dist/index.js",
|
||||||
|
{{#supportsES6}}
|
||||||
|
"type": "module",
|
||||||
|
"module": "./dist/index.js",
|
||||||
|
{{/supportsES6}}
|
||||||
|
{{^supportsES6}}
|
||||||
|
"type": "commonjs",
|
||||||
|
{{/supportsES6}}
|
||||||
|
"exports": {
|
||||||
|
".": "./dist/index.js"
|
||||||
|
},
|
||||||
"typings": "./dist/index.d.ts",
|
"typings": "./dist/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsc",
|
"build": "tsc",
|
||||||
@ -51,7 +61,8 @@
|
|||||||
"url-parse": "^1.4.3"
|
"url-parse": "^1.4.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"typescript": "^3.9.3"
|
"typescript": "^3.9.3",
|
||||||
|
"@types/url-parse": "1.4.4"
|
||||||
}{{#npmRepository}},{{/npmRepository}}
|
}{{#npmRepository}},{{/npmRepository}}
|
||||||
{{#npmRepository}}
|
{{#npmRepository}}
|
||||||
"publishConfig":{
|
"publishConfig":{
|
||||||
|
@ -2,8 +2,13 @@
|
|||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"strict": true,
|
"strict": true,
|
||||||
/* Basic Options */
|
/* Basic Options */
|
||||||
"target": "{{#supportsES6}}es6{{/supportsES6}}{{^supportsES6}}es5{{/supportsES6}}",
|
{{#supportsES6}}
|
||||||
"module": "{{#supportsES6}}es6{{/supportsES6}}{{^supportsES6}}commonjs{{/supportsES6}}",
|
"target": "es6",
|
||||||
|
"esModuleInterop": true,
|
||||||
|
{{/supportsES6}}
|
||||||
|
{{^supportsES6}}
|
||||||
|
"target": "es5",
|
||||||
|
{{/supportsES6}}
|
||||||
"moduleResolution": "node",
|
"moduleResolution": "node",
|
||||||
"declaration": true,
|
"declaration": true,
|
||||||
|
|
||||||
|
14
pom.xml
14
pom.xml
@ -924,6 +924,18 @@
|
|||||||
<module>samples/openapi3/client/petstore/typescript/tests/jquery</module>
|
<module>samples/openapi3/client/petstore/typescript/tests/jquery</module>
|
||||||
</modules>
|
</modules>
|
||||||
</profile>
|
</profile>
|
||||||
|
<profile>
|
||||||
|
<id>typescript-client-tests-browser</id>
|
||||||
|
<activation>
|
||||||
|
<property>
|
||||||
|
<name>env</name>
|
||||||
|
<value>java</value>
|
||||||
|
</property>
|
||||||
|
</activation>
|
||||||
|
<modules>
|
||||||
|
<module>samples/openapi3/client/petstore/typescript/tests/browser</module>
|
||||||
|
</modules>
|
||||||
|
</profile>
|
||||||
<profile>
|
<profile>
|
||||||
<id>typescript-fetch-client-tests-default</id>
|
<id>typescript-fetch-client-tests-default</id>
|
||||||
<activation>
|
<activation>
|
||||||
@ -1205,6 +1217,8 @@
|
|||||||
<!-- comment out due to failure in travis ci
|
<!-- comment out due to failure in travis ci
|
||||||
<module>samples/openapi3/client/petstore/typescript/tests/inversify</module>
|
<module>samples/openapi3/client/petstore/typescript/tests/inversify</module>
|
||||||
<module>samples/openapi3/client/petstore/typescript/tests/deno</module>-->
|
<module>samples/openapi3/client/petstore/typescript/tests/deno</module>-->
|
||||||
|
<module>samples/openapi3/client/petstore/typescript/builds/browser</module>
|
||||||
|
<module>samples/openapi3/client/petstore/typescript/tests/browser</module>
|
||||||
<module>samples/client/petstore/typescript-fetch/builds/default</module>
|
<module>samples/client/petstore/typescript-fetch/builds/default</module>
|
||||||
<module>samples/client/petstore/typescript-fetch/builds/es6-target</module>
|
<module>samples/client/petstore/typescript-fetch/builds/es6-target</module>
|
||||||
<module>samples/client/petstore/typescript-fetch/builds/with-npm-version</module>
|
<module>samples/client/petstore/typescript-fetch/builds/with-npm-version</module>
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
// typings for btoa are incorrect
|
|
||||||
import { RequestContext } from "../http/http";
|
import { RequestContext } from "../http/http";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// typings of url-parse are incorrect...
|
|
||||||
// @ts-ignore
|
|
||||||
import * as URLParse from "url-parse";
|
import * as URLParse from "url-parse";
|
||||||
import { Observable, from } from '../rxjsStub';
|
import { Observable, from } from '../rxjsStub';
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ export { createConfiguration } from "./configuration"
|
|||||||
export { Configuration } from "./configuration"
|
export { Configuration } from "./configuration"
|
||||||
export * from "./apis/exception";
|
export * from "./apis/exception";
|
||||||
export * from "./servers";
|
export * from "./servers";
|
||||||
|
export { RequiredError } from "./apis/baseapi";
|
||||||
|
|
||||||
export { PromiseMiddleware as Middleware } from './middleware';
|
export { PromiseMiddleware as Middleware } from './middleware';
|
||||||
export { PromiseDefaultApi as DefaultApi } from './types/PromiseAPI';
|
export { PromiseDefaultApi as DefaultApi } from './types/PromiseAPI';
|
||||||
|
@ -11,6 +11,10 @@
|
|||||||
],
|
],
|
||||||
"license": "Unlicense",
|
"license": "Unlicense",
|
||||||
"main": "./dist/index.js",
|
"main": "./dist/index.js",
|
||||||
|
"type": "commonjs",
|
||||||
|
"exports": {
|
||||||
|
".": "./dist/index.js"
|
||||||
|
},
|
||||||
"typings": "./dist/index.d.ts",
|
"typings": "./dist/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsc",
|
"build": "tsc",
|
||||||
@ -22,6 +26,7 @@
|
|||||||
"url-parse": "^1.4.3"
|
"url-parse": "^1.4.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"typescript": "^3.9.3"
|
"typescript": "^3.9.3",
|
||||||
|
"@types/url-parse": "1.4.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
"strict": true,
|
"strict": true,
|
||||||
/* Basic Options */
|
/* Basic Options */
|
||||||
"target": "es5",
|
"target": "es5",
|
||||||
"module": "commonjs",
|
|
||||||
"moduleResolution": "node",
|
"moduleResolution": "node",
|
||||||
"declaration": true,
|
"declaration": true,
|
||||||
|
|
||||||
|
1
samples/openapi3/client/petstore/typescript/builds/browser/.gitignore
vendored
Normal file
1
samples/openapi3/client/petstore/typescript/builds/browser/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
dist
|
@ -0,0 +1,23 @@
|
|||||||
|
# OpenAPI Generator Ignore
|
||||||
|
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
|
||||||
|
|
||||||
|
# Use this file to prevent files from being overwritten by the generator.
|
||||||
|
# The patterns follow closely to .gitignore or .dockerignore.
|
||||||
|
|
||||||
|
# As an example, the C# client generator defines ApiClient.cs.
|
||||||
|
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
|
||||||
|
#ApiClient.cs
|
||||||
|
|
||||||
|
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
|
||||||
|
#foo/*/qux
|
||||||
|
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
|
||||||
|
|
||||||
|
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
|
||||||
|
#foo/**/qux
|
||||||
|
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
|
||||||
|
|
||||||
|
# You can also negate patterns with an exclamation (!).
|
||||||
|
# For example, you can ignore all files in a docs folder with the file extension .md:
|
||||||
|
#docs/*.md
|
||||||
|
# Then explicitly reverse the ignore rule for a single file:
|
||||||
|
#!docs/README.md
|
@ -0,0 +1,33 @@
|
|||||||
|
.gitignore
|
||||||
|
PetApi.md
|
||||||
|
README.md
|
||||||
|
StoreApi.md
|
||||||
|
UserApi.md
|
||||||
|
apis/PetApi.ts
|
||||||
|
apis/StoreApi.ts
|
||||||
|
apis/UserApi.ts
|
||||||
|
apis/baseapi.ts
|
||||||
|
apis/exception.ts
|
||||||
|
auth/auth.ts
|
||||||
|
configuration.ts
|
||||||
|
git_push.sh
|
||||||
|
http/http.ts
|
||||||
|
http/isomorphic-fetch.ts
|
||||||
|
index.ts
|
||||||
|
middleware.ts
|
||||||
|
models/ApiResponse.ts
|
||||||
|
models/Category.ts
|
||||||
|
models/ObjectSerializer.ts
|
||||||
|
models/Order.ts
|
||||||
|
models/Pet.ts
|
||||||
|
models/Tag.ts
|
||||||
|
models/User.ts
|
||||||
|
models/all.ts
|
||||||
|
package.json
|
||||||
|
rxjsStub.ts
|
||||||
|
servers.ts
|
||||||
|
tsconfig.json
|
||||||
|
types/ObjectParamAPI.ts
|
||||||
|
types/ObservableAPI.ts
|
||||||
|
types/PromiseAPI.ts
|
||||||
|
util.ts
|
@ -0,0 +1 @@
|
|||||||
|
6.0.0-SNAPSHOT
|
@ -0,0 +1,510 @@
|
|||||||
|
# petstore.PetApi
|
||||||
|
|
||||||
|
All URIs are relative to *http://petstore.swagger.io/v2*
|
||||||
|
|
||||||
|
Method | HTTP request | Description
|
||||||
|
------------- | ------------- | -------------
|
||||||
|
[**addPet**](PetApi.md#addPet) | **POST** /pet | Add a new pet to the store
|
||||||
|
[**deletePet**](PetApi.md#deletePet) | **DELETE** /pet/{petId} | Deletes a pet
|
||||||
|
[**findPetsByStatus**](PetApi.md#findPetsByStatus) | **GET** /pet/findByStatus | Finds Pets by status
|
||||||
|
[**findPetsByTags**](PetApi.md#findPetsByTags) | **GET** /pet/findByTags | Finds Pets by tags
|
||||||
|
[**getPetById**](PetApi.md#getPetById) | **GET** /pet/{petId} | Find pet by ID
|
||||||
|
[**updatePet**](PetApi.md#updatePet) | **PUT** /pet | Update an existing pet
|
||||||
|
[**updatePetWithForm**](PetApi.md#updatePetWithForm) | **POST** /pet/{petId} | Updates a pet in the store with form data
|
||||||
|
[**uploadFile**](PetApi.md#uploadFile) | **POST** /pet/{petId}/uploadImage | uploads an image
|
||||||
|
|
||||||
|
|
||||||
|
# **addPet**
|
||||||
|
> Pet addPet(pet)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### Example
|
||||||
|
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import { petstore } from 'ts-petstore-client';
|
||||||
|
import * as fs from 'fs';
|
||||||
|
|
||||||
|
const configuration = petstore.createConfiguration();
|
||||||
|
const apiInstance = new petstore.PetApi(configuration);
|
||||||
|
|
||||||
|
let body:petstore.PetApiAddPetRequest = {
|
||||||
|
// Pet | Pet object that needs to be added to the store
|
||||||
|
pet: {
|
||||||
|
id: 1,
|
||||||
|
category: {
|
||||||
|
id: 1,
|
||||||
|
name: "CbUUGjjNSwg0_bs9ZayIMrKdgNvb6gvxmPb9GcsM61ate1RA89q3w1l4eH4XxEz.5awLMdeXylwK0lMGUSM4jsrh4dstlnQUN5vVdMLPA",
|
||||||
|
},
|
||||||
|
name: "doggie",
|
||||||
|
photoUrls: [
|
||||||
|
"photoUrls_example",
|
||||||
|
],
|
||||||
|
tags: [
|
||||||
|
{
|
||||||
|
id: 1,
|
||||||
|
name: "name_example",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
status: "available",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
apiInstance.addPet(body).then((data:any) => {
|
||||||
|
console.log('API called successfully. Returned data: ' + data);
|
||||||
|
}).catch((error:any) => console.error(error));
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------- | ------------- | ------------- | -------------
|
||||||
|
**pet** | **Pet**| Pet object that needs to be added to the store |
|
||||||
|
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
**Pet**
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
[petstore_auth](README.md#petstore_auth)
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: application/json, application/xml
|
||||||
|
- **Accept**: application/xml, application/json
|
||||||
|
|
||||||
|
|
||||||
|
### HTTP response details
|
||||||
|
| Status code | Description | Response headers |
|
||||||
|
|-------------|-------------|------------------|
|
||||||
|
**200** | successful operation | - |
|
||||||
|
**405** | Invalid input | - |
|
||||||
|
|
||||||
|
[[Back to top]](#) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to Model list]](README.md#documentation-for-models) [[Back to README]](README.md)
|
||||||
|
|
||||||
|
# **deletePet**
|
||||||
|
> deletePet()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### Example
|
||||||
|
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import { petstore } from 'ts-petstore-client';
|
||||||
|
import * as fs from 'fs';
|
||||||
|
|
||||||
|
const configuration = petstore.createConfiguration();
|
||||||
|
const apiInstance = new petstore.PetApi(configuration);
|
||||||
|
|
||||||
|
let body:petstore.PetApiDeletePetRequest = {
|
||||||
|
// number | Pet id to delete
|
||||||
|
petId: 1,
|
||||||
|
// string (optional)
|
||||||
|
apiKey: "api_key_example",
|
||||||
|
};
|
||||||
|
|
||||||
|
apiInstance.deletePet(body).then((data:any) => {
|
||||||
|
console.log('API called successfully. Returned data: ' + data);
|
||||||
|
}).catch((error:any) => console.error(error));
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------- | ------------- | ------------- | -------------
|
||||||
|
**petId** | [**number**] | Pet id to delete | defaults to undefined
|
||||||
|
**apiKey** | [**string**] | | (optional) defaults to undefined
|
||||||
|
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
void (empty response body)
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
[petstore_auth](README.md#petstore_auth)
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: Not defined
|
||||||
|
- **Accept**: Not defined
|
||||||
|
|
||||||
|
|
||||||
|
### HTTP response details
|
||||||
|
| Status code | Description | Response headers |
|
||||||
|
|-------------|-------------|------------------|
|
||||||
|
**400** | Invalid pet value | - |
|
||||||
|
|
||||||
|
[[Back to top]](#) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to Model list]](README.md#documentation-for-models) [[Back to README]](README.md)
|
||||||
|
|
||||||
|
# **findPetsByStatus**
|
||||||
|
> Array<Pet> findPetsByStatus()
|
||||||
|
|
||||||
|
Multiple status values can be provided with comma separated strings
|
||||||
|
|
||||||
|
### Example
|
||||||
|
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import { petstore } from 'ts-petstore-client';
|
||||||
|
import * as fs from 'fs';
|
||||||
|
|
||||||
|
const configuration = petstore.createConfiguration();
|
||||||
|
const apiInstance = new petstore.PetApi(configuration);
|
||||||
|
|
||||||
|
let body:petstore.PetApiFindPetsByStatusRequest = {
|
||||||
|
// Array<'available' | 'pending' | 'sold'> | Status values that need to be considered for filter
|
||||||
|
status: [
|
||||||
|
"available",
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
apiInstance.findPetsByStatus(body).then((data:any) => {
|
||||||
|
console.log('API called successfully. Returned data: ' + data);
|
||||||
|
}).catch((error:any) => console.error(error));
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------- | ------------- | ------------- | -------------
|
||||||
|
**status** | **Array<'available' | 'pending' | 'sold'>** | Status values that need to be considered for filter | defaults to undefined
|
||||||
|
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
**Array<Pet>**
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
[petstore_auth](README.md#petstore_auth)
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: Not defined
|
||||||
|
- **Accept**: application/xml, application/json
|
||||||
|
|
||||||
|
|
||||||
|
### HTTP response details
|
||||||
|
| Status code | Description | Response headers |
|
||||||
|
|-------------|-------------|------------------|
|
||||||
|
**200** | successful operation | - |
|
||||||
|
**400** | Invalid status value | - |
|
||||||
|
|
||||||
|
[[Back to top]](#) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to Model list]](README.md#documentation-for-models) [[Back to README]](README.md)
|
||||||
|
|
||||||
|
# **findPetsByTags**
|
||||||
|
> Array<Pet> findPetsByTags()
|
||||||
|
|
||||||
|
Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
||||||
|
|
||||||
|
### Example
|
||||||
|
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import { petstore } from 'ts-petstore-client';
|
||||||
|
import * as fs from 'fs';
|
||||||
|
|
||||||
|
const configuration = petstore.createConfiguration();
|
||||||
|
const apiInstance = new petstore.PetApi(configuration);
|
||||||
|
|
||||||
|
let body:petstore.PetApiFindPetsByTagsRequest = {
|
||||||
|
// Array<string> | Tags to filter by
|
||||||
|
tags: [
|
||||||
|
"tags_example",
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
apiInstance.findPetsByTags(body).then((data:any) => {
|
||||||
|
console.log('API called successfully. Returned data: ' + data);
|
||||||
|
}).catch((error:any) => console.error(error));
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------- | ------------- | ------------- | -------------
|
||||||
|
**tags** | **Array<string>** | Tags to filter by | defaults to undefined
|
||||||
|
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
**Array<Pet>**
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
[petstore_auth](README.md#petstore_auth)
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: Not defined
|
||||||
|
- **Accept**: application/xml, application/json
|
||||||
|
|
||||||
|
|
||||||
|
### HTTP response details
|
||||||
|
| Status code | Description | Response headers |
|
||||||
|
|-------------|-------------|------------------|
|
||||||
|
**200** | successful operation | - |
|
||||||
|
**400** | Invalid tag value | - |
|
||||||
|
|
||||||
|
[[Back to top]](#) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to Model list]](README.md#documentation-for-models) [[Back to README]](README.md)
|
||||||
|
|
||||||
|
# **getPetById**
|
||||||
|
> Pet getPetById()
|
||||||
|
|
||||||
|
Returns a single pet
|
||||||
|
|
||||||
|
### Example
|
||||||
|
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import { petstore } from 'ts-petstore-client';
|
||||||
|
import * as fs from 'fs';
|
||||||
|
|
||||||
|
const configuration = petstore.createConfiguration();
|
||||||
|
const apiInstance = new petstore.PetApi(configuration);
|
||||||
|
|
||||||
|
let body:petstore.PetApiGetPetByIdRequest = {
|
||||||
|
// number | ID of pet to return
|
||||||
|
petId: 1,
|
||||||
|
};
|
||||||
|
|
||||||
|
apiInstance.getPetById(body).then((data:any) => {
|
||||||
|
console.log('API called successfully. Returned data: ' + data);
|
||||||
|
}).catch((error:any) => console.error(error));
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------- | ------------- | ------------- | -------------
|
||||||
|
**petId** | [**number**] | ID of pet to return | defaults to undefined
|
||||||
|
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
**Pet**
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
[api_key](README.md#api_key)
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: Not defined
|
||||||
|
- **Accept**: application/xml, application/json
|
||||||
|
|
||||||
|
|
||||||
|
### HTTP response details
|
||||||
|
| Status code | Description | Response headers |
|
||||||
|
|-------------|-------------|------------------|
|
||||||
|
**200** | successful operation | - |
|
||||||
|
**400** | Invalid ID supplied | - |
|
||||||
|
**404** | Pet not found | - |
|
||||||
|
|
||||||
|
[[Back to top]](#) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to Model list]](README.md#documentation-for-models) [[Back to README]](README.md)
|
||||||
|
|
||||||
|
# **updatePet**
|
||||||
|
> Pet updatePet(pet)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### Example
|
||||||
|
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import { petstore } from 'ts-petstore-client';
|
||||||
|
import * as fs from 'fs';
|
||||||
|
|
||||||
|
const configuration = petstore.createConfiguration();
|
||||||
|
const apiInstance = new petstore.PetApi(configuration);
|
||||||
|
|
||||||
|
let body:petstore.PetApiUpdatePetRequest = {
|
||||||
|
// Pet | Pet object that needs to be added to the store
|
||||||
|
pet: {
|
||||||
|
id: 1,
|
||||||
|
category: {
|
||||||
|
id: 1,
|
||||||
|
name: "CbUUGjjNSwg0_bs9ZayIMrKdgNvb6gvxmPb9GcsM61ate1RA89q3w1l4eH4XxEz.5awLMdeXylwK0lMGUSM4jsrh4dstlnQUN5vVdMLPA",
|
||||||
|
},
|
||||||
|
name: "doggie",
|
||||||
|
photoUrls: [
|
||||||
|
"photoUrls_example",
|
||||||
|
],
|
||||||
|
tags: [
|
||||||
|
{
|
||||||
|
id: 1,
|
||||||
|
name: "name_example",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
status: "available",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
apiInstance.updatePet(body).then((data:any) => {
|
||||||
|
console.log('API called successfully. Returned data: ' + data);
|
||||||
|
}).catch((error:any) => console.error(error));
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------- | ------------- | ------------- | -------------
|
||||||
|
**pet** | **Pet**| Pet object that needs to be added to the store |
|
||||||
|
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
**Pet**
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
[petstore_auth](README.md#petstore_auth)
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: application/json, application/xml
|
||||||
|
- **Accept**: application/xml, application/json
|
||||||
|
|
||||||
|
|
||||||
|
### HTTP response details
|
||||||
|
| Status code | Description | Response headers |
|
||||||
|
|-------------|-------------|------------------|
|
||||||
|
**200** | successful operation | - |
|
||||||
|
**400** | Invalid ID supplied | - |
|
||||||
|
**404** | Pet not found | - |
|
||||||
|
**405** | Validation exception | - |
|
||||||
|
|
||||||
|
[[Back to top]](#) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to Model list]](README.md#documentation-for-models) [[Back to README]](README.md)
|
||||||
|
|
||||||
|
# **updatePetWithForm**
|
||||||
|
> updatePetWithForm()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### Example
|
||||||
|
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import { petstore } from 'ts-petstore-client';
|
||||||
|
import * as fs from 'fs';
|
||||||
|
|
||||||
|
const configuration = petstore.createConfiguration();
|
||||||
|
const apiInstance = new petstore.PetApi(configuration);
|
||||||
|
|
||||||
|
let body:petstore.PetApiUpdatePetWithFormRequest = {
|
||||||
|
// number | ID of pet that needs to be updated
|
||||||
|
petId: 1,
|
||||||
|
// string | Updated name of the pet (optional)
|
||||||
|
name: "name_example",
|
||||||
|
// string | Updated status of the pet (optional)
|
||||||
|
status: "status_example",
|
||||||
|
};
|
||||||
|
|
||||||
|
apiInstance.updatePetWithForm(body).then((data:any) => {
|
||||||
|
console.log('API called successfully. Returned data: ' + data);
|
||||||
|
}).catch((error:any) => console.error(error));
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------- | ------------- | ------------- | -------------
|
||||||
|
**petId** | [**number**] | ID of pet that needs to be updated | defaults to undefined
|
||||||
|
**name** | [**string**] | Updated name of the pet | (optional) defaults to undefined
|
||||||
|
**status** | [**string**] | Updated status of the pet | (optional) defaults to undefined
|
||||||
|
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
void (empty response body)
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
[petstore_auth](README.md#petstore_auth)
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: application/x-www-form-urlencoded
|
||||||
|
- **Accept**: Not defined
|
||||||
|
|
||||||
|
|
||||||
|
### HTTP response details
|
||||||
|
| Status code | Description | Response headers |
|
||||||
|
|-------------|-------------|------------------|
|
||||||
|
**405** | Invalid input | - |
|
||||||
|
|
||||||
|
[[Back to top]](#) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to Model list]](README.md#documentation-for-models) [[Back to README]](README.md)
|
||||||
|
|
||||||
|
# **uploadFile**
|
||||||
|
> ApiResponse uploadFile()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### Example
|
||||||
|
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import { petstore } from 'ts-petstore-client';
|
||||||
|
import * as fs from 'fs';
|
||||||
|
|
||||||
|
const configuration = petstore.createConfiguration();
|
||||||
|
const apiInstance = new petstore.PetApi(configuration);
|
||||||
|
|
||||||
|
let body:petstore.PetApiUploadFileRequest = {
|
||||||
|
// number | ID of pet to update
|
||||||
|
petId: 1,
|
||||||
|
// string | Additional data to pass to server (optional)
|
||||||
|
additionalMetadata: "additionalMetadata_example",
|
||||||
|
// HttpFile | file to upload (optional)
|
||||||
|
file: { data: Buffer.from(fs.readFileSync('/path/to/file', 'utf-8')), name: '/path/to/file' },
|
||||||
|
};
|
||||||
|
|
||||||
|
apiInstance.uploadFile(body).then((data:any) => {
|
||||||
|
console.log('API called successfully. Returned data: ' + data);
|
||||||
|
}).catch((error:any) => console.error(error));
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------- | ------------- | ------------- | -------------
|
||||||
|
**petId** | [**number**] | ID of pet to update | defaults to undefined
|
||||||
|
**additionalMetadata** | [**string**] | Additional data to pass to server | (optional) defaults to undefined
|
||||||
|
**file** | [**HttpFile**] | file to upload | (optional) defaults to undefined
|
||||||
|
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
**ApiResponse**
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
[petstore_auth](README.md#petstore_auth)
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: multipart/form-data
|
||||||
|
- **Accept**: application/json
|
||||||
|
|
||||||
|
|
||||||
|
### HTTP response details
|
||||||
|
| Status code | Description | Response headers |
|
||||||
|
|-------------|-------------|------------------|
|
||||||
|
**200** | successful operation | - |
|
||||||
|
|
||||||
|
[[Back to top]](#) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to Model list]](README.md#documentation-for-models) [[Back to README]](README.md)
|
||||||
|
|
||||||
|
|
@ -0,0 +1,30 @@
|
|||||||
|
## ts-petstore-client@1.0.0
|
||||||
|
|
||||||
|
This generator creates TypeScript/JavaScript client that utilizes fetch-api.
|
||||||
|
|
||||||
|
### Building
|
||||||
|
|
||||||
|
To build and compile the typescript sources to javascript use:
|
||||||
|
```
|
||||||
|
npm install
|
||||||
|
npm run build
|
||||||
|
```
|
||||||
|
|
||||||
|
### Publishing
|
||||||
|
|
||||||
|
First build the package then run ```npm publish```
|
||||||
|
|
||||||
|
### Consuming
|
||||||
|
|
||||||
|
navigate to the folder of your consuming project and run one of the following commands.
|
||||||
|
|
||||||
|
_published:_
|
||||||
|
|
||||||
|
```
|
||||||
|
npm install ts-petstore-client@1.0.0 --save
|
||||||
|
```
|
||||||
|
|
||||||
|
_unPublished (not recommended):_
|
||||||
|
|
||||||
|
```
|
||||||
|
npm install PATH_TO_GENERATED_PACKAGE --save
|
@ -0,0 +1,234 @@
|
|||||||
|
# petstore.StoreApi
|
||||||
|
|
||||||
|
All URIs are relative to *http://petstore.swagger.io/v2*
|
||||||
|
|
||||||
|
Method | HTTP request | Description
|
||||||
|
------------- | ------------- | -------------
|
||||||
|
[**deleteOrder**](StoreApi.md#deleteOrder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID
|
||||||
|
[**getInventory**](StoreApi.md#getInventory) | **GET** /store/inventory | Returns pet inventories by status
|
||||||
|
[**getOrderById**](StoreApi.md#getOrderById) | **GET** /store/order/{orderId} | Find purchase order by ID
|
||||||
|
[**placeOrder**](StoreApi.md#placeOrder) | **POST** /store/order | Place an order for a pet
|
||||||
|
|
||||||
|
|
||||||
|
# **deleteOrder**
|
||||||
|
> deleteOrder()
|
||||||
|
|
||||||
|
For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||||
|
|
||||||
|
### Example
|
||||||
|
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import { petstore } from 'ts-petstore-client';
|
||||||
|
import * as fs from 'fs';
|
||||||
|
|
||||||
|
const configuration = petstore.createConfiguration();
|
||||||
|
const apiInstance = new petstore.StoreApi(configuration);
|
||||||
|
|
||||||
|
let body:petstore.StoreApiDeleteOrderRequest = {
|
||||||
|
// string | ID of the order that needs to be deleted
|
||||||
|
orderId: "orderId_example",
|
||||||
|
};
|
||||||
|
|
||||||
|
apiInstance.deleteOrder(body).then((data:any) => {
|
||||||
|
console.log('API called successfully. Returned data: ' + data);
|
||||||
|
}).catch((error:any) => console.error(error));
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------- | ------------- | ------------- | -------------
|
||||||
|
**orderId** | [**string**] | ID of the order that needs to be deleted | defaults to undefined
|
||||||
|
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
void (empty response body)
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
No authorization required
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: Not defined
|
||||||
|
- **Accept**: Not defined
|
||||||
|
|
||||||
|
|
||||||
|
### HTTP response details
|
||||||
|
| Status code | Description | Response headers |
|
||||||
|
|-------------|-------------|------------------|
|
||||||
|
**400** | Invalid ID supplied | - |
|
||||||
|
**404** | Order not found | - |
|
||||||
|
|
||||||
|
[[Back to top]](#) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to Model list]](README.md#documentation-for-models) [[Back to README]](README.md)
|
||||||
|
|
||||||
|
# **getInventory**
|
||||||
|
> { [key: string]: number; } getInventory()
|
||||||
|
|
||||||
|
Returns a map of status codes to quantities
|
||||||
|
|
||||||
|
### Example
|
||||||
|
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import { petstore } from 'ts-petstore-client';
|
||||||
|
import * as fs from 'fs';
|
||||||
|
|
||||||
|
const configuration = petstore.createConfiguration();
|
||||||
|
const apiInstance = new petstore.StoreApi(configuration);
|
||||||
|
|
||||||
|
let body:any = {};
|
||||||
|
|
||||||
|
apiInstance.getInventory(body).then((data:any) => {
|
||||||
|
console.log('API called successfully. Returned data: ' + data);
|
||||||
|
}).catch((error:any) => console.error(error));
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
This endpoint does not need any parameter.
|
||||||
|
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
**{ [key: string]: number; }**
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
[api_key](README.md#api_key)
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: Not defined
|
||||||
|
- **Accept**: application/json
|
||||||
|
|
||||||
|
|
||||||
|
### HTTP response details
|
||||||
|
| Status code | Description | Response headers |
|
||||||
|
|-------------|-------------|------------------|
|
||||||
|
**200** | successful operation | - |
|
||||||
|
|
||||||
|
[[Back to top]](#) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to Model list]](README.md#documentation-for-models) [[Back to README]](README.md)
|
||||||
|
|
||||||
|
# **getOrderById**
|
||||||
|
> Order getOrderById()
|
||||||
|
|
||||||
|
For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||||
|
|
||||||
|
### Example
|
||||||
|
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import { petstore } from 'ts-petstore-client';
|
||||||
|
import * as fs from 'fs';
|
||||||
|
|
||||||
|
const configuration = petstore.createConfiguration();
|
||||||
|
const apiInstance = new petstore.StoreApi(configuration);
|
||||||
|
|
||||||
|
let body:petstore.StoreApiGetOrderByIdRequest = {
|
||||||
|
// number | ID of pet that needs to be fetched
|
||||||
|
orderId: 1,
|
||||||
|
};
|
||||||
|
|
||||||
|
apiInstance.getOrderById(body).then((data:any) => {
|
||||||
|
console.log('API called successfully. Returned data: ' + data);
|
||||||
|
}).catch((error:any) => console.error(error));
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------- | ------------- | ------------- | -------------
|
||||||
|
**orderId** | [**number**] | ID of pet that needs to be fetched | defaults to undefined
|
||||||
|
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
**Order**
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
No authorization required
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: Not defined
|
||||||
|
- **Accept**: application/xml, application/json
|
||||||
|
|
||||||
|
|
||||||
|
### HTTP response details
|
||||||
|
| Status code | Description | Response headers |
|
||||||
|
|-------------|-------------|------------------|
|
||||||
|
**200** | successful operation | - |
|
||||||
|
**400** | Invalid ID supplied | - |
|
||||||
|
**404** | Order not found | - |
|
||||||
|
|
||||||
|
[[Back to top]](#) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to Model list]](README.md#documentation-for-models) [[Back to README]](README.md)
|
||||||
|
|
||||||
|
# **placeOrder**
|
||||||
|
> Order placeOrder(order)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### Example
|
||||||
|
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import { petstore } from 'ts-petstore-client';
|
||||||
|
import * as fs from 'fs';
|
||||||
|
|
||||||
|
const configuration = petstore.createConfiguration();
|
||||||
|
const apiInstance = new petstore.StoreApi(configuration);
|
||||||
|
|
||||||
|
let body:petstore.StoreApiPlaceOrderRequest = {
|
||||||
|
// Order | order placed for purchasing the pet
|
||||||
|
order: {
|
||||||
|
id: 1,
|
||||||
|
petId: 1,
|
||||||
|
quantity: 1,
|
||||||
|
shipDate: new Date('1970-01-01T00:00:00.00Z'),
|
||||||
|
status: "placed",
|
||||||
|
complete: false,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
apiInstance.placeOrder(body).then((data:any) => {
|
||||||
|
console.log('API called successfully. Returned data: ' + data);
|
||||||
|
}).catch((error:any) => console.error(error));
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------- | ------------- | ------------- | -------------
|
||||||
|
**order** | **Order**| order placed for purchasing the pet |
|
||||||
|
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
**Order**
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
No authorization required
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: application/json
|
||||||
|
- **Accept**: application/xml, application/json
|
||||||
|
|
||||||
|
|
||||||
|
### HTTP response details
|
||||||
|
| Status code | Description | Response headers |
|
||||||
|
|-------------|-------------|------------------|
|
||||||
|
**200** | successful operation | - |
|
||||||
|
**400** | Invalid Order | - |
|
||||||
|
|
||||||
|
[[Back to top]](#) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to Model list]](README.md#documentation-for-models) [[Back to README]](README.md)
|
||||||
|
|
||||||
|
|
@ -0,0 +1,494 @@
|
|||||||
|
# petstore.UserApi
|
||||||
|
|
||||||
|
All URIs are relative to *http://petstore.swagger.io/v2*
|
||||||
|
|
||||||
|
Method | HTTP request | Description
|
||||||
|
------------- | ------------- | -------------
|
||||||
|
[**createUser**](UserApi.md#createUser) | **POST** /user | Create user
|
||||||
|
[**createUsersWithArrayInput**](UserApi.md#createUsersWithArrayInput) | **POST** /user/createWithArray | Creates list of users with given input array
|
||||||
|
[**createUsersWithListInput**](UserApi.md#createUsersWithListInput) | **POST** /user/createWithList | Creates list of users with given input array
|
||||||
|
[**deleteUser**](UserApi.md#deleteUser) | **DELETE** /user/{username} | Delete user
|
||||||
|
[**getUserByName**](UserApi.md#getUserByName) | **GET** /user/{username} | Get user by user name
|
||||||
|
[**loginUser**](UserApi.md#loginUser) | **GET** /user/login | Logs user into the system
|
||||||
|
[**logoutUser**](UserApi.md#logoutUser) | **GET** /user/logout | Logs out current logged in user session
|
||||||
|
[**updateUser**](UserApi.md#updateUser) | **PUT** /user/{username} | Updated user
|
||||||
|
|
||||||
|
|
||||||
|
# **createUser**
|
||||||
|
> createUser(user)
|
||||||
|
|
||||||
|
This can only be done by the logged in user.
|
||||||
|
|
||||||
|
### Example
|
||||||
|
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import { petstore } from 'ts-petstore-client';
|
||||||
|
import * as fs from 'fs';
|
||||||
|
|
||||||
|
const configuration = petstore.createConfiguration();
|
||||||
|
const apiInstance = new petstore.UserApi(configuration);
|
||||||
|
|
||||||
|
let body:petstore.UserApiCreateUserRequest = {
|
||||||
|
// User | Created user object
|
||||||
|
user: {
|
||||||
|
id: 1,
|
||||||
|
username: "username_example",
|
||||||
|
firstName: "firstName_example",
|
||||||
|
lastName: "lastName_example",
|
||||||
|
email: "email_example",
|
||||||
|
password: "password_example",
|
||||||
|
phone: "phone_example",
|
||||||
|
userStatus: 1,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
apiInstance.createUser(body).then((data:any) => {
|
||||||
|
console.log('API called successfully. Returned data: ' + data);
|
||||||
|
}).catch((error:any) => console.error(error));
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------- | ------------- | ------------- | -------------
|
||||||
|
**user** | **User**| Created user object |
|
||||||
|
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
void (empty response body)
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
[api_key](README.md#api_key)
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: application/json
|
||||||
|
- **Accept**: Not defined
|
||||||
|
|
||||||
|
|
||||||
|
### HTTP response details
|
||||||
|
| Status code | Description | Response headers |
|
||||||
|
|-------------|-------------|------------------|
|
||||||
|
**0** | successful operation | - |
|
||||||
|
|
||||||
|
[[Back to top]](#) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to Model list]](README.md#documentation-for-models) [[Back to README]](README.md)
|
||||||
|
|
||||||
|
# **createUsersWithArrayInput**
|
||||||
|
> createUsersWithArrayInput(user)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### Example
|
||||||
|
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import { petstore } from 'ts-petstore-client';
|
||||||
|
import * as fs from 'fs';
|
||||||
|
|
||||||
|
const configuration = petstore.createConfiguration();
|
||||||
|
const apiInstance = new petstore.UserApi(configuration);
|
||||||
|
|
||||||
|
let body:petstore.UserApiCreateUsersWithArrayInputRequest = {
|
||||||
|
// Array<User> | List of user object
|
||||||
|
user: [
|
||||||
|
{
|
||||||
|
id: 1,
|
||||||
|
username: "username_example",
|
||||||
|
firstName: "firstName_example",
|
||||||
|
lastName: "lastName_example",
|
||||||
|
email: "email_example",
|
||||||
|
password: "password_example",
|
||||||
|
phone: "phone_example",
|
||||||
|
userStatus: 1,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
apiInstance.createUsersWithArrayInput(body).then((data:any) => {
|
||||||
|
console.log('API called successfully. Returned data: ' + data);
|
||||||
|
}).catch((error:any) => console.error(error));
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------- | ------------- | ------------- | -------------
|
||||||
|
**user** | **Array<User>**| List of user object |
|
||||||
|
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
void (empty response body)
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
[api_key](README.md#api_key)
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: application/json
|
||||||
|
- **Accept**: Not defined
|
||||||
|
|
||||||
|
|
||||||
|
### HTTP response details
|
||||||
|
| Status code | Description | Response headers |
|
||||||
|
|-------------|-------------|------------------|
|
||||||
|
**0** | successful operation | - |
|
||||||
|
|
||||||
|
[[Back to top]](#) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to Model list]](README.md#documentation-for-models) [[Back to README]](README.md)
|
||||||
|
|
||||||
|
# **createUsersWithListInput**
|
||||||
|
> createUsersWithListInput(user)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### Example
|
||||||
|
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import { petstore } from 'ts-petstore-client';
|
||||||
|
import * as fs from 'fs';
|
||||||
|
|
||||||
|
const configuration = petstore.createConfiguration();
|
||||||
|
const apiInstance = new petstore.UserApi(configuration);
|
||||||
|
|
||||||
|
let body:petstore.UserApiCreateUsersWithListInputRequest = {
|
||||||
|
// Array<User> | List of user object
|
||||||
|
user: [
|
||||||
|
{
|
||||||
|
id: 1,
|
||||||
|
username: "username_example",
|
||||||
|
firstName: "firstName_example",
|
||||||
|
lastName: "lastName_example",
|
||||||
|
email: "email_example",
|
||||||
|
password: "password_example",
|
||||||
|
phone: "phone_example",
|
||||||
|
userStatus: 1,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
apiInstance.createUsersWithListInput(body).then((data:any) => {
|
||||||
|
console.log('API called successfully. Returned data: ' + data);
|
||||||
|
}).catch((error:any) => console.error(error));
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------- | ------------- | ------------- | -------------
|
||||||
|
**user** | **Array<User>**| List of user object |
|
||||||
|
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
void (empty response body)
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
[api_key](README.md#api_key)
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: application/json
|
||||||
|
- **Accept**: Not defined
|
||||||
|
|
||||||
|
|
||||||
|
### HTTP response details
|
||||||
|
| Status code | Description | Response headers |
|
||||||
|
|-------------|-------------|------------------|
|
||||||
|
**0** | successful operation | - |
|
||||||
|
|
||||||
|
[[Back to top]](#) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to Model list]](README.md#documentation-for-models) [[Back to README]](README.md)
|
||||||
|
|
||||||
|
# **deleteUser**
|
||||||
|
> deleteUser()
|
||||||
|
|
||||||
|
This can only be done by the logged in user.
|
||||||
|
|
||||||
|
### Example
|
||||||
|
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import { petstore } from 'ts-petstore-client';
|
||||||
|
import * as fs from 'fs';
|
||||||
|
|
||||||
|
const configuration = petstore.createConfiguration();
|
||||||
|
const apiInstance = new petstore.UserApi(configuration);
|
||||||
|
|
||||||
|
let body:petstore.UserApiDeleteUserRequest = {
|
||||||
|
// string | The name that needs to be deleted
|
||||||
|
username: "username_example",
|
||||||
|
};
|
||||||
|
|
||||||
|
apiInstance.deleteUser(body).then((data:any) => {
|
||||||
|
console.log('API called successfully. Returned data: ' + data);
|
||||||
|
}).catch((error:any) => console.error(error));
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------- | ------------- | ------------- | -------------
|
||||||
|
**username** | [**string**] | The name that needs to be deleted | defaults to undefined
|
||||||
|
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
void (empty response body)
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
[api_key](README.md#api_key)
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: Not defined
|
||||||
|
- **Accept**: Not defined
|
||||||
|
|
||||||
|
|
||||||
|
### HTTP response details
|
||||||
|
| Status code | Description | Response headers |
|
||||||
|
|-------------|-------------|------------------|
|
||||||
|
**400** | Invalid username supplied | - |
|
||||||
|
**404** | User not found | - |
|
||||||
|
|
||||||
|
[[Back to top]](#) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to Model list]](README.md#documentation-for-models) [[Back to README]](README.md)
|
||||||
|
|
||||||
|
# **getUserByName**
|
||||||
|
> User getUserByName()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### Example
|
||||||
|
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import { petstore } from 'ts-petstore-client';
|
||||||
|
import * as fs from 'fs';
|
||||||
|
|
||||||
|
const configuration = petstore.createConfiguration();
|
||||||
|
const apiInstance = new petstore.UserApi(configuration);
|
||||||
|
|
||||||
|
let body:petstore.UserApiGetUserByNameRequest = {
|
||||||
|
// string | The name that needs to be fetched. Use user1 for testing.
|
||||||
|
username: "username_example",
|
||||||
|
};
|
||||||
|
|
||||||
|
apiInstance.getUserByName(body).then((data:any) => {
|
||||||
|
console.log('API called successfully. Returned data: ' + data);
|
||||||
|
}).catch((error:any) => console.error(error));
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------- | ------------- | ------------- | -------------
|
||||||
|
**username** | [**string**] | The name that needs to be fetched. Use user1 for testing. | defaults to undefined
|
||||||
|
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
**User**
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
No authorization required
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: Not defined
|
||||||
|
- **Accept**: application/xml, application/json
|
||||||
|
|
||||||
|
|
||||||
|
### HTTP response details
|
||||||
|
| Status code | Description | Response headers |
|
||||||
|
|-------------|-------------|------------------|
|
||||||
|
**200** | successful operation | - |
|
||||||
|
**400** | Invalid username supplied | - |
|
||||||
|
**404** | User not found | - |
|
||||||
|
|
||||||
|
[[Back to top]](#) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to Model list]](README.md#documentation-for-models) [[Back to README]](README.md)
|
||||||
|
|
||||||
|
# **loginUser**
|
||||||
|
> string loginUser()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### Example
|
||||||
|
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import { petstore } from 'ts-petstore-client';
|
||||||
|
import * as fs from 'fs';
|
||||||
|
|
||||||
|
const configuration = petstore.createConfiguration();
|
||||||
|
const apiInstance = new petstore.UserApi(configuration);
|
||||||
|
|
||||||
|
let body:petstore.UserApiLoginUserRequest = {
|
||||||
|
// string | The user name for login
|
||||||
|
username: "CbUUGjjNSwg0_bs9ZayIMrKdgNvb6gvxmPb9GcsM61ate1RA89q3w1l4eH4XxEz.5awLMdeXylwK0lMGUSM4jsrh4dstlnQUN5vVdMLPA",
|
||||||
|
// string | The password for login in clear text
|
||||||
|
password: "password_example",
|
||||||
|
};
|
||||||
|
|
||||||
|
apiInstance.loginUser(body).then((data:any) => {
|
||||||
|
console.log('API called successfully. Returned data: ' + data);
|
||||||
|
}).catch((error:any) => console.error(error));
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------- | ------------- | ------------- | -------------
|
||||||
|
**username** | [**string**] | The user name for login | defaults to undefined
|
||||||
|
**password** | [**string**] | The password for login in clear text | defaults to undefined
|
||||||
|
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
**string**
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
No authorization required
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: Not defined
|
||||||
|
- **Accept**: application/xml, application/json
|
||||||
|
|
||||||
|
|
||||||
|
### HTTP response details
|
||||||
|
| Status code | Description | Response headers |
|
||||||
|
|-------------|-------------|------------------|
|
||||||
|
**200** | successful operation | * Set-Cookie - Cookie authentication key for use with the `api_key` apiKey authentication. <br> * X-Rate-Limit - calls per hour allowed by the user <br> * X-Expires-After - date in UTC when token expires <br> |
|
||||||
|
**400** | Invalid username/password supplied | - |
|
||||||
|
|
||||||
|
[[Back to top]](#) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to Model list]](README.md#documentation-for-models) [[Back to README]](README.md)
|
||||||
|
|
||||||
|
# **logoutUser**
|
||||||
|
> logoutUser()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### Example
|
||||||
|
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import { petstore } from 'ts-petstore-client';
|
||||||
|
import * as fs from 'fs';
|
||||||
|
|
||||||
|
const configuration = petstore.createConfiguration();
|
||||||
|
const apiInstance = new petstore.UserApi(configuration);
|
||||||
|
|
||||||
|
let body:any = {};
|
||||||
|
|
||||||
|
apiInstance.logoutUser(body).then((data:any) => {
|
||||||
|
console.log('API called successfully. Returned data: ' + data);
|
||||||
|
}).catch((error:any) => console.error(error));
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
This endpoint does not need any parameter.
|
||||||
|
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
void (empty response body)
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
[api_key](README.md#api_key)
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: Not defined
|
||||||
|
- **Accept**: Not defined
|
||||||
|
|
||||||
|
|
||||||
|
### HTTP response details
|
||||||
|
| Status code | Description | Response headers |
|
||||||
|
|-------------|-------------|------------------|
|
||||||
|
**0** | successful operation | - |
|
||||||
|
|
||||||
|
[[Back to top]](#) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to Model list]](README.md#documentation-for-models) [[Back to README]](README.md)
|
||||||
|
|
||||||
|
# **updateUser**
|
||||||
|
> updateUser(user)
|
||||||
|
|
||||||
|
This can only be done by the logged in user.
|
||||||
|
|
||||||
|
### Example
|
||||||
|
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import { petstore } from 'ts-petstore-client';
|
||||||
|
import * as fs from 'fs';
|
||||||
|
|
||||||
|
const configuration = petstore.createConfiguration();
|
||||||
|
const apiInstance = new petstore.UserApi(configuration);
|
||||||
|
|
||||||
|
let body:petstore.UserApiUpdateUserRequest = {
|
||||||
|
// string | name that need to be deleted
|
||||||
|
username: "username_example",
|
||||||
|
// User | Updated user object
|
||||||
|
user: {
|
||||||
|
id: 1,
|
||||||
|
username: "username_example",
|
||||||
|
firstName: "firstName_example",
|
||||||
|
lastName: "lastName_example",
|
||||||
|
email: "email_example",
|
||||||
|
password: "password_example",
|
||||||
|
phone: "phone_example",
|
||||||
|
userStatus: 1,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
apiInstance.updateUser(body).then((data:any) => {
|
||||||
|
console.log('API called successfully. Returned data: ' + data);
|
||||||
|
}).catch((error:any) => console.error(error));
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------- | ------------- | ------------- | -------------
|
||||||
|
**user** | **User**| Updated user object |
|
||||||
|
**username** | [**string**] | name that need to be deleted | defaults to undefined
|
||||||
|
|
||||||
|
|
||||||
|
### Return type
|
||||||
|
|
||||||
|
void (empty response body)
|
||||||
|
|
||||||
|
### Authorization
|
||||||
|
|
||||||
|
[api_key](README.md#api_key)
|
||||||
|
|
||||||
|
### HTTP request headers
|
||||||
|
|
||||||
|
- **Content-Type**: application/json
|
||||||
|
- **Accept**: Not defined
|
||||||
|
|
||||||
|
|
||||||
|
### HTTP response details
|
||||||
|
| Status code | Description | Response headers |
|
||||||
|
|-------------|-------------|------------------|
|
||||||
|
**400** | Invalid user supplied | - |
|
||||||
|
**404** | User not found | - |
|
||||||
|
|
||||||
|
[[Back to top]](#) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to Model list]](README.md#documentation-for-models) [[Back to README]](README.md)
|
||||||
|
|
||||||
|
|
@ -0,0 +1,672 @@
|
|||||||
|
// TODO: better import syntax?
|
||||||
|
import {BaseAPIRequestFactory, RequiredError} from './baseapi';
|
||||||
|
import {Configuration} from '../configuration';
|
||||||
|
import {RequestContext, HttpMethod, ResponseContext, HttpFile} from '../http/http';
|
||||||
|
import {ObjectSerializer} from '../models/ObjectSerializer';
|
||||||
|
import {ApiException} from './exception';
|
||||||
|
import {canConsumeForm, isCodeInRange} from '../util';
|
||||||
|
import {SecurityAuthentication} from '../auth/auth';
|
||||||
|
|
||||||
|
|
||||||
|
import { ApiResponse } from '../models/ApiResponse';
|
||||||
|
import { Pet } from '../models/Pet';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* no description
|
||||||
|
*/
|
||||||
|
export class PetApiRequestFactory extends BaseAPIRequestFactory {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Add a new pet to the store
|
||||||
|
* @param pet Pet object that needs to be added to the store
|
||||||
|
*/
|
||||||
|
public async addPet(pet: Pet, _options?: Configuration): Promise<RequestContext> {
|
||||||
|
let _config = _options || this.configuration;
|
||||||
|
|
||||||
|
// verify required parameter 'pet' is not null or undefined
|
||||||
|
if (pet === null || pet === undefined) {
|
||||||
|
throw new RequiredError("PetApi", "addPet", "pet");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Path Params
|
||||||
|
const localVarPath = '/pet';
|
||||||
|
|
||||||
|
// Make Request Context
|
||||||
|
const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST);
|
||||||
|
requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8")
|
||||||
|
|
||||||
|
|
||||||
|
// Body Params
|
||||||
|
const contentType = ObjectSerializer.getPreferredMediaType([
|
||||||
|
"application/json",
|
||||||
|
|
||||||
|
"application/xml"
|
||||||
|
]);
|
||||||
|
requestContext.setHeaderParam("Content-Type", contentType);
|
||||||
|
const serializedBody = ObjectSerializer.stringify(
|
||||||
|
ObjectSerializer.serialize(pet, "Pet", ""),
|
||||||
|
contentType
|
||||||
|
);
|
||||||
|
requestContext.setBody(serializedBody);
|
||||||
|
|
||||||
|
let authMethod: SecurityAuthentication | undefined;
|
||||||
|
// Apply auth methods
|
||||||
|
authMethod = _config.authMethods["petstore_auth"]
|
||||||
|
if (authMethod?.applySecurityAuthentication) {
|
||||||
|
await authMethod?.applySecurityAuthentication(requestContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default
|
||||||
|
if (defaultAuth?.applySecurityAuthentication) {
|
||||||
|
await defaultAuth?.applySecurityAuthentication(requestContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
return requestContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Deletes a pet
|
||||||
|
* @param petId Pet id to delete
|
||||||
|
* @param apiKey
|
||||||
|
*/
|
||||||
|
public async deletePet(petId: number, apiKey?: string, _options?: Configuration): Promise<RequestContext> {
|
||||||
|
let _config = _options || this.configuration;
|
||||||
|
|
||||||
|
// verify required parameter 'petId' is not null or undefined
|
||||||
|
if (petId === null || petId === undefined) {
|
||||||
|
throw new RequiredError("PetApi", "deletePet", "petId");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Path Params
|
||||||
|
const localVarPath = '/pet/{petId}'
|
||||||
|
.replace('{' + 'petId' + '}', encodeURIComponent(String(petId)));
|
||||||
|
|
||||||
|
// Make Request Context
|
||||||
|
const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.DELETE);
|
||||||
|
requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8")
|
||||||
|
|
||||||
|
// Header Params
|
||||||
|
requestContext.setHeaderParam("api_key", ObjectSerializer.serialize(apiKey, "string", ""));
|
||||||
|
|
||||||
|
|
||||||
|
let authMethod: SecurityAuthentication | undefined;
|
||||||
|
// Apply auth methods
|
||||||
|
authMethod = _config.authMethods["petstore_auth"]
|
||||||
|
if (authMethod?.applySecurityAuthentication) {
|
||||||
|
await authMethod?.applySecurityAuthentication(requestContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default
|
||||||
|
if (defaultAuth?.applySecurityAuthentication) {
|
||||||
|
await defaultAuth?.applySecurityAuthentication(requestContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
return requestContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Multiple status values can be provided with comma separated strings
|
||||||
|
* Finds Pets by status
|
||||||
|
* @param status Status values that need to be considered for filter
|
||||||
|
*/
|
||||||
|
public async findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, _options?: Configuration): Promise<RequestContext> {
|
||||||
|
let _config = _options || this.configuration;
|
||||||
|
|
||||||
|
// verify required parameter 'status' is not null or undefined
|
||||||
|
if (status === null || status === undefined) {
|
||||||
|
throw new RequiredError("PetApi", "findPetsByStatus", "status");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Path Params
|
||||||
|
const localVarPath = '/pet/findByStatus';
|
||||||
|
|
||||||
|
// Make Request Context
|
||||||
|
const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET);
|
||||||
|
requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8")
|
||||||
|
|
||||||
|
// Query Params
|
||||||
|
if (status !== undefined) {
|
||||||
|
requestContext.setQueryParam("status", ObjectSerializer.serialize(status, "Array<'available' | 'pending' | 'sold'>", ""));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
let authMethod: SecurityAuthentication | undefined;
|
||||||
|
// Apply auth methods
|
||||||
|
authMethod = _config.authMethods["petstore_auth"]
|
||||||
|
if (authMethod?.applySecurityAuthentication) {
|
||||||
|
await authMethod?.applySecurityAuthentication(requestContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default
|
||||||
|
if (defaultAuth?.applySecurityAuthentication) {
|
||||||
|
await defaultAuth?.applySecurityAuthentication(requestContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
return requestContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
||||||
|
* Finds Pets by tags
|
||||||
|
* @param tags Tags to filter by
|
||||||
|
*/
|
||||||
|
public async findPetsByTags(tags: Array<string>, _options?: Configuration): Promise<RequestContext> {
|
||||||
|
let _config = _options || this.configuration;
|
||||||
|
|
||||||
|
// verify required parameter 'tags' is not null or undefined
|
||||||
|
if (tags === null || tags === undefined) {
|
||||||
|
throw new RequiredError("PetApi", "findPetsByTags", "tags");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Path Params
|
||||||
|
const localVarPath = '/pet/findByTags';
|
||||||
|
|
||||||
|
// Make Request Context
|
||||||
|
const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET);
|
||||||
|
requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8")
|
||||||
|
|
||||||
|
// Query Params
|
||||||
|
if (tags !== undefined) {
|
||||||
|
requestContext.setQueryParam("tags", ObjectSerializer.serialize(tags, "Array<string>", ""));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
let authMethod: SecurityAuthentication | undefined;
|
||||||
|
// Apply auth methods
|
||||||
|
authMethod = _config.authMethods["petstore_auth"]
|
||||||
|
if (authMethod?.applySecurityAuthentication) {
|
||||||
|
await authMethod?.applySecurityAuthentication(requestContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default
|
||||||
|
if (defaultAuth?.applySecurityAuthentication) {
|
||||||
|
await defaultAuth?.applySecurityAuthentication(requestContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
return requestContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a single pet
|
||||||
|
* Find pet by ID
|
||||||
|
* @param petId ID of pet to return
|
||||||
|
*/
|
||||||
|
public async getPetById(petId: number, _options?: Configuration): Promise<RequestContext> {
|
||||||
|
let _config = _options || this.configuration;
|
||||||
|
|
||||||
|
// verify required parameter 'petId' is not null or undefined
|
||||||
|
if (petId === null || petId === undefined) {
|
||||||
|
throw new RequiredError("PetApi", "getPetById", "petId");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Path Params
|
||||||
|
const localVarPath = '/pet/{petId}'
|
||||||
|
.replace('{' + 'petId' + '}', encodeURIComponent(String(petId)));
|
||||||
|
|
||||||
|
// Make Request Context
|
||||||
|
const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET);
|
||||||
|
requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8")
|
||||||
|
|
||||||
|
|
||||||
|
let authMethod: SecurityAuthentication | undefined;
|
||||||
|
// Apply auth methods
|
||||||
|
authMethod = _config.authMethods["api_key"]
|
||||||
|
if (authMethod?.applySecurityAuthentication) {
|
||||||
|
await authMethod?.applySecurityAuthentication(requestContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default
|
||||||
|
if (defaultAuth?.applySecurityAuthentication) {
|
||||||
|
await defaultAuth?.applySecurityAuthentication(requestContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
return requestContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Update an existing pet
|
||||||
|
* @param pet Pet object that needs to be added to the store
|
||||||
|
*/
|
||||||
|
public async updatePet(pet: Pet, _options?: Configuration): Promise<RequestContext> {
|
||||||
|
let _config = _options || this.configuration;
|
||||||
|
|
||||||
|
// verify required parameter 'pet' is not null or undefined
|
||||||
|
if (pet === null || pet === undefined) {
|
||||||
|
throw new RequiredError("PetApi", "updatePet", "pet");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Path Params
|
||||||
|
const localVarPath = '/pet';
|
||||||
|
|
||||||
|
// Make Request Context
|
||||||
|
const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.PUT);
|
||||||
|
requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8")
|
||||||
|
|
||||||
|
|
||||||
|
// Body Params
|
||||||
|
const contentType = ObjectSerializer.getPreferredMediaType([
|
||||||
|
"application/json",
|
||||||
|
|
||||||
|
"application/xml"
|
||||||
|
]);
|
||||||
|
requestContext.setHeaderParam("Content-Type", contentType);
|
||||||
|
const serializedBody = ObjectSerializer.stringify(
|
||||||
|
ObjectSerializer.serialize(pet, "Pet", ""),
|
||||||
|
contentType
|
||||||
|
);
|
||||||
|
requestContext.setBody(serializedBody);
|
||||||
|
|
||||||
|
let authMethod: SecurityAuthentication | undefined;
|
||||||
|
// Apply auth methods
|
||||||
|
authMethod = _config.authMethods["petstore_auth"]
|
||||||
|
if (authMethod?.applySecurityAuthentication) {
|
||||||
|
await authMethod?.applySecurityAuthentication(requestContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default
|
||||||
|
if (defaultAuth?.applySecurityAuthentication) {
|
||||||
|
await defaultAuth?.applySecurityAuthentication(requestContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
return requestContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Updates a pet in the store with form data
|
||||||
|
* @param petId ID of pet that needs to be updated
|
||||||
|
* @param name Updated name of the pet
|
||||||
|
* @param status Updated status of the pet
|
||||||
|
*/
|
||||||
|
public async updatePetWithForm(petId: number, name?: string, status?: string, _options?: Configuration): Promise<RequestContext> {
|
||||||
|
let _config = _options || this.configuration;
|
||||||
|
|
||||||
|
// verify required parameter 'petId' is not null or undefined
|
||||||
|
if (petId === null || petId === undefined) {
|
||||||
|
throw new RequiredError("PetApi", "updatePetWithForm", "petId");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Path Params
|
||||||
|
const localVarPath = '/pet/{petId}'
|
||||||
|
.replace('{' + 'petId' + '}', encodeURIComponent(String(petId)));
|
||||||
|
|
||||||
|
// Make Request Context
|
||||||
|
const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST);
|
||||||
|
requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8")
|
||||||
|
|
||||||
|
// Form Params
|
||||||
|
const useForm = canConsumeForm([
|
||||||
|
'application/x-www-form-urlencoded',
|
||||||
|
]);
|
||||||
|
|
||||||
|
let localVarFormParams
|
||||||
|
if (useForm) {
|
||||||
|
localVarFormParams = new FormData();
|
||||||
|
} else {
|
||||||
|
localVarFormParams = new URLSearchParams();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (name !== undefined) {
|
||||||
|
// TODO: replace .append with .set
|
||||||
|
localVarFormParams.append('name', name as any);
|
||||||
|
}
|
||||||
|
if (status !== undefined) {
|
||||||
|
// TODO: replace .append with .set
|
||||||
|
localVarFormParams.append('status', status as any);
|
||||||
|
}
|
||||||
|
|
||||||
|
requestContext.setBody(localVarFormParams);
|
||||||
|
|
||||||
|
if(!useForm) {
|
||||||
|
const contentType = ObjectSerializer.getPreferredMediaType([
|
||||||
|
"application/x-www-form-urlencoded"
|
||||||
|
]);
|
||||||
|
requestContext.setHeaderParam("Content-Type", contentType);
|
||||||
|
}
|
||||||
|
|
||||||
|
let authMethod: SecurityAuthentication | undefined;
|
||||||
|
// Apply auth methods
|
||||||
|
authMethod = _config.authMethods["petstore_auth"]
|
||||||
|
if (authMethod?.applySecurityAuthentication) {
|
||||||
|
await authMethod?.applySecurityAuthentication(requestContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default
|
||||||
|
if (defaultAuth?.applySecurityAuthentication) {
|
||||||
|
await defaultAuth?.applySecurityAuthentication(requestContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
return requestContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* uploads an image
|
||||||
|
* @param petId ID of pet to update
|
||||||
|
* @param additionalMetadata Additional data to pass to server
|
||||||
|
* @param file file to upload
|
||||||
|
*/
|
||||||
|
public async uploadFile(petId: number, additionalMetadata?: string, file?: HttpFile, _options?: Configuration): Promise<RequestContext> {
|
||||||
|
let _config = _options || this.configuration;
|
||||||
|
|
||||||
|
// verify required parameter 'petId' is not null or undefined
|
||||||
|
if (petId === null || petId === undefined) {
|
||||||
|
throw new RequiredError("PetApi", "uploadFile", "petId");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Path Params
|
||||||
|
const localVarPath = '/pet/{petId}/uploadImage'
|
||||||
|
.replace('{' + 'petId' + '}', encodeURIComponent(String(petId)));
|
||||||
|
|
||||||
|
// Make Request Context
|
||||||
|
const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST);
|
||||||
|
requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8")
|
||||||
|
|
||||||
|
// Form Params
|
||||||
|
const useForm = canConsumeForm([
|
||||||
|
'multipart/form-data',
|
||||||
|
]);
|
||||||
|
|
||||||
|
let localVarFormParams
|
||||||
|
if (useForm) {
|
||||||
|
localVarFormParams = new FormData();
|
||||||
|
} else {
|
||||||
|
localVarFormParams = new URLSearchParams();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (additionalMetadata !== undefined) {
|
||||||
|
// TODO: replace .append with .set
|
||||||
|
localVarFormParams.append('additionalMetadata', additionalMetadata as any);
|
||||||
|
}
|
||||||
|
if (file !== undefined) {
|
||||||
|
// TODO: replace .append with .set
|
||||||
|
if (localVarFormParams instanceof FormData) {
|
||||||
|
localVarFormParams.append('file', file, file.name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
requestContext.setBody(localVarFormParams);
|
||||||
|
|
||||||
|
if(!useForm) {
|
||||||
|
const contentType = ObjectSerializer.getPreferredMediaType([
|
||||||
|
"multipart/form-data"
|
||||||
|
]);
|
||||||
|
requestContext.setHeaderParam("Content-Type", contentType);
|
||||||
|
}
|
||||||
|
|
||||||
|
let authMethod: SecurityAuthentication | undefined;
|
||||||
|
// Apply auth methods
|
||||||
|
authMethod = _config.authMethods["petstore_auth"]
|
||||||
|
if (authMethod?.applySecurityAuthentication) {
|
||||||
|
await authMethod?.applySecurityAuthentication(requestContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default
|
||||||
|
if (defaultAuth?.applySecurityAuthentication) {
|
||||||
|
await defaultAuth?.applySecurityAuthentication(requestContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
return requestContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export class PetApiResponseProcessor {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unwraps the actual response sent by the server from the response context and deserializes the response content
|
||||||
|
* to the expected objects
|
||||||
|
*
|
||||||
|
* @params response Response returned by the server for a request to addPet
|
||||||
|
* @throws ApiException if the response code was not in [200, 299]
|
||||||
|
*/
|
||||||
|
public async addPet(response: ResponseContext): Promise<Pet > {
|
||||||
|
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
|
||||||
|
if (isCodeInRange("200", response.httpStatusCode)) {
|
||||||
|
const body: Pet = ObjectSerializer.deserialize(
|
||||||
|
ObjectSerializer.parse(await response.body.text(), contentType),
|
||||||
|
"Pet", ""
|
||||||
|
) as Pet;
|
||||||
|
return body;
|
||||||
|
}
|
||||||
|
if (isCodeInRange("405", response.httpStatusCode)) {
|
||||||
|
throw new ApiException<undefined>(response.httpStatusCode, "Invalid input", undefined, response.headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Work around for missing responses in specification, e.g. for petstore.yaml
|
||||||
|
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
|
||||||
|
const body: Pet = ObjectSerializer.deserialize(
|
||||||
|
ObjectSerializer.parse(await response.body.text(), contentType),
|
||||||
|
"Pet", ""
|
||||||
|
) as Pet;
|
||||||
|
return body;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unwraps the actual response sent by the server from the response context and deserializes the response content
|
||||||
|
* to the expected objects
|
||||||
|
*
|
||||||
|
* @params response Response returned by the server for a request to deletePet
|
||||||
|
* @throws ApiException if the response code was not in [200, 299]
|
||||||
|
*/
|
||||||
|
public async deletePet(response: ResponseContext): Promise< void> {
|
||||||
|
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
|
||||||
|
if (isCodeInRange("400", response.httpStatusCode)) {
|
||||||
|
throw new ApiException<undefined>(response.httpStatusCode, "Invalid pet value", undefined, response.headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Work around for missing responses in specification, e.g. for petstore.yaml
|
||||||
|
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unwraps the actual response sent by the server from the response context and deserializes the response content
|
||||||
|
* to the expected objects
|
||||||
|
*
|
||||||
|
* @params response Response returned by the server for a request to findPetsByStatus
|
||||||
|
* @throws ApiException if the response code was not in [200, 299]
|
||||||
|
*/
|
||||||
|
public async findPetsByStatus(response: ResponseContext): Promise<Array<Pet> > {
|
||||||
|
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
|
||||||
|
if (isCodeInRange("200", response.httpStatusCode)) {
|
||||||
|
const body: Array<Pet> = ObjectSerializer.deserialize(
|
||||||
|
ObjectSerializer.parse(await response.body.text(), contentType),
|
||||||
|
"Array<Pet>", ""
|
||||||
|
) as Array<Pet>;
|
||||||
|
return body;
|
||||||
|
}
|
||||||
|
if (isCodeInRange("400", response.httpStatusCode)) {
|
||||||
|
throw new ApiException<undefined>(response.httpStatusCode, "Invalid status value", undefined, response.headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Work around for missing responses in specification, e.g. for petstore.yaml
|
||||||
|
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
|
||||||
|
const body: Array<Pet> = ObjectSerializer.deserialize(
|
||||||
|
ObjectSerializer.parse(await response.body.text(), contentType),
|
||||||
|
"Array<Pet>", ""
|
||||||
|
) as Array<Pet>;
|
||||||
|
return body;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unwraps the actual response sent by the server from the response context and deserializes the response content
|
||||||
|
* to the expected objects
|
||||||
|
*
|
||||||
|
* @params response Response returned by the server for a request to findPetsByTags
|
||||||
|
* @throws ApiException if the response code was not in [200, 299]
|
||||||
|
*/
|
||||||
|
public async findPetsByTags(response: ResponseContext): Promise<Array<Pet> > {
|
||||||
|
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
|
||||||
|
if (isCodeInRange("200", response.httpStatusCode)) {
|
||||||
|
const body: Array<Pet> = ObjectSerializer.deserialize(
|
||||||
|
ObjectSerializer.parse(await response.body.text(), contentType),
|
||||||
|
"Array<Pet>", ""
|
||||||
|
) as Array<Pet>;
|
||||||
|
return body;
|
||||||
|
}
|
||||||
|
if (isCodeInRange("400", response.httpStatusCode)) {
|
||||||
|
throw new ApiException<undefined>(response.httpStatusCode, "Invalid tag value", undefined, response.headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Work around for missing responses in specification, e.g. for petstore.yaml
|
||||||
|
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
|
||||||
|
const body: Array<Pet> = ObjectSerializer.deserialize(
|
||||||
|
ObjectSerializer.parse(await response.body.text(), contentType),
|
||||||
|
"Array<Pet>", ""
|
||||||
|
) as Array<Pet>;
|
||||||
|
return body;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unwraps the actual response sent by the server from the response context and deserializes the response content
|
||||||
|
* to the expected objects
|
||||||
|
*
|
||||||
|
* @params response Response returned by the server for a request to getPetById
|
||||||
|
* @throws ApiException if the response code was not in [200, 299]
|
||||||
|
*/
|
||||||
|
public async getPetById(response: ResponseContext): Promise<Pet > {
|
||||||
|
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
|
||||||
|
if (isCodeInRange("200", response.httpStatusCode)) {
|
||||||
|
const body: Pet = ObjectSerializer.deserialize(
|
||||||
|
ObjectSerializer.parse(await response.body.text(), contentType),
|
||||||
|
"Pet", ""
|
||||||
|
) as Pet;
|
||||||
|
return body;
|
||||||
|
}
|
||||||
|
if (isCodeInRange("400", response.httpStatusCode)) {
|
||||||
|
throw new ApiException<undefined>(response.httpStatusCode, "Invalid ID supplied", undefined, response.headers);
|
||||||
|
}
|
||||||
|
if (isCodeInRange("404", response.httpStatusCode)) {
|
||||||
|
throw new ApiException<undefined>(response.httpStatusCode, "Pet not found", undefined, response.headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Work around for missing responses in specification, e.g. for petstore.yaml
|
||||||
|
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
|
||||||
|
const body: Pet = ObjectSerializer.deserialize(
|
||||||
|
ObjectSerializer.parse(await response.body.text(), contentType),
|
||||||
|
"Pet", ""
|
||||||
|
) as Pet;
|
||||||
|
return body;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unwraps the actual response sent by the server from the response context and deserializes the response content
|
||||||
|
* to the expected objects
|
||||||
|
*
|
||||||
|
* @params response Response returned by the server for a request to updatePet
|
||||||
|
* @throws ApiException if the response code was not in [200, 299]
|
||||||
|
*/
|
||||||
|
public async updatePet(response: ResponseContext): Promise<Pet > {
|
||||||
|
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
|
||||||
|
if (isCodeInRange("200", response.httpStatusCode)) {
|
||||||
|
const body: Pet = ObjectSerializer.deserialize(
|
||||||
|
ObjectSerializer.parse(await response.body.text(), contentType),
|
||||||
|
"Pet", ""
|
||||||
|
) as Pet;
|
||||||
|
return body;
|
||||||
|
}
|
||||||
|
if (isCodeInRange("400", response.httpStatusCode)) {
|
||||||
|
throw new ApiException<undefined>(response.httpStatusCode, "Invalid ID supplied", undefined, response.headers);
|
||||||
|
}
|
||||||
|
if (isCodeInRange("404", response.httpStatusCode)) {
|
||||||
|
throw new ApiException<undefined>(response.httpStatusCode, "Pet not found", undefined, response.headers);
|
||||||
|
}
|
||||||
|
if (isCodeInRange("405", response.httpStatusCode)) {
|
||||||
|
throw new ApiException<undefined>(response.httpStatusCode, "Validation exception", undefined, response.headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Work around for missing responses in specification, e.g. for petstore.yaml
|
||||||
|
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
|
||||||
|
const body: Pet = ObjectSerializer.deserialize(
|
||||||
|
ObjectSerializer.parse(await response.body.text(), contentType),
|
||||||
|
"Pet", ""
|
||||||
|
) as Pet;
|
||||||
|
return body;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unwraps the actual response sent by the server from the response context and deserializes the response content
|
||||||
|
* to the expected objects
|
||||||
|
*
|
||||||
|
* @params response Response returned by the server for a request to updatePetWithForm
|
||||||
|
* @throws ApiException if the response code was not in [200, 299]
|
||||||
|
*/
|
||||||
|
public async updatePetWithForm(response: ResponseContext): Promise< void> {
|
||||||
|
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
|
||||||
|
if (isCodeInRange("405", response.httpStatusCode)) {
|
||||||
|
throw new ApiException<undefined>(response.httpStatusCode, "Invalid input", undefined, response.headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Work around for missing responses in specification, e.g. for petstore.yaml
|
||||||
|
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unwraps the actual response sent by the server from the response context and deserializes the response content
|
||||||
|
* to the expected objects
|
||||||
|
*
|
||||||
|
* @params response Response returned by the server for a request to uploadFile
|
||||||
|
* @throws ApiException if the response code was not in [200, 299]
|
||||||
|
*/
|
||||||
|
public async uploadFile(response: ResponseContext): Promise<ApiResponse > {
|
||||||
|
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
|
||||||
|
if (isCodeInRange("200", response.httpStatusCode)) {
|
||||||
|
const body: ApiResponse = ObjectSerializer.deserialize(
|
||||||
|
ObjectSerializer.parse(await response.body.text(), contentType),
|
||||||
|
"ApiResponse", ""
|
||||||
|
) as ApiResponse;
|
||||||
|
return body;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Work around for missing responses in specification, e.g. for petstore.yaml
|
||||||
|
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
|
||||||
|
const body: ApiResponse = ObjectSerializer.deserialize(
|
||||||
|
ObjectSerializer.parse(await response.body.text(), contentType),
|
||||||
|
"ApiResponse", ""
|
||||||
|
) as ApiResponse;
|
||||||
|
return body;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,278 @@
|
|||||||
|
// TODO: better import syntax?
|
||||||
|
import {BaseAPIRequestFactory, RequiredError} from './baseapi';
|
||||||
|
import {Configuration} from '../configuration';
|
||||||
|
import {RequestContext, HttpMethod, ResponseContext, HttpFile} from '../http/http';
|
||||||
|
import {ObjectSerializer} from '../models/ObjectSerializer';
|
||||||
|
import {ApiException} from './exception';
|
||||||
|
import {canConsumeForm, isCodeInRange} from '../util';
|
||||||
|
import {SecurityAuthentication} from '../auth/auth';
|
||||||
|
|
||||||
|
|
||||||
|
import { Order } from '../models/Order';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* no description
|
||||||
|
*/
|
||||||
|
export class StoreApiRequestFactory extends BaseAPIRequestFactory {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||||
|
* Delete purchase order by ID
|
||||||
|
* @param orderId ID of the order that needs to be deleted
|
||||||
|
*/
|
||||||
|
public async deleteOrder(orderId: string, _options?: Configuration): Promise<RequestContext> {
|
||||||
|
let _config = _options || this.configuration;
|
||||||
|
|
||||||
|
// verify required parameter 'orderId' is not null or undefined
|
||||||
|
if (orderId === null || orderId === undefined) {
|
||||||
|
throw new RequiredError("StoreApi", "deleteOrder", "orderId");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Path Params
|
||||||
|
const localVarPath = '/store/order/{orderId}'
|
||||||
|
.replace('{' + 'orderId' + '}', encodeURIComponent(String(orderId)));
|
||||||
|
|
||||||
|
// Make Request Context
|
||||||
|
const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.DELETE);
|
||||||
|
requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default
|
||||||
|
if (defaultAuth?.applySecurityAuthentication) {
|
||||||
|
await defaultAuth?.applySecurityAuthentication(requestContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
return requestContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a map of status codes to quantities
|
||||||
|
* Returns pet inventories by status
|
||||||
|
*/
|
||||||
|
public async getInventory(_options?: Configuration): Promise<RequestContext> {
|
||||||
|
let _config = _options || this.configuration;
|
||||||
|
|
||||||
|
// Path Params
|
||||||
|
const localVarPath = '/store/inventory';
|
||||||
|
|
||||||
|
// Make Request Context
|
||||||
|
const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET);
|
||||||
|
requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8")
|
||||||
|
|
||||||
|
|
||||||
|
let authMethod: SecurityAuthentication | undefined;
|
||||||
|
// Apply auth methods
|
||||||
|
authMethod = _config.authMethods["api_key"]
|
||||||
|
if (authMethod?.applySecurityAuthentication) {
|
||||||
|
await authMethod?.applySecurityAuthentication(requestContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default
|
||||||
|
if (defaultAuth?.applySecurityAuthentication) {
|
||||||
|
await defaultAuth?.applySecurityAuthentication(requestContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
return requestContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||||
|
* Find purchase order by ID
|
||||||
|
* @param orderId ID of pet that needs to be fetched
|
||||||
|
*/
|
||||||
|
public async getOrderById(orderId: number, _options?: Configuration): Promise<RequestContext> {
|
||||||
|
let _config = _options || this.configuration;
|
||||||
|
|
||||||
|
// verify required parameter 'orderId' is not null or undefined
|
||||||
|
if (orderId === null || orderId === undefined) {
|
||||||
|
throw new RequiredError("StoreApi", "getOrderById", "orderId");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Path Params
|
||||||
|
const localVarPath = '/store/order/{orderId}'
|
||||||
|
.replace('{' + 'orderId' + '}', encodeURIComponent(String(orderId)));
|
||||||
|
|
||||||
|
// Make Request Context
|
||||||
|
const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET);
|
||||||
|
requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default
|
||||||
|
if (defaultAuth?.applySecurityAuthentication) {
|
||||||
|
await defaultAuth?.applySecurityAuthentication(requestContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
return requestContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Place an order for a pet
|
||||||
|
* @param order order placed for purchasing the pet
|
||||||
|
*/
|
||||||
|
public async placeOrder(order: Order, _options?: Configuration): Promise<RequestContext> {
|
||||||
|
let _config = _options || this.configuration;
|
||||||
|
|
||||||
|
// verify required parameter 'order' is not null or undefined
|
||||||
|
if (order === null || order === undefined) {
|
||||||
|
throw new RequiredError("StoreApi", "placeOrder", "order");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Path Params
|
||||||
|
const localVarPath = '/store/order';
|
||||||
|
|
||||||
|
// Make Request Context
|
||||||
|
const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST);
|
||||||
|
requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8")
|
||||||
|
|
||||||
|
|
||||||
|
// Body Params
|
||||||
|
const contentType = ObjectSerializer.getPreferredMediaType([
|
||||||
|
"application/json"
|
||||||
|
]);
|
||||||
|
requestContext.setHeaderParam("Content-Type", contentType);
|
||||||
|
const serializedBody = ObjectSerializer.stringify(
|
||||||
|
ObjectSerializer.serialize(order, "Order", ""),
|
||||||
|
contentType
|
||||||
|
);
|
||||||
|
requestContext.setBody(serializedBody);
|
||||||
|
|
||||||
|
|
||||||
|
const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default
|
||||||
|
if (defaultAuth?.applySecurityAuthentication) {
|
||||||
|
await defaultAuth?.applySecurityAuthentication(requestContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
return requestContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export class StoreApiResponseProcessor {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unwraps the actual response sent by the server from the response context and deserializes the response content
|
||||||
|
* to the expected objects
|
||||||
|
*
|
||||||
|
* @params response Response returned by the server for a request to deleteOrder
|
||||||
|
* @throws ApiException if the response code was not in [200, 299]
|
||||||
|
*/
|
||||||
|
public async deleteOrder(response: ResponseContext): Promise< void> {
|
||||||
|
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
|
||||||
|
if (isCodeInRange("400", response.httpStatusCode)) {
|
||||||
|
throw new ApiException<undefined>(response.httpStatusCode, "Invalid ID supplied", undefined, response.headers);
|
||||||
|
}
|
||||||
|
if (isCodeInRange("404", response.httpStatusCode)) {
|
||||||
|
throw new ApiException<undefined>(response.httpStatusCode, "Order not found", undefined, response.headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Work around for missing responses in specification, e.g. for petstore.yaml
|
||||||
|
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unwraps the actual response sent by the server from the response context and deserializes the response content
|
||||||
|
* to the expected objects
|
||||||
|
*
|
||||||
|
* @params response Response returned by the server for a request to getInventory
|
||||||
|
* @throws ApiException if the response code was not in [200, 299]
|
||||||
|
*/
|
||||||
|
public async getInventory(response: ResponseContext): Promise<{ [key: string]: number; } > {
|
||||||
|
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
|
||||||
|
if (isCodeInRange("200", response.httpStatusCode)) {
|
||||||
|
const body: { [key: string]: number; } = ObjectSerializer.deserialize(
|
||||||
|
ObjectSerializer.parse(await response.body.text(), contentType),
|
||||||
|
"{ [key: string]: number; }", "int32"
|
||||||
|
) as { [key: string]: number; };
|
||||||
|
return body;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Work around for missing responses in specification, e.g. for petstore.yaml
|
||||||
|
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
|
||||||
|
const body: { [key: string]: number; } = ObjectSerializer.deserialize(
|
||||||
|
ObjectSerializer.parse(await response.body.text(), contentType),
|
||||||
|
"{ [key: string]: number; }", "int32"
|
||||||
|
) as { [key: string]: number; };
|
||||||
|
return body;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unwraps the actual response sent by the server from the response context and deserializes the response content
|
||||||
|
* to the expected objects
|
||||||
|
*
|
||||||
|
* @params response Response returned by the server for a request to getOrderById
|
||||||
|
* @throws ApiException if the response code was not in [200, 299]
|
||||||
|
*/
|
||||||
|
public async getOrderById(response: ResponseContext): Promise<Order > {
|
||||||
|
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
|
||||||
|
if (isCodeInRange("200", response.httpStatusCode)) {
|
||||||
|
const body: Order = ObjectSerializer.deserialize(
|
||||||
|
ObjectSerializer.parse(await response.body.text(), contentType),
|
||||||
|
"Order", ""
|
||||||
|
) as Order;
|
||||||
|
return body;
|
||||||
|
}
|
||||||
|
if (isCodeInRange("400", response.httpStatusCode)) {
|
||||||
|
throw new ApiException<undefined>(response.httpStatusCode, "Invalid ID supplied", undefined, response.headers);
|
||||||
|
}
|
||||||
|
if (isCodeInRange("404", response.httpStatusCode)) {
|
||||||
|
throw new ApiException<undefined>(response.httpStatusCode, "Order not found", undefined, response.headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Work around for missing responses in specification, e.g. for petstore.yaml
|
||||||
|
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
|
||||||
|
const body: Order = ObjectSerializer.deserialize(
|
||||||
|
ObjectSerializer.parse(await response.body.text(), contentType),
|
||||||
|
"Order", ""
|
||||||
|
) as Order;
|
||||||
|
return body;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unwraps the actual response sent by the server from the response context and deserializes the response content
|
||||||
|
* to the expected objects
|
||||||
|
*
|
||||||
|
* @params response Response returned by the server for a request to placeOrder
|
||||||
|
* @throws ApiException if the response code was not in [200, 299]
|
||||||
|
*/
|
||||||
|
public async placeOrder(response: ResponseContext): Promise<Order > {
|
||||||
|
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
|
||||||
|
if (isCodeInRange("200", response.httpStatusCode)) {
|
||||||
|
const body: Order = ObjectSerializer.deserialize(
|
||||||
|
ObjectSerializer.parse(await response.body.text(), contentType),
|
||||||
|
"Order", ""
|
||||||
|
) as Order;
|
||||||
|
return body;
|
||||||
|
}
|
||||||
|
if (isCodeInRange("400", response.httpStatusCode)) {
|
||||||
|
throw new ApiException<undefined>(response.httpStatusCode, "Invalid Order", undefined, response.headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Work around for missing responses in specification, e.g. for petstore.yaml
|
||||||
|
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
|
||||||
|
const body: Order = ObjectSerializer.deserialize(
|
||||||
|
ObjectSerializer.parse(await response.body.text(), contentType),
|
||||||
|
"Order", ""
|
||||||
|
) as Order;
|
||||||
|
return body;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,569 @@
|
|||||||
|
// TODO: better import syntax?
|
||||||
|
import {BaseAPIRequestFactory, RequiredError} from './baseapi';
|
||||||
|
import {Configuration} from '../configuration';
|
||||||
|
import {RequestContext, HttpMethod, ResponseContext, HttpFile} from '../http/http';
|
||||||
|
import {ObjectSerializer} from '../models/ObjectSerializer';
|
||||||
|
import {ApiException} from './exception';
|
||||||
|
import {canConsumeForm, isCodeInRange} from '../util';
|
||||||
|
import {SecurityAuthentication} from '../auth/auth';
|
||||||
|
|
||||||
|
|
||||||
|
import { User } from '../models/User';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* no description
|
||||||
|
*/
|
||||||
|
export class UserApiRequestFactory extends BaseAPIRequestFactory {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This can only be done by the logged in user.
|
||||||
|
* Create user
|
||||||
|
* @param user Created user object
|
||||||
|
*/
|
||||||
|
public async createUser(user: User, _options?: Configuration): Promise<RequestContext> {
|
||||||
|
let _config = _options || this.configuration;
|
||||||
|
|
||||||
|
// verify required parameter 'user' is not null or undefined
|
||||||
|
if (user === null || user === undefined) {
|
||||||
|
throw new RequiredError("UserApi", "createUser", "user");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Path Params
|
||||||
|
const localVarPath = '/user';
|
||||||
|
|
||||||
|
// Make Request Context
|
||||||
|
const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST);
|
||||||
|
requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8")
|
||||||
|
|
||||||
|
|
||||||
|
// Body Params
|
||||||
|
const contentType = ObjectSerializer.getPreferredMediaType([
|
||||||
|
"application/json"
|
||||||
|
]);
|
||||||
|
requestContext.setHeaderParam("Content-Type", contentType);
|
||||||
|
const serializedBody = ObjectSerializer.stringify(
|
||||||
|
ObjectSerializer.serialize(user, "User", ""),
|
||||||
|
contentType
|
||||||
|
);
|
||||||
|
requestContext.setBody(serializedBody);
|
||||||
|
|
||||||
|
let authMethod: SecurityAuthentication | undefined;
|
||||||
|
// Apply auth methods
|
||||||
|
authMethod = _config.authMethods["api_key"]
|
||||||
|
if (authMethod?.applySecurityAuthentication) {
|
||||||
|
await authMethod?.applySecurityAuthentication(requestContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default
|
||||||
|
if (defaultAuth?.applySecurityAuthentication) {
|
||||||
|
await defaultAuth?.applySecurityAuthentication(requestContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
return requestContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Creates list of users with given input array
|
||||||
|
* @param user List of user object
|
||||||
|
*/
|
||||||
|
public async createUsersWithArrayInput(user: Array<User>, _options?: Configuration): Promise<RequestContext> {
|
||||||
|
let _config = _options || this.configuration;
|
||||||
|
|
||||||
|
// verify required parameter 'user' is not null or undefined
|
||||||
|
if (user === null || user === undefined) {
|
||||||
|
throw new RequiredError("UserApi", "createUsersWithArrayInput", "user");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Path Params
|
||||||
|
const localVarPath = '/user/createWithArray';
|
||||||
|
|
||||||
|
// Make Request Context
|
||||||
|
const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST);
|
||||||
|
requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8")
|
||||||
|
|
||||||
|
|
||||||
|
// Body Params
|
||||||
|
const contentType = ObjectSerializer.getPreferredMediaType([
|
||||||
|
"application/json"
|
||||||
|
]);
|
||||||
|
requestContext.setHeaderParam("Content-Type", contentType);
|
||||||
|
const serializedBody = ObjectSerializer.stringify(
|
||||||
|
ObjectSerializer.serialize(user, "Array<User>", ""),
|
||||||
|
contentType
|
||||||
|
);
|
||||||
|
requestContext.setBody(serializedBody);
|
||||||
|
|
||||||
|
let authMethod: SecurityAuthentication | undefined;
|
||||||
|
// Apply auth methods
|
||||||
|
authMethod = _config.authMethods["api_key"]
|
||||||
|
if (authMethod?.applySecurityAuthentication) {
|
||||||
|
await authMethod?.applySecurityAuthentication(requestContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default
|
||||||
|
if (defaultAuth?.applySecurityAuthentication) {
|
||||||
|
await defaultAuth?.applySecurityAuthentication(requestContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
return requestContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Creates list of users with given input array
|
||||||
|
* @param user List of user object
|
||||||
|
*/
|
||||||
|
public async createUsersWithListInput(user: Array<User>, _options?: Configuration): Promise<RequestContext> {
|
||||||
|
let _config = _options || this.configuration;
|
||||||
|
|
||||||
|
// verify required parameter 'user' is not null or undefined
|
||||||
|
if (user === null || user === undefined) {
|
||||||
|
throw new RequiredError("UserApi", "createUsersWithListInput", "user");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Path Params
|
||||||
|
const localVarPath = '/user/createWithList';
|
||||||
|
|
||||||
|
// Make Request Context
|
||||||
|
const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST);
|
||||||
|
requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8")
|
||||||
|
|
||||||
|
|
||||||
|
// Body Params
|
||||||
|
const contentType = ObjectSerializer.getPreferredMediaType([
|
||||||
|
"application/json"
|
||||||
|
]);
|
||||||
|
requestContext.setHeaderParam("Content-Type", contentType);
|
||||||
|
const serializedBody = ObjectSerializer.stringify(
|
||||||
|
ObjectSerializer.serialize(user, "Array<User>", ""),
|
||||||
|
contentType
|
||||||
|
);
|
||||||
|
requestContext.setBody(serializedBody);
|
||||||
|
|
||||||
|
let authMethod: SecurityAuthentication | undefined;
|
||||||
|
// Apply auth methods
|
||||||
|
authMethod = _config.authMethods["api_key"]
|
||||||
|
if (authMethod?.applySecurityAuthentication) {
|
||||||
|
await authMethod?.applySecurityAuthentication(requestContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default
|
||||||
|
if (defaultAuth?.applySecurityAuthentication) {
|
||||||
|
await defaultAuth?.applySecurityAuthentication(requestContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
return requestContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This can only be done by the logged in user.
|
||||||
|
* Delete user
|
||||||
|
* @param username The name that needs to be deleted
|
||||||
|
*/
|
||||||
|
public async deleteUser(username: string, _options?: Configuration): Promise<RequestContext> {
|
||||||
|
let _config = _options || this.configuration;
|
||||||
|
|
||||||
|
// verify required parameter 'username' is not null or undefined
|
||||||
|
if (username === null || username === undefined) {
|
||||||
|
throw new RequiredError("UserApi", "deleteUser", "username");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Path Params
|
||||||
|
const localVarPath = '/user/{username}'
|
||||||
|
.replace('{' + 'username' + '}', encodeURIComponent(String(username)));
|
||||||
|
|
||||||
|
// Make Request Context
|
||||||
|
const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.DELETE);
|
||||||
|
requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8")
|
||||||
|
|
||||||
|
|
||||||
|
let authMethod: SecurityAuthentication | undefined;
|
||||||
|
// Apply auth methods
|
||||||
|
authMethod = _config.authMethods["api_key"]
|
||||||
|
if (authMethod?.applySecurityAuthentication) {
|
||||||
|
await authMethod?.applySecurityAuthentication(requestContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default
|
||||||
|
if (defaultAuth?.applySecurityAuthentication) {
|
||||||
|
await defaultAuth?.applySecurityAuthentication(requestContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
return requestContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Get user by user name
|
||||||
|
* @param username The name that needs to be fetched. Use user1 for testing.
|
||||||
|
*/
|
||||||
|
public async getUserByName(username: string, _options?: Configuration): Promise<RequestContext> {
|
||||||
|
let _config = _options || this.configuration;
|
||||||
|
|
||||||
|
// verify required parameter 'username' is not null or undefined
|
||||||
|
if (username === null || username === undefined) {
|
||||||
|
throw new RequiredError("UserApi", "getUserByName", "username");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Path Params
|
||||||
|
const localVarPath = '/user/{username}'
|
||||||
|
.replace('{' + 'username' + '}', encodeURIComponent(String(username)));
|
||||||
|
|
||||||
|
// Make Request Context
|
||||||
|
const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET);
|
||||||
|
requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default
|
||||||
|
if (defaultAuth?.applySecurityAuthentication) {
|
||||||
|
await defaultAuth?.applySecurityAuthentication(requestContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
return requestContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Logs user into the system
|
||||||
|
* @param username The user name for login
|
||||||
|
* @param password The password for login in clear text
|
||||||
|
*/
|
||||||
|
public async loginUser(username: string, password: string, _options?: Configuration): Promise<RequestContext> {
|
||||||
|
let _config = _options || this.configuration;
|
||||||
|
|
||||||
|
// verify required parameter 'username' is not null or undefined
|
||||||
|
if (username === null || username === undefined) {
|
||||||
|
throw new RequiredError("UserApi", "loginUser", "username");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// verify required parameter 'password' is not null or undefined
|
||||||
|
if (password === null || password === undefined) {
|
||||||
|
throw new RequiredError("UserApi", "loginUser", "password");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Path Params
|
||||||
|
const localVarPath = '/user/login';
|
||||||
|
|
||||||
|
// Make Request Context
|
||||||
|
const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET);
|
||||||
|
requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8")
|
||||||
|
|
||||||
|
// Query Params
|
||||||
|
if (username !== undefined) {
|
||||||
|
requestContext.setQueryParam("username", ObjectSerializer.serialize(username, "string", ""));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Query Params
|
||||||
|
if (password !== undefined) {
|
||||||
|
requestContext.setQueryParam("password", ObjectSerializer.serialize(password, "string", ""));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default
|
||||||
|
if (defaultAuth?.applySecurityAuthentication) {
|
||||||
|
await defaultAuth?.applySecurityAuthentication(requestContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
return requestContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Logs out current logged in user session
|
||||||
|
*/
|
||||||
|
public async logoutUser(_options?: Configuration): Promise<RequestContext> {
|
||||||
|
let _config = _options || this.configuration;
|
||||||
|
|
||||||
|
// Path Params
|
||||||
|
const localVarPath = '/user/logout';
|
||||||
|
|
||||||
|
// Make Request Context
|
||||||
|
const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET);
|
||||||
|
requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8")
|
||||||
|
|
||||||
|
|
||||||
|
let authMethod: SecurityAuthentication | undefined;
|
||||||
|
// Apply auth methods
|
||||||
|
authMethod = _config.authMethods["api_key"]
|
||||||
|
if (authMethod?.applySecurityAuthentication) {
|
||||||
|
await authMethod?.applySecurityAuthentication(requestContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default
|
||||||
|
if (defaultAuth?.applySecurityAuthentication) {
|
||||||
|
await defaultAuth?.applySecurityAuthentication(requestContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
return requestContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This can only be done by the logged in user.
|
||||||
|
* Updated user
|
||||||
|
* @param username name that need to be deleted
|
||||||
|
* @param user Updated user object
|
||||||
|
*/
|
||||||
|
public async updateUser(username: string, user: User, _options?: Configuration): Promise<RequestContext> {
|
||||||
|
let _config = _options || this.configuration;
|
||||||
|
|
||||||
|
// verify required parameter 'username' is not null or undefined
|
||||||
|
if (username === null || username === undefined) {
|
||||||
|
throw new RequiredError("UserApi", "updateUser", "username");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// verify required parameter 'user' is not null or undefined
|
||||||
|
if (user === null || user === undefined) {
|
||||||
|
throw new RequiredError("UserApi", "updateUser", "user");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Path Params
|
||||||
|
const localVarPath = '/user/{username}'
|
||||||
|
.replace('{' + 'username' + '}', encodeURIComponent(String(username)));
|
||||||
|
|
||||||
|
// Make Request Context
|
||||||
|
const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.PUT);
|
||||||
|
requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8")
|
||||||
|
|
||||||
|
|
||||||
|
// Body Params
|
||||||
|
const contentType = ObjectSerializer.getPreferredMediaType([
|
||||||
|
"application/json"
|
||||||
|
]);
|
||||||
|
requestContext.setHeaderParam("Content-Type", contentType);
|
||||||
|
const serializedBody = ObjectSerializer.stringify(
|
||||||
|
ObjectSerializer.serialize(user, "User", ""),
|
||||||
|
contentType
|
||||||
|
);
|
||||||
|
requestContext.setBody(serializedBody);
|
||||||
|
|
||||||
|
let authMethod: SecurityAuthentication | undefined;
|
||||||
|
// Apply auth methods
|
||||||
|
authMethod = _config.authMethods["api_key"]
|
||||||
|
if (authMethod?.applySecurityAuthentication) {
|
||||||
|
await authMethod?.applySecurityAuthentication(requestContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default
|
||||||
|
if (defaultAuth?.applySecurityAuthentication) {
|
||||||
|
await defaultAuth?.applySecurityAuthentication(requestContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
return requestContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export class UserApiResponseProcessor {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unwraps the actual response sent by the server from the response context and deserializes the response content
|
||||||
|
* to the expected objects
|
||||||
|
*
|
||||||
|
* @params response Response returned by the server for a request to createUser
|
||||||
|
* @throws ApiException if the response code was not in [200, 299]
|
||||||
|
*/
|
||||||
|
public async createUser(response: ResponseContext): Promise< void> {
|
||||||
|
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
|
||||||
|
if (isCodeInRange("0", response.httpStatusCode)) {
|
||||||
|
throw new ApiException<undefined>(response.httpStatusCode, "successful operation", undefined, response.headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Work around for missing responses in specification, e.g. for petstore.yaml
|
||||||
|
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unwraps the actual response sent by the server from the response context and deserializes the response content
|
||||||
|
* to the expected objects
|
||||||
|
*
|
||||||
|
* @params response Response returned by the server for a request to createUsersWithArrayInput
|
||||||
|
* @throws ApiException if the response code was not in [200, 299]
|
||||||
|
*/
|
||||||
|
public async createUsersWithArrayInput(response: ResponseContext): Promise< void> {
|
||||||
|
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
|
||||||
|
if (isCodeInRange("0", response.httpStatusCode)) {
|
||||||
|
throw new ApiException<undefined>(response.httpStatusCode, "successful operation", undefined, response.headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Work around for missing responses in specification, e.g. for petstore.yaml
|
||||||
|
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unwraps the actual response sent by the server from the response context and deserializes the response content
|
||||||
|
* to the expected objects
|
||||||
|
*
|
||||||
|
* @params response Response returned by the server for a request to createUsersWithListInput
|
||||||
|
* @throws ApiException if the response code was not in [200, 299]
|
||||||
|
*/
|
||||||
|
public async createUsersWithListInput(response: ResponseContext): Promise< void> {
|
||||||
|
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
|
||||||
|
if (isCodeInRange("0", response.httpStatusCode)) {
|
||||||
|
throw new ApiException<undefined>(response.httpStatusCode, "successful operation", undefined, response.headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Work around for missing responses in specification, e.g. for petstore.yaml
|
||||||
|
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unwraps the actual response sent by the server from the response context and deserializes the response content
|
||||||
|
* to the expected objects
|
||||||
|
*
|
||||||
|
* @params response Response returned by the server for a request to deleteUser
|
||||||
|
* @throws ApiException if the response code was not in [200, 299]
|
||||||
|
*/
|
||||||
|
public async deleteUser(response: ResponseContext): Promise< void> {
|
||||||
|
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
|
||||||
|
if (isCodeInRange("400", response.httpStatusCode)) {
|
||||||
|
throw new ApiException<undefined>(response.httpStatusCode, "Invalid username supplied", undefined, response.headers);
|
||||||
|
}
|
||||||
|
if (isCodeInRange("404", response.httpStatusCode)) {
|
||||||
|
throw new ApiException<undefined>(response.httpStatusCode, "User not found", undefined, response.headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Work around for missing responses in specification, e.g. for petstore.yaml
|
||||||
|
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unwraps the actual response sent by the server from the response context and deserializes the response content
|
||||||
|
* to the expected objects
|
||||||
|
*
|
||||||
|
* @params response Response returned by the server for a request to getUserByName
|
||||||
|
* @throws ApiException if the response code was not in [200, 299]
|
||||||
|
*/
|
||||||
|
public async getUserByName(response: ResponseContext): Promise<User > {
|
||||||
|
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
|
||||||
|
if (isCodeInRange("200", response.httpStatusCode)) {
|
||||||
|
const body: User = ObjectSerializer.deserialize(
|
||||||
|
ObjectSerializer.parse(await response.body.text(), contentType),
|
||||||
|
"User", ""
|
||||||
|
) as User;
|
||||||
|
return body;
|
||||||
|
}
|
||||||
|
if (isCodeInRange("400", response.httpStatusCode)) {
|
||||||
|
throw new ApiException<undefined>(response.httpStatusCode, "Invalid username supplied", undefined, response.headers);
|
||||||
|
}
|
||||||
|
if (isCodeInRange("404", response.httpStatusCode)) {
|
||||||
|
throw new ApiException<undefined>(response.httpStatusCode, "User not found", undefined, response.headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Work around for missing responses in specification, e.g. for petstore.yaml
|
||||||
|
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
|
||||||
|
const body: User = ObjectSerializer.deserialize(
|
||||||
|
ObjectSerializer.parse(await response.body.text(), contentType),
|
||||||
|
"User", ""
|
||||||
|
) as User;
|
||||||
|
return body;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unwraps the actual response sent by the server from the response context and deserializes the response content
|
||||||
|
* to the expected objects
|
||||||
|
*
|
||||||
|
* @params response Response returned by the server for a request to loginUser
|
||||||
|
* @throws ApiException if the response code was not in [200, 299]
|
||||||
|
*/
|
||||||
|
public async loginUser(response: ResponseContext): Promise<string > {
|
||||||
|
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
|
||||||
|
if (isCodeInRange("200", response.httpStatusCode)) {
|
||||||
|
const body: string = ObjectSerializer.deserialize(
|
||||||
|
ObjectSerializer.parse(await response.body.text(), contentType),
|
||||||
|
"string", ""
|
||||||
|
) as string;
|
||||||
|
return body;
|
||||||
|
}
|
||||||
|
if (isCodeInRange("400", response.httpStatusCode)) {
|
||||||
|
throw new ApiException<undefined>(response.httpStatusCode, "Invalid username/password supplied", undefined, response.headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Work around for missing responses in specification, e.g. for petstore.yaml
|
||||||
|
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
|
||||||
|
const body: string = ObjectSerializer.deserialize(
|
||||||
|
ObjectSerializer.parse(await response.body.text(), contentType),
|
||||||
|
"string", ""
|
||||||
|
) as string;
|
||||||
|
return body;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unwraps the actual response sent by the server from the response context and deserializes the response content
|
||||||
|
* to the expected objects
|
||||||
|
*
|
||||||
|
* @params response Response returned by the server for a request to logoutUser
|
||||||
|
* @throws ApiException if the response code was not in [200, 299]
|
||||||
|
*/
|
||||||
|
public async logoutUser(response: ResponseContext): Promise< void> {
|
||||||
|
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
|
||||||
|
if (isCodeInRange("0", response.httpStatusCode)) {
|
||||||
|
throw new ApiException<undefined>(response.httpStatusCode, "successful operation", undefined, response.headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Work around for missing responses in specification, e.g. for petstore.yaml
|
||||||
|
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unwraps the actual response sent by the server from the response context and deserializes the response content
|
||||||
|
* to the expected objects
|
||||||
|
*
|
||||||
|
* @params response Response returned by the server for a request to updateUser
|
||||||
|
* @throws ApiException if the response code was not in [200, 299]
|
||||||
|
*/
|
||||||
|
public async updateUser(response: ResponseContext): Promise< void> {
|
||||||
|
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
|
||||||
|
if (isCodeInRange("400", response.httpStatusCode)) {
|
||||||
|
throw new ApiException<undefined>(response.httpStatusCode, "Invalid user supplied", undefined, response.headers);
|
||||||
|
}
|
||||||
|
if (isCodeInRange("404", response.httpStatusCode)) {
|
||||||
|
throw new ApiException<undefined>(response.httpStatusCode, "User not found", undefined, response.headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Work around for missing responses in specification, e.g. for petstore.yaml
|
||||||
|
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,37 @@
|
|||||||
|
import { Configuration } from '../configuration'
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @export
|
||||||
|
*/
|
||||||
|
export const COLLECTION_FORMATS = {
|
||||||
|
csv: ",",
|
||||||
|
ssv: " ",
|
||||||
|
tsv: "\t",
|
||||||
|
pipes: "|",
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @export
|
||||||
|
* @class BaseAPI
|
||||||
|
*/
|
||||||
|
export class BaseAPIRequestFactory {
|
||||||
|
|
||||||
|
constructor(protected configuration: Configuration) {
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @export
|
||||||
|
* @class RequiredError
|
||||||
|
* @extends {Error}
|
||||||
|
*/
|
||||||
|
export class RequiredError extends Error {
|
||||||
|
name: "RequiredError" = "RequiredError";
|
||||||
|
constructor(public api: string, public method: string, public field: string) {
|
||||||
|
super("Required parameter " + field + " was null or undefined when calling " + api + "." + method + ".");
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
/**
|
||||||
|
* Represents an error caused by an api call i.e. it has attributes for a HTTP status code
|
||||||
|
* and the returned body object.
|
||||||
|
*
|
||||||
|
* Example
|
||||||
|
* API returns a ErrorMessageObject whenever HTTP status code is not in [200, 299]
|
||||||
|
* => ApiException(404, someErrorMessageObject)
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
export class ApiException<T> extends Error {
|
||||||
|
public constructor(public code: number, message: string, public body: T, public headers: { [key: string]: string; }) {
|
||||||
|
super("HTTP-Code: " + code + "\nMessage: " + message + "\nBody: " + JSON.stringify(body) + "\nHeaders: " +
|
||||||
|
JSON.stringify(headers))
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,107 @@
|
|||||||
|
import { RequestContext } from "../http/http";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface authentication schemes.
|
||||||
|
*/
|
||||||
|
export interface SecurityAuthentication {
|
||||||
|
/*
|
||||||
|
* @return returns the name of the security authentication as specified in OAI
|
||||||
|
*/
|
||||||
|
getName(): string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Applies the authentication scheme to the request context
|
||||||
|
*
|
||||||
|
* @params context the request context which should use this authentication scheme
|
||||||
|
*/
|
||||||
|
applySecurityAuthentication(context: RequestContext): void | Promise<void>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface TokenProvider {
|
||||||
|
getToken(): Promise<string> | string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Applies apiKey authentication to the request context.
|
||||||
|
*/
|
||||||
|
export class ApiKeyAuthentication implements SecurityAuthentication {
|
||||||
|
/**
|
||||||
|
* Configures this api key authentication with the necessary properties
|
||||||
|
*
|
||||||
|
* @param apiKey: The api key to be used for every request
|
||||||
|
*/
|
||||||
|
public constructor(private apiKey: string) {}
|
||||||
|
|
||||||
|
public getName(): string {
|
||||||
|
return "api_key";
|
||||||
|
}
|
||||||
|
|
||||||
|
public applySecurityAuthentication(context: RequestContext) {
|
||||||
|
context.setHeaderParam("api_key", this.apiKey);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Applies oauth2 authentication to the request context.
|
||||||
|
*/
|
||||||
|
export class PetstoreAuthAuthentication implements SecurityAuthentication {
|
||||||
|
/**
|
||||||
|
* Configures OAuth2 with the necessary properties
|
||||||
|
*
|
||||||
|
* @param accessToken: The access token to be used for every request
|
||||||
|
*/
|
||||||
|
public constructor(private accessToken: string) {}
|
||||||
|
|
||||||
|
public getName(): string {
|
||||||
|
return "petstore_auth";
|
||||||
|
}
|
||||||
|
|
||||||
|
public applySecurityAuthentication(context: RequestContext) {
|
||||||
|
context.setHeaderParam("Authorization", "Bearer " + this.accessToken);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export type AuthMethods = {
|
||||||
|
"default"?: SecurityAuthentication,
|
||||||
|
"api_key"?: SecurityAuthentication,
|
||||||
|
"petstore_auth"?: SecurityAuthentication
|
||||||
|
}
|
||||||
|
|
||||||
|
export type ApiKeyConfiguration = string;
|
||||||
|
export type HttpBasicConfiguration = { "username": string, "password": string };
|
||||||
|
export type HttpBearerConfiguration = { tokenProvider: TokenProvider };
|
||||||
|
export type OAuth2Configuration = { accessToken: string };
|
||||||
|
|
||||||
|
export type AuthMethodsConfiguration = {
|
||||||
|
"default"?: SecurityAuthentication,
|
||||||
|
"api_key"?: ApiKeyConfiguration,
|
||||||
|
"petstore_auth"?: OAuth2Configuration
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates the authentication methods from a swagger description.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
export function configureAuthMethods(config: AuthMethodsConfiguration | undefined): AuthMethods {
|
||||||
|
let authMethods: AuthMethods = {}
|
||||||
|
|
||||||
|
if (!config) {
|
||||||
|
return authMethods;
|
||||||
|
}
|
||||||
|
authMethods["default"] = config["default"]
|
||||||
|
|
||||||
|
if (config["api_key"]) {
|
||||||
|
authMethods["api_key"] = new ApiKeyAuthentication(
|
||||||
|
config["api_key"]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config["petstore_auth"]) {
|
||||||
|
authMethods["petstore_auth"] = new PetstoreAuthAuthentication(
|
||||||
|
config["petstore_auth"]["accessToken"]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return authMethods;
|
||||||
|
}
|
@ -0,0 +1,66 @@
|
|||||||
|
import { HttpLibrary } from "./http/http";
|
||||||
|
import { Middleware, PromiseMiddleware, PromiseMiddlewareWrapper } from "./middleware";
|
||||||
|
import { IsomorphicFetchHttpLibrary as DefaultHttpLibrary } from "./http/isomorphic-fetch";
|
||||||
|
import { BaseServerConfiguration, server1 } from "./servers";
|
||||||
|
import { configureAuthMethods, AuthMethods, AuthMethodsConfiguration } from "./auth/auth";
|
||||||
|
|
||||||
|
export interface Configuration {
|
||||||
|
readonly baseServer: BaseServerConfiguration;
|
||||||
|
readonly httpApi: HttpLibrary;
|
||||||
|
readonly middleware: Middleware[];
|
||||||
|
readonly authMethods: AuthMethods;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface with which a configuration object can be configured.
|
||||||
|
*/
|
||||||
|
export interface ConfigurationParameters {
|
||||||
|
/**
|
||||||
|
* Default server to use
|
||||||
|
*/
|
||||||
|
baseServer?: BaseServerConfiguration;
|
||||||
|
/**
|
||||||
|
* HTTP library to use e.g. IsomorphicFetch
|
||||||
|
*/
|
||||||
|
httpApi?: HttpLibrary;
|
||||||
|
/**
|
||||||
|
* The middlewares which will be applied to requests and responses
|
||||||
|
*/
|
||||||
|
middleware?: Middleware[];
|
||||||
|
/**
|
||||||
|
* Configures all middlewares using the promise api instead of observables (which Middleware uses)
|
||||||
|
*/
|
||||||
|
promiseMiddleware?: PromiseMiddleware[];
|
||||||
|
/**
|
||||||
|
* Configuration for the available authentication methods
|
||||||
|
*/
|
||||||
|
authMethods?: AuthMethodsConfiguration
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configuration factory function
|
||||||
|
*
|
||||||
|
* If a property is not included in conf, a default is used:
|
||||||
|
* - baseServer: server1
|
||||||
|
* - httpApi: IsomorphicFetchHttpLibrary
|
||||||
|
* - middleware: []
|
||||||
|
* - promiseMiddleware: []
|
||||||
|
* - authMethods: {}
|
||||||
|
*
|
||||||
|
* @param conf partial configuration
|
||||||
|
*/
|
||||||
|
export function createConfiguration(conf: ConfigurationParameters = {}): Configuration {
|
||||||
|
const configuration: Configuration = {
|
||||||
|
baseServer: conf.baseServer !== undefined ? conf.baseServer : server1,
|
||||||
|
httpApi: conf.httpApi || new DefaultHttpLibrary(),
|
||||||
|
middleware: conf.middleware || [],
|
||||||
|
authMethods: configureAuthMethods(conf.authMethods)
|
||||||
|
};
|
||||||
|
if (conf.promiseMiddleware) {
|
||||||
|
conf.promiseMiddleware.forEach(
|
||||||
|
m => configuration.middleware.push(new PromiseMiddlewareWrapper(m))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return configuration;
|
||||||
|
}
|
@ -0,0 +1,51 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
|
||||||
|
#
|
||||||
|
# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update"
|
||||||
|
|
||||||
|
git_user_id=$1
|
||||||
|
git_repo_id=$2
|
||||||
|
release_note=$3
|
||||||
|
|
||||||
|
if [ "$git_user_id" = "" ]; then
|
||||||
|
git_user_id="GIT_USER_ID"
|
||||||
|
echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$git_repo_id" = "" ]; then
|
||||||
|
git_repo_id="GIT_REPO_ID"
|
||||||
|
echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$release_note" = "" ]; then
|
||||||
|
release_note="Minor update"
|
||||||
|
echo "[INFO] No command line input provided. Set \$release_note to $release_note"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Initialize the local directory as a Git repository
|
||||||
|
git init
|
||||||
|
|
||||||
|
# Adds the files in the local repository and stages them for commit.
|
||||||
|
git add .
|
||||||
|
|
||||||
|
# Commits the tracked changes and prepares them to be pushed to a remote repository.
|
||||||
|
git commit -m "$release_note"
|
||||||
|
|
||||||
|
# Sets the new remote
|
||||||
|
git_remote=$(git remote)
|
||||||
|
if [ "$git_remote" = "" ]; then # git remote not defined
|
||||||
|
|
||||||
|
if [ "$GIT_TOKEN" = "" ]; then
|
||||||
|
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
|
||||||
|
git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
|
||||||
|
else
|
||||||
|
git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@github.com/${git_user_id}/${git_repo_id}.git
|
||||||
|
fi
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
git pull origin master
|
||||||
|
|
||||||
|
# Pushes (Forces) the changes in the local repository up to the remote repository
|
||||||
|
echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git"
|
||||||
|
git push origin master 2>&1 | grep -v 'To https'
|
@ -0,0 +1,234 @@
|
|||||||
|
import URLParse from "url-parse";
|
||||||
|
import { Observable, from } from '../rxjsStub';
|
||||||
|
|
||||||
|
export * from './isomorphic-fetch';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents an HTTP method.
|
||||||
|
*/
|
||||||
|
export enum HttpMethod {
|
||||||
|
GET = "GET",
|
||||||
|
HEAD = "HEAD",
|
||||||
|
POST = "POST",
|
||||||
|
PUT = "PUT",
|
||||||
|
DELETE = "DELETE",
|
||||||
|
CONNECT = "CONNECT",
|
||||||
|
OPTIONS = "OPTIONS",
|
||||||
|
TRACE = "TRACE",
|
||||||
|
PATCH = "PATCH"
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents an HTTP file which will be transferred from or to a server.
|
||||||
|
*/
|
||||||
|
export type HttpFile = Blob & { readonly name: string };
|
||||||
|
|
||||||
|
|
||||||
|
export class HttpException extends Error {
|
||||||
|
public constructor(msg: string) {
|
||||||
|
super(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents the body of an outgoing HTTP request.
|
||||||
|
*/
|
||||||
|
export type RequestBody = undefined | string | FormData | URLSearchParams;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents an HTTP request context
|
||||||
|
*/
|
||||||
|
export class RequestContext {
|
||||||
|
private headers: { [key: string]: string } = {};
|
||||||
|
private body: RequestBody = undefined;
|
||||||
|
private url: URLParse;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates the request context using a http method and request resource url
|
||||||
|
*
|
||||||
|
* @param url url of the requested resource
|
||||||
|
* @param httpMethod http method
|
||||||
|
*/
|
||||||
|
public constructor(url: string, private httpMethod: HttpMethod) {
|
||||||
|
this.url = new URLParse(url, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Returns the url set in the constructor including the query string
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public getUrl(): string {
|
||||||
|
return this.url.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replaces the url set in the constructor with this url.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public setUrl(url: string) {
|
||||||
|
this.url = new URLParse(url, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the body of the http request either as a string or FormData
|
||||||
|
*
|
||||||
|
* Note that setting a body on a HTTP GET, HEAD, DELETE, CONNECT or TRACE
|
||||||
|
* request is discouraged.
|
||||||
|
* https://httpwg.org/http-core/draft-ietf-httpbis-semantics-latest.html#rfc.section.7.3.1
|
||||||
|
*
|
||||||
|
* @param body the body of the request
|
||||||
|
*/
|
||||||
|
public setBody(body: RequestBody) {
|
||||||
|
this.body = body;
|
||||||
|
}
|
||||||
|
|
||||||
|
public getHttpMethod(): HttpMethod {
|
||||||
|
return this.httpMethod;
|
||||||
|
}
|
||||||
|
|
||||||
|
public getHeaders(): { [key: string]: string } {
|
||||||
|
return this.headers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public getBody(): RequestBody {
|
||||||
|
return this.body;
|
||||||
|
}
|
||||||
|
|
||||||
|
public setQueryParam(name: string, value: string) {
|
||||||
|
let queryObj = this.url.query;
|
||||||
|
queryObj[name] = value;
|
||||||
|
this.url.set("query", queryObj);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets a cookie with the name and value. NO check for duplicate cookies is performed
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public addCookie(name: string, value: string): void {
|
||||||
|
if (!this.headers["Cookie"]) {
|
||||||
|
this.headers["Cookie"] = "";
|
||||||
|
}
|
||||||
|
this.headers["Cookie"] += name + "=" + value + "; ";
|
||||||
|
}
|
||||||
|
|
||||||
|
public setHeaderParam(key: string, value: string): void {
|
||||||
|
this.headers[key] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ResponseBody {
|
||||||
|
text(): Promise<string>;
|
||||||
|
binary(): Promise<Blob>;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper class to generate a `ResponseBody` from binary data
|
||||||
|
*/
|
||||||
|
export class SelfDecodingBody implements ResponseBody {
|
||||||
|
constructor(private dataSource: Promise<Blob>) {}
|
||||||
|
|
||||||
|
binary(): Promise<Blob> {
|
||||||
|
return this.dataSource;
|
||||||
|
}
|
||||||
|
|
||||||
|
async text(): Promise<string> {
|
||||||
|
const data: Blob = await this.dataSource;
|
||||||
|
// @ts-ignore
|
||||||
|
if (data.text) {
|
||||||
|
// @ts-ignore
|
||||||
|
return data.text();
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Promise<string>((resolve, reject) => {
|
||||||
|
const reader = new FileReader();
|
||||||
|
reader.addEventListener("load", () => resolve(reader.result as string));
|
||||||
|
reader.addEventListener("error", () => reject(reader.error));
|
||||||
|
reader.readAsText(data);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class ResponseContext {
|
||||||
|
public constructor(
|
||||||
|
public httpStatusCode: number,
|
||||||
|
public headers: { [key: string]: string },
|
||||||
|
public body: ResponseBody
|
||||||
|
) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse header value in the form `value; param1="value1"`
|
||||||
|
*
|
||||||
|
* E.g. for Content-Type or Content-Disposition
|
||||||
|
* Parameter names are converted to lower case
|
||||||
|
* The first parameter is returned with the key `""`
|
||||||
|
*/
|
||||||
|
public getParsedHeader(headerName: string): { [parameter: string]: string } {
|
||||||
|
const result: { [parameter: string]: string } = {};
|
||||||
|
if (!this.headers[headerName]) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
const parameters = this.headers[headerName].split(";");
|
||||||
|
for (const parameter of parameters) {
|
||||||
|
let [key, value] = parameter.split("=", 2);
|
||||||
|
key = key.toLowerCase().trim();
|
||||||
|
if (value === undefined) {
|
||||||
|
result[""] = key;
|
||||||
|
} else {
|
||||||
|
value = value.trim();
|
||||||
|
if (value.startsWith('"') && value.endsWith('"')) {
|
||||||
|
value = value.substring(1, value.length - 1);
|
||||||
|
}
|
||||||
|
result[key] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getBodyAsFile(): Promise<HttpFile> {
|
||||||
|
const data = await this.body.binary();
|
||||||
|
const fileName = this.getParsedHeader("content-disposition")["filename"] || "";
|
||||||
|
const contentType = this.headers["content-type"] || "";
|
||||||
|
try {
|
||||||
|
return new File([data], fileName, { type: contentType });
|
||||||
|
} catch (error) {
|
||||||
|
/** Fallback for when the File constructor is not available */
|
||||||
|
return Object.assign(data, {
|
||||||
|
name: fileName,
|
||||||
|
type: contentType
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use a heuristic to get a body of unknown data structure.
|
||||||
|
* Return as string if possible, otherwise as binary.
|
||||||
|
*/
|
||||||
|
public getBodyAsAny(): Promise<string | Blob | undefined> {
|
||||||
|
try {
|
||||||
|
return this.body.text();
|
||||||
|
} catch {}
|
||||||
|
|
||||||
|
try {
|
||||||
|
return this.body.binary();
|
||||||
|
} catch {}
|
||||||
|
|
||||||
|
return Promise.resolve(undefined);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface HttpLibrary {
|
||||||
|
send(request: RequestContext): Observable<ResponseContext>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PromiseHttpLibrary {
|
||||||
|
send(request: RequestContext): Promise<ResponseContext>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function wrapHttpLibrary(promiseHttpLibrary: PromiseHttpLibrary): HttpLibrary {
|
||||||
|
return {
|
||||||
|
send(request: RequestContext): Observable<ResponseContext> {
|
||||||
|
return from(promiseHttpLibrary.send(request));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
import {HttpLibrary, RequestContext, ResponseContext} from './http';
|
||||||
|
import { from, Observable } from '../rxjsStub';
|
||||||
|
import "whatwg-fetch";
|
||||||
|
|
||||||
|
export class IsomorphicFetchHttpLibrary implements HttpLibrary {
|
||||||
|
|
||||||
|
public send(request: RequestContext): Observable<ResponseContext> {
|
||||||
|
let method = request.getHttpMethod().toString();
|
||||||
|
let body = request.getBody();
|
||||||
|
|
||||||
|
const resultPromise = fetch(request.getUrl(), {
|
||||||
|
method: method,
|
||||||
|
body: body as any,
|
||||||
|
headers: request.getHeaders(),
|
||||||
|
credentials: "same-origin"
|
||||||
|
}).then((resp: any) => {
|
||||||
|
const headers: { [name: string]: string } = {};
|
||||||
|
resp.headers.forEach((value: string, name: string) => {
|
||||||
|
headers[name] = value;
|
||||||
|
});
|
||||||
|
|
||||||
|
const body = {
|
||||||
|
text: () => resp.text(),
|
||||||
|
binary: () => resp.blob()
|
||||||
|
};
|
||||||
|
return new ResponseContext(resp.status, headers, body);
|
||||||
|
});
|
||||||
|
|
||||||
|
return from<Promise<ResponseContext>>(resultPromise);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
export * from "./http/http";
|
||||||
|
export * from "./auth/auth";
|
||||||
|
export * from "./models/all";
|
||||||
|
export { createConfiguration } from "./configuration"
|
||||||
|
export { Configuration } from "./configuration"
|
||||||
|
export * from "./apis/exception";
|
||||||
|
export * from "./servers";
|
||||||
|
export { RequiredError } from "./apis/baseapi";
|
||||||
|
|
||||||
|
export { PromiseMiddleware as Middleware } from './middleware';
|
||||||
|
export { PromisePetApi as PetApi, PromiseStoreApi as StoreApi, PromiseUserApi as UserApi } from './types/PromiseAPI';
|
||||||
|
|
@ -0,0 +1,66 @@
|
|||||||
|
import {RequestContext, ResponseContext} from './http/http';
|
||||||
|
import { Observable, from } from './rxjsStub';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines the contract for a middleware intercepting requests before
|
||||||
|
* they are sent (but after the RequestContext was created)
|
||||||
|
* and before the ResponseContext is unwrapped.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
export interface Middleware {
|
||||||
|
/**
|
||||||
|
* Modifies the request before the request is sent.
|
||||||
|
*
|
||||||
|
* @param context RequestContext of a request which is about to be sent to the server
|
||||||
|
* @returns an observable of the updated request context
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
pre(context: RequestContext): Observable<RequestContext>;
|
||||||
|
/**
|
||||||
|
* Modifies the returned response before it is deserialized.
|
||||||
|
*
|
||||||
|
* @param context ResponseContext of a sent request
|
||||||
|
* @returns an observable of the modified response context
|
||||||
|
*/
|
||||||
|
post(context: ResponseContext): Observable<ResponseContext>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class PromiseMiddlewareWrapper implements Middleware {
|
||||||
|
|
||||||
|
public constructor(private middleware: PromiseMiddleware) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
pre(context: RequestContext): Observable<RequestContext> {
|
||||||
|
return from(this.middleware.pre(context));
|
||||||
|
}
|
||||||
|
|
||||||
|
post(context: ResponseContext): Observable<ResponseContext> {
|
||||||
|
return from(this.middleware.post(context));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines the contract for a middleware intercepting requests before
|
||||||
|
* they are sent (but after the RequestContext was created)
|
||||||
|
* and before the ResponseContext is unwrapped.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
export interface PromiseMiddleware {
|
||||||
|
/**
|
||||||
|
* Modifies the request before the request is sent.
|
||||||
|
*
|
||||||
|
* @param context RequestContext of a request which is about to be sent to the server
|
||||||
|
* @returns an observable of the updated request context
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
pre(context: RequestContext): Promise<RequestContext>;
|
||||||
|
/**
|
||||||
|
* Modifies the returned response before it is deserialized.
|
||||||
|
*
|
||||||
|
* @param context ResponseContext of a sent request
|
||||||
|
* @returns an observable of the modified response context
|
||||||
|
*/
|
||||||
|
post(context: ResponseContext): Promise<ResponseContext>;
|
||||||
|
}
|
@ -0,0 +1,52 @@
|
|||||||
|
/**
|
||||||
|
* OpenAPI Petstore
|
||||||
|
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { HttpFile } from '../http/http';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Describes the result of uploading an image resource
|
||||||
|
*/
|
||||||
|
export class ApiResponse {
|
||||||
|
'code'?: number;
|
||||||
|
'type'?: string;
|
||||||
|
'message'?: string;
|
||||||
|
|
||||||
|
static readonly discriminator: string | undefined = undefined;
|
||||||
|
|
||||||
|
static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [
|
||||||
|
{
|
||||||
|
"name": "code",
|
||||||
|
"baseName": "code",
|
||||||
|
"type": "number",
|
||||||
|
"format": "int32"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "type",
|
||||||
|
"baseName": "type",
|
||||||
|
"type": "string",
|
||||||
|
"format": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "message",
|
||||||
|
"baseName": "message",
|
||||||
|
"type": "string",
|
||||||
|
"format": ""
|
||||||
|
} ];
|
||||||
|
|
||||||
|
static getAttributeTypeMap() {
|
||||||
|
return ApiResponse.attributeTypeMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
public constructor() {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,45 @@
|
|||||||
|
/**
|
||||||
|
* OpenAPI Petstore
|
||||||
|
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { HttpFile } from '../http/http';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A category for a pet
|
||||||
|
*/
|
||||||
|
export class Category {
|
||||||
|
'id'?: number;
|
||||||
|
'name'?: string;
|
||||||
|
|
||||||
|
static readonly discriminator: string | undefined = undefined;
|
||||||
|
|
||||||
|
static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [
|
||||||
|
{
|
||||||
|
"name": "id",
|
||||||
|
"baseName": "id",
|
||||||
|
"type": "number",
|
||||||
|
"format": "int64"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "name",
|
||||||
|
"baseName": "name",
|
||||||
|
"type": "string",
|
||||||
|
"format": ""
|
||||||
|
} ];
|
||||||
|
|
||||||
|
static getAttributeTypeMap() {
|
||||||
|
return Category.attributeTypeMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
public constructor() {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,238 @@
|
|||||||
|
export * from './ApiResponse';
|
||||||
|
export * from './Category';
|
||||||
|
export * from './Order';
|
||||||
|
export * from './Pet';
|
||||||
|
export * from './Tag';
|
||||||
|
export * from './User';
|
||||||
|
|
||||||
|
import { ApiResponse } from './ApiResponse';
|
||||||
|
import { Category } from './Category';
|
||||||
|
import { Order , OrderStatusEnum } from './Order';
|
||||||
|
import { Pet , PetStatusEnum } from './Pet';
|
||||||
|
import { Tag } from './Tag';
|
||||||
|
import { User } from './User';
|
||||||
|
|
||||||
|
/* tslint:disable:no-unused-variable */
|
||||||
|
let primitives = [
|
||||||
|
"string",
|
||||||
|
"boolean",
|
||||||
|
"double",
|
||||||
|
"integer",
|
||||||
|
"long",
|
||||||
|
"float",
|
||||||
|
"number",
|
||||||
|
"any"
|
||||||
|
];
|
||||||
|
|
||||||
|
const supportedMediaTypes: { [mediaType: string]: number } = {
|
||||||
|
"application/json": Infinity,
|
||||||
|
"application/octet-stream": 0,
|
||||||
|
"application/x-www-form-urlencoded": 0
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
let enumsMap: Set<string> = new Set<string>([
|
||||||
|
"OrderStatusEnum",
|
||||||
|
"PetStatusEnum",
|
||||||
|
]);
|
||||||
|
|
||||||
|
let typeMap: {[index: string]: any} = {
|
||||||
|
"ApiResponse": ApiResponse,
|
||||||
|
"Category": Category,
|
||||||
|
"Order": Order,
|
||||||
|
"Pet": Pet,
|
||||||
|
"Tag": Tag,
|
||||||
|
"User": User,
|
||||||
|
}
|
||||||
|
|
||||||
|
export class ObjectSerializer {
|
||||||
|
public static findCorrectType(data: any, expectedType: string) {
|
||||||
|
if (data == undefined) {
|
||||||
|
return expectedType;
|
||||||
|
} else if (primitives.indexOf(expectedType.toLowerCase()) !== -1) {
|
||||||
|
return expectedType;
|
||||||
|
} else if (expectedType === "Date") {
|
||||||
|
return expectedType;
|
||||||
|
} else {
|
||||||
|
if (enumsMap.has(expectedType)) {
|
||||||
|
return expectedType;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!typeMap[expectedType]) {
|
||||||
|
return expectedType; // w/e we don't know the type
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check the discriminator
|
||||||
|
let discriminatorProperty = typeMap[expectedType].discriminator;
|
||||||
|
if (discriminatorProperty == null) {
|
||||||
|
return expectedType; // the type does not have a discriminator. use it.
|
||||||
|
} else {
|
||||||
|
if (data[discriminatorProperty]) {
|
||||||
|
var discriminatorType = data[discriminatorProperty];
|
||||||
|
if(typeMap[discriminatorType]){
|
||||||
|
return discriminatorType; // use the type given in the discriminator
|
||||||
|
} else {
|
||||||
|
return expectedType; // discriminator did not map to a type
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return expectedType; // discriminator was not present (or an empty string)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static serialize(data: any, type: string, format: string) {
|
||||||
|
if (data == undefined) {
|
||||||
|
return data;
|
||||||
|
} else if (primitives.indexOf(type.toLowerCase()) !== -1) {
|
||||||
|
return data;
|
||||||
|
} else if (type.lastIndexOf("Array<", 0) === 0) { // string.startsWith pre es6
|
||||||
|
let subType: string = type.replace("Array<", ""); // Array<Type> => Type>
|
||||||
|
subType = subType.substring(0, subType.length - 1); // Type> => Type
|
||||||
|
let transformedData: any[] = [];
|
||||||
|
for (let index in data) {
|
||||||
|
let date = data[index];
|
||||||
|
transformedData.push(ObjectSerializer.serialize(date, subType, format));
|
||||||
|
}
|
||||||
|
return transformedData;
|
||||||
|
} else if (type === "Date") {
|
||||||
|
if (format == "date") {
|
||||||
|
let month = data.getMonth()+1
|
||||||
|
month = month < 10 ? "0" + month.toString() : month.toString()
|
||||||
|
let day = data.getDate();
|
||||||
|
day = day < 10 ? "0" + day.toString() : day.toString();
|
||||||
|
|
||||||
|
return data.getFullYear() + "-" + month + "-" + day;
|
||||||
|
} else {
|
||||||
|
return data.toISOString();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (enumsMap.has(type)) {
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
if (!typeMap[type]) { // in case we dont know the type
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the actual type of this object
|
||||||
|
type = this.findCorrectType(data, type);
|
||||||
|
|
||||||
|
// get the map for the correct type.
|
||||||
|
let attributeTypes = typeMap[type].getAttributeTypeMap();
|
||||||
|
let instance: {[index: string]: any} = {};
|
||||||
|
for (let index in attributeTypes) {
|
||||||
|
let attributeType = attributeTypes[index];
|
||||||
|
instance[attributeType.baseName] = ObjectSerializer.serialize(data[attributeType.name], attributeType.type, attributeType.format);
|
||||||
|
}
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static deserialize(data: any, type: string, format: string) {
|
||||||
|
// polymorphism may change the actual type.
|
||||||
|
type = ObjectSerializer.findCorrectType(data, type);
|
||||||
|
if (data == undefined) {
|
||||||
|
return data;
|
||||||
|
} else if (primitives.indexOf(type.toLowerCase()) !== -1) {
|
||||||
|
return data;
|
||||||
|
} else if (type.lastIndexOf("Array<", 0) === 0) { // string.startsWith pre es6
|
||||||
|
let subType: string = type.replace("Array<", ""); // Array<Type> => Type>
|
||||||
|
subType = subType.substring(0, subType.length - 1); // Type> => Type
|
||||||
|
let transformedData: any[] = [];
|
||||||
|
for (let index in data) {
|
||||||
|
let date = data[index];
|
||||||
|
transformedData.push(ObjectSerializer.deserialize(date, subType, format));
|
||||||
|
}
|
||||||
|
return transformedData;
|
||||||
|
} else if (type === "Date") {
|
||||||
|
return new Date(data);
|
||||||
|
} else {
|
||||||
|
if (enumsMap.has(type)) {// is Enum
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!typeMap[type]) { // dont know the type
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
let instance = new typeMap[type]();
|
||||||
|
let attributeTypes = typeMap[type].getAttributeTypeMap();
|
||||||
|
for (let index in attributeTypes) {
|
||||||
|
let attributeType = attributeTypes[index];
|
||||||
|
let value = ObjectSerializer.deserialize(data[attributeType.baseName], attributeType.type, attributeType.format);
|
||||||
|
if (value !== undefined) {
|
||||||
|
instance[attributeType.name] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Normalize media type
|
||||||
|
*
|
||||||
|
* We currently do not handle any media types attributes, i.e. anything
|
||||||
|
* after a semicolon. All content is assumed to be UTF-8 compatible.
|
||||||
|
*/
|
||||||
|
public static normalizeMediaType(mediaType: string | undefined): string | undefined {
|
||||||
|
if (mediaType === undefined) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
return mediaType.split(";")[0].trim().toLowerCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* From a list of possible media types, choose the one we can handle best.
|
||||||
|
*
|
||||||
|
* The order of the given media types does not have any impact on the choice
|
||||||
|
* made.
|
||||||
|
*/
|
||||||
|
public static getPreferredMediaType(mediaTypes: Array<string>): string {
|
||||||
|
/** According to OAS 3 we should default to json */
|
||||||
|
if (!mediaTypes) {
|
||||||
|
return "application/json";
|
||||||
|
}
|
||||||
|
|
||||||
|
const normalMediaTypes = mediaTypes.map(this.normalizeMediaType);
|
||||||
|
let selectedMediaType: string | undefined = undefined;
|
||||||
|
let selectedRank: number = -Infinity;
|
||||||
|
for (const mediaType of normalMediaTypes) {
|
||||||
|
if (supportedMediaTypes[mediaType!] > selectedRank) {
|
||||||
|
selectedMediaType = mediaType;
|
||||||
|
selectedRank = supportedMediaTypes[mediaType!];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (selectedMediaType === undefined) {
|
||||||
|
throw new Error("None of the given media types are supported: " + mediaTypes.join(", "));
|
||||||
|
}
|
||||||
|
|
||||||
|
return selectedMediaType!;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert data to a string according the given media type
|
||||||
|
*/
|
||||||
|
public static stringify(data: any, mediaType: string): string {
|
||||||
|
if (mediaType === "application/json") {
|
||||||
|
return JSON.stringify(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new Error("The mediaType " + mediaType + " is not supported by ObjectSerializer.stringify.");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse data from a string according to the given media type
|
||||||
|
*/
|
||||||
|
public static parse(rawData: string, mediaType: string | undefined) {
|
||||||
|
if (mediaType === undefined) {
|
||||||
|
throw new Error("Cannot parse content. No Content-Type defined.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mediaType === "application/json") {
|
||||||
|
return JSON.parse(rawData);
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new Error("The mediaType " + mediaType + " is not supported by ObjectSerializer.parse.");
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,79 @@
|
|||||||
|
/**
|
||||||
|
* OpenAPI Petstore
|
||||||
|
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { HttpFile } from '../http/http';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An order for a pets from the pet store
|
||||||
|
*/
|
||||||
|
export class Order {
|
||||||
|
'id'?: number;
|
||||||
|
'petId'?: number;
|
||||||
|
'quantity'?: number;
|
||||||
|
'shipDate'?: Date;
|
||||||
|
/**
|
||||||
|
* Order Status
|
||||||
|
*/
|
||||||
|
'status'?: OrderStatusEnum;
|
||||||
|
'complete'?: boolean;
|
||||||
|
|
||||||
|
static readonly discriminator: string | undefined = undefined;
|
||||||
|
|
||||||
|
static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [
|
||||||
|
{
|
||||||
|
"name": "id",
|
||||||
|
"baseName": "id",
|
||||||
|
"type": "number",
|
||||||
|
"format": "int64"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "petId",
|
||||||
|
"baseName": "petId",
|
||||||
|
"type": "number",
|
||||||
|
"format": "int64"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "quantity",
|
||||||
|
"baseName": "quantity",
|
||||||
|
"type": "number",
|
||||||
|
"format": "int32"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "shipDate",
|
||||||
|
"baseName": "shipDate",
|
||||||
|
"type": "Date",
|
||||||
|
"format": "date-time"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "status",
|
||||||
|
"baseName": "status",
|
||||||
|
"type": "OrderStatusEnum",
|
||||||
|
"format": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "complete",
|
||||||
|
"baseName": "complete",
|
||||||
|
"type": "boolean",
|
||||||
|
"format": ""
|
||||||
|
} ];
|
||||||
|
|
||||||
|
static getAttributeTypeMap() {
|
||||||
|
return Order.attributeTypeMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
public constructor() {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export type OrderStatusEnum = "placed" | "approved" | "delivered" ;
|
||||||
|
|
@ -0,0 +1,81 @@
|
|||||||
|
/**
|
||||||
|
* OpenAPI Petstore
|
||||||
|
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { Category } from './Category';
|
||||||
|
import { Tag } from './Tag';
|
||||||
|
import { HttpFile } from '../http/http';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A pet for sale in the pet store
|
||||||
|
*/
|
||||||
|
export class Pet {
|
||||||
|
'id'?: number;
|
||||||
|
'category'?: Category;
|
||||||
|
'name': string;
|
||||||
|
'photoUrls': Array<string>;
|
||||||
|
'tags'?: Array<Tag>;
|
||||||
|
/**
|
||||||
|
* pet status in the store
|
||||||
|
*/
|
||||||
|
'status'?: PetStatusEnum;
|
||||||
|
|
||||||
|
static readonly discriminator: string | undefined = undefined;
|
||||||
|
|
||||||
|
static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [
|
||||||
|
{
|
||||||
|
"name": "id",
|
||||||
|
"baseName": "id",
|
||||||
|
"type": "number",
|
||||||
|
"format": "int64"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "category",
|
||||||
|
"baseName": "category",
|
||||||
|
"type": "Category",
|
||||||
|
"format": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "name",
|
||||||
|
"baseName": "name",
|
||||||
|
"type": "string",
|
||||||
|
"format": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "photoUrls",
|
||||||
|
"baseName": "photoUrls",
|
||||||
|
"type": "Array<string>",
|
||||||
|
"format": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "tags",
|
||||||
|
"baseName": "tags",
|
||||||
|
"type": "Array<Tag>",
|
||||||
|
"format": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "status",
|
||||||
|
"baseName": "status",
|
||||||
|
"type": "PetStatusEnum",
|
||||||
|
"format": ""
|
||||||
|
} ];
|
||||||
|
|
||||||
|
static getAttributeTypeMap() {
|
||||||
|
return Pet.attributeTypeMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
public constructor() {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export type PetStatusEnum = "available" | "pending" | "sold" ;
|
||||||
|
|
@ -0,0 +1,45 @@
|
|||||||
|
/**
|
||||||
|
* OpenAPI Petstore
|
||||||
|
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { HttpFile } from '../http/http';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A tag for a pet
|
||||||
|
*/
|
||||||
|
export class Tag {
|
||||||
|
'id'?: number;
|
||||||
|
'name'?: string;
|
||||||
|
|
||||||
|
static readonly discriminator: string | undefined = undefined;
|
||||||
|
|
||||||
|
static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [
|
||||||
|
{
|
||||||
|
"name": "id",
|
||||||
|
"baseName": "id",
|
||||||
|
"type": "number",
|
||||||
|
"format": "int64"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "name",
|
||||||
|
"baseName": "name",
|
||||||
|
"type": "string",
|
||||||
|
"format": ""
|
||||||
|
} ];
|
||||||
|
|
||||||
|
static getAttributeTypeMap() {
|
||||||
|
return Tag.attributeTypeMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
public constructor() {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,90 @@
|
|||||||
|
/**
|
||||||
|
* OpenAPI Petstore
|
||||||
|
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
* https://openapi-generator.tech
|
||||||
|
* Do not edit the class manually.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { HttpFile } from '../http/http';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A User who is purchasing from the pet store
|
||||||
|
*/
|
||||||
|
export class User {
|
||||||
|
'id'?: number;
|
||||||
|
'username'?: string;
|
||||||
|
'firstName'?: string;
|
||||||
|
'lastName'?: string;
|
||||||
|
'email'?: string;
|
||||||
|
'password'?: string;
|
||||||
|
'phone'?: string;
|
||||||
|
/**
|
||||||
|
* User Status
|
||||||
|
*/
|
||||||
|
'userStatus'?: number;
|
||||||
|
|
||||||
|
static readonly discriminator: string | undefined = undefined;
|
||||||
|
|
||||||
|
static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [
|
||||||
|
{
|
||||||
|
"name": "id",
|
||||||
|
"baseName": "id",
|
||||||
|
"type": "number",
|
||||||
|
"format": "int64"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "username",
|
||||||
|
"baseName": "username",
|
||||||
|
"type": "string",
|
||||||
|
"format": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "firstName",
|
||||||
|
"baseName": "firstName",
|
||||||
|
"type": "string",
|
||||||
|
"format": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "lastName",
|
||||||
|
"baseName": "lastName",
|
||||||
|
"type": "string",
|
||||||
|
"format": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "email",
|
||||||
|
"baseName": "email",
|
||||||
|
"type": "string",
|
||||||
|
"format": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "password",
|
||||||
|
"baseName": "password",
|
||||||
|
"type": "string",
|
||||||
|
"format": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "phone",
|
||||||
|
"baseName": "phone",
|
||||||
|
"type": "string",
|
||||||
|
"format": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "userStatus",
|
||||||
|
"baseName": "userStatus",
|
||||||
|
"type": "number",
|
||||||
|
"format": "int32"
|
||||||
|
} ];
|
||||||
|
|
||||||
|
static getAttributeTypeMap() {
|
||||||
|
return User.attributeTypeMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
public constructor() {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,6 @@
|
|||||||
|
export * from './ApiResponse'
|
||||||
|
export * from './Category'
|
||||||
|
export * from './Order'
|
||||||
|
export * from './Pet'
|
||||||
|
export * from './Tag'
|
||||||
|
export * from './User'
|
113
samples/openapi3/client/petstore/typescript/builds/browser/package-lock.json
generated
Normal file
113
samples/openapi3/client/petstore/typescript/builds/browser/package-lock.json
generated
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
{
|
||||||
|
"name": "ts-petstore-client",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"lockfileVersion": 2,
|
||||||
|
"requires": true,
|
||||||
|
"packages": {
|
||||||
|
"": {
|
||||||
|
"name": "ts-petstore-client",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"license": "Unlicense",
|
||||||
|
"dependencies": {
|
||||||
|
"es6-promise": "^4.2.4",
|
||||||
|
"url-parse": "^1.4.3",
|
||||||
|
"whatwg-fetch": "^3.0.0"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/url-parse": "1.4.4",
|
||||||
|
"typescript": "^3.9.3"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@types/url-parse": {
|
||||||
|
"version": "1.4.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/url-parse/-/url-parse-1.4.4.tgz",
|
||||||
|
"integrity": "sha512-KtQLad12+4T/NfSxpoDhmr22+fig3T7/08QCgmutYA6QSznSRmEtuL95GrhVV40/0otTEdFc+etRcCTqhh1q5Q==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"node_modules/es6-promise": {
|
||||||
|
"version": "4.2.8",
|
||||||
|
"resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.8.tgz",
|
||||||
|
"integrity": "sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w=="
|
||||||
|
},
|
||||||
|
"node_modules/querystringify": {
|
||||||
|
"version": "2.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.2.0.tgz",
|
||||||
|
"integrity": "sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ=="
|
||||||
|
},
|
||||||
|
"node_modules/requires-port": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz",
|
||||||
|
"integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8="
|
||||||
|
},
|
||||||
|
"node_modules/typescript": {
|
||||||
|
"version": "3.9.10",
|
||||||
|
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.10.tgz",
|
||||||
|
"integrity": "sha512-w6fIxVE/H1PkLKcCPsFqKE7Kv7QUwhU8qQY2MueZXWx5cPZdwFupLgKK3vntcK98BtNHZtAF4LA/yl2a7k8R6Q==",
|
||||||
|
"dev": true,
|
||||||
|
"bin": {
|
||||||
|
"tsc": "bin/tsc",
|
||||||
|
"tsserver": "bin/tsserver"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=4.2.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/url-parse": {
|
||||||
|
"version": "1.5.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.5.4.tgz",
|
||||||
|
"integrity": "sha512-ITeAByWWoqutFClc/lRZnFplgXgEZr3WJ6XngMM/N9DMIm4K8zXPCZ1Jdu0rERwO84w1WC5wkle2ubwTA4NTBg==",
|
||||||
|
"dependencies": {
|
||||||
|
"querystringify": "^2.1.1",
|
||||||
|
"requires-port": "^1.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/whatwg-fetch": {
|
||||||
|
"version": "3.6.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-3.6.2.tgz",
|
||||||
|
"integrity": "sha512-bJlen0FcuU/0EMLrdbJ7zOnW6ITZLrZMIarMUVmdKtsGvZna8vxKYaexICWPfZ8qwf9fzNq+UEIZrnSaApt6RA=="
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@types/url-parse": {
|
||||||
|
"version": "1.4.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/url-parse/-/url-parse-1.4.4.tgz",
|
||||||
|
"integrity": "sha512-KtQLad12+4T/NfSxpoDhmr22+fig3T7/08QCgmutYA6QSznSRmEtuL95GrhVV40/0otTEdFc+etRcCTqhh1q5Q==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"es6-promise": {
|
||||||
|
"version": "4.2.8",
|
||||||
|
"resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.8.tgz",
|
||||||
|
"integrity": "sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w=="
|
||||||
|
},
|
||||||
|
"querystringify": {
|
||||||
|
"version": "2.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.2.0.tgz",
|
||||||
|
"integrity": "sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ=="
|
||||||
|
},
|
||||||
|
"requires-port": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz",
|
||||||
|
"integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8="
|
||||||
|
},
|
||||||
|
"typescript": {
|
||||||
|
"version": "3.9.10",
|
||||||
|
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.10.tgz",
|
||||||
|
"integrity": "sha512-w6fIxVE/H1PkLKcCPsFqKE7Kv7QUwhU8qQY2MueZXWx5cPZdwFupLgKK3vntcK98BtNHZtAF4LA/yl2a7k8R6Q==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"url-parse": {
|
||||||
|
"version": "1.5.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.5.4.tgz",
|
||||||
|
"integrity": "sha512-ITeAByWWoqutFClc/lRZnFplgXgEZr3WJ6XngMM/N9DMIm4K8zXPCZ1Jdu0rERwO84w1WC5wkle2ubwTA4NTBg==",
|
||||||
|
"requires": {
|
||||||
|
"querystringify": "^2.1.1",
|
||||||
|
"requires-port": "^1.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"whatwg-fetch": {
|
||||||
|
"version": "3.6.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-3.6.2.tgz",
|
||||||
|
"integrity": "sha512-bJlen0FcuU/0EMLrdbJ7zOnW6ITZLrZMIarMUVmdKtsGvZna8vxKYaexICWPfZ8qwf9fzNq+UEIZrnSaApt6RA=="
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
{
|
||||||
|
"name": "ts-petstore-client",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "OpenAPI client for ts-petstore-client",
|
||||||
|
"author": "OpenAPI-Generator Contributors",
|
||||||
|
"keywords": [
|
||||||
|
"fetch",
|
||||||
|
"typescript",
|
||||||
|
"openapi-client",
|
||||||
|
"openapi-generator"
|
||||||
|
],
|
||||||
|
"license": "Unlicense",
|
||||||
|
"main": "./dist/index.js",
|
||||||
|
"type": "module",
|
||||||
|
"module": "./dist/index.js",
|
||||||
|
"exports": {
|
||||||
|
".": "./dist/index.js"
|
||||||
|
},
|
||||||
|
"typings": "./dist/index.d.ts",
|
||||||
|
"scripts": {
|
||||||
|
"build": "tsc",
|
||||||
|
"prepare": "npm run build"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"whatwg-fetch": "^3.0.0",
|
||||||
|
"es6-promise": "^4.2.4",
|
||||||
|
"url-parse": "^1.4.3"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"typescript": "^3.9.3",
|
||||||
|
"@types/url-parse": "1.4.4"
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,60 @@
|
|||||||
|
<project>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>org.openapitools</groupId>
|
||||||
|
<artifactId>TypeScriptBuildBrowserPetstoreClientSample</artifactId>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<name>TS Browser Petstore Client</name>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-dependency-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>copy-dependencies</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<outputDirectory>${project.build.directory}</outputDirectory>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
|
<artifactId>exec-maven-plugin</artifactId>
|
||||||
|
<version>1.2.1</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>npm-install</id>
|
||||||
|
<phase>pre-integration-test</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>exec</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<executable>npm</executable>
|
||||||
|
<arguments>
|
||||||
|
<argument>install</argument>
|
||||||
|
</arguments>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>npm-build</id>
|
||||||
|
<phase>pre-integration-test</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>exec</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<executable>npm</executable>
|
||||||
|
<arguments>
|
||||||
|
<argument>run</argument>
|
||||||
|
<argument>build</argument>
|
||||||
|
</arguments>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
@ -0,0 +1,27 @@
|
|||||||
|
export class Observable<T> {
|
||||||
|
constructor(private promise: Promise<T>) {}
|
||||||
|
|
||||||
|
toPromise() {
|
||||||
|
return this.promise;
|
||||||
|
}
|
||||||
|
|
||||||
|
pipe<S>(callback: (value: T) => S | Promise<S>): Observable<S> {
|
||||||
|
return new Observable(this.promise.then(callback));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function from<T>(promise: Promise<any>) {
|
||||||
|
return new Observable(promise);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function of<T>(value: T) {
|
||||||
|
return new Observable<T>(Promise.resolve(value));
|
||||||
|
}
|
||||||
|
|
||||||
|
export function mergeMap<T, S>(callback: (value: T) => Observable<S>) {
|
||||||
|
return (value: T) => callback(value).toPromise();
|
||||||
|
}
|
||||||
|
|
||||||
|
export function map(callback: any) {
|
||||||
|
return callback;
|
||||||
|
}
|
@ -0,0 +1,53 @@
|
|||||||
|
import { RequestContext, HttpMethod } from "./http/http";
|
||||||
|
|
||||||
|
export interface BaseServerConfiguration {
|
||||||
|
makeRequestContext(endpoint: string, httpMethod: HttpMethod): RequestContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Represents the configuration of a server including its
|
||||||
|
* url template and variable configuration based on the url.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
export class ServerConfiguration<T extends { [key: string]: string }> implements BaseServerConfiguration {
|
||||||
|
public constructor(private url: string, private variableConfiguration: T) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the value of the variables of this server.
|
||||||
|
*
|
||||||
|
* @param variableConfiguration a partial variable configuration for the variables contained in the url
|
||||||
|
*/
|
||||||
|
public setVariables(variableConfiguration: Partial<T>) {
|
||||||
|
Object.assign(this.variableConfiguration, variableConfiguration);
|
||||||
|
}
|
||||||
|
|
||||||
|
public getConfiguration(): T {
|
||||||
|
return this.variableConfiguration
|
||||||
|
}
|
||||||
|
|
||||||
|
private getUrl() {
|
||||||
|
let replacedUrl = this.url;
|
||||||
|
for (const key in this.variableConfiguration) {
|
||||||
|
var re = new RegExp("{" + key + "}","g");
|
||||||
|
replacedUrl = replacedUrl.replace(re, this.variableConfiguration[key]);
|
||||||
|
}
|
||||||
|
return replacedUrl
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new request context for this server using the url with variables
|
||||||
|
* replaced with their respective values and the endpoint of the request appended.
|
||||||
|
*
|
||||||
|
* @param endpoint the endpoint to be queried on the server
|
||||||
|
* @param httpMethod httpMethod to be used
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public makeRequestContext(endpoint: string, httpMethod: HttpMethod): RequestContext {
|
||||||
|
return new RequestContext(this.getUrl() + endpoint, httpMethod);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const server1 = new ServerConfiguration<{ }>("http://petstore.swagger.io/v2", { })
|
||||||
|
|
||||||
|
export const servers = [server1];
|
@ -0,0 +1,29 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"strict": true,
|
||||||
|
/* Basic Options */
|
||||||
|
"target": "es6",
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"moduleResolution": "node",
|
||||||
|
"declaration": true,
|
||||||
|
|
||||||
|
/* Additional Checks */
|
||||||
|
"noUnusedLocals": false, /* Report errors on unused locals. */ // TODO: reenable (unused imports!)
|
||||||
|
"noUnusedParameters": false, /* Report errors on unused parameters. */ // TODO: set to true again
|
||||||
|
"noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
|
||||||
|
"noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
|
||||||
|
|
||||||
|
"removeComments": true,
|
||||||
|
"sourceMap": true,
|
||||||
|
"outDir": "./dist",
|
||||||
|
"noLib": false,
|
||||||
|
"lib": [ "es6", "dom" ],
|
||||||
|
},
|
||||||
|
"exclude": [
|
||||||
|
"dist",
|
||||||
|
"node_modules"
|
||||||
|
],
|
||||||
|
"filesGlob": [
|
||||||
|
"./**/*.ts",
|
||||||
|
]
|
||||||
|
}
|
@ -0,0 +1,436 @@
|
|||||||
|
import { ResponseContext, RequestContext, HttpFile } from '../http/http';
|
||||||
|
import * as models from '../models/all';
|
||||||
|
import { Configuration} from '../configuration'
|
||||||
|
|
||||||
|
import { ApiResponse } from '../models/ApiResponse';
|
||||||
|
import { Category } from '../models/Category';
|
||||||
|
import { Order } from '../models/Order';
|
||||||
|
import { Pet } from '../models/Pet';
|
||||||
|
import { Tag } from '../models/Tag';
|
||||||
|
import { User } from '../models/User';
|
||||||
|
|
||||||
|
import { ObservablePetApi } from "./ObservableAPI";
|
||||||
|
import { PetApiRequestFactory, PetApiResponseProcessor} from "../apis/PetApi";
|
||||||
|
|
||||||
|
export interface PetApiAddPetRequest {
|
||||||
|
/**
|
||||||
|
* Pet object that needs to be added to the store
|
||||||
|
* @type Pet
|
||||||
|
* @memberof PetApiaddPet
|
||||||
|
*/
|
||||||
|
pet: Pet
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PetApiDeletePetRequest {
|
||||||
|
/**
|
||||||
|
* Pet id to delete
|
||||||
|
* @type number
|
||||||
|
* @memberof PetApideletePet
|
||||||
|
*/
|
||||||
|
petId: number
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type string
|
||||||
|
* @memberof PetApideletePet
|
||||||
|
*/
|
||||||
|
apiKey?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PetApiFindPetsByStatusRequest {
|
||||||
|
/**
|
||||||
|
* Status values that need to be considered for filter
|
||||||
|
* @type Array<'available' | 'pending' | 'sold'>
|
||||||
|
* @memberof PetApifindPetsByStatus
|
||||||
|
*/
|
||||||
|
status: Array<'available' | 'pending' | 'sold'>
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PetApiFindPetsByTagsRequest {
|
||||||
|
/**
|
||||||
|
* Tags to filter by
|
||||||
|
* @type Array<string>
|
||||||
|
* @memberof PetApifindPetsByTags
|
||||||
|
*/
|
||||||
|
tags: Array<string>
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PetApiGetPetByIdRequest {
|
||||||
|
/**
|
||||||
|
* ID of pet to return
|
||||||
|
* @type number
|
||||||
|
* @memberof PetApigetPetById
|
||||||
|
*/
|
||||||
|
petId: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PetApiUpdatePetRequest {
|
||||||
|
/**
|
||||||
|
* Pet object that needs to be added to the store
|
||||||
|
* @type Pet
|
||||||
|
* @memberof PetApiupdatePet
|
||||||
|
*/
|
||||||
|
pet: Pet
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PetApiUpdatePetWithFormRequest {
|
||||||
|
/**
|
||||||
|
* ID of pet that needs to be updated
|
||||||
|
* @type number
|
||||||
|
* @memberof PetApiupdatePetWithForm
|
||||||
|
*/
|
||||||
|
petId: number
|
||||||
|
/**
|
||||||
|
* Updated name of the pet
|
||||||
|
* @type string
|
||||||
|
* @memberof PetApiupdatePetWithForm
|
||||||
|
*/
|
||||||
|
name?: string
|
||||||
|
/**
|
||||||
|
* Updated status of the pet
|
||||||
|
* @type string
|
||||||
|
* @memberof PetApiupdatePetWithForm
|
||||||
|
*/
|
||||||
|
status?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PetApiUploadFileRequest {
|
||||||
|
/**
|
||||||
|
* ID of pet to update
|
||||||
|
* @type number
|
||||||
|
* @memberof PetApiuploadFile
|
||||||
|
*/
|
||||||
|
petId: number
|
||||||
|
/**
|
||||||
|
* Additional data to pass to server
|
||||||
|
* @type string
|
||||||
|
* @memberof PetApiuploadFile
|
||||||
|
*/
|
||||||
|
additionalMetadata?: string
|
||||||
|
/**
|
||||||
|
* file to upload
|
||||||
|
* @type HttpFile
|
||||||
|
* @memberof PetApiuploadFile
|
||||||
|
*/
|
||||||
|
file?: HttpFile
|
||||||
|
}
|
||||||
|
|
||||||
|
export class ObjectPetApi {
|
||||||
|
private api: ObservablePetApi
|
||||||
|
|
||||||
|
public constructor(configuration: Configuration, requestFactory?: PetApiRequestFactory, responseProcessor?: PetApiResponseProcessor) {
|
||||||
|
this.api = new ObservablePetApi(configuration, requestFactory, responseProcessor);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Add a new pet to the store
|
||||||
|
* @param param the request object
|
||||||
|
*/
|
||||||
|
public addPet(param: PetApiAddPetRequest, options?: Configuration): Promise<Pet> {
|
||||||
|
return this.api.addPet(param.pet, options).toPromise();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Deletes a pet
|
||||||
|
* @param param the request object
|
||||||
|
*/
|
||||||
|
public deletePet(param: PetApiDeletePetRequest, options?: Configuration): Promise<void> {
|
||||||
|
return this.api.deletePet(param.petId, param.apiKey, options).toPromise();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Multiple status values can be provided with comma separated strings
|
||||||
|
* Finds Pets by status
|
||||||
|
* @param param the request object
|
||||||
|
*/
|
||||||
|
public findPetsByStatus(param: PetApiFindPetsByStatusRequest, options?: Configuration): Promise<Array<Pet>> {
|
||||||
|
return this.api.findPetsByStatus(param.status, options).toPromise();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
||||||
|
* Finds Pets by tags
|
||||||
|
* @param param the request object
|
||||||
|
*/
|
||||||
|
public findPetsByTags(param: PetApiFindPetsByTagsRequest, options?: Configuration): Promise<Array<Pet>> {
|
||||||
|
return this.api.findPetsByTags(param.tags, options).toPromise();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a single pet
|
||||||
|
* Find pet by ID
|
||||||
|
* @param param the request object
|
||||||
|
*/
|
||||||
|
public getPetById(param: PetApiGetPetByIdRequest, options?: Configuration): Promise<Pet> {
|
||||||
|
return this.api.getPetById(param.petId, options).toPromise();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Update an existing pet
|
||||||
|
* @param param the request object
|
||||||
|
*/
|
||||||
|
public updatePet(param: PetApiUpdatePetRequest, options?: Configuration): Promise<Pet> {
|
||||||
|
return this.api.updatePet(param.pet, options).toPromise();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Updates a pet in the store with form data
|
||||||
|
* @param param the request object
|
||||||
|
*/
|
||||||
|
public updatePetWithForm(param: PetApiUpdatePetWithFormRequest, options?: Configuration): Promise<void> {
|
||||||
|
return this.api.updatePetWithForm(param.petId, param.name, param.status, options).toPromise();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* uploads an image
|
||||||
|
* @param param the request object
|
||||||
|
*/
|
||||||
|
public uploadFile(param: PetApiUploadFileRequest, options?: Configuration): Promise<ApiResponse> {
|
||||||
|
return this.api.uploadFile(param.petId, param.additionalMetadata, param.file, options).toPromise();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
import { ObservableStoreApi } from "./ObservableAPI";
|
||||||
|
import { StoreApiRequestFactory, StoreApiResponseProcessor} from "../apis/StoreApi";
|
||||||
|
|
||||||
|
export interface StoreApiDeleteOrderRequest {
|
||||||
|
/**
|
||||||
|
* ID of the order that needs to be deleted
|
||||||
|
* @type string
|
||||||
|
* @memberof StoreApideleteOrder
|
||||||
|
*/
|
||||||
|
orderId: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface StoreApiGetInventoryRequest {
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface StoreApiGetOrderByIdRequest {
|
||||||
|
/**
|
||||||
|
* ID of pet that needs to be fetched
|
||||||
|
* @type number
|
||||||
|
* @memberof StoreApigetOrderById
|
||||||
|
*/
|
||||||
|
orderId: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface StoreApiPlaceOrderRequest {
|
||||||
|
/**
|
||||||
|
* order placed for purchasing the pet
|
||||||
|
* @type Order
|
||||||
|
* @memberof StoreApiplaceOrder
|
||||||
|
*/
|
||||||
|
order: Order
|
||||||
|
}
|
||||||
|
|
||||||
|
export class ObjectStoreApi {
|
||||||
|
private api: ObservableStoreApi
|
||||||
|
|
||||||
|
public constructor(configuration: Configuration, requestFactory?: StoreApiRequestFactory, responseProcessor?: StoreApiResponseProcessor) {
|
||||||
|
this.api = new ObservableStoreApi(configuration, requestFactory, responseProcessor);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||||
|
* Delete purchase order by ID
|
||||||
|
* @param param the request object
|
||||||
|
*/
|
||||||
|
public deleteOrder(param: StoreApiDeleteOrderRequest, options?: Configuration): Promise<void> {
|
||||||
|
return this.api.deleteOrder(param.orderId, options).toPromise();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a map of status codes to quantities
|
||||||
|
* Returns pet inventories by status
|
||||||
|
* @param param the request object
|
||||||
|
*/
|
||||||
|
public getInventory(param: StoreApiGetInventoryRequest = {}, options?: Configuration): Promise<{ [key: string]: number; }> {
|
||||||
|
return this.api.getInventory( options).toPromise();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||||
|
* Find purchase order by ID
|
||||||
|
* @param param the request object
|
||||||
|
*/
|
||||||
|
public getOrderById(param: StoreApiGetOrderByIdRequest, options?: Configuration): Promise<Order> {
|
||||||
|
return this.api.getOrderById(param.orderId, options).toPromise();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Place an order for a pet
|
||||||
|
* @param param the request object
|
||||||
|
*/
|
||||||
|
public placeOrder(param: StoreApiPlaceOrderRequest, options?: Configuration): Promise<Order> {
|
||||||
|
return this.api.placeOrder(param.order, options).toPromise();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
import { ObservableUserApi } from "./ObservableAPI";
|
||||||
|
import { UserApiRequestFactory, UserApiResponseProcessor} from "../apis/UserApi";
|
||||||
|
|
||||||
|
export interface UserApiCreateUserRequest {
|
||||||
|
/**
|
||||||
|
* Created user object
|
||||||
|
* @type User
|
||||||
|
* @memberof UserApicreateUser
|
||||||
|
*/
|
||||||
|
user: User
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UserApiCreateUsersWithArrayInputRequest {
|
||||||
|
/**
|
||||||
|
* List of user object
|
||||||
|
* @type Array<User>
|
||||||
|
* @memberof UserApicreateUsersWithArrayInput
|
||||||
|
*/
|
||||||
|
user: Array<User>
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UserApiCreateUsersWithListInputRequest {
|
||||||
|
/**
|
||||||
|
* List of user object
|
||||||
|
* @type Array<User>
|
||||||
|
* @memberof UserApicreateUsersWithListInput
|
||||||
|
*/
|
||||||
|
user: Array<User>
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UserApiDeleteUserRequest {
|
||||||
|
/**
|
||||||
|
* The name that needs to be deleted
|
||||||
|
* @type string
|
||||||
|
* @memberof UserApideleteUser
|
||||||
|
*/
|
||||||
|
username: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UserApiGetUserByNameRequest {
|
||||||
|
/**
|
||||||
|
* The name that needs to be fetched. Use user1 for testing.
|
||||||
|
* @type string
|
||||||
|
* @memberof UserApigetUserByName
|
||||||
|
*/
|
||||||
|
username: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UserApiLoginUserRequest {
|
||||||
|
/**
|
||||||
|
* The user name for login
|
||||||
|
* @type string
|
||||||
|
* @memberof UserApiloginUser
|
||||||
|
*/
|
||||||
|
username: string
|
||||||
|
/**
|
||||||
|
* The password for login in clear text
|
||||||
|
* @type string
|
||||||
|
* @memberof UserApiloginUser
|
||||||
|
*/
|
||||||
|
password: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UserApiLogoutUserRequest {
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UserApiUpdateUserRequest {
|
||||||
|
/**
|
||||||
|
* name that need to be deleted
|
||||||
|
* @type string
|
||||||
|
* @memberof UserApiupdateUser
|
||||||
|
*/
|
||||||
|
username: string
|
||||||
|
/**
|
||||||
|
* Updated user object
|
||||||
|
* @type User
|
||||||
|
* @memberof UserApiupdateUser
|
||||||
|
*/
|
||||||
|
user: User
|
||||||
|
}
|
||||||
|
|
||||||
|
export class ObjectUserApi {
|
||||||
|
private api: ObservableUserApi
|
||||||
|
|
||||||
|
public constructor(configuration: Configuration, requestFactory?: UserApiRequestFactory, responseProcessor?: UserApiResponseProcessor) {
|
||||||
|
this.api = new ObservableUserApi(configuration, requestFactory, responseProcessor);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This can only be done by the logged in user.
|
||||||
|
* Create user
|
||||||
|
* @param param the request object
|
||||||
|
*/
|
||||||
|
public createUser(param: UserApiCreateUserRequest, options?: Configuration): Promise<void> {
|
||||||
|
return this.api.createUser(param.user, options).toPromise();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Creates list of users with given input array
|
||||||
|
* @param param the request object
|
||||||
|
*/
|
||||||
|
public createUsersWithArrayInput(param: UserApiCreateUsersWithArrayInputRequest, options?: Configuration): Promise<void> {
|
||||||
|
return this.api.createUsersWithArrayInput(param.user, options).toPromise();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Creates list of users with given input array
|
||||||
|
* @param param the request object
|
||||||
|
*/
|
||||||
|
public createUsersWithListInput(param: UserApiCreateUsersWithListInputRequest, options?: Configuration): Promise<void> {
|
||||||
|
return this.api.createUsersWithListInput(param.user, options).toPromise();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This can only be done by the logged in user.
|
||||||
|
* Delete user
|
||||||
|
* @param param the request object
|
||||||
|
*/
|
||||||
|
public deleteUser(param: UserApiDeleteUserRequest, options?: Configuration): Promise<void> {
|
||||||
|
return this.api.deleteUser(param.username, options).toPromise();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Get user by user name
|
||||||
|
* @param param the request object
|
||||||
|
*/
|
||||||
|
public getUserByName(param: UserApiGetUserByNameRequest, options?: Configuration): Promise<User> {
|
||||||
|
return this.api.getUserByName(param.username, options).toPromise();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Logs user into the system
|
||||||
|
* @param param the request object
|
||||||
|
*/
|
||||||
|
public loginUser(param: UserApiLoginUserRequest, options?: Configuration): Promise<string> {
|
||||||
|
return this.api.loginUser(param.username, param.password, options).toPromise();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Logs out current logged in user session
|
||||||
|
* @param param the request object
|
||||||
|
*/
|
||||||
|
public logoutUser(param: UserApiLogoutUserRequest = {}, options?: Configuration): Promise<void> {
|
||||||
|
return this.api.logoutUser( options).toPromise();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This can only be done by the logged in user.
|
||||||
|
* Updated user
|
||||||
|
* @param param the request object
|
||||||
|
*/
|
||||||
|
public updateUser(param: UserApiUpdateUserRequest, options?: Configuration): Promise<void> {
|
||||||
|
return this.api.updateUser(param.username, param.user, options).toPromise();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,550 @@
|
|||||||
|
import { ResponseContext, RequestContext, HttpFile } from '../http/http';
|
||||||
|
import * as models from '../models/all';
|
||||||
|
import { Configuration} from '../configuration'
|
||||||
|
import { Observable, of, from } from '../rxjsStub';
|
||||||
|
import {mergeMap, map} from '../rxjsStub';
|
||||||
|
import { ApiResponse } from '../models/ApiResponse';
|
||||||
|
import { Category } from '../models/Category';
|
||||||
|
import { Order } from '../models/Order';
|
||||||
|
import { Pet } from '../models/Pet';
|
||||||
|
import { Tag } from '../models/Tag';
|
||||||
|
import { User } from '../models/User';
|
||||||
|
|
||||||
|
import { PetApiRequestFactory, PetApiResponseProcessor} from "../apis/PetApi";
|
||||||
|
export class ObservablePetApi {
|
||||||
|
private requestFactory: PetApiRequestFactory;
|
||||||
|
private responseProcessor: PetApiResponseProcessor;
|
||||||
|
private configuration: Configuration;
|
||||||
|
|
||||||
|
public constructor(
|
||||||
|
configuration: Configuration,
|
||||||
|
requestFactory?: PetApiRequestFactory,
|
||||||
|
responseProcessor?: PetApiResponseProcessor
|
||||||
|
) {
|
||||||
|
this.configuration = configuration;
|
||||||
|
this.requestFactory = requestFactory || new PetApiRequestFactory(configuration);
|
||||||
|
this.responseProcessor = responseProcessor || new PetApiResponseProcessor();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Add a new pet to the store
|
||||||
|
* @param pet Pet object that needs to be added to the store
|
||||||
|
*/
|
||||||
|
public addPet(pet: Pet, _options?: Configuration): Observable<Pet> {
|
||||||
|
const requestContextPromise = this.requestFactory.addPet(pet, _options);
|
||||||
|
|
||||||
|
// build promise chain
|
||||||
|
let middlewarePreObservable = from<RequestContext>(requestContextPromise);
|
||||||
|
for (let middleware of this.configuration.middleware) {
|
||||||
|
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
||||||
|
}
|
||||||
|
|
||||||
|
return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))).
|
||||||
|
pipe(mergeMap((response: ResponseContext) => {
|
||||||
|
let middlewarePostObservable = of(response);
|
||||||
|
for (let middleware of this.configuration.middleware) {
|
||||||
|
middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp)));
|
||||||
|
}
|
||||||
|
return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.addPet(rsp)));
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Deletes a pet
|
||||||
|
* @param petId Pet id to delete
|
||||||
|
* @param apiKey
|
||||||
|
*/
|
||||||
|
public deletePet(petId: number, apiKey?: string, _options?: Configuration): Observable<void> {
|
||||||
|
const requestContextPromise = this.requestFactory.deletePet(petId, apiKey, _options);
|
||||||
|
|
||||||
|
// build promise chain
|
||||||
|
let middlewarePreObservable = from<RequestContext>(requestContextPromise);
|
||||||
|
for (let middleware of this.configuration.middleware) {
|
||||||
|
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
||||||
|
}
|
||||||
|
|
||||||
|
return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))).
|
||||||
|
pipe(mergeMap((response: ResponseContext) => {
|
||||||
|
let middlewarePostObservable = of(response);
|
||||||
|
for (let middleware of this.configuration.middleware) {
|
||||||
|
middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp)));
|
||||||
|
}
|
||||||
|
return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.deletePet(rsp)));
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Multiple status values can be provided with comma separated strings
|
||||||
|
* Finds Pets by status
|
||||||
|
* @param status Status values that need to be considered for filter
|
||||||
|
*/
|
||||||
|
public findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, _options?: Configuration): Observable<Array<Pet>> {
|
||||||
|
const requestContextPromise = this.requestFactory.findPetsByStatus(status, _options);
|
||||||
|
|
||||||
|
// build promise chain
|
||||||
|
let middlewarePreObservable = from<RequestContext>(requestContextPromise);
|
||||||
|
for (let middleware of this.configuration.middleware) {
|
||||||
|
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
||||||
|
}
|
||||||
|
|
||||||
|
return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))).
|
||||||
|
pipe(mergeMap((response: ResponseContext) => {
|
||||||
|
let middlewarePostObservable = of(response);
|
||||||
|
for (let middleware of this.configuration.middleware) {
|
||||||
|
middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp)));
|
||||||
|
}
|
||||||
|
return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.findPetsByStatus(rsp)));
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
||||||
|
* Finds Pets by tags
|
||||||
|
* @param tags Tags to filter by
|
||||||
|
*/
|
||||||
|
public findPetsByTags(tags: Array<string>, _options?: Configuration): Observable<Array<Pet>> {
|
||||||
|
const requestContextPromise = this.requestFactory.findPetsByTags(tags, _options);
|
||||||
|
|
||||||
|
// build promise chain
|
||||||
|
let middlewarePreObservable = from<RequestContext>(requestContextPromise);
|
||||||
|
for (let middleware of this.configuration.middleware) {
|
||||||
|
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
||||||
|
}
|
||||||
|
|
||||||
|
return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))).
|
||||||
|
pipe(mergeMap((response: ResponseContext) => {
|
||||||
|
let middlewarePostObservable = of(response);
|
||||||
|
for (let middleware of this.configuration.middleware) {
|
||||||
|
middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp)));
|
||||||
|
}
|
||||||
|
return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.findPetsByTags(rsp)));
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a single pet
|
||||||
|
* Find pet by ID
|
||||||
|
* @param petId ID of pet to return
|
||||||
|
*/
|
||||||
|
public getPetById(petId: number, _options?: Configuration): Observable<Pet> {
|
||||||
|
const requestContextPromise = this.requestFactory.getPetById(petId, _options);
|
||||||
|
|
||||||
|
// build promise chain
|
||||||
|
let middlewarePreObservable = from<RequestContext>(requestContextPromise);
|
||||||
|
for (let middleware of this.configuration.middleware) {
|
||||||
|
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
||||||
|
}
|
||||||
|
|
||||||
|
return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))).
|
||||||
|
pipe(mergeMap((response: ResponseContext) => {
|
||||||
|
let middlewarePostObservable = of(response);
|
||||||
|
for (let middleware of this.configuration.middleware) {
|
||||||
|
middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp)));
|
||||||
|
}
|
||||||
|
return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.getPetById(rsp)));
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Update an existing pet
|
||||||
|
* @param pet Pet object that needs to be added to the store
|
||||||
|
*/
|
||||||
|
public updatePet(pet: Pet, _options?: Configuration): Observable<Pet> {
|
||||||
|
const requestContextPromise = this.requestFactory.updatePet(pet, _options);
|
||||||
|
|
||||||
|
// build promise chain
|
||||||
|
let middlewarePreObservable = from<RequestContext>(requestContextPromise);
|
||||||
|
for (let middleware of this.configuration.middleware) {
|
||||||
|
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
||||||
|
}
|
||||||
|
|
||||||
|
return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))).
|
||||||
|
pipe(mergeMap((response: ResponseContext) => {
|
||||||
|
let middlewarePostObservable = of(response);
|
||||||
|
for (let middleware of this.configuration.middleware) {
|
||||||
|
middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp)));
|
||||||
|
}
|
||||||
|
return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.updatePet(rsp)));
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Updates a pet in the store with form data
|
||||||
|
* @param petId ID of pet that needs to be updated
|
||||||
|
* @param name Updated name of the pet
|
||||||
|
* @param status Updated status of the pet
|
||||||
|
*/
|
||||||
|
public updatePetWithForm(petId: number, name?: string, status?: string, _options?: Configuration): Observable<void> {
|
||||||
|
const requestContextPromise = this.requestFactory.updatePetWithForm(petId, name, status, _options);
|
||||||
|
|
||||||
|
// build promise chain
|
||||||
|
let middlewarePreObservable = from<RequestContext>(requestContextPromise);
|
||||||
|
for (let middleware of this.configuration.middleware) {
|
||||||
|
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
||||||
|
}
|
||||||
|
|
||||||
|
return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))).
|
||||||
|
pipe(mergeMap((response: ResponseContext) => {
|
||||||
|
let middlewarePostObservable = of(response);
|
||||||
|
for (let middleware of this.configuration.middleware) {
|
||||||
|
middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp)));
|
||||||
|
}
|
||||||
|
return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.updatePetWithForm(rsp)));
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* uploads an image
|
||||||
|
* @param petId ID of pet to update
|
||||||
|
* @param additionalMetadata Additional data to pass to server
|
||||||
|
* @param file file to upload
|
||||||
|
*/
|
||||||
|
public uploadFile(petId: number, additionalMetadata?: string, file?: HttpFile, _options?: Configuration): Observable<ApiResponse> {
|
||||||
|
const requestContextPromise = this.requestFactory.uploadFile(petId, additionalMetadata, file, _options);
|
||||||
|
|
||||||
|
// build promise chain
|
||||||
|
let middlewarePreObservable = from<RequestContext>(requestContextPromise);
|
||||||
|
for (let middleware of this.configuration.middleware) {
|
||||||
|
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
||||||
|
}
|
||||||
|
|
||||||
|
return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))).
|
||||||
|
pipe(mergeMap((response: ResponseContext) => {
|
||||||
|
let middlewarePostObservable = of(response);
|
||||||
|
for (let middleware of this.configuration.middleware) {
|
||||||
|
middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp)));
|
||||||
|
}
|
||||||
|
return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.uploadFile(rsp)));
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
import { StoreApiRequestFactory, StoreApiResponseProcessor} from "../apis/StoreApi";
|
||||||
|
export class ObservableStoreApi {
|
||||||
|
private requestFactory: StoreApiRequestFactory;
|
||||||
|
private responseProcessor: StoreApiResponseProcessor;
|
||||||
|
private configuration: Configuration;
|
||||||
|
|
||||||
|
public constructor(
|
||||||
|
configuration: Configuration,
|
||||||
|
requestFactory?: StoreApiRequestFactory,
|
||||||
|
responseProcessor?: StoreApiResponseProcessor
|
||||||
|
) {
|
||||||
|
this.configuration = configuration;
|
||||||
|
this.requestFactory = requestFactory || new StoreApiRequestFactory(configuration);
|
||||||
|
this.responseProcessor = responseProcessor || new StoreApiResponseProcessor();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||||
|
* Delete purchase order by ID
|
||||||
|
* @param orderId ID of the order that needs to be deleted
|
||||||
|
*/
|
||||||
|
public deleteOrder(orderId: string, _options?: Configuration): Observable<void> {
|
||||||
|
const requestContextPromise = this.requestFactory.deleteOrder(orderId, _options);
|
||||||
|
|
||||||
|
// build promise chain
|
||||||
|
let middlewarePreObservable = from<RequestContext>(requestContextPromise);
|
||||||
|
for (let middleware of this.configuration.middleware) {
|
||||||
|
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
||||||
|
}
|
||||||
|
|
||||||
|
return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))).
|
||||||
|
pipe(mergeMap((response: ResponseContext) => {
|
||||||
|
let middlewarePostObservable = of(response);
|
||||||
|
for (let middleware of this.configuration.middleware) {
|
||||||
|
middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp)));
|
||||||
|
}
|
||||||
|
return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.deleteOrder(rsp)));
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a map of status codes to quantities
|
||||||
|
* Returns pet inventories by status
|
||||||
|
*/
|
||||||
|
public getInventory(_options?: Configuration): Observable<{ [key: string]: number; }> {
|
||||||
|
const requestContextPromise = this.requestFactory.getInventory(_options);
|
||||||
|
|
||||||
|
// build promise chain
|
||||||
|
let middlewarePreObservable = from<RequestContext>(requestContextPromise);
|
||||||
|
for (let middleware of this.configuration.middleware) {
|
||||||
|
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
||||||
|
}
|
||||||
|
|
||||||
|
return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))).
|
||||||
|
pipe(mergeMap((response: ResponseContext) => {
|
||||||
|
let middlewarePostObservable = of(response);
|
||||||
|
for (let middleware of this.configuration.middleware) {
|
||||||
|
middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp)));
|
||||||
|
}
|
||||||
|
return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.getInventory(rsp)));
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||||
|
* Find purchase order by ID
|
||||||
|
* @param orderId ID of pet that needs to be fetched
|
||||||
|
*/
|
||||||
|
public getOrderById(orderId: number, _options?: Configuration): Observable<Order> {
|
||||||
|
const requestContextPromise = this.requestFactory.getOrderById(orderId, _options);
|
||||||
|
|
||||||
|
// build promise chain
|
||||||
|
let middlewarePreObservable = from<RequestContext>(requestContextPromise);
|
||||||
|
for (let middleware of this.configuration.middleware) {
|
||||||
|
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
||||||
|
}
|
||||||
|
|
||||||
|
return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))).
|
||||||
|
pipe(mergeMap((response: ResponseContext) => {
|
||||||
|
let middlewarePostObservable = of(response);
|
||||||
|
for (let middleware of this.configuration.middleware) {
|
||||||
|
middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp)));
|
||||||
|
}
|
||||||
|
return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.getOrderById(rsp)));
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Place an order for a pet
|
||||||
|
* @param order order placed for purchasing the pet
|
||||||
|
*/
|
||||||
|
public placeOrder(order: Order, _options?: Configuration): Observable<Order> {
|
||||||
|
const requestContextPromise = this.requestFactory.placeOrder(order, _options);
|
||||||
|
|
||||||
|
// build promise chain
|
||||||
|
let middlewarePreObservable = from<RequestContext>(requestContextPromise);
|
||||||
|
for (let middleware of this.configuration.middleware) {
|
||||||
|
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
||||||
|
}
|
||||||
|
|
||||||
|
return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))).
|
||||||
|
pipe(mergeMap((response: ResponseContext) => {
|
||||||
|
let middlewarePostObservable = of(response);
|
||||||
|
for (let middleware of this.configuration.middleware) {
|
||||||
|
middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp)));
|
||||||
|
}
|
||||||
|
return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.placeOrder(rsp)));
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
import { UserApiRequestFactory, UserApiResponseProcessor} from "../apis/UserApi";
|
||||||
|
export class ObservableUserApi {
|
||||||
|
private requestFactory: UserApiRequestFactory;
|
||||||
|
private responseProcessor: UserApiResponseProcessor;
|
||||||
|
private configuration: Configuration;
|
||||||
|
|
||||||
|
public constructor(
|
||||||
|
configuration: Configuration,
|
||||||
|
requestFactory?: UserApiRequestFactory,
|
||||||
|
responseProcessor?: UserApiResponseProcessor
|
||||||
|
) {
|
||||||
|
this.configuration = configuration;
|
||||||
|
this.requestFactory = requestFactory || new UserApiRequestFactory(configuration);
|
||||||
|
this.responseProcessor = responseProcessor || new UserApiResponseProcessor();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This can only be done by the logged in user.
|
||||||
|
* Create user
|
||||||
|
* @param user Created user object
|
||||||
|
*/
|
||||||
|
public createUser(user: User, _options?: Configuration): Observable<void> {
|
||||||
|
const requestContextPromise = this.requestFactory.createUser(user, _options);
|
||||||
|
|
||||||
|
// build promise chain
|
||||||
|
let middlewarePreObservable = from<RequestContext>(requestContextPromise);
|
||||||
|
for (let middleware of this.configuration.middleware) {
|
||||||
|
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
||||||
|
}
|
||||||
|
|
||||||
|
return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))).
|
||||||
|
pipe(mergeMap((response: ResponseContext) => {
|
||||||
|
let middlewarePostObservable = of(response);
|
||||||
|
for (let middleware of this.configuration.middleware) {
|
||||||
|
middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp)));
|
||||||
|
}
|
||||||
|
return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.createUser(rsp)));
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Creates list of users with given input array
|
||||||
|
* @param user List of user object
|
||||||
|
*/
|
||||||
|
public createUsersWithArrayInput(user: Array<User>, _options?: Configuration): Observable<void> {
|
||||||
|
const requestContextPromise = this.requestFactory.createUsersWithArrayInput(user, _options);
|
||||||
|
|
||||||
|
// build promise chain
|
||||||
|
let middlewarePreObservable = from<RequestContext>(requestContextPromise);
|
||||||
|
for (let middleware of this.configuration.middleware) {
|
||||||
|
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
||||||
|
}
|
||||||
|
|
||||||
|
return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))).
|
||||||
|
pipe(mergeMap((response: ResponseContext) => {
|
||||||
|
let middlewarePostObservable = of(response);
|
||||||
|
for (let middleware of this.configuration.middleware) {
|
||||||
|
middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp)));
|
||||||
|
}
|
||||||
|
return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.createUsersWithArrayInput(rsp)));
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Creates list of users with given input array
|
||||||
|
* @param user List of user object
|
||||||
|
*/
|
||||||
|
public createUsersWithListInput(user: Array<User>, _options?: Configuration): Observable<void> {
|
||||||
|
const requestContextPromise = this.requestFactory.createUsersWithListInput(user, _options);
|
||||||
|
|
||||||
|
// build promise chain
|
||||||
|
let middlewarePreObservable = from<RequestContext>(requestContextPromise);
|
||||||
|
for (let middleware of this.configuration.middleware) {
|
||||||
|
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
||||||
|
}
|
||||||
|
|
||||||
|
return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))).
|
||||||
|
pipe(mergeMap((response: ResponseContext) => {
|
||||||
|
let middlewarePostObservable = of(response);
|
||||||
|
for (let middleware of this.configuration.middleware) {
|
||||||
|
middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp)));
|
||||||
|
}
|
||||||
|
return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.createUsersWithListInput(rsp)));
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This can only be done by the logged in user.
|
||||||
|
* Delete user
|
||||||
|
* @param username The name that needs to be deleted
|
||||||
|
*/
|
||||||
|
public deleteUser(username: string, _options?: Configuration): Observable<void> {
|
||||||
|
const requestContextPromise = this.requestFactory.deleteUser(username, _options);
|
||||||
|
|
||||||
|
// build promise chain
|
||||||
|
let middlewarePreObservable = from<RequestContext>(requestContextPromise);
|
||||||
|
for (let middleware of this.configuration.middleware) {
|
||||||
|
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
||||||
|
}
|
||||||
|
|
||||||
|
return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))).
|
||||||
|
pipe(mergeMap((response: ResponseContext) => {
|
||||||
|
let middlewarePostObservable = of(response);
|
||||||
|
for (let middleware of this.configuration.middleware) {
|
||||||
|
middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp)));
|
||||||
|
}
|
||||||
|
return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.deleteUser(rsp)));
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Get user by user name
|
||||||
|
* @param username The name that needs to be fetched. Use user1 for testing.
|
||||||
|
*/
|
||||||
|
public getUserByName(username: string, _options?: Configuration): Observable<User> {
|
||||||
|
const requestContextPromise = this.requestFactory.getUserByName(username, _options);
|
||||||
|
|
||||||
|
// build promise chain
|
||||||
|
let middlewarePreObservable = from<RequestContext>(requestContextPromise);
|
||||||
|
for (let middleware of this.configuration.middleware) {
|
||||||
|
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
||||||
|
}
|
||||||
|
|
||||||
|
return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))).
|
||||||
|
pipe(mergeMap((response: ResponseContext) => {
|
||||||
|
let middlewarePostObservable = of(response);
|
||||||
|
for (let middleware of this.configuration.middleware) {
|
||||||
|
middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp)));
|
||||||
|
}
|
||||||
|
return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.getUserByName(rsp)));
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Logs user into the system
|
||||||
|
* @param username The user name for login
|
||||||
|
* @param password The password for login in clear text
|
||||||
|
*/
|
||||||
|
public loginUser(username: string, password: string, _options?: Configuration): Observable<string> {
|
||||||
|
const requestContextPromise = this.requestFactory.loginUser(username, password, _options);
|
||||||
|
|
||||||
|
// build promise chain
|
||||||
|
let middlewarePreObservable = from<RequestContext>(requestContextPromise);
|
||||||
|
for (let middleware of this.configuration.middleware) {
|
||||||
|
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
||||||
|
}
|
||||||
|
|
||||||
|
return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))).
|
||||||
|
pipe(mergeMap((response: ResponseContext) => {
|
||||||
|
let middlewarePostObservable = of(response);
|
||||||
|
for (let middleware of this.configuration.middleware) {
|
||||||
|
middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp)));
|
||||||
|
}
|
||||||
|
return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.loginUser(rsp)));
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Logs out current logged in user session
|
||||||
|
*/
|
||||||
|
public logoutUser(_options?: Configuration): Observable<void> {
|
||||||
|
const requestContextPromise = this.requestFactory.logoutUser(_options);
|
||||||
|
|
||||||
|
// build promise chain
|
||||||
|
let middlewarePreObservable = from<RequestContext>(requestContextPromise);
|
||||||
|
for (let middleware of this.configuration.middleware) {
|
||||||
|
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
||||||
|
}
|
||||||
|
|
||||||
|
return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))).
|
||||||
|
pipe(mergeMap((response: ResponseContext) => {
|
||||||
|
let middlewarePostObservable = of(response);
|
||||||
|
for (let middleware of this.configuration.middleware) {
|
||||||
|
middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp)));
|
||||||
|
}
|
||||||
|
return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.logoutUser(rsp)));
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This can only be done by the logged in user.
|
||||||
|
* Updated user
|
||||||
|
* @param username name that need to be deleted
|
||||||
|
* @param user Updated user object
|
||||||
|
*/
|
||||||
|
public updateUser(username: string, user: User, _options?: Configuration): Observable<void> {
|
||||||
|
const requestContextPromise = this.requestFactory.updateUser(username, user, _options);
|
||||||
|
|
||||||
|
// build promise chain
|
||||||
|
let middlewarePreObservable = from<RequestContext>(requestContextPromise);
|
||||||
|
for (let middleware of this.configuration.middleware) {
|
||||||
|
middlewarePreObservable = middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => middleware.pre(ctx)));
|
||||||
|
}
|
||||||
|
|
||||||
|
return middlewarePreObservable.pipe(mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx))).
|
||||||
|
pipe(mergeMap((response: ResponseContext) => {
|
||||||
|
let middlewarePostObservable = of(response);
|
||||||
|
for (let middleware of this.configuration.middleware) {
|
||||||
|
middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp)));
|
||||||
|
}
|
||||||
|
return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.updateUser(rsp)));
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,272 @@
|
|||||||
|
import { ResponseContext, RequestContext, HttpFile } from '../http/http';
|
||||||
|
import * as models from '../models/all';
|
||||||
|
import { Configuration} from '../configuration'
|
||||||
|
|
||||||
|
import { ApiResponse } from '../models/ApiResponse';
|
||||||
|
import { Category } from '../models/Category';
|
||||||
|
import { Order } from '../models/Order';
|
||||||
|
import { Pet } from '../models/Pet';
|
||||||
|
import { Tag } from '../models/Tag';
|
||||||
|
import { User } from '../models/User';
|
||||||
|
import { ObservablePetApi } from './ObservableAPI';
|
||||||
|
|
||||||
|
import { PetApiRequestFactory, PetApiResponseProcessor} from "../apis/PetApi";
|
||||||
|
export class PromisePetApi {
|
||||||
|
private api: ObservablePetApi
|
||||||
|
|
||||||
|
public constructor(
|
||||||
|
configuration: Configuration,
|
||||||
|
requestFactory?: PetApiRequestFactory,
|
||||||
|
responseProcessor?: PetApiResponseProcessor
|
||||||
|
) {
|
||||||
|
this.api = new ObservablePetApi(configuration, requestFactory, responseProcessor);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Add a new pet to the store
|
||||||
|
* @param pet Pet object that needs to be added to the store
|
||||||
|
*/
|
||||||
|
public addPet(pet: Pet, _options?: Configuration): Promise<Pet> {
|
||||||
|
const result = this.api.addPet(pet, _options);
|
||||||
|
return result.toPromise();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Deletes a pet
|
||||||
|
* @param petId Pet id to delete
|
||||||
|
* @param apiKey
|
||||||
|
*/
|
||||||
|
public deletePet(petId: number, apiKey?: string, _options?: Configuration): Promise<void> {
|
||||||
|
const result = this.api.deletePet(petId, apiKey, _options);
|
||||||
|
return result.toPromise();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Multiple status values can be provided with comma separated strings
|
||||||
|
* Finds Pets by status
|
||||||
|
* @param status Status values that need to be considered for filter
|
||||||
|
*/
|
||||||
|
public findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, _options?: Configuration): Promise<Array<Pet>> {
|
||||||
|
const result = this.api.findPetsByStatus(status, _options);
|
||||||
|
return result.toPromise();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
||||||
|
* Finds Pets by tags
|
||||||
|
* @param tags Tags to filter by
|
||||||
|
*/
|
||||||
|
public findPetsByTags(tags: Array<string>, _options?: Configuration): Promise<Array<Pet>> {
|
||||||
|
const result = this.api.findPetsByTags(tags, _options);
|
||||||
|
return result.toPromise();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a single pet
|
||||||
|
* Find pet by ID
|
||||||
|
* @param petId ID of pet to return
|
||||||
|
*/
|
||||||
|
public getPetById(petId: number, _options?: Configuration): Promise<Pet> {
|
||||||
|
const result = this.api.getPetById(petId, _options);
|
||||||
|
return result.toPromise();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Update an existing pet
|
||||||
|
* @param pet Pet object that needs to be added to the store
|
||||||
|
*/
|
||||||
|
public updatePet(pet: Pet, _options?: Configuration): Promise<Pet> {
|
||||||
|
const result = this.api.updatePet(pet, _options);
|
||||||
|
return result.toPromise();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Updates a pet in the store with form data
|
||||||
|
* @param petId ID of pet that needs to be updated
|
||||||
|
* @param name Updated name of the pet
|
||||||
|
* @param status Updated status of the pet
|
||||||
|
*/
|
||||||
|
public updatePetWithForm(petId: number, name?: string, status?: string, _options?: Configuration): Promise<void> {
|
||||||
|
const result = this.api.updatePetWithForm(petId, name, status, _options);
|
||||||
|
return result.toPromise();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* uploads an image
|
||||||
|
* @param petId ID of pet to update
|
||||||
|
* @param additionalMetadata Additional data to pass to server
|
||||||
|
* @param file file to upload
|
||||||
|
*/
|
||||||
|
public uploadFile(petId: number, additionalMetadata?: string, file?: HttpFile, _options?: Configuration): Promise<ApiResponse> {
|
||||||
|
const result = this.api.uploadFile(petId, additionalMetadata, file, _options);
|
||||||
|
return result.toPromise();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import { ObservableStoreApi } from './ObservableAPI';
|
||||||
|
|
||||||
|
import { StoreApiRequestFactory, StoreApiResponseProcessor} from "../apis/StoreApi";
|
||||||
|
export class PromiseStoreApi {
|
||||||
|
private api: ObservableStoreApi
|
||||||
|
|
||||||
|
public constructor(
|
||||||
|
configuration: Configuration,
|
||||||
|
requestFactory?: StoreApiRequestFactory,
|
||||||
|
responseProcessor?: StoreApiResponseProcessor
|
||||||
|
) {
|
||||||
|
this.api = new ObservableStoreApi(configuration, requestFactory, responseProcessor);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||||
|
* Delete purchase order by ID
|
||||||
|
* @param orderId ID of the order that needs to be deleted
|
||||||
|
*/
|
||||||
|
public deleteOrder(orderId: string, _options?: Configuration): Promise<void> {
|
||||||
|
const result = this.api.deleteOrder(orderId, _options);
|
||||||
|
return result.toPromise();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a map of status codes to quantities
|
||||||
|
* Returns pet inventories by status
|
||||||
|
*/
|
||||||
|
public getInventory(_options?: Configuration): Promise<{ [key: string]: number; }> {
|
||||||
|
const result = this.api.getInventory(_options);
|
||||||
|
return result.toPromise();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||||
|
* Find purchase order by ID
|
||||||
|
* @param orderId ID of pet that needs to be fetched
|
||||||
|
*/
|
||||||
|
public getOrderById(orderId: number, _options?: Configuration): Promise<Order> {
|
||||||
|
const result = this.api.getOrderById(orderId, _options);
|
||||||
|
return result.toPromise();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Place an order for a pet
|
||||||
|
* @param order order placed for purchasing the pet
|
||||||
|
*/
|
||||||
|
public placeOrder(order: Order, _options?: Configuration): Promise<Order> {
|
||||||
|
const result = this.api.placeOrder(order, _options);
|
||||||
|
return result.toPromise();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import { ObservableUserApi } from './ObservableAPI';
|
||||||
|
|
||||||
|
import { UserApiRequestFactory, UserApiResponseProcessor} from "../apis/UserApi";
|
||||||
|
export class PromiseUserApi {
|
||||||
|
private api: ObservableUserApi
|
||||||
|
|
||||||
|
public constructor(
|
||||||
|
configuration: Configuration,
|
||||||
|
requestFactory?: UserApiRequestFactory,
|
||||||
|
responseProcessor?: UserApiResponseProcessor
|
||||||
|
) {
|
||||||
|
this.api = new ObservableUserApi(configuration, requestFactory, responseProcessor);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This can only be done by the logged in user.
|
||||||
|
* Create user
|
||||||
|
* @param user Created user object
|
||||||
|
*/
|
||||||
|
public createUser(user: User, _options?: Configuration): Promise<void> {
|
||||||
|
const result = this.api.createUser(user, _options);
|
||||||
|
return result.toPromise();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Creates list of users with given input array
|
||||||
|
* @param user List of user object
|
||||||
|
*/
|
||||||
|
public createUsersWithArrayInput(user: Array<User>, _options?: Configuration): Promise<void> {
|
||||||
|
const result = this.api.createUsersWithArrayInput(user, _options);
|
||||||
|
return result.toPromise();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Creates list of users with given input array
|
||||||
|
* @param user List of user object
|
||||||
|
*/
|
||||||
|
public createUsersWithListInput(user: Array<User>, _options?: Configuration): Promise<void> {
|
||||||
|
const result = this.api.createUsersWithListInput(user, _options);
|
||||||
|
return result.toPromise();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This can only be done by the logged in user.
|
||||||
|
* Delete user
|
||||||
|
* @param username The name that needs to be deleted
|
||||||
|
*/
|
||||||
|
public deleteUser(username: string, _options?: Configuration): Promise<void> {
|
||||||
|
const result = this.api.deleteUser(username, _options);
|
||||||
|
return result.toPromise();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Get user by user name
|
||||||
|
* @param username The name that needs to be fetched. Use user1 for testing.
|
||||||
|
*/
|
||||||
|
public getUserByName(username: string, _options?: Configuration): Promise<User> {
|
||||||
|
const result = this.api.getUserByName(username, _options);
|
||||||
|
return result.toPromise();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Logs user into the system
|
||||||
|
* @param username The user name for login
|
||||||
|
* @param password The password for login in clear text
|
||||||
|
*/
|
||||||
|
public loginUser(username: string, password: string, _options?: Configuration): Promise<string> {
|
||||||
|
const result = this.api.loginUser(username, password, _options);
|
||||||
|
return result.toPromise();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Logs out current logged in user session
|
||||||
|
*/
|
||||||
|
public logoutUser(_options?: Configuration): Promise<void> {
|
||||||
|
const result = this.api.logoutUser(_options);
|
||||||
|
return result.toPromise();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This can only be done by the logged in user.
|
||||||
|
* Updated user
|
||||||
|
* @param username name that need to be deleted
|
||||||
|
* @param user Updated user object
|
||||||
|
*/
|
||||||
|
public updateUser(username: string, user: User, _options?: Configuration): Promise<void> {
|
||||||
|
const result = this.api.updateUser(username, user, _options);
|
||||||
|
return result.toPromise();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,37 @@
|
|||||||
|
/**
|
||||||
|
* Returns if a specific http code is in a given code range
|
||||||
|
* where the code range is defined as a combination of digits
|
||||||
|
* and "X" (the letter X) with a length of 3
|
||||||
|
*
|
||||||
|
* @param codeRange string with length 3 consisting of digits and "X" (the letter X)
|
||||||
|
* @param code the http status code to be checked against the code range
|
||||||
|
*/
|
||||||
|
export function isCodeInRange(codeRange: string, code: number): boolean {
|
||||||
|
// This is how the default value is encoded in OAG
|
||||||
|
if (codeRange === "0") {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (codeRange == code.toString()) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
const codeString = code.toString();
|
||||||
|
if (codeString.length != codeRange.length) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
for (let i = 0; i < codeString.length; i++) {
|
||||||
|
if (codeRange.charAt(i) != "X" && codeRange.charAt(i) != codeString.charAt(i)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns if it can consume form
|
||||||
|
*
|
||||||
|
* @param consumes array
|
||||||
|
*/
|
||||||
|
export function canConsumeForm(contentTypes: string[]): boolean {
|
||||||
|
return contentTypes.indexOf('multipart/form-data') !== -1
|
||||||
|
}
|
@ -1,4 +1,3 @@
|
|||||||
// typings for btoa are incorrect
|
|
||||||
import { RequestContext } from "../http/http";
|
import { RequestContext } from "../http/http";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// typings of url-parse are incorrect...
|
|
||||||
// @ts-ignore
|
|
||||||
import * as URLParse from "url-parse";
|
import * as URLParse from "url-parse";
|
||||||
import { Observable, from } from '../rxjsStub';
|
import { Observable, from } from '../rxjsStub';
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ export { createConfiguration } from "./configuration"
|
|||||||
export { Configuration } from "./configuration"
|
export { Configuration } from "./configuration"
|
||||||
export * from "./apis/exception";
|
export * from "./apis/exception";
|
||||||
export * from "./servers";
|
export * from "./servers";
|
||||||
|
export { RequiredError } from "./apis/baseapi";
|
||||||
|
|
||||||
export { PromiseMiddleware as Middleware } from './middleware';
|
export { PromiseMiddleware as Middleware } from './middleware';
|
||||||
export { PromiseDefaultApi as DefaultApi } from './types/PromiseAPI';
|
export { PromiseDefaultApi as DefaultApi } from './types/PromiseAPI';
|
||||||
|
@ -11,6 +11,10 @@
|
|||||||
],
|
],
|
||||||
"license": "Unlicense",
|
"license": "Unlicense",
|
||||||
"main": "./dist/index.js",
|
"main": "./dist/index.js",
|
||||||
|
"type": "commonjs",
|
||||||
|
"exports": {
|
||||||
|
".": "./dist/index.js"
|
||||||
|
},
|
||||||
"typings": "./dist/index.d.ts",
|
"typings": "./dist/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsc",
|
"build": "tsc",
|
||||||
@ -22,6 +26,7 @@
|
|||||||
"url-parse": "^1.4.3"
|
"url-parse": "^1.4.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"typescript": "^3.9.3"
|
"typescript": "^3.9.3",
|
||||||
|
"@types/url-parse": "1.4.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
"strict": true,
|
"strict": true,
|
||||||
/* Basic Options */
|
/* Basic Options */
|
||||||
"target": "es5",
|
"target": "es5",
|
||||||
"module": "commonjs",
|
|
||||||
"moduleResolution": "node",
|
"moduleResolution": "node",
|
||||||
"declaration": true,
|
"declaration": true,
|
||||||
|
|
||||||
|
@ -3,8 +3,6 @@ import * as FormData from "form-data";
|
|||||||
import { URLSearchParams } from 'url';
|
import { URLSearchParams } from 'url';
|
||||||
import * as http from 'http';
|
import * as http from 'http';
|
||||||
import * as https from 'https';
|
import * as https from 'https';
|
||||||
// typings of url-parse are incorrect...
|
|
||||||
// @ts-ignore
|
|
||||||
import * as URLParse from "url-parse";
|
import * as URLParse from "url-parse";
|
||||||
import { Observable, from } from '../rxjsStub';
|
import { Observable, from } from '../rxjsStub';
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ export { createConfiguration } from "./configuration"
|
|||||||
export { Configuration } from "./configuration"
|
export { Configuration } from "./configuration"
|
||||||
export * from "./apis/exception";
|
export * from "./apis/exception";
|
||||||
export * from "./servers";
|
export * from "./servers";
|
||||||
|
export { RequiredError } from "./apis/baseapi";
|
||||||
|
|
||||||
export { PromiseMiddleware as Middleware } from './middleware';
|
export { PromiseMiddleware as Middleware } from './middleware';
|
||||||
export { PromisePetApi as PetApi, PromiseStoreApi as StoreApi, PromiseUserApi as UserApi } from './types/PromiseAPI';
|
export { PromisePetApi as PetApi, PromiseStoreApi as StoreApi, PromiseUserApi as UserApi } from './types/PromiseAPI';
|
||||||
|
@ -11,6 +11,10 @@
|
|||||||
],
|
],
|
||||||
"license": "Unlicense",
|
"license": "Unlicense",
|
||||||
"main": "./dist/index.js",
|
"main": "./dist/index.js",
|
||||||
|
"type": "commonjs",
|
||||||
|
"exports": {
|
||||||
|
".": "./dist/index.js"
|
||||||
|
},
|
||||||
"typings": "./dist/index.d.ts",
|
"typings": "./dist/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsc",
|
"build": "tsc",
|
||||||
@ -26,6 +30,7 @@
|
|||||||
"url-parse": "^1.4.3"
|
"url-parse": "^1.4.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"typescript": "^3.9.3"
|
"typescript": "^3.9.3",
|
||||||
|
"@types/url-parse": "1.4.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
"strict": true,
|
"strict": true,
|
||||||
/* Basic Options */
|
/* Basic Options */
|
||||||
"target": "es5",
|
"target": "es5",
|
||||||
"module": "commonjs",
|
|
||||||
"moduleResolution": "node",
|
"moduleResolution": "node",
|
||||||
"declaration": true,
|
"declaration": true,
|
||||||
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
// typings for btoa are incorrect
|
|
||||||
import { RequestContext } from "../http/http.ts";
|
import { RequestContext } from "../http/http.ts";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -5,6 +5,7 @@ export { createConfiguration } from "./configuration.ts"
|
|||||||
export type { Configuration } from "./configuration.ts"
|
export type { Configuration } from "./configuration.ts"
|
||||||
export * from "./apis/exception.ts";
|
export * from "./apis/exception.ts";
|
||||||
export * from "./servers.ts";
|
export * from "./servers.ts";
|
||||||
|
export { RequiredError } from "./apis/baseapi.ts";
|
||||||
|
|
||||||
export type { PromiseMiddleware as Middleware } from './middleware.ts';
|
export type { PromiseMiddleware as Middleware } from './middleware.ts';
|
||||||
export { PromisePetApi as PetApi, PromiseStoreApi as StoreApi, PromiseUserApi as UserApi } from './types/PromiseAPI.ts';
|
export { PromisePetApi as PetApi, PromiseStoreApi as StoreApi, PromiseUserApi as UserApi } from './types/PromiseAPI.ts';
|
||||||
|
@ -3,8 +3,6 @@ import * as FormData from "form-data";
|
|||||||
import { URLSearchParams } from 'url';
|
import { URLSearchParams } from 'url';
|
||||||
import * as http from 'http';
|
import * as http from 'http';
|
||||||
import * as https from 'https';
|
import * as https from 'https';
|
||||||
// typings of url-parse are incorrect...
|
|
||||||
// @ts-ignore
|
|
||||||
import * as URLParse from "url-parse";
|
import * as URLParse from "url-parse";
|
||||||
import { Observable, from } from '../rxjsStub';
|
import { Observable, from } from '../rxjsStub';
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ export { createConfiguration } from "./configuration"
|
|||||||
export { Configuration } from "./configuration"
|
export { Configuration } from "./configuration"
|
||||||
export * from "./apis/exception";
|
export * from "./apis/exception";
|
||||||
export * from "./servers";
|
export * from "./servers";
|
||||||
|
export { RequiredError } from "./apis/baseapi";
|
||||||
|
|
||||||
export { PromiseMiddleware as Middleware } from './middleware';
|
export { PromiseMiddleware as Middleware } from './middleware';
|
||||||
export { PromisePetApi as PetApi, PromiseStoreApi as StoreApi, PromiseUserApi as UserApi } from './types/PromiseAPI';
|
export { PromisePetApi as PetApi, PromiseStoreApi as StoreApi, PromiseUserApi as UserApi } from './types/PromiseAPI';
|
||||||
|
@ -11,6 +11,10 @@
|
|||||||
],
|
],
|
||||||
"license": "Unlicense",
|
"license": "Unlicense",
|
||||||
"main": "./dist/index.js",
|
"main": "./dist/index.js",
|
||||||
|
"type": "commonjs",
|
||||||
|
"exports": {
|
||||||
|
".": "./dist/index.js"
|
||||||
|
},
|
||||||
"typings": "./dist/index.d.ts",
|
"typings": "./dist/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsc",
|
"build": "tsc",
|
||||||
@ -27,6 +31,7 @@
|
|||||||
"url-parse": "^1.4.3"
|
"url-parse": "^1.4.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"typescript": "^3.9.3"
|
"typescript": "^3.9.3",
|
||||||
|
"@types/url-parse": "1.4.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
"strict": true,
|
"strict": true,
|
||||||
/* Basic Options */
|
/* Basic Options */
|
||||||
"target": "es5",
|
"target": "es5",
|
||||||
"module": "commonjs",
|
|
||||||
"moduleResolution": "node",
|
"moduleResolution": "node",
|
||||||
"declaration": true,
|
"declaration": true,
|
||||||
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
// typings for btoa are incorrect
|
|
||||||
import { RequestContext } from "../http/http";
|
import { RequestContext } from "../http/http";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// typings of url-parse are incorrect...
|
|
||||||
// @ts-ignore
|
|
||||||
import * as URLParse from "url-parse";
|
import * as URLParse from "url-parse";
|
||||||
import { Observable, from } from '../rxjsStub';
|
import { Observable, from } from '../rxjsStub';
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ export { createConfiguration } from "./configuration"
|
|||||||
export { Configuration } from "./configuration"
|
export { Configuration } from "./configuration"
|
||||||
export * from "./apis/exception";
|
export * from "./apis/exception";
|
||||||
export * from "./servers";
|
export * from "./servers";
|
||||||
|
export { RequiredError } from "./apis/baseapi";
|
||||||
|
|
||||||
export { PromiseMiddleware as Middleware } from './middleware';
|
export { PromiseMiddleware as Middleware } from './middleware';
|
||||||
export { PromisePetApi as PetApi, PromiseStoreApi as StoreApi, PromiseUserApi as UserApi } from './types/PromiseAPI';
|
export { PromisePetApi as PetApi, PromiseStoreApi as StoreApi, PromiseUserApi as UserApi } from './types/PromiseAPI';
|
||||||
|
@ -1,8 +1,86 @@
|
|||||||
{
|
{
|
||||||
"name": "ts-petstore-client",
|
"name": "ts-petstore-client",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
|
"packages": {
|
||||||
|
"": {
|
||||||
|
"name": "ts-petstore-client",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"license": "Unlicense",
|
||||||
|
"dependencies": {
|
||||||
|
"@types/jquery": "^3.3.29",
|
||||||
|
"es6-promise": "^4.2.4",
|
||||||
|
"jquery": "^3.4.1",
|
||||||
|
"url-parse": "^1.4.3"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/url-parse": "1.4.4",
|
||||||
|
"typescript": "^3.9.3"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@types/jquery": {
|
||||||
|
"version": "3.3.29",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/jquery/-/jquery-3.3.29.tgz",
|
||||||
|
"integrity": "sha512-FhJvBninYD36v3k6c+bVk1DSZwh7B5Dpb/Pyk3HKVsiohn0nhbefZZ+3JXbWQhFyt0MxSl2jRDdGQPHeOHFXrQ==",
|
||||||
|
"dependencies": {
|
||||||
|
"@types/sizzle": "*"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@types/sizzle": {
|
||||||
|
"version": "2.3.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/sizzle/-/sizzle-2.3.2.tgz",
|
||||||
|
"integrity": "sha512-7EJYyKTL7tFR8+gDbB6Wwz/arpGa0Mywk1TJbNzKzHtzbwVmY4HR9WqS5VV7dsBUKQmPNr192jHr/VpBluj/hg=="
|
||||||
|
},
|
||||||
|
"node_modules/@types/url-parse": {
|
||||||
|
"version": "1.4.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/url-parse/-/url-parse-1.4.4.tgz",
|
||||||
|
"integrity": "sha512-KtQLad12+4T/NfSxpoDhmr22+fig3T7/08QCgmutYA6QSznSRmEtuL95GrhVV40/0otTEdFc+etRcCTqhh1q5Q==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"node_modules/es6-promise": {
|
||||||
|
"version": "4.2.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.6.tgz",
|
||||||
|
"integrity": "sha512-aRVgGdnmW2OiySVPUC9e6m+plolMAJKjZnQlCwNSuK5yQ0JN61DZSO1X1Ufd1foqWRAlig0rhduTCHe7sVtK5Q=="
|
||||||
|
},
|
||||||
|
"node_modules/jquery": {
|
||||||
|
"version": "3.5.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/jquery/-/jquery-3.5.1.tgz",
|
||||||
|
"integrity": "sha512-XwIBPqcMn57FxfT+Go5pzySnm4KWkT1Tv7gjrpT1srtf8Weynl6R273VJ5GjkRb51IzMp5nbaPjJXMWeju2MKg=="
|
||||||
|
},
|
||||||
|
"node_modules/querystringify": {
|
||||||
|
"version": "2.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.1.1.tgz",
|
||||||
|
"integrity": "sha512-w7fLxIRCRT7U8Qu53jQnJyPkYZIaR4n5151KMfcJlO/A9397Wxb1amJvROTK6TOnp7PfoAmg/qXiNHI+08jRfA=="
|
||||||
|
},
|
||||||
|
"node_modules/requires-port": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz",
|
||||||
|
"integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8="
|
||||||
|
},
|
||||||
|
"node_modules/typescript": {
|
||||||
|
"version": "3.9.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.3.tgz",
|
||||||
|
"integrity": "sha512-D/wqnB2xzNFIcoBG9FG8cXRDjiqSTbG2wd8DMZeQyJlP1vfTkIxH4GKveWaEBYySKIg+USu+E+EDIR47SqnaMQ==",
|
||||||
|
"dev": true,
|
||||||
|
"bin": {
|
||||||
|
"tsc": "bin/tsc",
|
||||||
|
"tsserver": "bin/tsserver"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=4.2.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/url-parse": {
|
||||||
|
"version": "1.4.7",
|
||||||
|
"resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.4.7.tgz",
|
||||||
|
"integrity": "sha512-d3uaVyzDB9tQoSXFvuSUNFibTd9zxd2bkVrDRvF5TmvWWQwqE4lgYJ5m+x1DbecWkw+LK4RNl2CU1hHuOKPVlg==",
|
||||||
|
"dependencies": {
|
||||||
|
"querystringify": "^2.1.1",
|
||||||
|
"requires-port": "^1.0.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/jquery": {
|
"@types/jquery": {
|
||||||
"version": "3.3.29",
|
"version": "3.3.29",
|
||||||
@ -17,6 +95,12 @@
|
|||||||
"resolved": "https://registry.npmjs.org/@types/sizzle/-/sizzle-2.3.2.tgz",
|
"resolved": "https://registry.npmjs.org/@types/sizzle/-/sizzle-2.3.2.tgz",
|
||||||
"integrity": "sha512-7EJYyKTL7tFR8+gDbB6Wwz/arpGa0Mywk1TJbNzKzHtzbwVmY4HR9WqS5VV7dsBUKQmPNr192jHr/VpBluj/hg=="
|
"integrity": "sha512-7EJYyKTL7tFR8+gDbB6Wwz/arpGa0Mywk1TJbNzKzHtzbwVmY4HR9WqS5VV7dsBUKQmPNr192jHr/VpBluj/hg=="
|
||||||
},
|
},
|
||||||
|
"@types/url-parse": {
|
||||||
|
"version": "1.4.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/url-parse/-/url-parse-1.4.4.tgz",
|
||||||
|
"integrity": "sha512-KtQLad12+4T/NfSxpoDhmr22+fig3T7/08QCgmutYA6QSznSRmEtuL95GrhVV40/0otTEdFc+etRcCTqhh1q5Q==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"es6-promise": {
|
"es6-promise": {
|
||||||
"version": "4.2.6",
|
"version": "4.2.6",
|
||||||
"resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.6.tgz",
|
"resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.6.tgz",
|
||||||
|
@ -11,6 +11,10 @@
|
|||||||
],
|
],
|
||||||
"license": "Unlicense",
|
"license": "Unlicense",
|
||||||
"main": "./dist/index.js",
|
"main": "./dist/index.js",
|
||||||
|
"type": "commonjs",
|
||||||
|
"exports": {
|
||||||
|
".": "./dist/index.js"
|
||||||
|
},
|
||||||
"typings": "./dist/index.d.ts",
|
"typings": "./dist/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsc",
|
"build": "tsc",
|
||||||
@ -23,6 +27,7 @@
|
|||||||
"url-parse": "^1.4.3"
|
"url-parse": "^1.4.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"typescript": "^3.9.3"
|
"typescript": "^3.9.3",
|
||||||
|
"@types/url-parse": "1.4.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
"strict": true,
|
"strict": true,
|
||||||
/* Basic Options */
|
/* Basic Options */
|
||||||
"target": "es5",
|
"target": "es5",
|
||||||
"module": "commonjs",
|
|
||||||
"moduleResolution": "node",
|
"moduleResolution": "node",
|
||||||
"declaration": true,
|
"declaration": true,
|
||||||
|
|
||||||
|
@ -3,8 +3,6 @@ import * as FormData from "form-data";
|
|||||||
import { URLSearchParams } from 'url';
|
import { URLSearchParams } from 'url';
|
||||||
import * as http from 'http';
|
import * as http from 'http';
|
||||||
import * as https from 'https';
|
import * as https from 'https';
|
||||||
// typings of url-parse are incorrect...
|
|
||||||
// @ts-ignore
|
|
||||||
import * as URLParse from "url-parse";
|
import * as URLParse from "url-parse";
|
||||||
import { Observable, from } from '../rxjsStub';
|
import { Observable, from } from '../rxjsStub';
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ export { createConfiguration } from "./configuration"
|
|||||||
export { Configuration } from "./configuration"
|
export { Configuration } from "./configuration"
|
||||||
export * from "./apis/exception";
|
export * from "./apis/exception";
|
||||||
export * from "./servers";
|
export * from "./servers";
|
||||||
|
export { RequiredError } from "./apis/baseapi";
|
||||||
|
|
||||||
export { PromiseMiddleware as Middleware } from './middleware';
|
export { PromiseMiddleware as Middleware } from './middleware';
|
||||||
export { PetApiAddPetRequest, PetApiDeletePetRequest, PetApiFindPetsByStatusRequest, PetApiFindPetsByTagsRequest, PetApiGetPetByIdRequest, PetApiUpdatePetRequest, PetApiUpdatePetWithFormRequest, PetApiUploadFileRequest, ObjectPetApi as PetApi, StoreApiDeleteOrderRequest, StoreApiGetInventoryRequest, StoreApiGetOrderByIdRequest, StoreApiPlaceOrderRequest, ObjectStoreApi as StoreApi, UserApiCreateUserRequest, UserApiCreateUsersWithArrayInputRequest, UserApiCreateUsersWithListInputRequest, UserApiDeleteUserRequest, UserApiGetUserByNameRequest, UserApiLoginUserRequest, UserApiLogoutUserRequest, UserApiUpdateUserRequest, ObjectUserApi as UserApi } from './types/ObjectParamAPI';
|
export { PetApiAddPetRequest, PetApiDeletePetRequest, PetApiFindPetsByStatusRequest, PetApiFindPetsByTagsRequest, PetApiGetPetByIdRequest, PetApiUpdatePetRequest, PetApiUpdatePetWithFormRequest, PetApiUploadFileRequest, ObjectPetApi as PetApi, StoreApiDeleteOrderRequest, StoreApiGetInventoryRequest, StoreApiGetOrderByIdRequest, StoreApiPlaceOrderRequest, ObjectStoreApi as StoreApi, UserApiCreateUserRequest, UserApiCreateUsersWithArrayInputRequest, UserApiCreateUsersWithListInputRequest, UserApiDeleteUserRequest, UserApiGetUserByNameRequest, UserApiLoginUserRequest, UserApiLogoutUserRequest, UserApiUpdateUserRequest, ObjectUserApi as UserApi } from './types/ObjectParamAPI';
|
||||||
|
@ -11,6 +11,10 @@
|
|||||||
],
|
],
|
||||||
"license": "Unlicense",
|
"license": "Unlicense",
|
||||||
"main": "./dist/index.js",
|
"main": "./dist/index.js",
|
||||||
|
"type": "commonjs",
|
||||||
|
"exports": {
|
||||||
|
".": "./dist/index.js"
|
||||||
|
},
|
||||||
"typings": "./dist/index.d.ts",
|
"typings": "./dist/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsc",
|
"build": "tsc",
|
||||||
@ -26,6 +30,7 @@
|
|||||||
"url-parse": "^1.4.3"
|
"url-parse": "^1.4.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"typescript": "^3.9.3"
|
"typescript": "^3.9.3",
|
||||||
|
"@types/url-parse": "1.4.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
"strict": true,
|
"strict": true,
|
||||||
/* Basic Options */
|
/* Basic Options */
|
||||||
"target": "es5",
|
"target": "es5",
|
||||||
"module": "commonjs",
|
|
||||||
"moduleResolution": "node",
|
"moduleResolution": "node",
|
||||||
"declaration": true,
|
"declaration": true,
|
||||||
|
|
||||||
|
5
samples/openapi3/client/petstore/typescript/tests/browser/.gitignore
vendored
Normal file
5
samples/openapi3/client/petstore/typescript/tests/browser/.gitignore
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
node_modules
|
||||||
|
.DS_Store
|
||||||
|
dist
|
||||||
|
bundle
|
||||||
|
*.local
|
5958
samples/openapi3/client/petstore/typescript/tests/browser/package-lock.json
generated
Normal file
5958
samples/openapi3/client/petstore/typescript/tests/browser/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,20 @@
|
|||||||
|
{
|
||||||
|
"name": "typescript-test",
|
||||||
|
"private": true,
|
||||||
|
"version": "0.0.0",
|
||||||
|
"type": "module",
|
||||||
|
"scripts": {
|
||||||
|
"build": "tsc --noEmit && esbuild test/*.ts --bundle --outdir=dist",
|
||||||
|
"test": "web-test-runner"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@esm-bundle/chai": "^4.3.4-fix.0",
|
||||||
|
"@web/test-runner": "^0.13.26",
|
||||||
|
"@web/test-runner-puppeteer": "^0.10.5",
|
||||||
|
"ts-petstore-client": "file:../../builds/browser"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"esbuild": "^0.14.14",
|
||||||
|
"typescript": "^4.4.4"
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,73 @@
|
|||||||
|
<project>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>org.openapitools</groupId>
|
||||||
|
<artifactId>TypeScriptBrowserPetstoreClientTests</artifactId>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<name>TS Browser Petstore Test Client</name>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-dependency-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>copy-dependencies</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<outputDirectory>${project.build.directory}</outputDirectory>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
|
<artifactId>exec-maven-plugin</artifactId>
|
||||||
|
<version>1.2.1</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>npm-install</id>
|
||||||
|
<phase>pre-integration-test</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>exec</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<executable>npm</executable>
|
||||||
|
<arguments>
|
||||||
|
<argument>install</argument>
|
||||||
|
</arguments>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>npm-build</id>
|
||||||
|
<phase>pre-integration-test</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>exec</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<executable>npm</executable>
|
||||||
|
<arguments>
|
||||||
|
<argument>run</argument>
|
||||||
|
<argument>build</argument>
|
||||||
|
</arguments>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>npm-test</id>
|
||||||
|
<phase>integration-test</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>exec</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<executable>npm</executable>
|
||||||
|
<arguments>
|
||||||
|
<argument>test</argument>
|
||||||
|
</arguments>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
@ -0,0 +1,131 @@
|
|||||||
|
import { expect } from '@esm-bundle/chai';
|
||||||
|
import { ServerConfiguration, createConfiguration, PetApi, Tag, Pet, ApiException, RequiredError } from 'ts-petstore-client'
|
||||||
|
import image from "./pet";
|
||||||
|
|
||||||
|
const configuration = createConfiguration({
|
||||||
|
baseServer: new ServerConfiguration("http://localhost/v2", {}),
|
||||||
|
})
|
||||||
|
const petApi = new PetApi(configuration)
|
||||||
|
|
||||||
|
function createTag() {
|
||||||
|
const tag = new Tag();
|
||||||
|
tag.name = "tag1"
|
||||||
|
tag.id = Math.floor(Math.random() * 100000)
|
||||||
|
return tag as Required<Tag>;
|
||||||
|
}
|
||||||
|
const tag = createTag();
|
||||||
|
|
||||||
|
function createPet() {
|
||||||
|
const pet = new Pet()
|
||||||
|
pet.id = Math.floor(Math.random() * 100000)
|
||||||
|
pet.name = "PetName"
|
||||||
|
pet.photoUrls = []
|
||||||
|
pet.status = 'available'
|
||||||
|
pet.tags = [ tag ]
|
||||||
|
return pet as Required<Pet>;
|
||||||
|
}
|
||||||
|
let pet: Required<Pet>;
|
||||||
|
|
||||||
|
describe("PetApi", () => {
|
||||||
|
beforeEach(async () => {
|
||||||
|
pet = createPet();
|
||||||
|
await petApi.addPet(pet);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("addPet", async () => {
|
||||||
|
const createdPet = await petApi.getPetById(pet.id)
|
||||||
|
expect(createdPet).to.deep.equal(pet);
|
||||||
|
})
|
||||||
|
|
||||||
|
it("deletePet", async () => {
|
||||||
|
await petApi.deletePet(pet.id);
|
||||||
|
let deletedPet;
|
||||||
|
try {
|
||||||
|
deletedPet = await petApi.getPetById(pet.id)
|
||||||
|
} catch (error) {
|
||||||
|
const err = error as ApiException<unknown>;
|
||||||
|
expect(err.code).to.equal(404);
|
||||||
|
expect(err.message).to.include("Pet not found");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
throw new Error("Pet with id " + deletedPet.id + " was not deleted!");
|
||||||
|
})
|
||||||
|
|
||||||
|
it("deleteNonExistantPet", async () => {
|
||||||
|
// Use an id that is too big for the server to handle.
|
||||||
|
const nonExistantId = 100000000000000000000000000.0;
|
||||||
|
try {
|
||||||
|
await petApi.deletePet(nonExistantId)
|
||||||
|
} catch (error) {
|
||||||
|
const err = error as ApiException<unknown>;
|
||||||
|
// The 404 response for this endpoint is officially documented, but
|
||||||
|
// that documentation is not used for generating the client code.
|
||||||
|
// That means we get an error about the response being undefined
|
||||||
|
// here.
|
||||||
|
expect(err.code).to.equal(404);
|
||||||
|
expect(err.message).to.include("Unknown API Status Code");
|
||||||
|
expect(err.body).to.include("404");
|
||||||
|
expect(err.body).to.include("message");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
throw new Error("Deleted non-existant pet with id " + nonExistantId + "!");
|
||||||
|
})
|
||||||
|
|
||||||
|
it("failRunTimeRequiredParameterCheck", async () => {
|
||||||
|
try {
|
||||||
|
await petApi.deletePet(null as unknown as number)
|
||||||
|
} catch (error) {
|
||||||
|
const err = error as RequiredError;
|
||||||
|
expect(err.api).to.equal("PetApi");
|
||||||
|
expect(err.message).to.include("PetApi");
|
||||||
|
expect(err.method).to.equal("deletePet");
|
||||||
|
expect(err.message).to.include("deletePet");
|
||||||
|
expect(err.field).to.equal("petId");
|
||||||
|
expect(err.message).to.include("petId");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
throw new Error("Accepted missing parameter!");
|
||||||
|
})
|
||||||
|
|
||||||
|
it("findPetsByStatus", async () => {
|
||||||
|
const pets = await petApi.findPetsByStatus(["available"]);
|
||||||
|
expect(pets.length).to.be.at.least(1);
|
||||||
|
})
|
||||||
|
|
||||||
|
it("findPetsByTag", async () => {
|
||||||
|
const pets = await petApi.findPetsByTags([tag.name])
|
||||||
|
expect(pets.length).to.be.at.least(1);
|
||||||
|
})
|
||||||
|
|
||||||
|
it("getPetById", async () => {
|
||||||
|
const returnedPet = await petApi.getPetById(pet.id);
|
||||||
|
expect(returnedPet).to.deep.equal(pet);
|
||||||
|
})
|
||||||
|
|
||||||
|
it("updatePet", async () => {
|
||||||
|
pet.name = "updated name";
|
||||||
|
await petApi.updatePet(pet);
|
||||||
|
await petApi.updatePet(pet);
|
||||||
|
|
||||||
|
const returnedPet = await petApi.getPetById(pet.id);
|
||||||
|
expect(returnedPet.id).to.equal(pet.id)
|
||||||
|
expect(returnedPet.name).to.equal(pet.name);
|
||||||
|
})
|
||||||
|
|
||||||
|
it("updatePetWithForm", async () => {
|
||||||
|
const updatedName = "updated name";
|
||||||
|
await petApi.updatePetWithForm(pet.id, updatedName);
|
||||||
|
|
||||||
|
const returnedPet = await petApi.getPetById(pet.id)
|
||||||
|
expect(returnedPet.id).to.equal(pet.id)
|
||||||
|
expect(returnedPet.name).to.equal(updatedName);
|
||||||
|
})
|
||||||
|
|
||||||
|
it("uploadFile", async () => {
|
||||||
|
const imageResponse = await fetch(image);
|
||||||
|
const imageFile = new File([await imageResponse.blob()], "pet.png", { type: "image/png" });
|
||||||
|
const response = await petApi.uploadFile(pet.id, "Metadata", imageFile);
|
||||||
|
expect(response.code).to.be.gte(200).and.lt(300);
|
||||||
|
expect(response.message).to.contain("pet.png");
|
||||||
|
})
|
||||||
|
})
|
@ -0,0 +1,48 @@
|
|||||||
|
import { expect } from '@esm-bundle/chai';
|
||||||
|
import * as petstore from "ts-petstore-client";
|
||||||
|
|
||||||
|
let libs: { [key: string]: petstore.HttpLibrary } = {
|
||||||
|
"isomorphic-fetch": new petstore.IsomorphicFetchHttpLibrary()
|
||||||
|
}
|
||||||
|
|
||||||
|
for (let libName in libs) {
|
||||||
|
let lib = libs[libName];
|
||||||
|
|
||||||
|
describe("Isomorphic Fetch", () => {
|
||||||
|
it("GET-Request", (done) => {
|
||||||
|
let requestContext = new petstore.RequestContext("http://httpbin.org/get", petstore.HttpMethod.GET);
|
||||||
|
requestContext.setHeaderParam("X-Test-Token", "Test-Token");
|
||||||
|
lib.send(requestContext).toPromise().then((resp: petstore.ResponseContext) => {
|
||||||
|
expect(resp.httpStatusCode, "Expected status code to be 200").to.eq(200);
|
||||||
|
return resp.body.text();
|
||||||
|
}).then((bodyText: string) => {
|
||||||
|
let body = JSON.parse(bodyText);
|
||||||
|
expect(body["headers"]).to.exist;
|
||||||
|
expect(body["headers"]["X-Test-Token"]).to.equal("Test-Token");
|
||||||
|
done();
|
||||||
|
}).catch(done)
|
||||||
|
});
|
||||||
|
|
||||||
|
it("POST-Request", (done) => {
|
||||||
|
let requestContext = new petstore.RequestContext("http://httpbin.org/post", petstore.HttpMethod.POST);
|
||||||
|
requestContext.setHeaderParam("X-Test-Token", "Test-Token");
|
||||||
|
let formData: FormData = new FormData()
|
||||||
|
formData.append("test", "test2");
|
||||||
|
formData.append("testFile", new Blob(["abc"]), "fileName.json");
|
||||||
|
|
||||||
|
requestContext.setBody(formData);
|
||||||
|
lib.send(requestContext).toPromise().then(
|
||||||
|
(resp: petstore.ResponseContext) => {
|
||||||
|
expect(resp.httpStatusCode, "Expected status code to be 200").to.eq(200);
|
||||||
|
return resp.body.text();
|
||||||
|
}).then((bodyText: string) => {
|
||||||
|
let body = JSON.parse(bodyText);
|
||||||
|
expect(body["headers"]).to.exist;
|
||||||
|
expect(body["headers"]["X-Test-Token"]).to.equal("Test-Token");
|
||||||
|
expect(body["files"]["testFile"]).to.equal("abc");
|
||||||
|
expect(body["form"]["test"]).to.equal("test2");
|
||||||
|
done();
|
||||||
|
}).catch(done)
|
||||||
|
});
|
||||||
|
})
|
||||||
|
}
|
@ -0,0 +1,2 @@
|
|||||||
|
const pet = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH4wMDFScQ1I7VKAAAAB1pVFh0Q29tbWVudAAAAAAAQ3JlYXRlZCB3aXRoIEdJTVBkLmUHAAAD2ElEQVRIx51W2W7jMAzUQR2WHbfo//9ikcSxLev0PkyjTRtv0a4ehCCwZsjhkBLf9519u0opKaUQQgjBe48ftVYhBBF1XWeM6bpOa621llJyzh+P0/fotdZaa845hLCu6+12W9d12zYQKKVSSn3fCyE451JK/PgFwb7vOecYo/d+nudpmkCQcyYirXXOed93IpJSYuecP3L8IoNlWZZlOZ/Py7IgA2vt6+srEVlrlVJa62cE+j58ZADd13Wdpgkq5ZyVUqUUKaXW2jlnrS2llFK+qPTTDKDSsiy32817n3OWUoImhJBSAvpBBvu+fynLYwa11mYhJLGuKxCllFLKbdu2bYsxllLw/VeClBIRCSGeoYEeY8w5e++3bQshxBhRZFQ151xKqbWC4AsOY4xKKZzzfd+llI+yAD2l5L2Hc+Z5XtcVTKUUIjLG5PtCPz13FW3bppRSSjHGoBXUxDGALsvivUeXxRhjjJxzRJ1zbrjP+jDGaJ7nrusQMhLc9x2xQ250wPV6nec5hLBtW0rpMZSUErCaBp8IYOqcszGGiGDNVtLr9Xo+n+d5RvjruqaUEDURPeIKIY4zeH9/H8fROZdzhoVLKc2Ul8sFzXW5XODOnDMs1HSHtrXWf2aw73spJYSglIKyqO3tdpvneZ5nyAIXtTgwGFA/WLbW+ux4ul6vCKrrOqUUJFqWBbMBHLA/HCmEKKUopYgIO8Yq9i+DiDFG0zShlWKMyIAx5r2PMU7TBBrM52ZlBK61tveltVZK8fv6ROC9R49s22athZdQ5Bgjqoq0MJ+hhrW273vnnHMOqYP1oNEw3EspWmv4r5UBEwazBOrlnDnnxhhr7TiOwzC8vLwMwzAMg7X2+TJgjFEIQQiB2YDziLc1ERGhevAlERGRc+50Or29vYFAa42SHBAAt9ZK9DE2EEi7FLGjUXFnWWudc+M4juMIAuec1vq5AIwxanWDShAROnDOYXakBaGMMbiEgT6OIy7kwwIwxj7maJOPc951HQzThge6FJXUWvf35Zzr+x6USO6AANpJKfFR3/cIH2lBety66Cxrbdd1cKcxxjl3eNf/JYAsaBljDO6/Btc4ELsQAs8TRI1Th/31qQb4DscQoFLKWgtQxhj0xQ2Dxw+OtAj+hc4YI+ccnjRoTuy4xPEb0O3Z03Dx56HunwiMMShpm1zNJ/gNUHwj7usn0H9rgCbAfYCQrbV4FiJegMJObf/hotPphI5FvMBljMFUTf12of52Udd1mBDoI7Q72rJJ8X/QHwR932PQwzNIosnyvUN+RDAMAwYypIBzDp+x/7f+ANNHbm3PivMgAAAAAElFTkSuQmCC";
|
||||||
|
export default pet;
|
@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "es6",
|
||||||
|
"useDefineForClassFields": true,
|
||||||
|
"module": "es6",
|
||||||
|
"lib": ["es6", "DOM"],
|
||||||
|
"moduleResolution": "Node",
|
||||||
|
"strict": true,
|
||||||
|
"sourceMap": true,
|
||||||
|
"resolveJsonModule": true,
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"noUnusedLocals": true,
|
||||||
|
"noUnusedParameters": true,
|
||||||
|
"noImplicitReturns": true,
|
||||||
|
"outDir": "./dist"
|
||||||
|
},
|
||||||
|
"include": ["./test"]
|
||||||
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
import { puppeteerLauncher } from '@web/test-runner-puppeteer';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
files: "./dist/*.test.js",
|
||||||
|
nodeResolve: true,
|
||||||
|
manual: false,
|
||||||
|
browsers: [
|
||||||
|
puppeteerLauncher(),
|
||||||
|
],
|
||||||
|
};
|
Loading…
x
Reference in New Issue
Block a user