[typescript] fix: deno: type exports for isolatedModules (#19484)

This commit is contained in:
Joscha Feth 2024-08-29 12:56:02 +01:00 committed by GitHub
parent 4238f17322
commit 1518237c25
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
35 changed files with 6094 additions and 1 deletions

View File

@ -0,0 +1,10 @@
generatorName: typescript
outputDir: samples/openapi3/client/petstore/typescript/builds/deno_object_params
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
templateDir: modules/openapi-generator/src/main/resources/typescript
additionalProperties:
platform: deno
npmName: ts-petstore-client
useObjectParameters: true
projectName: ts-petstore-client
moduleName: petstore

View File

@ -16,7 +16,7 @@ export { Middleware } from './middleware{{importFileExtension}}';
export{{#platforms}}{{#deno}} type{{/deno}}{{/platforms}} { PromiseMiddleware as Middleware } from './middleware{{importFileExtension}}';
{{/useRxJS}}
{{#useObjectParameters}}
export { {{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}{{classname}}{{operationIdCamelCase}}Request, {{/operation}}Object{{classname}} as {{classname}}{{^-last}}, {{/-last}} {{/operations}}{{/apis}}{{/apiInfo}}} from './types/ObjectParamAPI{{importFileExtension}}';
export { {{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}{{#platforms}}{{#deno}}type {{/deno}}{{/platforms}}{{classname}}{{operationIdCamelCase}}Request, {{/operation}}Object{{classname}} as {{classname}}{{^-last}}, {{/-last}} {{/operations}}{{/apis}}{{/apiInfo}}} from './types/ObjectParamAPI{{importFileExtension}}';
{{/useObjectParameters}}
{{^useObjectParameters}}
{{#useRxJS}}

View File

@ -0,0 +1 @@
dist

View File

@ -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

View File

@ -0,0 +1,30 @@
.gitignore
PetApi.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
rxjsStub.ts
servers.ts
types/ObjectParamAPI.ts
types/ObservableAPI.ts
types/PromiseAPI.ts
util.ts

View File

@ -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<&#39;available&#39; &#124; &#39;pending&#39; &#124; &#39;sold&#39;>** | 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&lt;string&gt;** | 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)

View File

@ -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 generate 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)

View File

@ -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 &#x60;api_key&#x60; 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)

View File

@ -0,0 +1,672 @@
// TODO: better import syntax?
import {BaseAPIRequestFactory, RequiredError, COLLECTION_FORMATS} from './baseapi.ts';
import {Configuration} from '../configuration.ts';
import {RequestContext, HttpMethod, ResponseContext, HttpFile, HttpInfo} from '../http/http.ts';
import {ObjectSerializer} from '../models/ObjectSerializer.ts';
import {ApiException} from './exception.ts';
import {canConsumeForm, isCodeInRange} from '../util.ts';
import {SecurityAuthentication} from '../auth/auth.ts';
import { ApiResponse } from '../models/ApiResponse.ts';
import { Pet } from '../models/Pet.ts';
/**
* 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 addPetWithHttpInfo(response: ResponseContext): Promise<HttpInfo<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 new HttpInfo(response.httpStatusCode, response.headers, response.body, 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 new HttpInfo(response.httpStatusCode, response.headers, response.body, 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 deletePetWithHttpInfo(response: ResponseContext): Promise<HttpInfo< 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 new HttpInfo(response.httpStatusCode, response.headers, response.body, undefined);
}
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 findPetsByStatusWithHttpInfo(response: ResponseContext): Promise<HttpInfo<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 new HttpInfo(response.httpStatusCode, response.headers, response.body, 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 new HttpInfo(response.httpStatusCode, response.headers, response.body, 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 findPetsByTagsWithHttpInfo(response: ResponseContext): Promise<HttpInfo<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 new HttpInfo(response.httpStatusCode, response.headers, response.body, 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 new HttpInfo(response.httpStatusCode, response.headers, response.body, 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 getPetByIdWithHttpInfo(response: ResponseContext): Promise<HttpInfo<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 new HttpInfo(response.httpStatusCode, response.headers, response.body, 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 new HttpInfo(response.httpStatusCode, response.headers, response.body, 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 updatePetWithHttpInfo(response: ResponseContext): Promise<HttpInfo<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 new HttpInfo(response.httpStatusCode, response.headers, response.body, 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 new HttpInfo(response.httpStatusCode, response.headers, response.body, 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 updatePetWithFormWithHttpInfo(response: ResponseContext): Promise<HttpInfo< 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 new HttpInfo(response.httpStatusCode, response.headers, response.body, undefined);
}
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 uploadFileWithHttpInfo(response: ResponseContext): Promise<HttpInfo<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 new HttpInfo(response.httpStatusCode, response.headers, response.body, 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 new HttpInfo(response.httpStatusCode, response.headers, response.body, body);
}
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
}

View File

@ -0,0 +1,278 @@
// TODO: better import syntax?
import {BaseAPIRequestFactory, RequiredError, COLLECTION_FORMATS} from './baseapi.ts';
import {Configuration} from '../configuration.ts';
import {RequestContext, HttpMethod, ResponseContext, HttpFile, HttpInfo} from '../http/http.ts';
import {ObjectSerializer} from '../models/ObjectSerializer.ts';
import {ApiException} from './exception.ts';
import {canConsumeForm, isCodeInRange} from '../util.ts';
import {SecurityAuthentication} from '../auth/auth.ts';
import { Order } from '../models/Order.ts';
/**
* 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 generate 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 deleteOrderWithHttpInfo(response: ResponseContext): Promise<HttpInfo< 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 new HttpInfo(response.httpStatusCode, response.headers, response.body, undefined);
}
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 getInventoryWithHttpInfo(response: ResponseContext): Promise<HttpInfo<{ [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 new HttpInfo(response.httpStatusCode, response.headers, response.body, 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 new HttpInfo(response.httpStatusCode, response.headers, response.body, 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 getOrderByIdWithHttpInfo(response: ResponseContext): Promise<HttpInfo<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 new HttpInfo(response.httpStatusCode, response.headers, response.body, 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 new HttpInfo(response.httpStatusCode, response.headers, response.body, 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 placeOrderWithHttpInfo(response: ResponseContext): Promise<HttpInfo<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 new HttpInfo(response.httpStatusCode, response.headers, response.body, 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 new HttpInfo(response.httpStatusCode, response.headers, response.body, body);
}
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
}

View File

@ -0,0 +1,569 @@
// TODO: better import syntax?
import {BaseAPIRequestFactory, RequiredError, COLLECTION_FORMATS} from './baseapi.ts';
import {Configuration} from '../configuration.ts';
import {RequestContext, HttpMethod, ResponseContext, HttpFile, HttpInfo} from '../http/http.ts';
import {ObjectSerializer} from '../models/ObjectSerializer.ts';
import {ApiException} from './exception.ts';
import {canConsumeForm, isCodeInRange} from '../util.ts';
import {SecurityAuthentication} from '../auth/auth.ts';
import { User } from '../models/User.ts';
/**
* 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 createUserWithHttpInfo(response: ResponseContext): Promise<HttpInfo< 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 new HttpInfo(response.httpStatusCode, response.headers, response.body, undefined);
}
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 createUsersWithArrayInputWithHttpInfo(response: ResponseContext): Promise<HttpInfo< 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 new HttpInfo(response.httpStatusCode, response.headers, response.body, undefined);
}
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 createUsersWithListInputWithHttpInfo(response: ResponseContext): Promise<HttpInfo< 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 new HttpInfo(response.httpStatusCode, response.headers, response.body, undefined);
}
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 deleteUserWithHttpInfo(response: ResponseContext): Promise<HttpInfo< 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 new HttpInfo(response.httpStatusCode, response.headers, response.body, undefined);
}
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 getUserByNameWithHttpInfo(response: ResponseContext): Promise<HttpInfo<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 new HttpInfo(response.httpStatusCode, response.headers, response.body, 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 new HttpInfo(response.httpStatusCode, response.headers, response.body, 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 loginUserWithHttpInfo(response: ResponseContext): Promise<HttpInfo<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 new HttpInfo(response.httpStatusCode, response.headers, response.body, 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 new HttpInfo(response.httpStatusCode, response.headers, response.body, 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 logoutUserWithHttpInfo(response: ResponseContext): Promise<HttpInfo< 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 new HttpInfo(response.httpStatusCode, response.headers, response.body, undefined);
}
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 updateUserWithHttpInfo(response: ResponseContext): Promise<HttpInfo< 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 new HttpInfo(response.httpStatusCode, response.headers, response.body, undefined);
}
throw new ApiException<string | Blob | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
}

View File

@ -0,0 +1,37 @@
import { Configuration } from '../configuration.ts'
/**
*
* @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 + ".");
}
}

View File

@ -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))
}
}

View File

@ -0,0 +1,107 @@
import { RequestContext } from "../http/http.ts";
/**
* 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 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);
}
}
/**
* 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);
}
}
export type AuthMethods = {
"default"?: SecurityAuthentication,
"petstore_auth"?: SecurityAuthentication,
"api_key"?: 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,
"petstore_auth"?: OAuth2Configuration,
"api_key"?: ApiKeyConfiguration
}
/**
* 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["petstore_auth"]) {
authMethods["petstore_auth"] = new PetstoreAuthAuthentication(
config["petstore_auth"]["accessToken"]
);
}
if (config["api_key"]) {
authMethods["api_key"] = new ApiKeyAuthentication(
config["api_key"]
);
}
return authMethods;
}

View File

@ -0,0 +1,82 @@
import { HttpLibrary } from "./http/http.ts";
import { Middleware, PromiseMiddleware, PromiseMiddlewareWrapper } from "./middleware.ts";
import { IsomorphicFetchHttpLibrary as DefaultHttpLibrary } from "./http/isomorphic-fetch.ts";
import { BaseServerConfiguration, server1 } from "./servers.ts";
import { configureAuthMethods, AuthMethods, AuthMethodsConfiguration } from "./auth/auth.ts";
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 - a list of available servers (according to the
* OpenAPI yaml definition) is included in the `servers` const in `./servers`. You can also
* create your own server with the `ServerConfiguration` class from the same
* file.
*/
baseServer?: BaseServerConfiguration;
/**
* HTTP library to use e.g. IsomorphicFetch. This can usually be skipped as
* all generators come with a default library.
* If available, additional libraries can be imported from `./http/*`
*/
httpApi?: HttpLibrary;
/**
* The middlewares which will be applied to requests and responses. You can
* add any number of middleware components to modify requests before they
* are sent or before they are deserialized by implementing the `Middleware`
* interface defined in `./middleware`
*/
middleware?: Middleware[];
/**
* Configures middleware functions that return promises instead of
* Observables (which are used by `middleware`). Otherwise allows for the
* same functionality as `middleware`, i.e., modifying requests before they
* are sent and before they are deserialized.
*/
promiseMiddleware?: PromiseMiddleware[];
/**
* Configuration for the available authentication methods (e.g., api keys)
* according to the OpenAPI yaml definition. For the definition, please refer to
* `./auth/auth`
*/
authMethods?: AuthMethodsConfiguration
}
/**
* Provide your `ConfigurationParameters` to this function to get a `Configuration`
* object that can be used to configure your APIs (in the constructor or
* for each request individually).
*
* 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;
}

View File

@ -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'

View File

@ -0,0 +1,238 @@
import { Observable, from } from '../rxjsStub.ts';
/**
* 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;
function ensureAbsoluteUrl(url: string) {
if (url.startsWith("http://") || url.startsWith("https://")) {
return url;
}
return window.location.origin + url;
}
/**
* Represents an HTTP request context
*/
export class RequestContext {
private headers: { [key: string]: string } = {};
private body: RequestBody = undefined;
private url: URL;
/**
* 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 URL(ensureAbsoluteUrl(url));
}
/*
* Returns the url set in the constructor including the query string
*
*/
public getUrl(): string {
return this.url.toString().endsWith("/") ?
this.url.toString().slice(0, -1)
: this.url.toString();
}
/**
* Replaces the url set in the constructor with this url.
*
*/
public setUrl(url: string) {
this.url = new URL(ensureAbsoluteUrl(url));
}
/**
* 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) {
this.url.searchParams.set(name, value);
}
/**
* 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;
return data.text();
}
}
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));
}
}
}
export class HttpInfo<T> extends ResponseContext {
public constructor(
public httpStatusCode: number,
public headers: { [key: string]: string },
public body: ResponseBody,
public data: T,
) {
super(httpStatusCode, headers, body);
}
}

View File

@ -0,0 +1,30 @@
import {HttpLibrary, RequestContext, ResponseContext} from './http.ts';
import { from, Observable } from '../rxjsStub.ts';
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(),
}).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);
}
}

View File

@ -0,0 +1,12 @@
export * from "./http/http.ts";
export * from "./auth/auth.ts";
export * from "./models/all.ts";
export { createConfiguration } from "./configuration.ts"
export type { Configuration } from "./configuration.ts"
export * from "./apis/exception.ts";
export * from "./servers.ts";
export { RequiredError } from "./apis/baseapi.ts";
export type { PromiseMiddleware as Middleware } from './middleware.ts';
export { type PetApiAddPetRequest, type PetApiDeletePetRequest, type PetApiFindPetsByStatusRequest, type PetApiFindPetsByTagsRequest, type PetApiGetPetByIdRequest, type PetApiUpdatePetRequest, type PetApiUpdatePetWithFormRequest, type PetApiUploadFileRequest, ObjectPetApi as PetApi, type StoreApiDeleteOrderRequest, type StoreApiGetInventoryRequest, type StoreApiGetOrderByIdRequest, type StoreApiPlaceOrderRequest, ObjectStoreApi as StoreApi, type UserApiCreateUserRequest, type UserApiCreateUsersWithArrayInputRequest, type UserApiCreateUsersWithListInputRequest, type UserApiDeleteUserRequest, type UserApiGetUserByNameRequest, type UserApiLoginUserRequest, type UserApiLogoutUserRequest, type UserApiUpdateUserRequest, ObjectUserApi as UserApi } from './types/ObjectParamAPI.ts';

View File

@ -0,0 +1,66 @@
import {RequestContext, ResponseContext} from './http/http.ts';
import { Observable, from } from './rxjsStub.ts';
/**
* 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>;
}

View File

@ -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.ts';
/**
* 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() {
}
}

View File

@ -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.ts';
/**
* 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() {
}
}

View File

@ -0,0 +1,283 @@
export * from '../models/ApiResponse.ts';
export * from '../models/Category.ts';
export * from '../models/Order.ts';
export * from '../models/Pet.ts';
export * from '../models/Tag.ts';
export * from '../models/User.ts';
import { ApiResponse } from '../models/ApiResponse.ts';
import { Category } from '../models/Category.ts';
import { Order , OrderStatusEnum } from '../models/Order.ts';
import { Pet , PetStatusEnum } from '../models/Pet.ts';
import { Tag } from '../models/Tag.ts';
import { User } from '../models/User.ts';
/* tslint:disable:no-unused-variable */
let primitives = [
"string",
"boolean",
"double",
"integer",
"long",
"float",
"number",
"any"
];
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,
}
type MimeTypeDescriptor = {
type: string;
subtype: string;
subtypeTokens: string[];
};
/**
* Every mime-type consists of a type, subtype, and optional parameters.
* The subtype can be composite, including information about the content format.
* For example: `application/json-patch+json`, `application/merge-patch+json`.
*
* This helper transforms a string mime-type into an internal representation.
* This simplifies the implementation of predicates that in turn define common rules for parsing or stringifying
* the payload.
*/
const parseMimeType = (mimeType: string): MimeTypeDescriptor => {
const [type, subtype] = mimeType.split('/');
return {
type,
subtype,
subtypeTokens: subtype.split('+'),
};
};
type MimeTypePredicate = (mimeType: string) => boolean;
// This factory creates a predicate function that checks a string mime-type against defined rules.
const mimeTypePredicateFactory = (predicate: (descriptor: MimeTypeDescriptor) => boolean): MimeTypePredicate => (mimeType) => predicate(parseMimeType(mimeType));
// Use this factory when you need to define a simple predicate based only on type and, if applicable, subtype.
const mimeTypeSimplePredicateFactory = (type: string, subtype?: string): MimeTypePredicate => mimeTypePredicateFactory((descriptor) => {
if (descriptor.type !== type) return false;
if (subtype != null && descriptor.subtype !== subtype) return false;
return true;
});
// Creating a set of named predicates that will help us determine how to handle different mime-types
const isTextLikeMimeType = mimeTypeSimplePredicateFactory('text');
const isJsonMimeType = mimeTypeSimplePredicateFactory('application', 'json');
const isJsonLikeMimeType = mimeTypePredicateFactory((descriptor) => descriptor.type === 'application' && descriptor.subtypeTokens.some((item) => item === 'json'));
const isOctetStreamMimeType = mimeTypeSimplePredicateFactory('application', 'octet-stream');
const isFormUrlencodedMimeType = mimeTypeSimplePredicateFactory('application', 'x-www-form-urlencoded');
// Defining a list of mime-types in the order of prioritization for handling.
const supportedMimeTypePredicatesWithPriority: MimeTypePredicate[] = [
isJsonMimeType,
isJsonLikeMimeType,
isTextLikeMimeType,
isOctetStreamMimeType,
isFormUrlencodedMimeType,
];
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 date of data) {
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 attributeType of attributeTypes) {
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 date of data) {
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 attributeType of attributeTypes) {
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.length === 0) {
return "application/json";
}
const normalMediaTypes = mediaTypes.map(this.normalizeMediaType);
for (const predicate of supportedMimeTypePredicatesWithPriority) {
for (const mediaType of normalMediaTypes) {
if (mediaType != null && predicate(mediaType)) {
return mediaType;
}
}
}
throw new Error("None of the given media types are supported: " + mediaTypes.join(", "));
}
/**
* Convert data to a string according the given media type
*/
public static stringify(data: any, mediaType: string): string {
if (isTextLikeMimeType(mediaType)) {
return String(data);
}
if (isJsonLikeMimeType(mediaType)) {
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 (isTextLikeMimeType(mediaType)) {
return rawData;
}
if (isJsonLikeMimeType(mediaType)) {
return JSON.parse(rawData);
}
throw new Error("The mediaType " + mediaType + " is not supported by ObjectSerializer.parse.");
}
}

View File

@ -0,0 +1,83 @@
/**
* 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.ts';
/**
* 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 enum OrderStatusEnum {
Placed = 'placed',
Approved = 'approved',
Delivered = 'delivered'
}

View File

@ -0,0 +1,85 @@
/**
* 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 '../models/Category.ts';
import { Tag } from '../models/Tag.ts';
import { HttpFile } from '../http/http.ts';
/**
* 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 enum PetStatusEnum {
Available = 'available',
Pending = 'pending',
Sold = 'sold'
}

View File

@ -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.ts';
/**
* 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() {
}
}

View File

@ -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.ts';
/**
* 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() {
}
}

View File

@ -0,0 +1,6 @@
export * from '../models/ApiResponse.ts'
export * from '../models/Category.ts'
export * from '../models/Order.ts'
export * from '../models/Pet.ts'
export * from '../models/Tag.ts'
export * from '../models/User.ts'

View File

@ -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;
}

View File

@ -0,0 +1,55 @@
import { RequestContext, HttpMethod } from "./http/http.ts";
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. Variables are included in
* the `url` of this ServerConfiguration in the form `{variableName}`
*
* @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];

View File

@ -0,0 +1,615 @@
import { ResponseContext, RequestContext, HttpFile, HttpInfo } from '../http/http.ts';
import { Configuration} from '../configuration.ts'
import { ApiResponse } from '../models/ApiResponse.ts';
import { Category } from '../models/Category.ts';
import { Order } from '../models/Order.ts';
import { Pet } from '../models/Pet.ts';
import { Tag } from '../models/Tag.ts';
import { User } from '../models/User.ts';
import { ObservablePetApi } from "./ObservableAPI.ts";
import { PetApiRequestFactory, PetApiResponseProcessor} from "../apis/PetApi.ts";
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&lt;&#39;available&#39; | &#39;pending&#39; | &#39;sold&#39;&gt;
* @memberof PetApifindPetsByStatus
*/
status: Array<'available' | 'pending' | 'sold'>
}
export interface PetApiFindPetsByTagsRequest {
/**
* Tags to filter by
* @type Array&lt;string&gt;
* @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 addPetWithHttpInfo(param: PetApiAddPetRequest, options?: Configuration): Promise<HttpInfo<Pet>> {
return this.api.addPetWithHttpInfo(param.pet, options).toPromise();
}
/**
*
* 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 deletePetWithHttpInfo(param: PetApiDeletePetRequest, options?: Configuration): Promise<HttpInfo<void>> {
return this.api.deletePetWithHttpInfo(param.petId, param.apiKey, 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 findPetsByStatusWithHttpInfo(param: PetApiFindPetsByStatusRequest, options?: Configuration): Promise<HttpInfo<Array<Pet>>> {
return this.api.findPetsByStatusWithHttpInfo(param.status, 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 findPetsByTagsWithHttpInfo(param: PetApiFindPetsByTagsRequest, options?: Configuration): Promise<HttpInfo<Array<Pet>>> {
return this.api.findPetsByTagsWithHttpInfo(param.tags, 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 getPetByIdWithHttpInfo(param: PetApiGetPetByIdRequest, options?: Configuration): Promise<HttpInfo<Pet>> {
return this.api.getPetByIdWithHttpInfo(param.petId, 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 updatePetWithHttpInfo(param: PetApiUpdatePetRequest, options?: Configuration): Promise<HttpInfo<Pet>> {
return this.api.updatePetWithHttpInfo(param.pet, 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 updatePetWithFormWithHttpInfo(param: PetApiUpdatePetWithFormRequest, options?: Configuration): Promise<HttpInfo<void>> {
return this.api.updatePetWithFormWithHttpInfo(param.petId, param.name, param.status, 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 uploadFileWithHttpInfo(param: PetApiUploadFileRequest, options?: Configuration): Promise<HttpInfo<ApiResponse>> {
return this.api.uploadFileWithHttpInfo(param.petId, param.additionalMetadata, param.file, 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.ts";
import { StoreApiRequestFactory, StoreApiResponseProcessor} from "../apis/StoreApi.ts";
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 deleteOrderWithHttpInfo(param: StoreApiDeleteOrderRequest, options?: Configuration): Promise<HttpInfo<void>> {
return this.api.deleteOrderWithHttpInfo(param.orderId, options).toPromise();
}
/**
* 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 getInventoryWithHttpInfo(param: StoreApiGetInventoryRequest = {}, options?: Configuration): Promise<HttpInfo<{ [key: string]: number; }>> {
return this.api.getInventoryWithHttpInfo( 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 generate exceptions
* Find purchase order by ID
* @param param the request object
*/
public getOrderByIdWithHttpInfo(param: StoreApiGetOrderByIdRequest, options?: Configuration): Promise<HttpInfo<Order>> {
return this.api.getOrderByIdWithHttpInfo(param.orderId, options).toPromise();
}
/**
* For valid response try integer IDs with value <= 5 or > 10. Other values will generate 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 placeOrderWithHttpInfo(param: StoreApiPlaceOrderRequest, options?: Configuration): Promise<HttpInfo<Order>> {
return this.api.placeOrderWithHttpInfo(param.order, 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.ts";
import { UserApiRequestFactory, UserApiResponseProcessor} from "../apis/UserApi.ts";
export interface UserApiCreateUserRequest {
/**
* Created user object
* @type User
* @memberof UserApicreateUser
*/
user: User
}
export interface UserApiCreateUsersWithArrayInputRequest {
/**
* List of user object
* @type Array&lt;User&gt;
* @memberof UserApicreateUsersWithArrayInput
*/
user: Array<User>
}
export interface UserApiCreateUsersWithListInputRequest {
/**
* List of user object
* @type Array&lt;User&gt;
* @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 createUserWithHttpInfo(param: UserApiCreateUserRequest, options?: Configuration): Promise<HttpInfo<void>> {
return this.api.createUserWithHttpInfo(param.user, options).toPromise();
}
/**
* 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 createUsersWithArrayInputWithHttpInfo(param: UserApiCreateUsersWithArrayInputRequest, options?: Configuration): Promise<HttpInfo<void>> {
return this.api.createUsersWithArrayInputWithHttpInfo(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 createUsersWithListInputWithHttpInfo(param: UserApiCreateUsersWithListInputRequest, options?: Configuration): Promise<HttpInfo<void>> {
return this.api.createUsersWithListInputWithHttpInfo(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 deleteUserWithHttpInfo(param: UserApiDeleteUserRequest, options?: Configuration): Promise<HttpInfo<void>> {
return this.api.deleteUserWithHttpInfo(param.username, 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 getUserByNameWithHttpInfo(param: UserApiGetUserByNameRequest, options?: Configuration): Promise<HttpInfo<User>> {
return this.api.getUserByNameWithHttpInfo(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 loginUserWithHttpInfo(param: UserApiLoginUserRequest, options?: Configuration): Promise<HttpInfo<string>> {
return this.api.loginUserWithHttpInfo(param.username, param.password, 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 logoutUserWithHttpInfo(param: UserApiLogoutUserRequest = {}, options?: Configuration): Promise<HttpInfo<void>> {
return this.api.logoutUserWithHttpInfo( 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 updateUserWithHttpInfo(param: UserApiUpdateUserRequest, options?: Configuration): Promise<HttpInfo<void>> {
return this.api.updateUserWithHttpInfo(param.username, param.user, 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();
}
}

View File

@ -0,0 +1,734 @@
import { ResponseContext, RequestContext, HttpFile, HttpInfo } from '../http/http.ts';
import { Configuration} from '../configuration.ts'
import { Observable, of, from } from '../rxjsStub.ts';
import {mergeMap, map} from '../rxjsStub.ts';
import { ApiResponse } from '../models/ApiResponse.ts';
import { Category } from '../models/Category.ts';
import { Order } from '../models/Order.ts';
import { Pet } from '../models/Pet.ts';
import { Tag } from '../models/Tag.ts';
import { User } from '../models/User.ts';
import { PetApiRequestFactory, PetApiResponseProcessor} from "../apis/PetApi.ts";
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 addPetWithHttpInfo(pet: Pet, _options?: Configuration): Observable<HttpInfo<Pet>> {
const requestContextPromise = this.requestFactory.addPet(pet, _options);
// build promise chain
let middlewarePreObservable = from<RequestContext>(requestContextPromise);
for (const 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 (const middleware of this.configuration.middleware) {
middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp)));
}
return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.addPetWithHttpInfo(rsp)));
}));
}
/**
*
* 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> {
return this.addPetWithHttpInfo(pet, _options).pipe(map((apiResponse: HttpInfo<Pet>) => apiResponse.data));
}
/**
*
* Deletes a pet
* @param petId Pet id to delete
* @param apiKey
*/
public deletePetWithHttpInfo(petId: number, apiKey?: string, _options?: Configuration): Observable<HttpInfo<void>> {
const requestContextPromise = this.requestFactory.deletePet(petId, apiKey, _options);
// build promise chain
let middlewarePreObservable = from<RequestContext>(requestContextPromise);
for (const 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 (const middleware of this.configuration.middleware) {
middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp)));
}
return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.deletePetWithHttpInfo(rsp)));
}));
}
/**
*
* Deletes a pet
* @param petId Pet id to delete
* @param apiKey
*/
public deletePet(petId: number, apiKey?: string, _options?: Configuration): Observable<void> {
return this.deletePetWithHttpInfo(petId, apiKey, _options).pipe(map((apiResponse: HttpInfo<void>) => apiResponse.data));
}
/**
* 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 findPetsByStatusWithHttpInfo(status: Array<'available' | 'pending' | 'sold'>, _options?: Configuration): Observable<HttpInfo<Array<Pet>>> {
const requestContextPromise = this.requestFactory.findPetsByStatus(status, _options);
// build promise chain
let middlewarePreObservable = from<RequestContext>(requestContextPromise);
for (const 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 (const middleware of this.configuration.middleware) {
middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp)));
}
return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.findPetsByStatusWithHttpInfo(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>> {
return this.findPetsByStatusWithHttpInfo(status, _options).pipe(map((apiResponse: HttpInfo<Array<Pet>>) => apiResponse.data));
}
/**
* 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 findPetsByTagsWithHttpInfo(tags: Array<string>, _options?: Configuration): Observable<HttpInfo<Array<Pet>>> {
const requestContextPromise = this.requestFactory.findPetsByTags(tags, _options);
// build promise chain
let middlewarePreObservable = from<RequestContext>(requestContextPromise);
for (const 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 (const middleware of this.configuration.middleware) {
middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp)));
}
return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.findPetsByTagsWithHttpInfo(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>> {
return this.findPetsByTagsWithHttpInfo(tags, _options).pipe(map((apiResponse: HttpInfo<Array<Pet>>) => apiResponse.data));
}
/**
* Returns a single pet
* Find pet by ID
* @param petId ID of pet to return
*/
public getPetByIdWithHttpInfo(petId: number, _options?: Configuration): Observable<HttpInfo<Pet>> {
const requestContextPromise = this.requestFactory.getPetById(petId, _options);
// build promise chain
let middlewarePreObservable = from<RequestContext>(requestContextPromise);
for (const 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 (const middleware of this.configuration.middleware) {
middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp)));
}
return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.getPetByIdWithHttpInfo(rsp)));
}));
}
/**
* Returns a single pet
* Find pet by ID
* @param petId ID of pet to return
*/
public getPetById(petId: number, _options?: Configuration): Observable<Pet> {
return this.getPetByIdWithHttpInfo(petId, _options).pipe(map((apiResponse: HttpInfo<Pet>) => apiResponse.data));
}
/**
*
* Update an existing pet
* @param pet Pet object that needs to be added to the store
*/
public updatePetWithHttpInfo(pet: Pet, _options?: Configuration): Observable<HttpInfo<Pet>> {
const requestContextPromise = this.requestFactory.updatePet(pet, _options);
// build promise chain
let middlewarePreObservable = from<RequestContext>(requestContextPromise);
for (const 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 (const middleware of this.configuration.middleware) {
middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp)));
}
return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.updatePetWithHttpInfo(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> {
return this.updatePetWithHttpInfo(pet, _options).pipe(map((apiResponse: HttpInfo<Pet>) => apiResponse.data));
}
/**
*
* Updates a pet in the store with form data
* @param petId ID of pet that needs to be updated
* @param name Updated name of the pet
* @param status Updated status of the pet
*/
public updatePetWithFormWithHttpInfo(petId: number, name?: string, status?: string, _options?: Configuration): Observable<HttpInfo<void>> {
const requestContextPromise = this.requestFactory.updatePetWithForm(petId, name, status, _options);
// build promise chain
let middlewarePreObservable = from<RequestContext>(requestContextPromise);
for (const 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 (const middleware of this.configuration.middleware) {
middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp)));
}
return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.updatePetWithFormWithHttpInfo(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> {
return this.updatePetWithFormWithHttpInfo(petId, name, status, _options).pipe(map((apiResponse: HttpInfo<void>) => apiResponse.data));
}
/**
*
* uploads an image
* @param petId ID of pet to update
* @param additionalMetadata Additional data to pass to server
* @param file file to upload
*/
public uploadFileWithHttpInfo(petId: number, additionalMetadata?: string, file?: HttpFile, _options?: Configuration): Observable<HttpInfo<ApiResponse>> {
const requestContextPromise = this.requestFactory.uploadFile(petId, additionalMetadata, file, _options);
// build promise chain
let middlewarePreObservable = from<RequestContext>(requestContextPromise);
for (const 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 (const middleware of this.configuration.middleware) {
middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp)));
}
return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.uploadFileWithHttpInfo(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> {
return this.uploadFileWithHttpInfo(petId, additionalMetadata, file, _options).pipe(map((apiResponse: HttpInfo<ApiResponse>) => apiResponse.data));
}
}
import { StoreApiRequestFactory, StoreApiResponseProcessor} from "../apis/StoreApi.ts";
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 deleteOrderWithHttpInfo(orderId: string, _options?: Configuration): Observable<HttpInfo<void>> {
const requestContextPromise = this.requestFactory.deleteOrder(orderId, _options);
// build promise chain
let middlewarePreObservable = from<RequestContext>(requestContextPromise);
for (const 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 (const middleware of this.configuration.middleware) {
middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp)));
}
return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.deleteOrderWithHttpInfo(rsp)));
}));
}
/**
* 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> {
return this.deleteOrderWithHttpInfo(orderId, _options).pipe(map((apiResponse: HttpInfo<void>) => apiResponse.data));
}
/**
* Returns a map of status codes to quantities
* Returns pet inventories by status
*/
public getInventoryWithHttpInfo(_options?: Configuration): Observable<HttpInfo<{ [key: string]: number; }>> {
const requestContextPromise = this.requestFactory.getInventory(_options);
// build promise chain
let middlewarePreObservable = from<RequestContext>(requestContextPromise);
for (const 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 (const middleware of this.configuration.middleware) {
middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp)));
}
return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.getInventoryWithHttpInfo(rsp)));
}));
}
/**
* Returns a map of status codes to quantities
* Returns pet inventories by status
*/
public getInventory(_options?: Configuration): Observable<{ [key: string]: number; }> {
return this.getInventoryWithHttpInfo(_options).pipe(map((apiResponse: HttpInfo<{ [key: string]: number; }>) => apiResponse.data));
}
/**
* For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions
* Find purchase order by ID
* @param orderId ID of pet that needs to be fetched
*/
public getOrderByIdWithHttpInfo(orderId: number, _options?: Configuration): Observable<HttpInfo<Order>> {
const requestContextPromise = this.requestFactory.getOrderById(orderId, _options);
// build promise chain
let middlewarePreObservable = from<RequestContext>(requestContextPromise);
for (const 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 (const middleware of this.configuration.middleware) {
middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp)));
}
return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.getOrderByIdWithHttpInfo(rsp)));
}));
}
/**
* For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions
* Find purchase order by ID
* @param orderId ID of pet that needs to be fetched
*/
public getOrderById(orderId: number, _options?: Configuration): Observable<Order> {
return this.getOrderByIdWithHttpInfo(orderId, _options).pipe(map((apiResponse: HttpInfo<Order>) => apiResponse.data));
}
/**
*
* Place an order for a pet
* @param order order placed for purchasing the pet
*/
public placeOrderWithHttpInfo(order: Order, _options?: Configuration): Observable<HttpInfo<Order>> {
const requestContextPromise = this.requestFactory.placeOrder(order, _options);
// build promise chain
let middlewarePreObservable = from<RequestContext>(requestContextPromise);
for (const 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 (const middleware of this.configuration.middleware) {
middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp)));
}
return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.placeOrderWithHttpInfo(rsp)));
}));
}
/**
*
* Place an order for a pet
* @param order order placed for purchasing the pet
*/
public placeOrder(order: Order, _options?: Configuration): Observable<Order> {
return this.placeOrderWithHttpInfo(order, _options).pipe(map((apiResponse: HttpInfo<Order>) => apiResponse.data));
}
}
import { UserApiRequestFactory, UserApiResponseProcessor} from "../apis/UserApi.ts";
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 createUserWithHttpInfo(user: User, _options?: Configuration): Observable<HttpInfo<void>> {
const requestContextPromise = this.requestFactory.createUser(user, _options);
// build promise chain
let middlewarePreObservable = from<RequestContext>(requestContextPromise);
for (const 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 (const middleware of this.configuration.middleware) {
middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp)));
}
return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.createUserWithHttpInfo(rsp)));
}));
}
/**
* 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> {
return this.createUserWithHttpInfo(user, _options).pipe(map((apiResponse: HttpInfo<void>) => apiResponse.data));
}
/**
*
* Creates list of users with given input array
* @param user List of user object
*/
public createUsersWithArrayInputWithHttpInfo(user: Array<User>, _options?: Configuration): Observable<HttpInfo<void>> {
const requestContextPromise = this.requestFactory.createUsersWithArrayInput(user, _options);
// build promise chain
let middlewarePreObservable = from<RequestContext>(requestContextPromise);
for (const 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 (const middleware of this.configuration.middleware) {
middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp)));
}
return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.createUsersWithArrayInputWithHttpInfo(rsp)));
}));
}
/**
*
* Creates list of users with given input array
* @param user List of user object
*/
public createUsersWithArrayInput(user: Array<User>, _options?: Configuration): Observable<void> {
return this.createUsersWithArrayInputWithHttpInfo(user, _options).pipe(map((apiResponse: HttpInfo<void>) => apiResponse.data));
}
/**
*
* Creates list of users with given input array
* @param user List of user object
*/
public createUsersWithListInputWithHttpInfo(user: Array<User>, _options?: Configuration): Observable<HttpInfo<void>> {
const requestContextPromise = this.requestFactory.createUsersWithListInput(user, _options);
// build promise chain
let middlewarePreObservable = from<RequestContext>(requestContextPromise);
for (const 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 (const middleware of this.configuration.middleware) {
middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp)));
}
return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.createUsersWithListInputWithHttpInfo(rsp)));
}));
}
/**
*
* Creates list of users with given input array
* @param user List of user object
*/
public createUsersWithListInput(user: Array<User>, _options?: Configuration): Observable<void> {
return this.createUsersWithListInputWithHttpInfo(user, _options).pipe(map((apiResponse: HttpInfo<void>) => apiResponse.data));
}
/**
* This can only be done by the logged in user.
* Delete user
* @param username The name that needs to be deleted
*/
public deleteUserWithHttpInfo(username: string, _options?: Configuration): Observable<HttpInfo<void>> {
const requestContextPromise = this.requestFactory.deleteUser(username, _options);
// build promise chain
let middlewarePreObservable = from<RequestContext>(requestContextPromise);
for (const 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 (const middleware of this.configuration.middleware) {
middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp)));
}
return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.deleteUserWithHttpInfo(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> {
return this.deleteUserWithHttpInfo(username, _options).pipe(map((apiResponse: HttpInfo<void>) => apiResponse.data));
}
/**
*
* Get user by user name
* @param username The name that needs to be fetched. Use user1 for testing.
*/
public getUserByNameWithHttpInfo(username: string, _options?: Configuration): Observable<HttpInfo<User>> {
const requestContextPromise = this.requestFactory.getUserByName(username, _options);
// build promise chain
let middlewarePreObservable = from<RequestContext>(requestContextPromise);
for (const 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 (const middleware of this.configuration.middleware) {
middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp)));
}
return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.getUserByNameWithHttpInfo(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> {
return this.getUserByNameWithHttpInfo(username, _options).pipe(map((apiResponse: HttpInfo<User>) => apiResponse.data));
}
/**
*
* Logs user into the system
* @param username The user name for login
* @param password The password for login in clear text
*/
public loginUserWithHttpInfo(username: string, password: string, _options?: Configuration): Observable<HttpInfo<string>> {
const requestContextPromise = this.requestFactory.loginUser(username, password, _options);
// build promise chain
let middlewarePreObservable = from<RequestContext>(requestContextPromise);
for (const 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 (const middleware of this.configuration.middleware) {
middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp)));
}
return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.loginUserWithHttpInfo(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> {
return this.loginUserWithHttpInfo(username, password, _options).pipe(map((apiResponse: HttpInfo<string>) => apiResponse.data));
}
/**
*
* Logs out current logged in user session
*/
public logoutUserWithHttpInfo(_options?: Configuration): Observable<HttpInfo<void>> {
const requestContextPromise = this.requestFactory.logoutUser(_options);
// build promise chain
let middlewarePreObservable = from<RequestContext>(requestContextPromise);
for (const 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 (const middleware of this.configuration.middleware) {
middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp)));
}
return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.logoutUserWithHttpInfo(rsp)));
}));
}
/**
*
* Logs out current logged in user session
*/
public logoutUser(_options?: Configuration): Observable<void> {
return this.logoutUserWithHttpInfo(_options).pipe(map((apiResponse: HttpInfo<void>) => apiResponse.data));
}
/**
* 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 updateUserWithHttpInfo(username: string, user: User, _options?: Configuration): Observable<HttpInfo<void>> {
const requestContextPromise = this.requestFactory.updateUser(username, user, _options);
// build promise chain
let middlewarePreObservable = from<RequestContext>(requestContextPromise);
for (const 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 (const middleware of this.configuration.middleware) {
middlewarePostObservable = middlewarePostObservable.pipe(mergeMap((rsp: ResponseContext) => middleware.post(rsp)));
}
return middlewarePostObservable.pipe(map((rsp: ResponseContext) => this.responseProcessor.updateUserWithHttpInfo(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> {
return this.updateUserWithHttpInfo(username, user, _options).pipe(map((apiResponse: HttpInfo<void>) => apiResponse.data));
}
}

View File

@ -0,0 +1,476 @@
import { ResponseContext, RequestContext, HttpFile, HttpInfo } from '../http/http.ts';
import { Configuration} from '../configuration.ts'
import { ApiResponse } from '../models/ApiResponse.ts';
import { Category } from '../models/Category.ts';
import { Order } from '../models/Order.ts';
import { Pet } from '../models/Pet.ts';
import { Tag } from '../models/Tag.ts';
import { User } from '../models/User.ts';
import { ObservablePetApi } from './ObservableAPI.ts';
import { PetApiRequestFactory, PetApiResponseProcessor} from "../apis/PetApi.ts";
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 addPetWithHttpInfo(pet: Pet, _options?: Configuration): Promise<HttpInfo<Pet>> {
const result = this.api.addPetWithHttpInfo(pet, _options);
return result.toPromise();
}
/**
*
* 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 deletePetWithHttpInfo(petId: number, apiKey?: string, _options?: Configuration): Promise<HttpInfo<void>> {
const result = this.api.deletePetWithHttpInfo(petId, apiKey, _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 findPetsByStatusWithHttpInfo(status: Array<'available' | 'pending' | 'sold'>, _options?: Configuration): Promise<HttpInfo<Array<Pet>>> {
const result = this.api.findPetsByStatusWithHttpInfo(status, _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 findPetsByTagsWithHttpInfo(tags: Array<string>, _options?: Configuration): Promise<HttpInfo<Array<Pet>>> {
const result = this.api.findPetsByTagsWithHttpInfo(tags, _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 getPetByIdWithHttpInfo(petId: number, _options?: Configuration): Promise<HttpInfo<Pet>> {
const result = this.api.getPetByIdWithHttpInfo(petId, _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 updatePetWithHttpInfo(pet: Pet, _options?: Configuration): Promise<HttpInfo<Pet>> {
const result = this.api.updatePetWithHttpInfo(pet, _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 updatePetWithFormWithHttpInfo(petId: number, name?: string, status?: string, _options?: Configuration): Promise<HttpInfo<void>> {
const result = this.api.updatePetWithFormWithHttpInfo(petId, name, status, _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 uploadFileWithHttpInfo(petId: number, additionalMetadata?: string, file?: HttpFile, _options?: Configuration): Promise<HttpInfo<ApiResponse>> {
const result = this.api.uploadFileWithHttpInfo(petId, additionalMetadata, file, _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.ts';
import { StoreApiRequestFactory, StoreApiResponseProcessor} from "../apis/StoreApi.ts";
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 deleteOrderWithHttpInfo(orderId: string, _options?: Configuration): Promise<HttpInfo<void>> {
const result = this.api.deleteOrderWithHttpInfo(orderId, _options);
return result.toPromise();
}
/**
* 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 getInventoryWithHttpInfo(_options?: Configuration): Promise<HttpInfo<{ [key: string]: number; }>> {
const result = this.api.getInventoryWithHttpInfo(_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 generate exceptions
* Find purchase order by ID
* @param orderId ID of pet that needs to be fetched
*/
public getOrderByIdWithHttpInfo(orderId: number, _options?: Configuration): Promise<HttpInfo<Order>> {
const result = this.api.getOrderByIdWithHttpInfo(orderId, _options);
return result.toPromise();
}
/**
* For valid response try integer IDs with value <= 5 or > 10. Other values will generate 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 placeOrderWithHttpInfo(order: Order, _options?: Configuration): Promise<HttpInfo<Order>> {
const result = this.api.placeOrderWithHttpInfo(order, _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.ts';
import { UserApiRequestFactory, UserApiResponseProcessor} from "../apis/UserApi.ts";
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 createUserWithHttpInfo(user: User, _options?: Configuration): Promise<HttpInfo<void>> {
const result = this.api.createUserWithHttpInfo(user, _options);
return result.toPromise();
}
/**
* 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 createUsersWithArrayInputWithHttpInfo(user: Array<User>, _options?: Configuration): Promise<HttpInfo<void>> {
const result = this.api.createUsersWithArrayInputWithHttpInfo(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 createUsersWithListInputWithHttpInfo(user: Array<User>, _options?: Configuration): Promise<HttpInfo<void>> {
const result = this.api.createUsersWithListInputWithHttpInfo(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 deleteUserWithHttpInfo(username: string, _options?: Configuration): Promise<HttpInfo<void>> {
const result = this.api.deleteUserWithHttpInfo(username, _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 getUserByNameWithHttpInfo(username: string, _options?: Configuration): Promise<HttpInfo<User>> {
const result = this.api.getUserByNameWithHttpInfo(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 loginUserWithHttpInfo(username: string, password: string, _options?: Configuration): Promise<HttpInfo<string>> {
const result = this.api.loginUserWithHttpInfo(username, password, _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 logoutUserWithHttpInfo(_options?: Configuration): Promise<HttpInfo<void>> {
const result = this.api.logoutUserWithHttpInfo(_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 updateUserWithHttpInfo(username: string, user: User, _options?: Configuration): Promise<HttpInfo<void>> {
const result = this.api.updateUserWithHttpInfo(username, user, _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();
}
}

View File

@ -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
}