[typescript] fix: explode: true should yield appended query params (#19519)

* [typescript] fix: `explode: true` should yield appended `query` params

* fix: object keys should be `set`
This commit is contained in:
Joscha Feth 2024-09-04 07:16:21 +01:00 committed by GitHub
parent 8678ee8a1f
commit f40f72cea8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
97 changed files with 14183 additions and 0 deletions

View File

@ -0,0 +1,9 @@
generatorName: typescript
outputDir: samples/openapi3/client/petstore/typescript/builds/explode-query
inputSpec: modules/openapi-generator/src/test/resources/3_0/snakecase-discriminator.yaml
templateDir: modules/openapi-generator/src/main/resources/typescript
additionalProperties:
platform: node
npmName: ts-petstore-client
projectName: ts-petstore-client
moduleName: petstore

View File

@ -66,7 +66,27 @@ export class {{classname}}RequestFactory extends BaseAPIRequestFactory {
// Query Params
if ({{paramName}} !== undefined) {
{{#isPrimitiveType}}
requestContext.setQueryParam("{{baseName}}", ObjectSerializer.serialize({{paramName}}, "{{{dataType}}}", "{{dataFormat}}"));
{{/isPrimitiveType}}
{{^isPrimitiveType}}
{{#isExplode}}
const serializedParams = ObjectSerializer.serialize({{paramName}}, "{{{dataType}}}", "{{dataFormat}}");
{{#isArray}}
for (const serializedParam of serializedParams) {
requestContext.appendQueryParam("{{baseName}}", serializedParam);
}
{{/isArray}}
{{^isArray}}
for (const key of Object.keys(serializedParams)) {
requestContext.setQueryParam(key, serializedParams[key]);
}
{{/isArray}}
{{/isExplode}}
{{^isExplode}}
requestContext.setQueryParam("{{baseName}}", ObjectSerializer.serialize({{paramName}}, "{{{dataType}}}", "{{dataFormat}}"));
{{/isExplode}}
{{/isPrimitiveType}}
}
{{/queryParams}}
{{#headerParams}}

View File

@ -147,6 +147,10 @@ export class RequestContext {
this.url.searchParams.set(name, value);
}
public appendQueryParam(name: string, value: string) {
this.url.searchParams.append(name, value);
}
/**
* Sets a cookie with the name and value. NO check for duplicate cookies is performed
*

View File

@ -105,6 +105,10 @@ export class RequestContext {
this.url.searchParams.set(name, value);
}
public appendQueryParam(name: string, value: string) {
this.url.searchParams.append(name, value);
}
/**
* Sets a cookie with the name and value. NO check for duplicate cookies is performed
*

View File

@ -105,6 +105,10 @@ export class RequestContext {
this.url.searchParams.set(name, value);
}
public appendQueryParam(name: string, value: string) {
this.url.searchParams.append(name, value);
}
/**
* Sets a cookie with the name and value. NO check for duplicate cookies is performed
*

View File

@ -105,6 +105,10 @@ export class RequestContext {
this.url.searchParams.set(name, value);
}
public appendQueryParam(name: string, value: string) {
this.url.searchParams.append(name, value);
}
/**
* Sets a cookie with the name and value. NO check for duplicate cookies is performed
*

View File

@ -114,6 +114,10 @@ export class RequestContext {
this.url.searchParams.set(name, value);
}
public appendQueryParam(name: string, value: string) {
this.url.searchParams.append(name, value);
}
/**
* Sets a cookie with the name and value. NO check for duplicate cookies is performed
*

View File

@ -104,6 +104,10 @@ export class RequestContext {
this.url.searchParams.set(name, value);
}
public appendQueryParam(name: string, value: string) {
this.url.searchParams.append(name, value);
}
/**
* Sets a cookie with the name and value. NO check for duplicate cookies is performed
*

View File

@ -104,6 +104,10 @@ export class RequestContext {
this.url.searchParams.set(name, value);
}
public appendQueryParam(name: string, value: string) {
this.url.searchParams.append(name, value);
}
/**
* Sets a cookie with the name and value. NO check for duplicate cookies is performed
*

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,82 @@
.gitignore
AnotherFakeApi.md
DefaultApi.md
FakeApi.md
FakeClassnameTags123Api.md
PetApi.md
README.md
StoreApi.md
UserApi.md
apis/AnotherFakeApi.ts
apis/DefaultApi.ts
apis/FakeApi.ts
apis/FakeClassnameTags123Api.ts
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/AdditionalPropertiesClass.ts
models/AllOfWithSingleRef.ts
models/Animal.ts
models/ApiResponse.ts
models/ArrayOfArrayOfNumberOnly.ts
models/ArrayOfNumberOnly.ts
models/ArrayTest.ts
models/Capitalization.ts
models/Cat.ts
models/Category.ts
models/ClassModel.ts
models/Client.ts
models/DeprecatedObject.ts
models/Dog.ts
models/EnumArrays.ts
models/EnumClass.ts
models/EnumTest.ts
models/FakeBigDecimalMap200Response.ts
models/FileSchemaTestClass.ts
models/Foo.ts
models/FooGetDefaultResponse.ts
models/FormatTest.ts
models/HasOnlyReadOnly.ts
models/HealthCheckResult.ts
models/List.ts
models/MapTest.ts
models/MixedPropertiesAndAdditionalPropertiesClass.ts
models/Model200Response.ts
models/ModelFile.ts
models/Name.ts
models/NullableClass.ts
models/NumberOnly.ts
models/ObjectSerializer.ts
models/ObjectWithDeprecatedFields.ts
models/Order.ts
models/OuterComposite.ts
models/OuterEnum.ts
models/OuterEnumDefaultValue.ts
models/OuterEnumInteger.ts
models/OuterEnumIntegerDefaultValue.ts
models/OuterObjectWithEnumProperty.ts
models/Pet.ts
models/ReadOnlyFirst.ts
models/Return.ts
models/SingleRefType.ts
models/SpecialModelName.ts
models/Tag.ts
models/User.ts
models/all.ts
package.json
rxjsStub.ts
servers.ts
tsconfig.json
types/ObjectParamAPI.ts
types/ObservableAPI.ts
types/PromiseAPI.ts
util.ts

View File

@ -0,0 +1,66 @@
# petstore.AnotherFakeApi
All URIs are relative to *http://petstore.swagger.io:80/v2*
Method | HTTP request | Description
------------- | ------------- | -------------
[**_123testSpecialTags**](AnotherFakeApi.md#_123testSpecialTags) | **PATCH** /another-fake/dummy | To test special tags
# **_123testSpecialTags**
> Client _123testSpecialTags(client)
To test special tags and operation ID starting with number
### Example
```typescript
import { petstore } from 'ts-petstore-client';
import * as fs from 'fs';
const configuration = petstore.createConfiguration();
const apiInstance = new petstore.AnotherFakeApi(configuration);
let body:petstore.AnotherFakeApi123testSpecialTagsRequest = {
// Client | client model
client: {
client: "client_example",
},
};
apiInstance._123testSpecialTags(body).then((data:any) => {
console.log('API called successfully. Returned data: ' + data);
}).catch((error:any) => console.error(error));
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**client** | **Client**| client model |
### Return type
**Client**
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: application/json
- **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,57 @@
# petstore.DefaultApi
All URIs are relative to *http://petstore.swagger.io:80/v2*
Method | HTTP request | Description
------------- | ------------- | -------------
[**fooGet**](DefaultApi.md#fooGet) | **GET** /foo |
# **fooGet**
> fooGet()
### Example
```typescript
import { petstore } from 'ts-petstore-client';
import * as fs from 'fs';
const configuration = petstore.createConfiguration();
const apiInstance = new petstore.DefaultApi(configuration);
let body:any = {};
apiInstance.fooGet(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
No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/json
### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
**0** | response | - |
[[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)

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,66 @@
# petstore.FakeClassnameTags123Api
All URIs are relative to *http://petstore.swagger.io:80/v2*
Method | HTTP request | Description
------------- | ------------- | -------------
[**testClassname**](FakeClassnameTags123Api.md#testClassname) | **PATCH** /fake_classname_test | To test class name in snake case
# **testClassname**
> Client testClassname(client)
To test class name in snake case
### Example
```typescript
import { petstore } from 'ts-petstore-client';
import * as fs from 'fs';
const configuration = petstore.createConfiguration();
const apiInstance = new petstore.FakeClassnameTags123Api(configuration);
let body:petstore.FakeClassnameTags123ApiTestClassnameRequest = {
// Client | client model
client: {
client: "client_example",
},
};
apiInstance.testClassname(body).then((data:any) => {
console.log('API called successfully. Returned data: ' + data);
}).catch((error:any) => console.error(error));
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**client** | **Client**| client model |
### Return type
**Client**
### Authorization
[api_key_query](README.md#api_key_query)
### HTTP request headers
- **Content-Type**: application/json
- **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,573 @@
# petstore.PetApi
All URIs are relative to *http://petstore.swagger.io:80/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
[**uploadFileWithRequiredFile**](PetApi.md#uploadFileWithRequiredFile) | **POST** /fake/{petId}/uploadImageWithRequiredFile | uploads an image (required)
# **addPet**
> void 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: "default-name",
},
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
**void**
### Authorization
[petstore_auth](README.md#petstore_auth)
### HTTP request headers
- **Content-Type**: application/json, application/xml
- **Accept**: Not defined
### 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**
> void 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**
### 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 |
|-------------|-------------|------------------|
**200** | Successful operation | - |
**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**
> Set<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 = {
// Set<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** | **Set&lt;string&gt;** | Tags to filter by | defaults to undefined
### Return type
**Set<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**
> void 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: "default-name",
},
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
**void**
### Authorization
[petstore_auth](README.md#petstore_auth)
### HTTP request headers
- **Content-Type**: application/json, application/xml
- **Accept**: Not defined
### 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**
> void 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**
### 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 |
|-------------|-------------|------------------|
**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)
# **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)
# **uploadFileWithRequiredFile**
> ApiResponse uploadFileWithRequiredFile()
### 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.PetApiUploadFileWithRequiredFileRequest = {
// number | ID of pet to update
petId: 1,
// HttpFile | file to upload
requiredFile: { data: Buffer.from(fs.readFileSync('/path/to/file', 'utf-8')), name: '/path/to/file' },
// string | Additional data to pass to server (optional)
additionalMetadata: "additionalMetadata_example",
};
apiInstance.uploadFileWithRequiredFile(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
**requiredFile** | [**HttpFile**] | file to upload | defaults to undefined
**additionalMetadata** | [**string**] | Additional data to pass to server | (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,80 @@
## ts-petstore-client@1.0.0
This generator creates TypeScript/JavaScript client that utilizes fetch-api.
### Building
To build and compile the typescript sources to javascript use:
```
npm install
npm run build
```
### Publishing
First build the package then run ```npm publish```
### Consuming
Navigate to the folder of your consuming project and run one of the following commands.
_published:_
```
npm install ts-petstore-client@1.0.0 --save
```
_unPublished (not recommended):_
```
npm install PATH_TO_GENERATED_PACKAGE --save
```
### Usage
Below code snippet shows exemplary usage of the configuration and the API based
on the typical `PetStore` example used for OpenAPI.
```
import * as your_api from 'your_api_package'
// Covers all auth methods included in your OpenAPI yaml definition
const authConfig: your_api.AuthMethodsConfiguration = {
"api_key": "YOUR_API_KEY"
}
// Implements a simple middleware to modify requests before (`pre`) they are sent
// and after (`post`) they have been received
class Test implements your_api.Middleware {
pre(context: your_api.RequestContext): Promise<your_api.RequestContext> {
// Modify context here and return
return Promise.resolve(context);
}
post(context: your_api.ResponseContext): Promise<your_api.ResponseContext> {
return Promise.resolve(context);
}
}
// Create configuration parameter object
const configurationParameters = {
httpApi: new your_api.JQueryHttpLibrary(), // Can also be ignored - default is usually fine
baseServer: your_api.servers[0], // First server is default
authMethods: authConfig, // No auth is default
promiseMiddleware: [new Test()],
}
// Convert to actual configuration
const config = your_api.createConfiguration(configurationParameters);
// Use configuration with your_api
const api = new your_api.PetApi(config);
your_api.Pet p = new your_api.Pet();
p.name = "My new pet";
p.photoUrls = [];
p.tags = [];
p.status = "available";
Promise<your_api.Pet> createdPet = api.addPet(p);
```

View File

@ -0,0 +1,234 @@
# petstore.StoreApi
All URIs are relative to *http://petstore.swagger.io:80/v2*
Method | HTTP request | Description
------------- | ------------- | -------------
[**deleteOrder**](StoreApi.md#deleteOrder) | **DELETE** /store/order/{order_id} | Delete purchase order by ID
[**getInventory**](StoreApi.md#getInventory) | **GET** /store/inventory | Returns pet inventories by status
[**getOrderById**](StoreApi.md#getOrderById) | **GET** /store/order/{order_id} | 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: "order_id_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:80/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
No authorization required
### 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
No authorization required
### 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
No authorization required
### 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
No authorization required
### 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: "username_example",
// 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 | * 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
No authorization required
### 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
No authorization required
### 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,95 @@
// TODO: better import syntax?
import {BaseAPIRequestFactory, RequiredError, COLLECTION_FORMATS} from './baseapi';
import {Configuration} from '../configuration';
import {RequestContext, HttpMethod, ResponseContext, HttpFile, HttpInfo} from '../http/http';
import * as FormData from "form-data";
import { URLSearchParams } from 'url';
import {ObjectSerializer} from '../models/ObjectSerializer';
import {ApiException} from './exception';
import {canConsumeForm, isCodeInRange} from '../util';
import {SecurityAuthentication} from '../auth/auth';
import { Client } from '../models/Client';
/**
* no description
*/
export class AnotherFakeApiRequestFactory extends BaseAPIRequestFactory {
/**
* To test special tags and operation ID starting with number
* To test special tags
* @param client client model
*/
public async _123testSpecialTags(client: Client, _options?: Configuration): Promise<RequestContext> {
let _config = _options || this.configuration;
// verify required parameter 'client' is not null or undefined
if (client === null || client === undefined) {
throw new RequiredError("AnotherFakeApi", "_123testSpecialTags", "client");
}
// Path Params
const localVarPath = '/another-fake/dummy';
// Make Request Context
const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.PATCH);
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(client, "Client", ""),
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 AnotherFakeApiResponseProcessor {
/**
* 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 _123testSpecialTags
* @throws ApiException if the response code was not in [200, 299]
*/
public async _123testSpecialTagsWithHttpInfo(response: ResponseContext): Promise<HttpInfo<Client >> {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("200", response.httpStatusCode)) {
const body: Client = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"Client", ""
) as Client;
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: Client = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"Client", ""
) as Client;
return new HttpInfo(response.httpStatusCode, response.headers, response.body, body);
}
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
}

View File

@ -0,0 +1,71 @@
// TODO: better import syntax?
import {BaseAPIRequestFactory, RequiredError, COLLECTION_FORMATS} from './baseapi';
import {Configuration} from '../configuration';
import {RequestContext, HttpMethod, ResponseContext, HttpFile, HttpInfo} from '../http/http';
import * as FormData from "form-data";
import { URLSearchParams } from 'url';
import {ObjectSerializer} from '../models/ObjectSerializer';
import {ApiException} from './exception';
import {canConsumeForm, isCodeInRange} from '../util';
import {SecurityAuthentication} from '../auth/auth';
import { FooGetDefaultResponse } from '../models/FooGetDefaultResponse';
/**
* no description
*/
export class DefaultApiRequestFactory extends BaseAPIRequestFactory {
/**
*/
public async fooGet(_options?: Configuration): Promise<RequestContext> {
let _config = _options || this.configuration;
// Path Params
const localVarPath = '/foo';
// 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;
}
}
export class DefaultApiResponseProcessor {
/**
* 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 fooGet
* @throws ApiException if the response code was not in [200, 299]
*/
public async fooGetWithHttpInfo(response: ResponseContext): Promise<HttpInfo< void>> {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("0", response.httpStatusCode)) {
const body: FooGetDefaultResponse = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"FooGetDefaultResponse", ""
) as FooGetDefaultResponse;
throw new ApiException<FooGetDefaultResponse>(response.httpStatusCode, "response", body, 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 | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,101 @@
// TODO: better import syntax?
import {BaseAPIRequestFactory, RequiredError, COLLECTION_FORMATS} from './baseapi';
import {Configuration} from '../configuration';
import {RequestContext, HttpMethod, ResponseContext, HttpFile, HttpInfo} from '../http/http';
import * as FormData from "form-data";
import { URLSearchParams } from 'url';
import {ObjectSerializer} from '../models/ObjectSerializer';
import {ApiException} from './exception';
import {canConsumeForm, isCodeInRange} from '../util';
import {SecurityAuthentication} from '../auth/auth';
import { Client } from '../models/Client';
/**
* no description
*/
export class FakeClassnameTags123ApiRequestFactory extends BaseAPIRequestFactory {
/**
* To test class name in snake case
* To test class name in snake case
* @param client client model
*/
public async testClassname(client: Client, _options?: Configuration): Promise<RequestContext> {
let _config = _options || this.configuration;
// verify required parameter 'client' is not null or undefined
if (client === null || client === undefined) {
throw new RequiredError("FakeClassnameTags123Api", "testClassname", "client");
}
// Path Params
const localVarPath = '/fake_classname_test';
// Make Request Context
const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.PATCH);
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(client, "Client", ""),
contentType
);
requestContext.setBody(serializedBody);
let authMethod: SecurityAuthentication | undefined;
// Apply auth methods
authMethod = _config.authMethods["api_key_query"]
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 FakeClassnameTags123ApiResponseProcessor {
/**
* 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 testClassname
* @throws ApiException if the response code was not in [200, 299]
*/
public async testClassnameWithHttpInfo(response: ResponseContext): Promise<HttpInfo<Client >> {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("200", response.httpStatusCode)) {
const body: Client = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"Client", ""
) as Client;
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: Client = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"Client", ""
) as Client;
return new HttpInfo(response.httpStatusCode, response.headers, response.body, body);
}
throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
}

View File

@ -0,0 +1,787 @@
// TODO: better import syntax?
import {BaseAPIRequestFactory, RequiredError, COLLECTION_FORMATS} from './baseapi';
import {Configuration} from '../configuration';
import {RequestContext, HttpMethod, ResponseContext, HttpFile, HttpInfo} from '../http/http';
import * as FormData from "form-data";
import { URLSearchParams } from 'url';
import {ObjectSerializer} from '../models/ObjectSerializer';
import {ApiException} from './exception';
import {canConsumeForm, isCodeInRange} from '../util';
import {SecurityAuthentication} from '../auth/auth';
import { ApiResponse } from '../models/ApiResponse';
import { Pet } from '../models/Pet';
/**
* no description
*/
export class PetApiRequestFactory extends BaseAPIRequestFactory {
/**
*
* Add a new pet to the store
* @param pet Pet object that needs to be added to the store
*/
public async addPet(pet: Pet, _options?: Configuration): Promise<RequestContext> {
let _config = _options || this.configuration;
// verify required parameter 'pet' is not null or undefined
if (pet === null || pet === undefined) {
throw new RequiredError("PetApi", "addPet", "pet");
}
// Path Params
const localVarPath = '/pet';
// Make Request Context
const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST);
requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8")
// Body Params
const contentType = ObjectSerializer.getPreferredMediaType([
"application/json",
"application/xml"
]);
requestContext.setHeaderParam("Content-Type", contentType);
const serializedBody = ObjectSerializer.stringify(
ObjectSerializer.serialize(pet, "Pet", ""),
contentType
);
requestContext.setBody(serializedBody);
let authMethod: SecurityAuthentication | undefined;
// Apply auth methods
authMethod = _config.authMethods["petstore_auth"]
if (authMethod?.applySecurityAuthentication) {
await authMethod?.applySecurityAuthentication(requestContext);
}
const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default
if (defaultAuth?.applySecurityAuthentication) {
await defaultAuth?.applySecurityAuthentication(requestContext);
}
return requestContext;
}
/**
*
* Deletes a pet
* @param petId Pet id to delete
* @param apiKey
*/
public async deletePet(petId: number, apiKey?: string, _options?: Configuration): Promise<RequestContext> {
let _config = _options || this.configuration;
// verify required parameter 'petId' is not null or undefined
if (petId === null || petId === undefined) {
throw new RequiredError("PetApi", "deletePet", "petId");
}
// Path Params
const localVarPath = '/pet/{petId}'
.replace('{' + 'petId' + '}', encodeURIComponent(String(petId)));
// Make Request Context
const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.DELETE);
requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8")
// Header Params
requestContext.setHeaderParam("api_key", ObjectSerializer.serialize(apiKey, "string", ""));
let authMethod: SecurityAuthentication | undefined;
// Apply auth methods
authMethod = _config.authMethods["petstore_auth"]
if (authMethod?.applySecurityAuthentication) {
await authMethod?.applySecurityAuthentication(requestContext);
}
const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default
if (defaultAuth?.applySecurityAuthentication) {
await defaultAuth?.applySecurityAuthentication(requestContext);
}
return requestContext;
}
/**
* Multiple status values can be provided with comma separated strings
* Finds Pets by status
* @param status Status values that need to be considered for filter
*/
public async findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, _options?: Configuration): Promise<RequestContext> {
let _config = _options || this.configuration;
// verify required parameter 'status' is not null or undefined
if (status === null || status === undefined) {
throw new RequiredError("PetApi", "findPetsByStatus", "status");
}
// Path Params
const localVarPath = '/pet/findByStatus';
// Make Request Context
const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET);
requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8")
// Query Params
if (status !== undefined) {
requestContext.setQueryParam("status", ObjectSerializer.serialize(status, "Array<'available' | 'pending' | 'sold'>", ""));
}
let authMethod: SecurityAuthentication | undefined;
// Apply auth methods
authMethod = _config.authMethods["petstore_auth"]
if (authMethod?.applySecurityAuthentication) {
await authMethod?.applySecurityAuthentication(requestContext);
}
const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default
if (defaultAuth?.applySecurityAuthentication) {
await defaultAuth?.applySecurityAuthentication(requestContext);
}
return requestContext;
}
/**
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
* Finds Pets by tags
* @param tags Tags to filter by
*/
public async findPetsByTags(tags: Set<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, "Set<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.data, 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;
}
/**
*
* uploads an image (required)
* @param petId ID of pet to update
* @param requiredFile file to upload
* @param additionalMetadata Additional data to pass to server
*/
public async uploadFileWithRequiredFile(petId: number, requiredFile: HttpFile, additionalMetadata?: 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", "uploadFileWithRequiredFile", "petId");
}
// verify required parameter 'requiredFile' is not null or undefined
if (requiredFile === null || requiredFile === undefined) {
throw new RequiredError("PetApi", "uploadFileWithRequiredFile", "requiredFile");
}
// Path Params
const localVarPath = '/fake/{petId}/uploadImageWithRequiredFile'
.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 (requiredFile !== undefined) {
// TODO: replace .append with .set
if (localVarFormParams instanceof FormData) {
localVarFormParams.append('requiredFile', requiredFile.data, requiredFile.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<void >> {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("200", response.httpStatusCode)) {
return new HttpInfo(response.httpStatusCode, response.headers, response.body, undefined);
}
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: void = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"void", ""
) as void;
return new HttpInfo(response.httpStatusCode, response.headers, response.body, body);
}
throw new ApiException<string | Buffer | 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("200", response.httpStatusCode)) {
return new HttpInfo(response.httpStatusCode, response.headers, response.body, undefined);
}
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) {
const body: void = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"void", ""
) as void;
return new HttpInfo(response.httpStatusCode, response.headers, response.body, body);
}
throw new ApiException<string | Buffer | 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 | Buffer | 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<Set<Pet> >> {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("200", response.httpStatusCode)) {
const body: Set<Pet> = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"Set<Pet>", ""
) as Set<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: Set<Pet> = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"Set<Pet>", ""
) as Set<Pet>;
return new HttpInfo(response.httpStatusCode, response.headers, response.body, body);
}
throw new ApiException<string | Buffer | 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 | Buffer | 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<void >> {
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (isCodeInRange("200", response.httpStatusCode)) {
return new HttpInfo(response.httpStatusCode, response.headers, response.body, undefined);
}
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: void = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"void", ""
) as void;
return new HttpInfo(response.httpStatusCode, response.headers, response.body, body);
}
throw new ApiException<string | Buffer | 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("200", response.httpStatusCode)) {
return new HttpInfo(response.httpStatusCode, response.headers, response.body, undefined);
}
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: void = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"void", ""
) as void;
return new HttpInfo(response.httpStatusCode, response.headers, response.body, body);
}
throw new ApiException<string | Buffer | 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 | Buffer | 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 uploadFileWithRequiredFile
* @throws ApiException if the response code was not in [200, 299]
*/
public async uploadFileWithRequiredFileWithHttpInfo(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 | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
}

View File

@ -0,0 +1,280 @@
// TODO: better import syntax?
import {BaseAPIRequestFactory, RequiredError, COLLECTION_FORMATS} from './baseapi';
import {Configuration} from '../configuration';
import {RequestContext, HttpMethod, ResponseContext, HttpFile, HttpInfo} from '../http/http';
import * as FormData from "form-data";
import { URLSearchParams } from 'url';
import {ObjectSerializer} from '../models/ObjectSerializer';
import {ApiException} from './exception';
import {canConsumeForm, isCodeInRange} from '../util';
import {SecurityAuthentication} from '../auth/auth';
import { Order } from '../models/Order';
/**
* no description
*/
export class StoreApiRequestFactory extends BaseAPIRequestFactory {
/**
* For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
* Delete purchase order by ID
* @param orderId ID of the order that needs to be deleted
*/
public async deleteOrder(orderId: string, _options?: Configuration): Promise<RequestContext> {
let _config = _options || this.configuration;
// verify required parameter 'orderId' is not null or undefined
if (orderId === null || orderId === undefined) {
throw new RequiredError("StoreApi", "deleteOrder", "orderId");
}
// Path Params
const localVarPath = '/store/order/{order_id}'
.replace('{' + 'order_id' + '}', 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/{order_id}'
.replace('{' + 'order_id' + '}', 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 | Buffer | 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 | Buffer | 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 | Buffer | 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 | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
}

View File

@ -0,0 +1,535 @@
// TODO: better import syntax?
import {BaseAPIRequestFactory, RequiredError, COLLECTION_FORMATS} from './baseapi';
import {Configuration} from '../configuration';
import {RequestContext, HttpMethod, ResponseContext, HttpFile, HttpInfo} from '../http/http';
import * as FormData from "form-data";
import { URLSearchParams } from 'url';
import {ObjectSerializer} from '../models/ObjectSerializer';
import {ApiException} from './exception';
import {canConsumeForm, isCodeInRange} from '../util';
import {SecurityAuthentication} from '../auth/auth';
import { User } from '../models/User';
/**
* no description
*/
export class UserApiRequestFactory extends BaseAPIRequestFactory {
/**
* This can only be done by the logged in user.
* Create user
* @param user Created user object
*/
public async createUser(user: User, _options?: Configuration): Promise<RequestContext> {
let _config = _options || this.configuration;
// verify required parameter 'user' is not null or undefined
if (user === null || user === undefined) {
throw new RequiredError("UserApi", "createUser", "user");
}
// Path Params
const localVarPath = '/user';
// Make Request Context
const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST);
requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8")
// Body Params
const contentType = ObjectSerializer.getPreferredMediaType([
"application/json"
]);
requestContext.setHeaderParam("Content-Type", contentType);
const serializedBody = ObjectSerializer.stringify(
ObjectSerializer.serialize(user, "User", ""),
contentType
);
requestContext.setBody(serializedBody);
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);
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);
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")
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")
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);
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 | Buffer | 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 | Buffer | 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 | Buffer | 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 | Buffer | 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 | Buffer | 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 | Buffer | 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 | Buffer | 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 | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}
}

View File

@ -0,0 +1,37 @@
import { Configuration } from '../configuration'
/**
*
* @export
*/
export const COLLECTION_FORMATS = {
csv: ",",
ssv: " ",
tsv: "\t",
pipes: "|",
};
/**
*
* @export
* @class BaseAPI
*/
export class BaseAPIRequestFactory {
constructor(protected configuration: Configuration) {
}
};
/**
*
* @export
* @class RequiredError
* @extends {Error}
*/
export class RequiredError extends Error {
name: "RequiredError" = "RequiredError";
constructor(public api: string, public method: string, public field: string) {
super("Required parameter " + field + " was null or undefined when calling " + api + "." + method + ".");
}
}

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,217 @@
import { RequestContext } from "../http/http";
/**
* Interface authentication schemes.
*/
export interface SecurityAuthentication {
/*
* @return returns the name of the security authentication as specified in OAI
*/
getName(): string;
/**
* Applies the authentication scheme to the request context
*
* @params context the request context which should use this authentication scheme
*/
applySecurityAuthentication(context: RequestContext): void | Promise<void>;
}
export interface TokenProvider {
getToken(): Promise<string> | string;
}
/**
* Applies 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);
}
}
/**
* Applies apiKey authentication to the request context.
*/
export class ApiKeyQueryAuthentication 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_query";
}
public applySecurityAuthentication(context: RequestContext) {
context.setQueryParam("api_key_query", this.apiKey);
}
}
/**
* Applies http authentication to the request context.
*/
export class HttpBasicTestAuthentication implements SecurityAuthentication {
/**
* Configures the http authentication with the required details.
*
* @param username username for http basic authentication
* @param password password for http basic authentication
*/
public constructor(
private username: string,
private password: string
) {}
public getName(): string {
return "http_basic_test";
}
public applySecurityAuthentication(context: RequestContext) {
let comb = Buffer.from(this.username + ":" + this.password, 'binary').toString('base64');
context.setHeaderParam("Authorization", "Basic " + comb);
}
}
/**
* Applies http authentication to the request context.
*/
export class BearerTestAuthentication implements SecurityAuthentication {
/**
* Configures the http authentication with the required details.
*
* @param tokenProvider service that can provide the up-to-date token when needed
*/
public constructor(private tokenProvider: TokenProvider) {}
public getName(): string {
return "bearer_test";
}
public async applySecurityAuthentication(context: RequestContext) {
context.setHeaderParam("Authorization", "Bearer " + await this.tokenProvider.getToken());
}
}
/**
* Applies http authentication to the request context.
*/
export class HttpSignatureTestAuthentication implements SecurityAuthentication {
public getName(): string {
return "http_signature_test";
}
public applySecurityAuthentication(context: RequestContext) {
}
}
export type AuthMethods = {
"default"?: SecurityAuthentication,
"petstore_auth"?: SecurityAuthentication,
"api_key"?: SecurityAuthentication,
"api_key_query"?: SecurityAuthentication,
"http_basic_test"?: SecurityAuthentication,
"bearer_test"?: SecurityAuthentication,
"http_signature_test"?: 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,
"api_key_query"?: ApiKeyConfiguration,
"http_basic_test"?: HttpBasicConfiguration,
"bearer_test"?: HttpBearerConfiguration,
"http_signature_test"?:
}
/**
* 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"]
);
}
if (config["api_key_query"]) {
authMethods["api_key_query"] = new ApiKeyQueryAuthentication(
config["api_key_query"]
);
}
if (config["http_basic_test"]) {
authMethods["http_basic_test"] = new HttpBasicTestAuthentication(
config["http_basic_test"]["username"],
config["http_basic_test"]["password"]
);
}
if (config["bearer_test"]) {
authMethods["bearer_test"] = new BearerTestAuthentication(
config["bearer_test"]["tokenProvider"]
);
}
if (config["http_signature_test"]) {
authMethods["http_signature_test"] = new HttpSignatureTestAuthentication(
);
}
return authMethods;
}

View File

@ -0,0 +1,82 @@
import { HttpLibrary } from "./http/http";
import { Middleware, PromiseMiddleware, PromiseMiddlewareWrapper } from "./middleware";
import { IsomorphicFetchHttpLibrary as DefaultHttpLibrary } from "./http/isomorphic-fetch";
import { BaseServerConfiguration, server1 } from "./servers";
import { configureAuthMethods, AuthMethods, AuthMethodsConfiguration } from "./auth/auth";
export interface Configuration {
readonly baseServer: BaseServerConfiguration;
readonly httpApi: HttpLibrary;
readonly middleware: Middleware[];
readonly authMethods: AuthMethods;
}
/**
* Interface with which a configuration object can be configured.
*/
export interface ConfigurationParameters {
/**
* Default server to use - 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,251 @@
// TODO: evaluate if we can easily get rid of this library
import * as FormData from "form-data";
import { URL, URLSearchParams } from 'url';
import * as http from 'http';
import * as https from 'https';
import { Observable, from } from '../rxjsStub';
export * from './isomorphic-fetch';
/**
* Represents an HTTP method.
*/
export enum HttpMethod {
GET = "GET",
HEAD = "HEAD",
POST = "POST",
PUT = "PUT",
DELETE = "DELETE",
CONNECT = "CONNECT",
OPTIONS = "OPTIONS",
TRACE = "TRACE",
PATCH = "PATCH"
}
/**
* Represents an HTTP file which will be transferred from or to a server.
*/
export type HttpFile = {
data: Buffer,
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;
}
throw new Error("You need to define an absolute base url for the server.");
}
/**
* Represents an HTTP request context
*/
export class RequestContext {
private headers: { [key: string]: string } = {};
private body: RequestBody = undefined;
private url: URL;
private agent: http.Agent | https.Agent | undefined = undefined;
/**
* 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);
}
public appendQueryParam(name: string, value: string) {
this.url.searchParams.append(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;
}
public setAgent(agent: http.Agent | https.Agent) {
this.agent = agent;
}
public getAgent(): http.Agent | https.Agent | undefined {
return this.agent;
}
}
export interface ResponseBody {
text(): Promise<string>;
binary(): Promise<Buffer>;
}
/**
* Helper class to generate a `ResponseBody` from binary data
*/
export class SelfDecodingBody implements ResponseBody {
constructor(private dataSource: Promise<Buffer>) {}
binary(): Promise<Buffer> {
return this.dataSource;
}
async text(): Promise<string> {
const data: Buffer = await this.dataSource;
return data.toString();
}
}
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"] || "";
return { data, name: fileName };
}
/**
* Use a heuristic to get a body of unknown data structure.
* Return as string if possible, otherwise as binary.
*/
public getBodyAsAny(): Promise<string | Buffer | 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,32 @@
import {HttpLibrary, RequestContext, ResponseContext} from './http';
import { from, Observable } from '../rxjsStub';
import fetch from "node-fetch";
export class IsomorphicFetchHttpLibrary implements HttpLibrary {
public send(request: RequestContext): Observable<ResponseContext> {
let method = request.getHttpMethod().toString();
let body = request.getBody();
const resultPromise = fetch(request.getUrl(), {
method: method,
body: body as any,
headers: request.getHeaders(),
agent: request.getAgent(),
}).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.buffer()
};
return new ResponseContext(resp.status, headers, body);
});
return from<Promise<ResponseContext>>(resultPromise);
}
}

View File

@ -0,0 +1,12 @@
export * from "./http/http";
export * from "./auth/auth";
export * from "./models/all";
export { createConfiguration } from "./configuration"
export { Configuration } from "./configuration"
export * from "./apis/exception";
export * from "./servers";
export { RequiredError } from "./apis/baseapi";
export { PromiseMiddleware as Middleware } from './middleware';
export { PromiseAnotherFakeApi as AnotherFakeApi, PromiseDefaultApi as DefaultApi, PromiseFakeApi as FakeApi, PromiseFakeClassnameTags123Api as FakeClassnameTags123Api, PromisePetApi as PetApi, PromiseStoreApi as StoreApi, PromiseUserApi as UserApi } from './types/PromiseAPI';

View File

@ -0,0 +1,66 @@
import {RequestContext, ResponseContext} from './http/http';
import { Observable, from } from './rxjsStub';
/**
* Defines the contract for a middleware intercepting requests before
* they are sent (but after the RequestContext was created)
* and before the ResponseContext is unwrapped.
*
*/
export interface Middleware {
/**
* Modifies the request before the request is sent.
*
* @param context RequestContext of a request which is about to be sent to the server
* @returns an observable of the updated request context
*
*/
pre(context: RequestContext): Observable<RequestContext>;
/**
* Modifies the returned response before it is deserialized.
*
* @param context ResponseContext of a sent request
* @returns an observable of the modified response context
*/
post(context: ResponseContext): Observable<ResponseContext>;
}
export class PromiseMiddlewareWrapper implements Middleware {
public constructor(private middleware: PromiseMiddleware) {
}
pre(context: RequestContext): Observable<RequestContext> {
return from(this.middleware.pre(context));
}
post(context: ResponseContext): Observable<ResponseContext> {
return from(this.middleware.post(context));
}
}
/**
* Defines the contract for a middleware intercepting requests before
* they are sent (but after the RequestContext was created)
* and before the ResponseContext is unwrapped.
*
*/
export interface PromiseMiddleware {
/**
* Modifies the request before the request is sent.
*
* @param context RequestContext of a request which is about to be sent to the server
* @returns an observable of the updated request context
*
*/
pre(context: RequestContext): Promise<RequestContext>;
/**
* Modifies the returned response before it is deserialized.
*
* @param context ResponseContext of a sent request
* @returns an observable of the modified response context
*/
post(context: ResponseContext): Promise<ResponseContext>;
}

View File

@ -0,0 +1,43 @@
/**
* OpenAPI Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* 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';
export class AdditionalPropertiesClass {
'mapProperty'?: { [key: string]: string; };
'mapOfMapProperty'?: { [key: string]: { [key: string]: string; }; };
static readonly discriminator: string | undefined = undefined;
static readonly mapping: {[index: string]: string} | undefined = undefined;
static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [
{
"name": "mapProperty",
"baseName": "map_property",
"type": "{ [key: string]: string; }",
"format": ""
},
{
"name": "mapOfMapProperty",
"baseName": "map_of_map_property",
"type": "{ [key: string]: { [key: string]: string; }; }",
"format": ""
} ];
static getAttributeTypeMap() {
return AdditionalPropertiesClass.attributeTypeMap;
}
public constructor() {
}
}

View File

@ -0,0 +1,46 @@
/**
* OpenAPI Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* 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 { SingleRefType } from '../models/SingleRefType';
import { HttpFile } from '../http/http';
export class AllOfWithSingleRef {
'username'?: string;
'singleRefType'?: SingleRefType;
static readonly discriminator: string | undefined = undefined;
static readonly mapping: {[index: string]: string} | undefined = undefined;
static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [
{
"name": "username",
"baseName": "username",
"type": "string",
"format": ""
},
{
"name": "singleRefType",
"baseName": "SingleRefType",
"type": "SingleRefType",
"format": ""
} ];
static getAttributeTypeMap() {
return AllOfWithSingleRef.attributeTypeMap;
}
public constructor() {
}
}

View File

@ -0,0 +1,47 @@
/**
* OpenAPI Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* 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';
export class Animal {
'className': string;
'color'?: string;
static readonly discriminator: string | undefined = "className";
static readonly mapping: {[index: string]: string} | undefined = {
"CAT": "Cat",
"DOG": "Dog",
};
static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [
{
"name": "className",
"baseName": "class_name",
"type": "string",
"format": ""
},
{
"name": "color",
"baseName": "color",
"type": "string",
"format": ""
} ];
static getAttributeTypeMap() {
return Animal.attributeTypeMap;
}
public constructor() {
this.className = "Animal";
}
}

View File

@ -0,0 +1,50 @@
/**
* OpenAPI Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* 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';
export class ApiResponse {
'code'?: number;
'type'?: string;
'message'?: string;
static readonly discriminator: string | undefined = undefined;
static readonly mapping: {[index: string]: 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,36 @@
/**
* OpenAPI Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* 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';
export class ArrayOfArrayOfNumberOnly {
'arrayArrayNumber'?: Array<Array<number>>;
static readonly discriminator: string | undefined = undefined;
static readonly mapping: {[index: string]: string} | undefined = undefined;
static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [
{
"name": "arrayArrayNumber",
"baseName": "ArrayArrayNumber",
"type": "Array<Array<number>>",
"format": ""
} ];
static getAttributeTypeMap() {
return ArrayOfArrayOfNumberOnly.attributeTypeMap;
}
public constructor() {
}
}

View File

@ -0,0 +1,36 @@
/**
* OpenAPI Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* 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';
export class ArrayOfNumberOnly {
'arrayNumber'?: Array<number>;
static readonly discriminator: string | undefined = undefined;
static readonly mapping: {[index: string]: string} | undefined = undefined;
static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [
{
"name": "arrayNumber",
"baseName": "ArrayNumber",
"type": "Array<number>",
"format": ""
} ];
static getAttributeTypeMap() {
return ArrayOfNumberOnly.attributeTypeMap;
}
public constructor() {
}
}

View File

@ -0,0 +1,51 @@
/**
* OpenAPI Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* 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 { ReadOnlyFirst } from '../models/ReadOnlyFirst';
import { HttpFile } from '../http/http';
export class ArrayTest {
'arrayOfString'?: Array<string>;
'arrayArrayOfInteger'?: Array<Array<number>>;
'arrayArrayOfModel'?: Array<Array<ReadOnlyFirst>>;
static readonly discriminator: string | undefined = undefined;
static readonly mapping: {[index: string]: string} | undefined = undefined;
static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [
{
"name": "arrayOfString",
"baseName": "array_of_string",
"type": "Array<string>",
"format": ""
},
{
"name": "arrayArrayOfInteger",
"baseName": "array_array_of_integer",
"type": "Array<Array<number>>",
"format": "int64"
},
{
"name": "arrayArrayOfModel",
"baseName": "array_array_of_model",
"type": "Array<Array<ReadOnlyFirst>>",
"format": ""
} ];
static getAttributeTypeMap() {
return ArrayTest.attributeTypeMap;
}
public constructor() {
}
}

View File

@ -0,0 +1,74 @@
/**
* OpenAPI Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* 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';
export class Capitalization {
'smallCamel'?: string;
'capitalCamel'?: string;
'smallSnake'?: string;
'capitalSnake'?: string;
'sCAETHFlowPoints'?: string;
/**
* Name of the pet
*/
'ATT_NAME'?: string;
static readonly discriminator: string | undefined = undefined;
static readonly mapping: {[index: string]: string} | undefined = undefined;
static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [
{
"name": "smallCamel",
"baseName": "smallCamel",
"type": "string",
"format": ""
},
{
"name": "capitalCamel",
"baseName": "CapitalCamel",
"type": "string",
"format": ""
},
{
"name": "smallSnake",
"baseName": "small_Snake",
"type": "string",
"format": ""
},
{
"name": "capitalSnake",
"baseName": "Capital_Snake",
"type": "string",
"format": ""
},
{
"name": "sCAETHFlowPoints",
"baseName": "SCA_ETH_Flow_Points",
"type": "string",
"format": ""
},
{
"name": "ATT_NAME",
"baseName": "ATT_NAME",
"type": "string",
"format": ""
} ];
static getAttributeTypeMap() {
return Capitalization.attributeTypeMap;
}
public constructor() {
}
}

View File

@ -0,0 +1,38 @@
/**
* OpenAPI Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* 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 { Animal } from '../models/Animal';
import { HttpFile } from '../http/http';
export class Cat extends Animal {
'declawed'?: boolean;
static readonly discriminator: string | undefined = undefined;
static readonly mapping: {[index: string]: string} | undefined = undefined;
static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [
{
"name": "declawed",
"baseName": "declawed",
"type": "boolean",
"format": ""
} ];
static getAttributeTypeMap() {
return super.getAttributeTypeMap().concat(Cat.attributeTypeMap);
}
public constructor() {
super();
}
}

View File

@ -0,0 +1,43 @@
/**
* OpenAPI Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* 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';
export class Category {
'id'?: number;
'name': string;
static readonly discriminator: string | undefined = undefined;
static readonly mapping: {[index: string]: 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,39 @@
/**
* OpenAPI Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* 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';
/**
* Model for testing model with \"_class\" property
*/
export class ClassModel {
'_class'?: string;
static readonly discriminator: string | undefined = undefined;
static readonly mapping: {[index: string]: string} | undefined = undefined;
static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [
{
"name": "_class",
"baseName": "_class",
"type": "string",
"format": ""
} ];
static getAttributeTypeMap() {
return ClassModel.attributeTypeMap;
}
public constructor() {
}
}

View File

@ -0,0 +1,36 @@
/**
* OpenAPI Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* 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';
export class Client {
'client'?: string;
static readonly discriminator: string | undefined = undefined;
static readonly mapping: {[index: string]: string} | undefined = undefined;
static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [
{
"name": "client",
"baseName": "client",
"type": "string",
"format": ""
} ];
static getAttributeTypeMap() {
return Client.attributeTypeMap;
}
public constructor() {
}
}

View File

@ -0,0 +1,36 @@
/**
* OpenAPI Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* 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';
export class DeprecatedObject {
'name'?: string;
static readonly discriminator: string | undefined = undefined;
static readonly mapping: {[index: string]: string} | undefined = undefined;
static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [
{
"name": "name",
"baseName": "name",
"type": "string",
"format": ""
} ];
static getAttributeTypeMap() {
return DeprecatedObject.attributeTypeMap;
}
public constructor() {
}
}

View File

@ -0,0 +1,38 @@
/**
* OpenAPI Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* 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 { Animal } from '../models/Animal';
import { HttpFile } from '../http/http';
export class Dog extends Animal {
'breed'?: string;
static readonly discriminator: string | undefined = undefined;
static readonly mapping: {[index: string]: string} | undefined = undefined;
static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [
{
"name": "breed",
"baseName": "breed",
"type": "string",
"format": ""
} ];
static getAttributeTypeMap() {
return super.getAttributeTypeMap().concat(Dog.attributeTypeMap);
}
public constructor() {
super();
}
}

View File

@ -0,0 +1,53 @@
/**
* OpenAPI Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* 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';
export class EnumArrays {
'justSymbol'?: EnumArraysJustSymbolEnum;
'arrayEnum'?: Array<EnumArraysArrayEnumEnum>;
static readonly discriminator: string | undefined = undefined;
static readonly mapping: {[index: string]: string} | undefined = undefined;
static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [
{
"name": "justSymbol",
"baseName": "just_symbol",
"type": "EnumArraysJustSymbolEnum",
"format": ""
},
{
"name": "arrayEnum",
"baseName": "array_enum",
"type": "Array<EnumArraysArrayEnumEnum>",
"format": ""
} ];
static getAttributeTypeMap() {
return EnumArrays.attributeTypeMap;
}
public constructor() {
}
}
export enum EnumArraysJustSymbolEnum {
GreaterThanOrEqualTo = '>=',
Dollar = '$'
}
export enum EnumArraysArrayEnumEnum {
Fish = 'fish',
Crab = 'crab'
}

View File

@ -0,0 +1,19 @@
/**
* OpenAPI Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* 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';
export enum EnumClass {
Abc = '_abc',
Efg = '-efg',
Xyz = '(xyz)'
}

View File

@ -0,0 +1,109 @@
/**
* OpenAPI Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* 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 { OuterEnum } from '../models/OuterEnum';
import { OuterEnumDefaultValue } from '../models/OuterEnumDefaultValue';
import { OuterEnumInteger } from '../models/OuterEnumInteger';
import { OuterEnumIntegerDefaultValue } from '../models/OuterEnumIntegerDefaultValue';
import { HttpFile } from '../http/http';
export class EnumTest {
'enumString'?: EnumTestEnumStringEnum;
'enumStringRequired': EnumTestEnumStringRequiredEnum;
'enumInteger'?: EnumTestEnumIntegerEnum;
'enumNumber'?: EnumTestEnumNumberEnum;
'outerEnum'?: OuterEnum | null;
'outerEnumInteger'?: OuterEnumInteger;
'outerEnumDefaultValue'?: OuterEnumDefaultValue;
'outerEnumIntegerDefaultValue'?: OuterEnumIntegerDefaultValue;
static readonly discriminator: string | undefined = undefined;
static readonly mapping: {[index: string]: string} | undefined = undefined;
static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [
{
"name": "enumString",
"baseName": "enum_string",
"type": "EnumTestEnumStringEnum",
"format": ""
},
{
"name": "enumStringRequired",
"baseName": "enum_string_required",
"type": "EnumTestEnumStringRequiredEnum",
"format": ""
},
{
"name": "enumInteger",
"baseName": "enum_integer",
"type": "EnumTestEnumIntegerEnum",
"format": "int32"
},
{
"name": "enumNumber",
"baseName": "enum_number",
"type": "EnumTestEnumNumberEnum",
"format": "double"
},
{
"name": "outerEnum",
"baseName": "outerEnum",
"type": "OuterEnum",
"format": ""
},
{
"name": "outerEnumInteger",
"baseName": "outerEnumInteger",
"type": "OuterEnumInteger",
"format": ""
},
{
"name": "outerEnumDefaultValue",
"baseName": "outerEnumDefaultValue",
"type": "OuterEnumDefaultValue",
"format": ""
},
{
"name": "outerEnumIntegerDefaultValue",
"baseName": "outerEnumIntegerDefaultValue",
"type": "OuterEnumIntegerDefaultValue",
"format": ""
} ];
static getAttributeTypeMap() {
return EnumTest.attributeTypeMap;
}
public constructor() {
}
}
export enum EnumTestEnumStringEnum {
Upper = 'UPPER',
Lower = 'lower',
Empty = ''
}
export enum EnumTestEnumStringRequiredEnum {
Upper = 'UPPER',
Lower = 'lower',
Empty = ''
}
export enum EnumTestEnumIntegerEnum {
NUMBER_1 = 1,
NUMBER_MINUS_1 = -1
}
export enum EnumTestEnumNumberEnum {
NUMBER_1_DOT_1 = 1.1,
NUMBER_MINUS_1_DOT_2 = -1.2
}

View File

@ -0,0 +1,43 @@
/**
* OpenAPI Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* 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';
export class FakeBigDecimalMap200Response {
'someId'?: number;
'someMap'?: { [key: string]: number; };
static readonly discriminator: string | undefined = undefined;
static readonly mapping: {[index: string]: string} | undefined = undefined;
static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [
{
"name": "someId",
"baseName": "someId",
"type": "number",
"format": ""
},
{
"name": "someMap",
"baseName": "someMap",
"type": "{ [key: string]: number; }",
"format": ""
} ];
static getAttributeTypeMap() {
return FakeBigDecimalMap200Response.attributeTypeMap;
}
public constructor() {
}
}

View File

@ -0,0 +1,43 @@
/**
* OpenAPI Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* 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';
export class FileSchemaTestClass {
'file'?: any;
'files'?: Array<any>;
static readonly discriminator: string | undefined = undefined;
static readonly mapping: {[index: string]: string} | undefined = undefined;
static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [
{
"name": "file",
"baseName": "file",
"type": "any",
"format": ""
},
{
"name": "files",
"baseName": "files",
"type": "Array<any>",
"format": ""
} ];
static getAttributeTypeMap() {
return FileSchemaTestClass.attributeTypeMap;
}
public constructor() {
}
}

View File

@ -0,0 +1,36 @@
/**
* OpenAPI Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* 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';
export class Foo {
'bar'?: string;
static readonly discriminator: string | undefined = undefined;
static readonly mapping: {[index: string]: string} | undefined = undefined;
static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [
{
"name": "bar",
"baseName": "bar",
"type": "string",
"format": ""
} ];
static getAttributeTypeMap() {
return Foo.attributeTypeMap;
}
public constructor() {
}
}

View File

@ -0,0 +1,37 @@
/**
* OpenAPI Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* 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 { Foo } from '../models/Foo';
import { HttpFile } from '../http/http';
export class FooGetDefaultResponse {
'string'?: Foo;
static readonly discriminator: string | undefined = undefined;
static readonly mapping: {[index: string]: string} | undefined = undefined;
static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [
{
"name": "string",
"baseName": "string",
"type": "Foo",
"format": ""
} ];
static getAttributeTypeMap() {
return FooGetDefaultResponse.attributeTypeMap;
}
public constructor() {
}
}

View File

@ -0,0 +1,148 @@
/**
* OpenAPI Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* 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 { Decimal } from '../models/Decimal';
import { HttpFile } from '../http/http';
export class FormatTest {
'integer'?: number;
'int32'?: number;
'int64'?: number;
'number': number;
'_float'?: number;
'_double'?: number;
'decimal'?: Decimal;
'string'?: string;
'_byte': string;
'binary'?: HttpFile;
'date': string;
'dateTime'?: Date;
'uuid'?: string;
'password': string;
/**
* A string that is a 10 digit number. Can have leading zeros.
*/
'patternWithDigits'?: string;
/**
* A string starting with \'image_\' (case insensitive) and one to three digits following i.e. Image_01.
*/
'patternWithDigitsAndDelimiter'?: string;
static readonly discriminator: string | undefined = undefined;
static readonly mapping: {[index: string]: string} | undefined = undefined;
static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [
{
"name": "integer",
"baseName": "integer",
"type": "number",
"format": ""
},
{
"name": "int32",
"baseName": "int32",
"type": "number",
"format": "int32"
},
{
"name": "int64",
"baseName": "int64",
"type": "number",
"format": "int64"
},
{
"name": "number",
"baseName": "number",
"type": "number",
"format": ""
},
{
"name": "_float",
"baseName": "float",
"type": "number",
"format": "float"
},
{
"name": "_double",
"baseName": "double",
"type": "number",
"format": "double"
},
{
"name": "decimal",
"baseName": "decimal",
"type": "Decimal",
"format": "number"
},
{
"name": "string",
"baseName": "string",
"type": "string",
"format": ""
},
{
"name": "_byte",
"baseName": "byte",
"type": "string",
"format": "byte"
},
{
"name": "binary",
"baseName": "binary",
"type": "HttpFile",
"format": "binary"
},
{
"name": "date",
"baseName": "date",
"type": "string",
"format": "date"
},
{
"name": "dateTime",
"baseName": "dateTime",
"type": "Date",
"format": "date-time"
},
{
"name": "uuid",
"baseName": "uuid",
"type": "string",
"format": "uuid"
},
{
"name": "password",
"baseName": "password",
"type": "string",
"format": "password"
},
{
"name": "patternWithDigits",
"baseName": "pattern_with_digits",
"type": "string",
"format": ""
},
{
"name": "patternWithDigitsAndDelimiter",
"baseName": "pattern_with_digits_and_delimiter",
"type": "string",
"format": ""
} ];
static getAttributeTypeMap() {
return FormatTest.attributeTypeMap;
}
public constructor() {
}
}

View File

@ -0,0 +1,43 @@
/**
* OpenAPI Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* 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';
export class HasOnlyReadOnly {
'bar'?: string;
'foo'?: string;
static readonly discriminator: string | undefined = undefined;
static readonly mapping: {[index: string]: string} | undefined = undefined;
static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [
{
"name": "bar",
"baseName": "bar",
"type": "string",
"format": ""
},
{
"name": "foo",
"baseName": "foo",
"type": "string",
"format": ""
} ];
static getAttributeTypeMap() {
return HasOnlyReadOnly.attributeTypeMap;
}
public constructor() {
}
}

View File

@ -0,0 +1,39 @@
/**
* OpenAPI Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* 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';
/**
* Just a string to inform instance is up and running. Make it nullable in hope to get it as pointer in generated model.
*/
export class HealthCheckResult {
'nullableMessage'?: string | null;
static readonly discriminator: string | undefined = undefined;
static readonly mapping: {[index: string]: string} | undefined = undefined;
static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [
{
"name": "nullableMessage",
"baseName": "NullableMessage",
"type": "string",
"format": ""
} ];
static getAttributeTypeMap() {
return HealthCheckResult.attributeTypeMap;
}
public constructor() {
}
}

View File

@ -0,0 +1,36 @@
/**
* OpenAPI Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* 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';
export class List {
'_123list'?: string;
static readonly discriminator: string | undefined = undefined;
static readonly mapping: {[index: string]: string} | undefined = undefined;
static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [
{
"name": "_123list",
"baseName": "123-list",
"type": "string",
"format": ""
} ];
static getAttributeTypeMap() {
return List.attributeTypeMap;
}
public constructor() {
}
}

View File

@ -0,0 +1,63 @@
/**
* OpenAPI Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* 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';
export class MapTest {
'mapMapOfString'?: { [key: string]: { [key: string]: string; }; };
'mapOfEnumString'?: { [key: string]: string; };
'directMap'?: { [key: string]: boolean; };
'indirectMap'?: { [key: string]: boolean; };
static readonly discriminator: string | undefined = undefined;
static readonly mapping: {[index: string]: string} | undefined = undefined;
static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [
{
"name": "mapMapOfString",
"baseName": "map_map_of_string",
"type": "{ [key: string]: { [key: string]: string; }; }",
"format": ""
},
{
"name": "mapOfEnumString",
"baseName": "map_of_enum_string",
"type": "{ [key: string]: string; }",
"format": ""
},
{
"name": "directMap",
"baseName": "direct_map",
"type": "{ [key: string]: boolean; }",
"format": ""
},
{
"name": "indirectMap",
"baseName": "indirect_map",
"type": "{ [key: string]: boolean; }",
"format": ""
} ];
static getAttributeTypeMap() {
return MapTest.attributeTypeMap;
}
public constructor() {
}
}
export enum MapTestMapOfEnumStringEnum {
Upper = 'UPPER',
Lower = 'lower'
}

View File

@ -0,0 +1,51 @@
/**
* OpenAPI Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* 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 { Animal } from '../models/Animal';
import { HttpFile } from '../http/http';
export class MixedPropertiesAndAdditionalPropertiesClass {
'uuid'?: string;
'dateTime'?: Date;
'map'?: { [key: string]: Animal; };
static readonly discriminator: string | undefined = undefined;
static readonly mapping: {[index: string]: string} | undefined = undefined;
static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [
{
"name": "uuid",
"baseName": "uuid",
"type": "string",
"format": "uuid"
},
{
"name": "dateTime",
"baseName": "dateTime",
"type": "Date",
"format": "date-time"
},
{
"name": "map",
"baseName": "map",
"type": "{ [key: string]: Animal; }",
"format": ""
} ];
static getAttributeTypeMap() {
return MixedPropertiesAndAdditionalPropertiesClass.attributeTypeMap;
}
public constructor() {
}
}

View File

@ -0,0 +1,46 @@
/**
* OpenAPI Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* 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';
/**
* Model for testing model name starting with number
*/
export class Model200Response {
'name'?: number;
'_class'?: string;
static readonly discriminator: string | undefined = undefined;
static readonly mapping: {[index: string]: string} | undefined = undefined;
static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [
{
"name": "name",
"baseName": "name",
"type": "number",
"format": "int32"
},
{
"name": "_class",
"baseName": "class",
"type": "string",
"format": ""
} ];
static getAttributeTypeMap() {
return Model200Response.attributeTypeMap;
}
public constructor() {
}
}

View File

@ -0,0 +1,42 @@
/**
* OpenAPI Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* 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';
/**
* Must be named `File` for test.
*/
export class ModelFile {
/**
* Test capitalization
*/
'sourceURI'?: string;
static readonly discriminator: string | undefined = undefined;
static readonly mapping: {[index: string]: string} | undefined = undefined;
static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [
{
"name": "sourceURI",
"baseName": "sourceURI",
"type": "string",
"format": ""
} ];
static getAttributeTypeMap() {
return ModelFile.attributeTypeMap;
}
public constructor() {
}
}

View File

@ -0,0 +1,60 @@
/**
* OpenAPI Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* 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';
/**
* Model for testing model name same as property name
*/
export class Name {
'name': number;
'snakeCase'?: number;
'property'?: string;
'_123number'?: number;
static readonly discriminator: string | undefined = undefined;
static readonly mapping: {[index: string]: string} | undefined = undefined;
static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [
{
"name": "name",
"baseName": "name",
"type": "number",
"format": "int32"
},
{
"name": "snakeCase",
"baseName": "snake_case",
"type": "number",
"format": "int32"
},
{
"name": "property",
"baseName": "property",
"type": "string",
"format": ""
},
{
"name": "_123number",
"baseName": "123Number",
"type": "number",
"format": ""
} ];
static getAttributeTypeMap() {
return Name.attributeTypeMap;
}
public constructor() {
}
}

View File

@ -0,0 +1,113 @@
/**
* OpenAPI Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* 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';
export class NullableClass {
'integerProp'?: number | null;
'numberProp'?: number | null;
'booleanProp'?: boolean | null;
'stringProp'?: string | null;
'dateProp'?: string | null;
'datetimeProp'?: Date | null;
'arrayNullableProp'?: Array<any> | null;
'arrayAndItemsNullableProp'?: Array<any | null> | null;
'arrayItemsNullable'?: Array<any | null>;
'objectNullableProp'?: { [key: string]: any; } | null;
'objectAndItemsNullableProp'?: { [key: string]: any | null; } | null;
'objectItemsNullable'?: { [key: string]: any | null; };
static readonly discriminator: string | undefined = undefined;
static readonly mapping: {[index: string]: string} | undefined = undefined;
static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [
{
"name": "integerProp",
"baseName": "integer_prop",
"type": "number",
"format": ""
},
{
"name": "numberProp",
"baseName": "number_prop",
"type": "number",
"format": ""
},
{
"name": "booleanProp",
"baseName": "boolean_prop",
"type": "boolean",
"format": ""
},
{
"name": "stringProp",
"baseName": "string_prop",
"type": "string",
"format": ""
},
{
"name": "dateProp",
"baseName": "date_prop",
"type": "string",
"format": "date"
},
{
"name": "datetimeProp",
"baseName": "datetime_prop",
"type": "Date",
"format": "date-time"
},
{
"name": "arrayNullableProp",
"baseName": "array_nullable_prop",
"type": "Array<any>",
"format": ""
},
{
"name": "arrayAndItemsNullableProp",
"baseName": "array_and_items_nullable_prop",
"type": "Array<any | null>",
"format": ""
},
{
"name": "arrayItemsNullable",
"baseName": "array_items_nullable",
"type": "Array<any | null>",
"format": ""
},
{
"name": "objectNullableProp",
"baseName": "object_nullable_prop",
"type": "{ [key: string]: any; }",
"format": ""
},
{
"name": "objectAndItemsNullableProp",
"baseName": "object_and_items_nullable_prop",
"type": "{ [key: string]: any | null; }",
"format": ""
},
{
"name": "objectItemsNullable",
"baseName": "object_items_nullable",
"type": "{ [key: string]: any | null; }",
"format": ""
} ];
static getAttributeTypeMap() {
return NullableClass.attributeTypeMap;
}
public constructor() {
}
}

View File

@ -0,0 +1,36 @@
/**
* OpenAPI Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* 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';
export class NumberOnly {
'justNumber'?: number;
static readonly discriminator: string | undefined = undefined;
static readonly mapping: {[index: string]: string} | undefined = undefined;
static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [
{
"name": "justNumber",
"baseName": "JustNumber",
"type": "number",
"format": ""
} ];
static getAttributeTypeMap() {
return NumberOnly.attributeTypeMap;
}
public constructor() {
}
}

View File

@ -0,0 +1,416 @@
export * from '../models/AdditionalPropertiesClass';
export * from '../models/AllOfWithSingleRef';
export * from '../models/Animal';
export * from '../models/ApiResponse';
export * from '../models/ArrayOfArrayOfNumberOnly';
export * from '../models/ArrayOfNumberOnly';
export * from '../models/ArrayTest';
export * from '../models/Capitalization';
export * from '../models/Cat';
export * from '../models/Category';
export * from '../models/ClassModel';
export * from '../models/Client';
export * from '../models/DeprecatedObject';
export * from '../models/Dog';
export * from '../models/EnumArrays';
export * from '../models/EnumClass';
export * from '../models/EnumTest';
export * from '../models/FakeBigDecimalMap200Response';
export * from '../models/FileSchemaTestClass';
export * from '../models/Foo';
export * from '../models/FooGetDefaultResponse';
export * from '../models/FormatTest';
export * from '../models/HasOnlyReadOnly';
export * from '../models/HealthCheckResult';
export * from '../models/List';
export * from '../models/MapTest';
export * from '../models/MixedPropertiesAndAdditionalPropertiesClass';
export * from '../models/Model200Response';
export * from '../models/ModelFile';
export * from '../models/Name';
export * from '../models/NullableClass';
export * from '../models/NumberOnly';
export * from '../models/ObjectWithDeprecatedFields';
export * from '../models/Order';
export * from '../models/OuterComposite';
export * from '../models/OuterEnum';
export * from '../models/OuterEnumDefaultValue';
export * from '../models/OuterEnumInteger';
export * from '../models/OuterEnumIntegerDefaultValue';
export * from '../models/OuterObjectWithEnumProperty';
export * from '../models/Pet';
export * from '../models/ReadOnlyFirst';
export * from '../models/Return';
export * from '../models/SingleRefType';
export * from '../models/SpecialModelName';
export * from '../models/Tag';
export * from '../models/User';
import { AdditionalPropertiesClass } from '../models/AdditionalPropertiesClass';
import { AllOfWithSingleRef } from '../models/AllOfWithSingleRef';
import { Animal } from '../models/Animal';
import { ApiResponse } from '../models/ApiResponse';
import { ArrayOfArrayOfNumberOnly } from '../models/ArrayOfArrayOfNumberOnly';
import { ArrayOfNumberOnly } from '../models/ArrayOfNumberOnly';
import { ArrayTest } from '../models/ArrayTest';
import { Capitalization } from '../models/Capitalization';
import { Cat } from '../models/Cat';
import { Category } from '../models/Category';
import { ClassModel } from '../models/ClassModel';
import { Client } from '../models/Client';
import { DeprecatedObject } from '../models/DeprecatedObject';
import { Dog } from '../models/Dog';
import { EnumArrays, EnumArraysJustSymbolEnum , EnumArraysArrayEnumEnum } from '../models/EnumArrays';
import { EnumClass } from '../models/EnumClass';
import { EnumTest, EnumTestEnumStringEnum , EnumTestEnumStringRequiredEnum , EnumTestEnumIntegerEnum , EnumTestEnumNumberEnum } from '../models/EnumTest';
import { FakeBigDecimalMap200Response } from '../models/FakeBigDecimalMap200Response';
import { FileSchemaTestClass } from '../models/FileSchemaTestClass';
import { Foo } from '../models/Foo';
import { FooGetDefaultResponse } from '../models/FooGetDefaultResponse';
import { FormatTest } from '../models/FormatTest';
import { HasOnlyReadOnly } from '../models/HasOnlyReadOnly';
import { HealthCheckResult } from '../models/HealthCheckResult';
import { List } from '../models/List';
import { MapTest , MapTestMapOfEnumStringEnum } from '../models/MapTest';
import { MixedPropertiesAndAdditionalPropertiesClass } from '../models/MixedPropertiesAndAdditionalPropertiesClass';
import { Model200Response } from '../models/Model200Response';
import { ModelFile } from '../models/ModelFile';
import { Name } from '../models/Name';
import { NullableClass } from '../models/NullableClass';
import { NumberOnly } from '../models/NumberOnly';
import { ObjectWithDeprecatedFields } from '../models/ObjectWithDeprecatedFields';
import { Order , OrderStatusEnum } from '../models/Order';
import { OuterComposite } from '../models/OuterComposite';
import { OuterEnum } from '../models/OuterEnum';
import { OuterEnumDefaultValue } from '../models/OuterEnumDefaultValue';
import { OuterEnumInteger } from '../models/OuterEnumInteger';
import { OuterEnumIntegerDefaultValue } from '../models/OuterEnumIntegerDefaultValue';
import { OuterObjectWithEnumProperty } from '../models/OuterObjectWithEnumProperty';
import { Pet , PetStatusEnum } from '../models/Pet';
import { ReadOnlyFirst } from '../models/ReadOnlyFirst';
import { Return } from '../models/Return';
import { SingleRefType } from '../models/SingleRefType';
import { SpecialModelName } from '../models/SpecialModelName';
import { Tag } from '../models/Tag';
import { User } from '../models/User';
/* tslint:disable:no-unused-variable */
let primitives = [
"string",
"boolean",
"double",
"integer",
"long",
"float",
"number",
"any"
];
let enumsMap: Set<string> = new Set<string>([
"EnumArraysJustSymbolEnum",
"EnumArraysArrayEnumEnum",
"EnumClass",
"EnumTestEnumStringEnum",
"EnumTestEnumStringRequiredEnum",
"EnumTestEnumIntegerEnum",
"EnumTestEnumNumberEnum",
"MapTestMapOfEnumStringEnum",
"OrderStatusEnum",
"OuterEnum",
"OuterEnumDefaultValue",
"OuterEnumInteger",
"OuterEnumIntegerDefaultValue",
"PetStatusEnum",
"SingleRefType",
]);
let typeMap: {[index: string]: any} = {
"AdditionalPropertiesClass": AdditionalPropertiesClass,
"AllOfWithSingleRef": AllOfWithSingleRef,
"Animal": Animal,
"ApiResponse": ApiResponse,
"ArrayOfArrayOfNumberOnly": ArrayOfArrayOfNumberOnly,
"ArrayOfNumberOnly": ArrayOfNumberOnly,
"ArrayTest": ArrayTest,
"Capitalization": Capitalization,
"Cat": Cat,
"Category": Category,
"ClassModel": ClassModel,
"Client": Client,
"DeprecatedObject": DeprecatedObject,
"Dog": Dog,
"EnumArrays": EnumArrays,
"EnumTest": EnumTest,
"FakeBigDecimalMap200Response": FakeBigDecimalMap200Response,
"FileSchemaTestClass": FileSchemaTestClass,
"Foo": Foo,
"FooGetDefaultResponse": FooGetDefaultResponse,
"FormatTest": FormatTest,
"HasOnlyReadOnly": HasOnlyReadOnly,
"HealthCheckResult": HealthCheckResult,
"List": List,
"MapTest": MapTest,
"MixedPropertiesAndAdditionalPropertiesClass": MixedPropertiesAndAdditionalPropertiesClass,
"Model200Response": Model200Response,
"ModelFile": ModelFile,
"Name": Name,
"NullableClass": NullableClass,
"NumberOnly": NumberOnly,
"ObjectWithDeprecatedFields": ObjectWithDeprecatedFields,
"Order": Order,
"OuterComposite": OuterComposite,
"OuterObjectWithEnumProperty": OuterObjectWithEnumProperty,
"Pet": Pet,
"ReadOnlyFirst": ReadOnlyFirst,
"Return": Return,
"SpecialModelName": SpecialModelName,
"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];
let mapping = typeMap[expectedType].mapping;
if (mapping != undefined && mapping[discriminatorType]) {
return mapping[discriminatorType]; // use the type given in the discriminator
} else if(typeMap[discriminatorType]) {
return discriminatorType;
} 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,58 @@
/**
* OpenAPI Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* 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 { DeprecatedObject } from '../models/DeprecatedObject';
import { HttpFile } from '../http/http';
export class ObjectWithDeprecatedFields {
'uuid'?: string;
'id'?: number;
'deprecatedRef'?: DeprecatedObject;
'bars'?: Array<string>;
static readonly discriminator: string | undefined = undefined;
static readonly mapping: {[index: string]: string} | undefined = undefined;
static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [
{
"name": "uuid",
"baseName": "uuid",
"type": "string",
"format": ""
},
{
"name": "id",
"baseName": "id",
"type": "number",
"format": ""
},
{
"name": "deprecatedRef",
"baseName": "deprecatedRef",
"type": "DeprecatedObject",
"format": ""
},
{
"name": "bars",
"baseName": "bars",
"type": "Array<string>",
"format": ""
} ];
static getAttributeTypeMap() {
return ObjectWithDeprecatedFields.attributeTypeMap;
}
public constructor() {
}
}

View File

@ -0,0 +1,81 @@
/**
* OpenAPI Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* 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';
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 mapping: {[index: string]: 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,50 @@
/**
* OpenAPI Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* 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';
export class OuterComposite {
'myNumber'?: number;
'myString'?: string;
'myBoolean'?: boolean;
static readonly discriminator: string | undefined = undefined;
static readonly mapping: {[index: string]: string} | undefined = undefined;
static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [
{
"name": "myNumber",
"baseName": "my_number",
"type": "number",
"format": ""
},
{
"name": "myString",
"baseName": "my_string",
"type": "string",
"format": ""
},
{
"name": "myBoolean",
"baseName": "my_boolean",
"type": "boolean",
"format": ""
} ];
static getAttributeTypeMap() {
return OuterComposite.attributeTypeMap;
}
public constructor() {
}
}

View File

@ -0,0 +1,19 @@
/**
* OpenAPI Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* 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';
export enum OuterEnum {
Placed = 'placed',
Approved = 'approved',
Delivered = 'delivered'
}

View File

@ -0,0 +1,19 @@
/**
* OpenAPI Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* 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';
export enum OuterEnumDefaultValue {
Placed = 'placed',
Approved = 'approved',
Delivered = 'delivered'
}

View File

@ -0,0 +1,19 @@
/**
* OpenAPI Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* 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';
export enum OuterEnumInteger {
NUMBER_0 = 0,
NUMBER_1 = 1,
NUMBER_2 = 2
}

View File

@ -0,0 +1,19 @@
/**
* OpenAPI Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* 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';
export enum OuterEnumIntegerDefaultValue {
NUMBER_0 = 0,
NUMBER_1 = 1,
NUMBER_2 = 2
}

View File

@ -0,0 +1,39 @@
/**
* OpenAPI Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* 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 { OuterEnumInteger } from '../models/OuterEnumInteger';
import { HttpFile } from '../http/http';
export class OuterObjectWithEnumProperty {
'value': OuterEnumInteger;
static readonly discriminator: string | undefined = undefined;
static readonly mapping: {[index: string]: string} | undefined = undefined;
static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [
{
"name": "value",
"baseName": "value",
"type": "OuterEnumInteger",
"format": ""
} ];
static getAttributeTypeMap() {
return OuterObjectWithEnumProperty.attributeTypeMap;
}
public constructor() {
}
}

View File

@ -0,0 +1,83 @@
/**
* OpenAPI Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* 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';
import { Tag } from '../models/Tag';
import { HttpFile } from '../http/http';
export class Pet {
'id'?: number;
'category'?: Category;
'name': string;
'photoUrls': Set<string>;
'tags'?: Array<Tag>;
/**
* pet status in the store
*/
'status'?: PetStatusEnum;
static readonly discriminator: string | undefined = undefined;
static readonly mapping: {[index: string]: 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": "Set<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,43 @@
/**
* OpenAPI Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* 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';
export class ReadOnlyFirst {
'bar'?: string;
'baz'?: string;
static readonly discriminator: string | undefined = undefined;
static readonly mapping: {[index: string]: string} | undefined = undefined;
static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [
{
"name": "bar",
"baseName": "bar",
"type": "string",
"format": ""
},
{
"name": "baz",
"baseName": "baz",
"type": "string",
"format": ""
} ];
static getAttributeTypeMap() {
return ReadOnlyFirst.attributeTypeMap;
}
public constructor() {
}
}

View File

@ -0,0 +1,39 @@
/**
* OpenAPI Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* 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';
/**
* Model for testing reserved words
*/
export class Return {
'_return'?: number;
static readonly discriminator: string | undefined = undefined;
static readonly mapping: {[index: string]: string} | undefined = undefined;
static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [
{
"name": "_return",
"baseName": "return",
"type": "number",
"format": "int32"
} ];
static getAttributeTypeMap() {
return Return.attributeTypeMap;
}
public constructor() {
}
}

View File

@ -0,0 +1,18 @@
/**
* OpenAPI Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* 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';
export enum SingleRefType {
Admin = 'admin',
User = 'user'
}

View File

@ -0,0 +1,36 @@
/**
* OpenAPI Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* 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';
export class SpecialModelName {
'specialPropertyName'?: number;
static readonly discriminator: string | undefined = undefined;
static readonly mapping: {[index: string]: string} | undefined = undefined;
static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [
{
"name": "specialPropertyName",
"baseName": "$special[property.name]",
"type": "number",
"format": "int64"
} ];
static getAttributeTypeMap() {
return SpecialModelName.attributeTypeMap;
}
public constructor() {
}
}

View File

@ -0,0 +1,43 @@
/**
* OpenAPI Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* 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';
export class Tag {
'id'?: number;
'name'?: string;
static readonly discriminator: string | undefined = undefined;
static readonly mapping: {[index: string]: 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,88 @@
/**
* OpenAPI Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
*
* 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';
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 mapping: {[index: string]: 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,47 @@
export * from '../models/AdditionalPropertiesClass'
export * from '../models/AllOfWithSingleRef'
export * from '../models/Animal'
export * from '../models/ApiResponse'
export * from '../models/ArrayOfArrayOfNumberOnly'
export * from '../models/ArrayOfNumberOnly'
export * from '../models/ArrayTest'
export * from '../models/Capitalization'
export * from '../models/Cat'
export * from '../models/Category'
export * from '../models/ClassModel'
export * from '../models/Client'
export * from '../models/DeprecatedObject'
export * from '../models/Dog'
export * from '../models/EnumArrays'
export * from '../models/EnumClass'
export * from '../models/EnumTest'
export * from '../models/FakeBigDecimalMap200Response'
export * from '../models/FileSchemaTestClass'
export * from '../models/Foo'
export * from '../models/FooGetDefaultResponse'
export * from '../models/FormatTest'
export * from '../models/HasOnlyReadOnly'
export * from '../models/HealthCheckResult'
export * from '../models/List'
export * from '../models/MapTest'
export * from '../models/MixedPropertiesAndAdditionalPropertiesClass'
export * from '../models/Model200Response'
export * from '../models/ModelFile'
export * from '../models/Name'
export * from '../models/NullableClass'
export * from '../models/NumberOnly'
export * from '../models/ObjectWithDeprecatedFields'
export * from '../models/Order'
export * from '../models/OuterComposite'
export * from '../models/OuterEnum'
export * from '../models/OuterEnumDefaultValue'
export * from '../models/OuterEnumInteger'
export * from '../models/OuterEnumIntegerDefaultValue'
export * from '../models/OuterObjectWithEnumProperty'
export * from '../models/Pet'
export * from '../models/ReadOnlyFirst'
export * from '../models/Return'
export * from '../models/SingleRefType'
export * from '../models/SpecialModelName'
export * from '../models/Tag'
export * from '../models/User'

View File

@ -0,0 +1,45 @@
{
"name": "ts-petstore-client",
"version": "1.0.0",
"description": "OpenAPI client for ts-petstore-client",
"author": "OpenAPI-Generator Contributors",
"repository": {
"type": "git",
"url": "https://github.com/GIT_USER_ID/GIT_REPO_ID.git"
},
"keywords": [
"fetch",
"typescript",
"openapi-client",
"openapi-generator"
],
"license": "Unlicense",
"main": "./dist/index.js",
"type": "commonjs",
"exports": {
".": {
"require": "./dist/index.js",
"types": "./dist/index.d.js"
}
},
"files": [
"dist"
],
"typings": "./dist/index.d.ts",
"scripts": {
"build": "tsc",
"prepare": "npm run build"
},
"dependencies": {
"node-fetch": "^2.6.0",
"@types/node-fetch": "^2.5.7",
"@types/node": "*",
"form-data": "^2.5.0",
"es6-promise": "^4.2.4",
"url-parse": "^1.4.3"
},
"devDependencies": {
"typescript": "^4.0",
"@types/url-parse": "1.4.4"
}
}

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,57 @@
import { RequestContext, HttpMethod } from "./http/http";
export interface BaseServerConfiguration {
makeRequestContext(endpoint: string, httpMethod: HttpMethod): RequestContext;
}
/**
*
* Represents the configuration of a server including its
* url template and variable configuration based on the url.
*
*/
export class ServerConfiguration<T extends { [key: string]: string }> implements BaseServerConfiguration {
public constructor(private url: string, private variableConfiguration: T) {}
/**
* Sets the value of the variables of this server. 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<{ "server": "petstore" | "qa-petstore" | "dev-petstore", "port": "80" | "8080" }>("http://{server}.swagger.io:{port}/v2", { "server": "petstore" , "port": "80" })
export const server2 = new ServerConfiguration<{ "version": "v1" | "v2" }>("https://localhost:8080/{version}", { "version": "v2" })
export const server3 = new ServerConfiguration<{ }>("https://127.0.0.1/no_varaible", { })
export const servers = [server1, server2, server3];

View File

@ -0,0 +1,28 @@
{
"compilerOptions": {
"strict": true,
/* Basic Options */
"target": "es5",
"moduleResolution": "node",
"declaration": true,
/* Additional Checks */
"noUnusedLocals": false, /* Report errors on unused locals. */ // TODO: reenable (unused imports!)
"noUnusedParameters": false, /* Report errors on unused parameters. */ // TODO: set to true again
"noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
"noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
"removeComments": true,
"sourceMap": true,
"outDir": "./dist",
"noLib": false,
"lib": [ "es6" ],
},
"exclude": [
"dist",
"node_modules"
],
"filesGlob": [
"./**/*.ts",
]
}

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
}

View File

@ -114,6 +114,10 @@ export class RequestContext {
this.url.searchParams.set(name, value);
}
public appendQueryParam(name: string, value: string) {
this.url.searchParams.append(name, value);
}
/**
* Sets a cookie with the name and value. NO check for duplicate cookies is performed
*

View File

@ -105,6 +105,10 @@ export class RequestContext {
this.url.searchParams.set(name, value);
}
public appendQueryParam(name: string, value: string) {
this.url.searchParams.append(name, value);
}
/**
* Sets a cookie with the name and value. NO check for duplicate cookies is performed
*

View File

@ -114,6 +114,10 @@ export class RequestContext {
this.url.searchParams.set(name, value);
}
public appendQueryParam(name: string, value: string) {
this.url.searchParams.append(name, value);
}
/**
* Sets a cookie with the name and value. NO check for duplicate cookies is performed
*