forked from loafle/openapi-generator-original
Adds python-experimental with dynamic base classes (#8325)
This commit is contained in:
parent
361b593da2
commit
3243279b4d
8
bin/configs/python-experimental.yaml
Normal file
8
bin/configs/python-experimental.yaml
Normal file
@ -0,0 +1,8 @@
|
||||
generatorName: python-experimental
|
||||
outputDir: samples/openapi3/client/petstore/python-experimental
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/python-experimental/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/python-experimental
|
||||
templatingEngineName: handlebars
|
||||
additionalProperties:
|
||||
packageName: petstore_api
|
||||
recursionLimit: "1234"
|
@ -54,6 +54,7 @@ The following generators are available:
|
||||
* [php-dt (beta)](generators/php-dt.md)
|
||||
* [powershell (beta)](generators/powershell.md)
|
||||
* [python (experimental)](generators/python.md)
|
||||
* [python-experimental (experimental)](generators/python-experimental.md)
|
||||
* [python-legacy](generators/python-legacy.md)
|
||||
* [r](generators/r.md)
|
||||
* [ruby](generators/ruby.md)
|
||||
|
221
docs/generators/python-experimental.md
Normal file
221
docs/generators/python-experimental.md
Normal file
@ -0,0 +1,221 @@
|
||||
---
|
||||
title: Config Options for python-experimental
|
||||
sidebar_label: python-experimental
|
||||
---
|
||||
|
||||
These options may be applied as additional-properties (cli) or configOptions (plugins). Refer to [configuration docs](https://openapi-generator.tech/docs/configuration) for more details.
|
||||
|
||||
| Option | Description | Values | Default |
|
||||
| ------ | ----------- | ------ | ------- |
|
||||
|generateSourceCodeOnly|Specifies that only a library source code is to be generated.| |false|
|
||||
|hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |true|
|
||||
|library|library template (sub-template) to use: asyncio, tornado, urllib3| |urllib3|
|
||||
|packageName|python package name (convention: snake_case).| |openapi_client|
|
||||
|packageUrl|python package URL.| |null|
|
||||
|packageVersion|python package version.| |1.0.0|
|
||||
|projectName|python project name in setup.py (e.g. petstore-api).| |null|
|
||||
|recursionLimit|Set the recursion limit. If not set, use the system default value.| |null|
|
||||
|useNose|use the nose test framework| |false|
|
||||
|
||||
## IMPORT MAPPING
|
||||
|
||||
| Type/Alias | Imports |
|
||||
| ---------- | ------- |
|
||||
|
||||
|
||||
## INSTANTIATION TYPES
|
||||
|
||||
| Type/Alias | Instantiated By |
|
||||
| ---------- | --------------- |
|
||||
|map|dict|
|
||||
|
||||
|
||||
## LANGUAGE PRIMITIVES
|
||||
|
||||
<ul class="column-ul">
|
||||
<li>bool</li>
|
||||
<li>bytes</li>
|
||||
<li>date</li>
|
||||
<li>datetime</li>
|
||||
<li>dict</li>
|
||||
<li>file</li>
|
||||
<li>file_type</li>
|
||||
<li>float</li>
|
||||
<li>int</li>
|
||||
<li>list</li>
|
||||
<li>none_type</li>
|
||||
<li>object</li>
|
||||
<li>str</li>
|
||||
</ul>
|
||||
|
||||
## RESERVED WORDS
|
||||
|
||||
<ul class="column-ul">
|
||||
<li>all_params</li>
|
||||
<li>and</li>
|
||||
<li>as</li>
|
||||
<li>assert</li>
|
||||
<li>async</li>
|
||||
<li>auth_settings</li>
|
||||
<li>await</li>
|
||||
<li>body_params</li>
|
||||
<li>bool</li>
|
||||
<li>break</li>
|
||||
<li>class</li>
|
||||
<li>continue</li>
|
||||
<li>def</li>
|
||||
<li>del</li>
|
||||
<li>dict</li>
|
||||
<li>elif</li>
|
||||
<li>else</li>
|
||||
<li>except</li>
|
||||
<li>exec</li>
|
||||
<li>false</li>
|
||||
<li>file_type</li>
|
||||
<li>finally</li>
|
||||
<li>float</li>
|
||||
<li>for</li>
|
||||
<li>form_params</li>
|
||||
<li>from</li>
|
||||
<li>frozendict</li>
|
||||
<li>global</li>
|
||||
<li>header_params</li>
|
||||
<li>if</li>
|
||||
<li>import</li>
|
||||
<li>in</li>
|
||||
<li>int</li>
|
||||
<li>is</li>
|
||||
<li>lambda</li>
|
||||
<li>list</li>
|
||||
<li>local_var_files</li>
|
||||
<li>none</li>
|
||||
<li>none_type</li>
|
||||
<li>nonlocal</li>
|
||||
<li>not</li>
|
||||
<li>or</li>
|
||||
<li>pass</li>
|
||||
<li>path_params</li>
|
||||
<li>print</li>
|
||||
<li>property</li>
|
||||
<li>query_params</li>
|
||||
<li>raise</li>
|
||||
<li>resource_path</li>
|
||||
<li>return</li>
|
||||
<li>self</li>
|
||||
<li>str</li>
|
||||
<li>true</li>
|
||||
<li>try</li>
|
||||
<li>tuple</li>
|
||||
<li>while</li>
|
||||
<li>with</li>
|
||||
<li>yield</li>
|
||||
</ul>
|
||||
|
||||
## FEATURE SET
|
||||
|
||||
|
||||
### Client Modification Feature
|
||||
| Name | Supported | Defined By |
|
||||
| ---- | --------- | ---------- |
|
||||
|BasePath|✗|ToolingExtension
|
||||
|Authorizations|✗|ToolingExtension
|
||||
|UserAgent|✗|ToolingExtension
|
||||
|MockServer|✗|ToolingExtension
|
||||
|
||||
### Data Type Feature
|
||||
| Name | Supported | Defined By |
|
||||
| ---- | --------- | ---------- |
|
||||
|Custom|✗|OAS2,OAS3
|
||||
|Int32|✓|OAS2,OAS3
|
||||
|Int64|✓|OAS2,OAS3
|
||||
|Float|✓|OAS2,OAS3
|
||||
|Double|✓|OAS2,OAS3
|
||||
|Decimal|✓|ToolingExtension
|
||||
|String|✓|OAS2,OAS3
|
||||
|Byte|✓|OAS2,OAS3
|
||||
|Binary|✓|OAS2,OAS3
|
||||
|Boolean|✓|OAS2,OAS3
|
||||
|Date|✓|OAS2,OAS3
|
||||
|DateTime|✓|OAS2,OAS3
|
||||
|Password|✓|OAS2,OAS3
|
||||
|File|✓|OAS2
|
||||
|Array|✓|OAS2,OAS3
|
||||
|Maps|✓|ToolingExtension
|
||||
|CollectionFormat|✓|OAS2
|
||||
|CollectionFormatMulti|✓|OAS2
|
||||
|Enum|✓|OAS2,OAS3
|
||||
|ArrayOfEnum|✓|ToolingExtension
|
||||
|ArrayOfModel|✓|ToolingExtension
|
||||
|ArrayOfCollectionOfPrimitives|✓|ToolingExtension
|
||||
|ArrayOfCollectionOfModel|✓|ToolingExtension
|
||||
|ArrayOfCollectionOfEnum|✓|ToolingExtension
|
||||
|MapOfEnum|✓|ToolingExtension
|
||||
|MapOfModel|✓|ToolingExtension
|
||||
|MapOfCollectionOfPrimitives|✓|ToolingExtension
|
||||
|MapOfCollectionOfModel|✓|ToolingExtension
|
||||
|MapOfCollectionOfEnum|✓|ToolingExtension
|
||||
|
||||
### Documentation Feature
|
||||
| Name | Supported | Defined By |
|
||||
| ---- | --------- | ---------- |
|
||||
|Readme|✓|ToolingExtension
|
||||
|Model|✓|ToolingExtension
|
||||
|Api|✓|ToolingExtension
|
||||
|
||||
### Global Feature
|
||||
| Name | Supported | Defined By |
|
||||
| ---- | --------- | ---------- |
|
||||
|Host|✓|OAS2,OAS3
|
||||
|BasePath|✓|OAS2,OAS3
|
||||
|Info|✓|OAS2,OAS3
|
||||
|Schemes|✗|OAS2,OAS3
|
||||
|PartialSchemes|✓|OAS2,OAS3
|
||||
|Consumes|✓|OAS2
|
||||
|Produces|✓|OAS2
|
||||
|ExternalDocumentation|✓|OAS2,OAS3
|
||||
|Examples|✓|OAS2,OAS3
|
||||
|XMLStructureDefinitions|✗|OAS2,OAS3
|
||||
|MultiServer|✗|OAS3
|
||||
|ParameterizedServer|✓|OAS3
|
||||
|ParameterStyling|✓|OAS3
|
||||
|Callbacks|✗|OAS3
|
||||
|LinkObjects|✗|OAS3
|
||||
|
||||
### Parameter Feature
|
||||
| Name | Supported | Defined By |
|
||||
| ---- | --------- | ---------- |
|
||||
|Path|✓|OAS2,OAS3
|
||||
|Query|✓|OAS2,OAS3
|
||||
|Header|✓|OAS2,OAS3
|
||||
|Body|✓|OAS2
|
||||
|FormUnencoded|✓|OAS2
|
||||
|FormMultipart|✓|OAS2
|
||||
|Cookie|✗|OAS3
|
||||
|
||||
### Schema Support Feature
|
||||
| Name | Supported | Defined By |
|
||||
| ---- | --------- | ---------- |
|
||||
|Simple|✓|OAS2,OAS3
|
||||
|Composite|✓|OAS2,OAS3
|
||||
|Polymorphism|✓|OAS2,OAS3
|
||||
|Union|✓|OAS3
|
||||
|
||||
### Security Feature
|
||||
| Name | Supported | Defined By |
|
||||
| ---- | --------- | ---------- |
|
||||
|BasicAuth|✓|OAS2,OAS3
|
||||
|ApiKey|✓|OAS2,OAS3
|
||||
|OpenIDConnect|✗|OAS3
|
||||
|BearerToken|✓|OAS3
|
||||
|OAuth2_Implicit|✓|OAS2,OAS3
|
||||
|OAuth2_Password|✗|OAS2,OAS3
|
||||
|OAuth2_ClientCredentials|✗|OAS2,OAS3
|
||||
|OAuth2_AuthorizationCode|✗|OAS2,OAS3
|
||||
|
||||
### Wire Format Feature
|
||||
| Name | Supported | Defined By |
|
||||
| ---- | --------- | ---------- |
|
||||
|JSON|✓|OAS2,OAS3
|
||||
|XML|✗|OAS2,OAS3
|
||||
|PROTOBUF|✗|ToolingExtension
|
||||
|Custom|✓|OAS2,OAS3
|
@ -1051,6 +1051,9 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
|
||||
this.emptyVars = emptyVars;
|
||||
}
|
||||
|
||||
public boolean getHasItems() {
|
||||
return this.items != null;
|
||||
}
|
||||
/**
|
||||
* Remove duplicated properties in all variable list
|
||||
*/
|
||||
|
@ -778,6 +778,10 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
|
||||
this.hasDiscriminatorWithNonEmptyMapping = hasDiscriminatorWithNonEmptyMapping;
|
||||
}
|
||||
|
||||
public boolean getHasItems() {
|
||||
return this.items != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsString() { return isString; }
|
||||
|
||||
|
@ -2731,7 +2731,6 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
addParentContainer(m, name, schema);
|
||||
} else if (ModelUtils.isIntegerSchema(schema)) { // integer type
|
||||
// NOTE: Integral schemas as CodegenModel is a rare use case and may be removed at a later date.
|
||||
|
||||
m.isNumeric = Boolean.TRUE;
|
||||
if (ModelUtils.isLongSchema(schema)) { // int64/long format
|
||||
m.isLong = Boolean.TRUE;
|
||||
@ -2823,6 +2822,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
postProcessModelProperty(m, prop);
|
||||
}
|
||||
}
|
||||
|
||||
return m;
|
||||
}
|
||||
|
||||
@ -2870,16 +2870,15 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Recursively look in Schema sc for the discriminator discPropName
|
||||
* and return a CodegenProperty with the dataType and required params set
|
||||
* the returned CodegenProperty may not be required and it may not be of type string
|
||||
*
|
||||
* @param composedSchemaName The name of the sc Schema
|
||||
* @param sc The Schema that may contain the discriminator
|
||||
* @param discPropName The String that is the discriminator propertyName in the schema
|
||||
*/
|
||||
/**
|
||||
* Recursively look in Schema sc for the discriminator discPropName
|
||||
* and return a CodegenProperty with the dataType and required params set
|
||||
* the returned CodegenProperty may not be required and it may not be of type string
|
||||
*
|
||||
* @param composedSchemaName The name of the sc Schema
|
||||
* @param sc The Schema that may contain the discriminator
|
||||
* @param discPropName The String that is the discriminator propertyName in the schema
|
||||
*/
|
||||
private CodegenProperty discriminatorFound(String composedSchemaName, Schema sc, String discPropName, OpenAPI openAPI) {
|
||||
Schema refSchema = ModelUtils.getReferencedSchema(openAPI, sc);
|
||||
if (refSchema.getProperties() != null && refSchema.getProperties().get(discPropName) != null) {
|
||||
@ -5199,7 +5198,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
* @param properties a map of properties (schema)
|
||||
* @param mandatory a set of required properties' name
|
||||
*/
|
||||
private void addVars(IJsonSchemaValidationProperties m, List<CodegenProperty> vars, Map<String, Schema> properties, Set<String> mandatory) {
|
||||
protected void addVars(IJsonSchemaValidationProperties m, List<CodegenProperty> vars, Map<String, Schema> properties, Set<String> mandatory) {
|
||||
if (properties == null) {
|
||||
return;
|
||||
}
|
||||
@ -6826,7 +6825,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
return codegenParameter;
|
||||
}
|
||||
|
||||
private void addVarsRequiredVarsAdditionalProps(Schema schema, IJsonSchemaValidationProperties property){
|
||||
protected void addVarsRequiredVarsAdditionalProps(Schema schema, IJsonSchemaValidationProperties property){
|
||||
setAddProps(schema, property);
|
||||
if (!"object".equals(schema.getType())) {
|
||||
return;
|
||||
|
@ -41,6 +41,7 @@ import org.openapitools.codegen.api.TemplatingEngineAdapter;
|
||||
import org.openapitools.codegen.api.TemplateFileType;
|
||||
import org.openapitools.codegen.ignore.CodegenIgnoreProcessor;
|
||||
import org.openapitools.codegen.languages.PythonClientCodegen;
|
||||
import org.openapitools.codegen.languages.PythonExperimentalClientCodegen;
|
||||
import org.openapitools.codegen.meta.GeneratorMetadata;
|
||||
import org.openapitools.codegen.meta.Stability;
|
||||
import org.openapitools.codegen.serializer.SerializerUtils;
|
||||
@ -527,7 +528,7 @@ public class DefaultGenerator implements Generator {
|
||||
Map<String, Object> modelTemplate = (Map<String, Object>) modelList.get(0);
|
||||
if (modelTemplate != null && modelTemplate.containsKey("model")) {
|
||||
CodegenModel m = (CodegenModel) modelTemplate.get("model");
|
||||
if (m.isAlias && !(config instanceof PythonClientCodegen)) {
|
||||
if (m.isAlias && !((config instanceof PythonClientCodegen) || (config instanceof PythonExperimentalClientCodegen))) {
|
||||
// alias to number, string, enum, etc, which should not be generated as model
|
||||
// for PythonClientCodegen, all aliases are generated as models
|
||||
continue; // Don't create user-defined classes for aliases
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -102,6 +102,7 @@ org.openapitools.codegen.languages.ProtobufSchemaCodegen
|
||||
org.openapitools.codegen.languages.PythonLegacyClientCodegen
|
||||
org.openapitools.codegen.languages.PythonClientCodegen
|
||||
org.openapitools.codegen.languages.PythonFastAPIServerCodegen
|
||||
org.openapitools.codegen.languages.PythonExperimentalClientCodegen
|
||||
org.openapitools.codegen.languages.PythonFlaskConnexionServerCodegen
|
||||
org.openapitools.codegen.languages.PythonAiohttpConnexionServerCodegen
|
||||
org.openapitools.codegen.languages.PythonBluePlanetServerCodegen
|
||||
|
@ -0,0 +1,57 @@
|
||||
# {{{projectName}}}
|
||||
{{#if appDescriptionWithNewLines}}
|
||||
{{{appDescriptionWithNewLines}}}
|
||||
{{/if}}
|
||||
|
||||
This Python package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:
|
||||
|
||||
- API version: {{appVersion}}
|
||||
- Package version: {{packageVersion}}
|
||||
{{#unless hideGenerationTimestamp}}
|
||||
- Build date: {{generatedDate}}
|
||||
{{/unless}}
|
||||
- Build package: {{generatorClass}}
|
||||
{{#if infoUrl}}
|
||||
For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}})
|
||||
{{/if}}
|
||||
|
||||
## Requirements.
|
||||
|
||||
Python >= 3.9
|
||||
v3.9 is needed so one can combine classmethod and property decorators to define
|
||||
object schema properties as classes
|
||||
|
||||
## Installation & Usage
|
||||
### pip install
|
||||
|
||||
If the python package is hosted on a repository, you can install directly using:
|
||||
|
||||
```sh
|
||||
pip install git+https://{{gitHost}}/{{{gitUserId}}}/{{{gitRepoId}}}.git
|
||||
```
|
||||
(you may need to run `pip` with root permission: `sudo pip install git+https://{{gitHost}}/{{{gitUserId}}}/{{{gitRepoId}}}.git`)
|
||||
|
||||
Then import the package:
|
||||
```python
|
||||
import {{{packageName}}}
|
||||
```
|
||||
|
||||
### Setuptools
|
||||
|
||||
Install via [Setuptools](http://pypi.python.org/pypi/setuptools).
|
||||
|
||||
```sh
|
||||
python setup.py install --user
|
||||
```
|
||||
(or `sudo python setup.py install` to install the package for all users)
|
||||
|
||||
Then import the package:
|
||||
```python
|
||||
import {{{packageName}}}
|
||||
```
|
||||
|
||||
## Getting Started
|
||||
|
||||
Please follow the [installation procedure](#installation--usage) and then run the following:
|
||||
|
||||
{{> README_common }}
|
@ -0,0 +1,111 @@
|
||||
```python
|
||||
{{#with apiInfo}}{{#each apis}}{{#unless hasMore}}{{#if hasHttpSignatureMethods}}import datetime{{/if}}{{/unless}}{{/each}}{{/with}}
|
||||
import time
|
||||
import {{{packageName}}}
|
||||
from pprint import pprint
|
||||
{{#with apiInfo}}
|
||||
{{#each apis}}
|
||||
{{#if @first}}
|
||||
from {{packageName}}.{{apiPackage}} import {{classVarName}}
|
||||
{{#each imports}}
|
||||
{{{import}}}
|
||||
{{/each}}
|
||||
{{#with operations}}
|
||||
{{#each operation}}
|
||||
{{#if @first}}
|
||||
{{> doc_auth_partial}}
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with {{{packageName}}}.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = {{classVarName}}.{{{classname}}}(api_client)
|
||||
{{#each allParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{#unless required}} (optional){{/unless}}{{#if defaultValue}} (default to {{{.}}}){{/if}}
|
||||
{{/each}}
|
||||
|
||||
try:
|
||||
{{#if summary}} # {{{summary}}}
|
||||
{{/if}} {{#if returnType}}api_response = {{/if}}api_instance.{{{operationId}}}({{#each allParams}}{{#if required}}{{paramName}}{{/if}}{{#unless required}}{{paramName}}={{paramName}}{{/unless}}{{#if hasMore}}, {{/if}}{{/each}}){{#if returnType}}
|
||||
pprint(api_response){{/if}}
|
||||
except {{{packageName}}}.ApiException as e:
|
||||
print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e)
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
{{/with}}
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
{{/with}}
|
||||
```
|
||||
|
||||
## Documentation for API Endpoints
|
||||
|
||||
All URIs are relative to *{{basePath}}*
|
||||
|
||||
Class | Method | HTTP request | Description
|
||||
------------ | ------------- | ------------- | -------------
|
||||
{{#with apiInfo}}{{#each apis}}{{#with operations}}{{#each operation}}*{{classname}}* | [**{{operationId}}**]({{apiDocPath}}{{classname}}.md#{{operationIdLowerCase}}) | **{{httpMethod}}** {{path}} | {{#if summary}}{{summary}}{{/if}}
|
||||
{{/each}}{{/with}}{{/each}}{{/with}}
|
||||
|
||||
## Documentation For Models
|
||||
|
||||
{{#each models}}{{#with model}} - [{{{classname}}}]({{modelDocPath}}{{{classname}}}.md)
|
||||
{{/with}}{{/each}}
|
||||
|
||||
## Documentation For Authorization
|
||||
|
||||
{{#unless authMethods}}
|
||||
All endpoints do not require authorization.
|
||||
{{/unless}}
|
||||
{{#each authMethods}}
|
||||
{{#if @last}} Authentication schemes defined for the API:{{/if}}
|
||||
## {{{name}}}
|
||||
|
||||
{{#if isApiKey}}
|
||||
- **Type**: API key
|
||||
- **API key parameter name**: {{{keyParamName}}}
|
||||
- **Location**: {{#if isKeyInQuery}}URL query string{{/if}}{{#if isKeyInHeader}}HTTP header{{/if}}
|
||||
{{/if}}
|
||||
{{#if isBasic}}
|
||||
{{#if isBasicBasic}}
|
||||
- **Type**: HTTP basic authentication
|
||||
{{/if}}
|
||||
{{#if isBasicBearer}}
|
||||
- **Type**: Bearer authentication{{#if bearerFormat}} ({{{bearerFormat}}}){{/if}}
|
||||
{{/if}}
|
||||
{{#if isHttpSignature}}
|
||||
- **Type**: HTTP signature authentication
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{#if isOAuth}}
|
||||
- **Type**: OAuth
|
||||
- **Flow**: {{{flow}}}
|
||||
- **Authorization URL**: {{{authorizationUrl}}}
|
||||
- **Scopes**: {{#unless scopes}}N/A{{/unless}}
|
||||
{{#each scopes}} - **{{{scope}}}**: {{{description}}}
|
||||
{{/each}}
|
||||
{{/if}}
|
||||
|
||||
{{/each}}
|
||||
|
||||
## Author
|
||||
|
||||
{{#with apiInfo}}{{#each apis}}{{#unless hasMore}}{{infoEmail}}
|
||||
{{/unless}}{{/each}}{{/with}}
|
||||
|
||||
## Notes for Large OpenAPI documents
|
||||
If the OpenAPI document is large, imports in {{{packageName}}}.apis and {{{packageName}}}.models may fail with a
|
||||
RecursionError indicating the maximum recursion limit has been exceeded. In that case, there are a couple of solutions:
|
||||
|
||||
Solution 1:
|
||||
Use specific imports for apis and models like:
|
||||
- `from {{{packageName}}}.{{apiPackage}}.default_api import DefaultApi`
|
||||
- `from {{{packageName}}}.{{modelPackage}}.pet import Pet`
|
||||
|
||||
Solution 1:
|
||||
Before importing the package, adjust the maximum recursion limit as shown below:
|
||||
```
|
||||
import sys
|
||||
sys.setrecursionlimit(1500)
|
||||
import {{{packageName}}}
|
||||
from {{{packageName}}}.apis import *
|
||||
from {{{packageName}}}.models import *
|
||||
```
|
@ -0,0 +1,43 @@
|
||||
# {{{projectName}}}
|
||||
{{#if appDescription}}
|
||||
{{{appDescription}}}
|
||||
{{/if}}
|
||||
|
||||
The `{{packageName}}` package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:
|
||||
|
||||
- API version: {{appVersion}}
|
||||
- Package version: {{packageVersion}}
|
||||
{{#unless hideGenerationTimestamp}}
|
||||
- Build date: {{generatedDate}}
|
||||
{{/unless}}
|
||||
- Build package: {{generatorClass}}
|
||||
{{#if infoUrl}}
|
||||
For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}})
|
||||
{{/if}}
|
||||
|
||||
## Requirements.
|
||||
|
||||
Python >= 3.6
|
||||
|
||||
## Installation & Usage
|
||||
|
||||
This python library package is generated without supporting files like setup.py or requirements files
|
||||
|
||||
To be able to use it, you will need these dependencies in your own package that uses this library:
|
||||
|
||||
* urllib3 >= 1.15
|
||||
* certifi
|
||||
* python-dateutil
|
||||
{{#if asyncio}}
|
||||
* aiohttp
|
||||
{{/if}}
|
||||
{{#if tornado}}
|
||||
* tornado>=4.2,<5
|
||||
{{/if}}
|
||||
|
||||
## Getting Started
|
||||
|
||||
In your own code, to use this library to connect and interact with {{{projectName}}},
|
||||
you can run the following:
|
||||
|
||||
{{> README_common }}
|
@ -0,0 +1,9 @@
|
||||
{{#with apiInfo}}
|
||||
{{#each apis}}
|
||||
{{#if @first}}
|
||||
# do not import all apis into this module because that uses a lot of memory and stack frames
|
||||
# if you need the ability to import all apis from one package, import them with
|
||||
# from {{packageName}}.apis import {{classname}}
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
{{/with}}
|
@ -0,0 +1,24 @@
|
||||
{{#with apiInfo}}
|
||||
{{#each apis}}
|
||||
{{#if @first}}
|
||||
# coding: utf-8
|
||||
|
||||
# flake8: noqa
|
||||
|
||||
# Import all APIs into this package.
|
||||
# If you have many APIs here with many many models used in each API this may
|
||||
# raise a `RecursionError`.
|
||||
# In order to avoid this, import only the API that you directly need like:
|
||||
#
|
||||
# from {{packagename}}.{{apiPackage}}.{{classVarName}} import {{classname}}
|
||||
#
|
||||
# or import this package, but before doing it, use:
|
||||
#
|
||||
# import sys
|
||||
# sys.setrecursionlimit(n)
|
||||
|
||||
# Import APIs into API package:
|
||||
{{/if}}
|
||||
from {{packageName}}.{{apiPackage}}.{{classVarName}} import {{classname}}
|
||||
{{/each}}
|
||||
{{/with}}
|
@ -0,0 +1,5 @@
|
||||
# we can not import model classes here because that would create a circular
|
||||
# reference which would not work in python2
|
||||
# do not import all models into this module because that uses a lot of memory and stack frames
|
||||
# if you need the ability to import all models from one package, import them with
|
||||
# from {{packageName}}.models import ModelA, ModelB
|
@ -0,0 +1,18 @@
|
||||
# coding: utf-8
|
||||
|
||||
# flake8: noqa
|
||||
|
||||
# import all models into this package
|
||||
# if you have many models here with many references from one model to another this may
|
||||
# raise a RecursionError
|
||||
# to avoid this, import only the models that you directly need like:
|
||||
# from from {{packageName}}.{{modelPackage}}.pet import Pet
|
||||
# or import this package, but before doing it, use:
|
||||
# import sys
|
||||
# sys.setrecursionlimit(n)
|
||||
|
||||
{{#each models}}
|
||||
{{#with model}}
|
||||
from {{packageName}}.{{modelPackage}}.{{classFilename}} import {{classname}}
|
||||
{{/with}}
|
||||
{{/each}}
|
@ -0,0 +1,28 @@
|
||||
# coding: utf-8
|
||||
|
||||
# flake8: noqa
|
||||
|
||||
{{>partial_header}}
|
||||
|
||||
__version__ = "{{packageVersion}}"
|
||||
|
||||
# import ApiClient
|
||||
from {{packageName}}.api_client import ApiClient
|
||||
|
||||
# import Configuration
|
||||
from {{packageName}}.configuration import Configuration
|
||||
{{#if hasHttpSignatureMethods}}
|
||||
from {{packageName}}.signing import HttpSigningConfiguration
|
||||
{{/if}}
|
||||
|
||||
# import exceptions
|
||||
from {{packageName}}.exceptions import OpenApiException
|
||||
from {{packageName}}.exceptions import ApiAttributeError
|
||||
from {{packageName}}.exceptions import ApiTypeError
|
||||
from {{packageName}}.exceptions import ApiValueError
|
||||
from {{packageName}}.exceptions import ApiKeyError
|
||||
from {{packageName}}.exceptions import ApiException
|
||||
{{#if recursionLimit}}
|
||||
|
||||
__import__('sys').setrecursionlimit({{recursionLimit}})
|
||||
{{/if}}
|
@ -0,0 +1,26 @@
|
||||
# coding: utf-8
|
||||
|
||||
{{>partial_header}}
|
||||
|
||||
from {{packageName}}.api_client import ApiClient
|
||||
{{#with operations}}
|
||||
{{#each operation}}
|
||||
from {{packageName}}.api.{{classFilename}}_endpoints.{{operationId}} import {{operationIdCamelCase}}
|
||||
{{/each}}
|
||||
{{/with}}
|
||||
|
||||
|
||||
{{#with operations}}
|
||||
class {{classname}}(
|
||||
{{#each operation}}
|
||||
{{operationIdCamelCase}},
|
||||
{{/each}}
|
||||
ApiClient,
|
||||
):
|
||||
"""NOTE: This class is auto generated by OpenAPI Generator
|
||||
Ref: https://openapi-generator.tech
|
||||
|
||||
Do not edit the class manually.
|
||||
"""
|
||||
pass
|
||||
{{/with}}
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,212 @@
|
||||
# {{packageName}}.{{classname}}{{#if description}}
|
||||
{{description}}{{/if}}
|
||||
|
||||
All URIs are relative to *{{basePath}}*
|
||||
|
||||
Method | HTTP request | Description
|
||||
------------- | ------------- | -------------
|
||||
{{#with operations}}{{#each operation}}[**{{operationId}}**]({{classname}}.md#{{operationId}}) | **{{httpMethod}}** {{path}} | {{#if summary}}{{summary}}{{/if}}
|
||||
{{/each}}{{/with}}
|
||||
|
||||
{{#with operations}}
|
||||
{{#each operation}}
|
||||
# **{{{operationId}}}**
|
||||
> {{#if returnType}}{{{returnType}}} {{/if}}{{{operationId}}}({{#each requiredParams}}{{#unless defaultValue}}{{paramName}}{{#if hasMore}}, {{/if}}{{/unless}}{{/each}})
|
||||
|
||||
{{{summary}}}{{#if notes}}
|
||||
|
||||
{{{notes}}}{{/if}}
|
||||
|
||||
### Example
|
||||
|
||||
{{#if hasAuthMethods}}
|
||||
{{#each authMethods}}
|
||||
{{#if isBasic}}
|
||||
{{#if isBasicBasic}}
|
||||
* Basic Authentication ({{name}}):
|
||||
{{/if}}
|
||||
{{#if isBasicBearer}}
|
||||
* Bearer{{#if bearerFormat}} ({{{bearerFormat}}}){{/if}} Authentication ({{name}}):
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{#if isApiKey}}
|
||||
* Api Key Authentication ({{name}}):
|
||||
{{/if}}
|
||||
{{#if isOAuth}}
|
||||
* OAuth Authentication ({{name}}):
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
{{/if}}
|
||||
{{> api_doc_example }}
|
||||
### Parameters
|
||||
{{#if allParams}}
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
{{#with bodyParam}}
|
||||
{{baseName}} | typing.Union[{{#each content}}{{#unless @first}}, {{/unless}}{{this.schema.baseName}}{{/each}}{{#unless required}}, Unset]{{else}}]{{/unless}} | {{#if required}}required{{else}}optional, default is unset{{/if}} |
|
||||
{{/with}}
|
||||
{{#if queryParams}}
|
||||
query_params | RequestQueryParams | |
|
||||
{{/if}}
|
||||
{{#if headerParams}}
|
||||
header_params | RequestHeaderParams | |
|
||||
{{/if}}
|
||||
{{#if pathParams}}
|
||||
path_params | RequestPathParams | |
|
||||
{{/if}}
|
||||
{{#if cookieParams}}
|
||||
cookie_params | RequestCookieParams | |
|
||||
{{/if}}
|
||||
{{#with bodyParam}}
|
||||
{{#each content}}
|
||||
{{#if @first}}
|
||||
content_type | str | optional, default is '{{@key}}' | Selects the schema and serialization of the request body
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
{{/with}}
|
||||
{{#if produces}}
|
||||
accept_content_types | typing.Tuple[str] | default is ({{#each produces}}'{{this.mediaType}}', {{/each}}) | Tells the server the content type(s) that are accepted by the client
|
||||
{{/if}}
|
||||
{{#if servers}}
|
||||
host_index | typing.Optional[int] | default is None | Allows one to select a different host
|
||||
{{/if}}
|
||||
stream | bool | default is False | if True then the response.content will be streamed and loaded from a file like object. When downloading a file, set this to True to force the code to deserialize the content to a FileSchema file
|
||||
timeout | typing.Optional[typing.Union[int, typing.Tuple]] | default is None | the timeout used by the rest client
|
||||
skip_deserialization | bool | default is False | when True, headers and body will be unset and an instance of api_client.ApiResponseWithoutDeserialization will be returned
|
||||
{{#with bodyParam}}
|
||||
|
||||
### body
|
||||
{{#each content}}
|
||||
{{#with this.schema}}
|
||||
{{> api_doc_schema_type_hint }}
|
||||
{{/with}}
|
||||
{{/each}}
|
||||
{{/with}}
|
||||
{{#if queryParams}}
|
||||
|
||||
### query_params
|
||||
#### RequestQueryParams
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
{{#each queryParams}}
|
||||
{{baseName}} | {{#with schema}}{{baseName}}{{/with}} | | {{#unless required}}optional{{/unless}}
|
||||
{{/each}}
|
||||
|
||||
{{#each queryParams}}
|
||||
{{#with schema}}
|
||||
{{> api_doc_schema_type_hint }}
|
||||
{{/with}}
|
||||
{{/each}}
|
||||
{{/if}}
|
||||
{{#if headerParams}}
|
||||
|
||||
### header_params
|
||||
#### RequestHeaderParams
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
{{#each headerParams}}
|
||||
{{baseName}} | {{#with schema}}{{baseName}}{{/with}} | | {{#unless required}}optional{{/unless}}
|
||||
{{/each}}
|
||||
{{#each headerParams}}
|
||||
{{#with schema}}
|
||||
{{> api_doc_schema_type_hint }}
|
||||
{{/with}}
|
||||
{{/each}}
|
||||
{{/if}}
|
||||
{{#if pathParams}}
|
||||
|
||||
### path_params
|
||||
#### RequestPathParams
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
{{#each pathParams}}
|
||||
{{baseName}} | {{#with schema}}{{baseName}}{{/with}} | | {{#unless required}}optional{{/unless}}
|
||||
{{/each}}
|
||||
{{#each pathParams}}
|
||||
{{#with schema}}
|
||||
{{> api_doc_schema_type_hint }}
|
||||
{{/with}}
|
||||
{{/each}}
|
||||
{{/if}}
|
||||
{{#if cookieParams}}
|
||||
|
||||
### cookie_params
|
||||
#### RequestCookieParams
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
{{#each cookieParams}}
|
||||
{{baseName}} | {{#with schema}}{{baseName}}{{/with}} | | {{#unless required}}optional{{/unless}}
|
||||
{{/each}}
|
||||
{{#each cookieParams}}
|
||||
{{#with schema}}
|
||||
{{> api_doc_schema_type_hint }}
|
||||
{{/with}}
|
||||
{{/each}}
|
||||
{{/if}}
|
||||
{{else}}
|
||||
This endpoint does not need any parameter.
|
||||
{{/if}}
|
||||
|
||||
### Return Types, Responses
|
||||
|
||||
Code | Class | Description
|
||||
------------- | ------------- | -------------
|
||||
n/a | api_client.ApiResponseWithoutDeserialization | When skip_deserialization is True this response is returned
|
||||
{{#each responses}}
|
||||
{{#if isDefault}}
|
||||
default | ApiResponseForDefault | {{message}} {{description}}
|
||||
{{else}}
|
||||
{{code}} | ApiResponseFor{{code}} | {{message}} {{description}}
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
{{#each responses}}
|
||||
{{#if isDefault}}
|
||||
|
||||
#### ApiResponseForDefault
|
||||
{{else}}
|
||||
|
||||
#### ApiResponseFor{{code}}
|
||||
{{/if}}
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
response | urllib3.HTTPResponse | Raw response |
|
||||
body | {{#unless content}}Unset{{else}}typing.Union[{{#each content}}{{this.schema.baseName}}, {{/each}}]{{/unless}} | {{#unless content}}body was not defined{{/unless}} |
|
||||
headers | {{#unless responseHeaders}}Unset{{else}}ResponseHeadersFor{{code}}{{/unless}} | {{#unless responseHeaders}}headers were not defined{{/unless}} |
|
||||
{{#each content}}
|
||||
{{#with this.schema}}
|
||||
{{> api_doc_schema_type_hint }}
|
||||
{{/with}}
|
||||
{{/each}}
|
||||
{{#if responseHeaders}}
|
||||
#### ResponseHeadersFor{{code}}
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
{{#each responseHeaders}}
|
||||
{{baseName}} | {{#with schema}}{{baseName}}{{/with}} | | {{#unless required}}optional{{/unless}}
|
||||
{{/each}}
|
||||
{{#each responseHeaders}}
|
||||
{{#with schema}}
|
||||
{{> api_doc_schema_type_hint }}
|
||||
{{/with}}
|
||||
{{/each}}
|
||||
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
|
||||
|
||||
{{#if returnType}}{{#if returnTypeIsPrimitive}}**{{{returnType}}}**{{/if}}{{#unless returnTypeIsPrimitive}}[**{{{returnType}}}**]({{returnBaseType}}.md){{/unless}}{{/if}}{{#unless returnType}}void (empty response body){{/unless}}
|
||||
|
||||
### Authorization
|
||||
|
||||
{{#unless authMethods}}No authorization required{{/unless}}{{#each authMethods}}[{{{name}}}](../README.md#{{{name}}}){{#unless @last}}, {{/unless}}{{/each}}
|
||||
|
||||
[[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)
|
||||
|
||||
{{/each}}
|
||||
{{/with}}
|
@ -0,0 +1,163 @@
|
||||
```python
|
||||
import {{{packageName}}}
|
||||
from {{packageName}}.{{apiPackage}} import {{classVarName}}
|
||||
{{#each imports}}
|
||||
{{{.}}}
|
||||
{{/each}}
|
||||
from pprint import pprint
|
||||
{{> doc_auth_partial}}
|
||||
# Enter a context with an instance of the API client
|
||||
with {{{packageName}}}.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = {{classVarName}}.{{{classname}}}(api_client)
|
||||
{{#if requiredParams}}
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
{{#if pathParams}}
|
||||
path_params = {
|
||||
{{#each pathParams}}
|
||||
{{#if required}}
|
||||
'{{baseName}}': {{{example}}},
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
}
|
||||
{{/if}}
|
||||
{{#if queryParams}}
|
||||
query_params = {
|
||||
{{#each queryParams}}
|
||||
{{#if required}}
|
||||
'{{baseName}}': {{{example}}},
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
}
|
||||
{{/if}}
|
||||
{{#if cookieParams}}
|
||||
cookie_params = {
|
||||
{{#each cookieParams}}
|
||||
{{#if required}}
|
||||
'{{baseName}}': {{{example}}},
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
}
|
||||
{{/if}}
|
||||
{{#if headerParams}}
|
||||
header_params = {
|
||||
{{#each headerParams}}
|
||||
{{#if required}}
|
||||
'{{baseName}}': {{{example}}},
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
}
|
||||
{{/if}}
|
||||
{{#with bodyParam}}
|
||||
{{#if required}}
|
||||
body = {{{example}}}
|
||||
{{/if}}
|
||||
{{/with}}
|
||||
try:
|
||||
{{#if summary}}
|
||||
# {{{summary}}}
|
||||
{{/if}}
|
||||
api_response = api_instance.{{{operationId}}}(
|
||||
{{#if pathParams}}
|
||||
path_params=path_params,
|
||||
{{/if}}
|
||||
{{#if queryParams}}
|
||||
query_params=query_params,
|
||||
{{/if}}
|
||||
{{#if headerParams}}
|
||||
header_params=header_params,
|
||||
{{/if}}
|
||||
{{#if cookieParams}}
|
||||
cookie_params=cookie_params,
|
||||
{{/if}}
|
||||
{{#with bodyParam}}
|
||||
{{#if required}}
|
||||
body=body,
|
||||
{{/if}}
|
||||
{{/with}}
|
||||
)
|
||||
{{#if returnType}}
|
||||
pprint(api_response)
|
||||
{{/if}}
|
||||
except {{{packageName}}}.ApiException as e:
|
||||
print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e)
|
||||
{{/if}}
|
||||
{{#if optionalParams}}
|
||||
|
||||
# example passing only optional values
|
||||
{{#if pathParams}}
|
||||
path_params = {
|
||||
{{#each pathParams}}
|
||||
'{{baseName}}': {{{example}}},
|
||||
{{/each}}
|
||||
}
|
||||
{{/if}}
|
||||
{{#if queryParams}}
|
||||
query_params = {
|
||||
{{#each queryParams}}
|
||||
'{{baseName}}': {{{example}}},
|
||||
{{/each}}
|
||||
}
|
||||
{{/if}}
|
||||
{{#if cookieParams}}
|
||||
cookie_params = {
|
||||
{{#each cookieParams}}
|
||||
'{{baseName}}': {{{example}}},
|
||||
{{/each}}
|
||||
}
|
||||
{{/if}}
|
||||
{{#if headerParams}}
|
||||
header_params = {
|
||||
{{#each headerParams}}
|
||||
'{{baseName}}': {{{example}}},
|
||||
{{/each}}
|
||||
}
|
||||
{{/if}}
|
||||
{{#with bodyParam}}
|
||||
body = {{{example}}}
|
||||
{{/with}}
|
||||
try:
|
||||
{{#if summary}}
|
||||
# {{{summary}}}
|
||||
{{/if}}
|
||||
api_response = api_instance.{{{operationId}}}(
|
||||
{{#if pathParams}}
|
||||
path_params=path_params,
|
||||
{{/if}}
|
||||
{{#if queryParams}}
|
||||
query_params=query_params,
|
||||
{{/if}}
|
||||
{{#if headerParams}}
|
||||
header_params=header_params,
|
||||
{{/if}}
|
||||
{{#if cookieParams}}
|
||||
cookie_params=cookie_params,
|
||||
{{/if}}
|
||||
{{#if bodyParam}}
|
||||
body=body,
|
||||
{{/if}}
|
||||
)
|
||||
{{#if returnType}}
|
||||
pprint(api_response)
|
||||
{{/if}}
|
||||
except {{{packageName}}}.ApiException as e:
|
||||
print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e)
|
||||
{{/if}}
|
||||
{{#unless requiredParams}}
|
||||
{{#unless optionalParams}}
|
||||
|
||||
# example, this endpoint has no required or optional parameters
|
||||
try:
|
||||
{{#if summary}}
|
||||
# {{{summary}}}
|
||||
{{/if}}
|
||||
api_response = api_instance.{{{operationId}}}()
|
||||
{{#if returnType}}
|
||||
pprint(api_response)
|
||||
{{/if}}
|
||||
except {{{packageName}}}.ApiException as e:
|
||||
print("Exception when calling {{classname}}->{{operationId}}: %s\n" % e)
|
||||
{{/unless}}
|
||||
{{/unless}}
|
||||
```
|
@ -0,0 +1,10 @@
|
||||
|
||||
#### {{baseName}}
|
||||
{{#if complexType}}
|
||||
Type | Description | Notes
|
||||
------------- | ------------- | -------------
|
||||
[**{{dataType}}**]({{complexType}}.md) | {{description}} | {{#if isReadOnly}}[readonly] {{/if}}
|
||||
|
||||
{{else}}
|
||||
{{> schema_doc }}
|
||||
{{/if}}
|
@ -0,0 +1,34 @@
|
||||
# coding: utf-8
|
||||
|
||||
{{>partial_header}}
|
||||
|
||||
import unittest
|
||||
|
||||
import {{packageName}}
|
||||
from {{packageName}}.api.{{classFilename}} import {{classname}} # noqa: E501
|
||||
|
||||
|
||||
class {{#with operations}}Test{{classname}}(unittest.TestCase):
|
||||
"""{{classname}} unit test stubs"""
|
||||
|
||||
def setUp(self):
|
||||
self.api = {{classname}}() # noqa: E501
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
||||
{{#each operation}}
|
||||
def test_{{operationId}}(self):
|
||||
"""Test case for {{{operationId}}}
|
||||
|
||||
{{#if summary}}
|
||||
{{{summary}}} # noqa: E501
|
||||
{{/if}}
|
||||
"""
|
||||
pass
|
||||
|
||||
{{/each}}
|
||||
{{/with}}
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
@ -0,0 +1,636 @@
|
||||
# coding: utf-8
|
||||
|
||||
{{>partial_header}}
|
||||
|
||||
import copy
|
||||
import logging
|
||||
{{#unless asyncio}}
|
||||
import multiprocessing
|
||||
{{/unless}}
|
||||
import sys
|
||||
import urllib3
|
||||
|
||||
from http import client as http_client
|
||||
from {{packageName}}.exceptions import ApiValueError
|
||||
|
||||
|
||||
JSON_SCHEMA_VALIDATION_KEYWORDS = {
|
||||
'multipleOf', 'maximum', 'exclusiveMaximum',
|
||||
'minimum', 'exclusiveMinimum', 'maxLength',
|
||||
'minLength', 'pattern', 'maxItems', 'minItems',
|
||||
'uniqueItems', 'maxProperties', 'minProperties',
|
||||
}
|
||||
|
||||
class Configuration(object):
|
||||
"""NOTE: This class is auto generated by OpenAPI Generator
|
||||
|
||||
Ref: https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
|
||||
:param host: Base url
|
||||
:param api_key: Dict to store API key(s).
|
||||
Each entry in the dict specifies an API key.
|
||||
The dict key is the name of the security scheme in the OAS specification.
|
||||
The dict value is the API key secret.
|
||||
:param api_key_prefix: Dict to store API prefix (e.g. Bearer)
|
||||
The dict key is the name of the security scheme in the OAS specification.
|
||||
The dict value is an API key prefix when generating the auth data.
|
||||
:param username: Username for HTTP basic authentication
|
||||
:param password: Password for HTTP basic authentication
|
||||
:param discard_unknown_keys: Boolean value indicating whether to discard
|
||||
unknown properties. A server may send a response that includes additional
|
||||
properties that are not known by the client in the following scenarios:
|
||||
1. The OpenAPI document is incomplete, i.e. it does not match the server
|
||||
implementation.
|
||||
2. The client was generated using an older version of the OpenAPI document
|
||||
and the server has been upgraded since then.
|
||||
If a schema in the OpenAPI document defines the additionalProperties attribute,
|
||||
then all undeclared properties received by the server are injected into the
|
||||
additional properties map. In that case, there are undeclared properties, and
|
||||
nothing to discard.
|
||||
:param disabled_client_side_validations (string): Comma-separated list of
|
||||
JSON schema validation keywords to disable JSON schema structural validation
|
||||
rules. The following keywords may be specified: multipleOf, maximum,
|
||||
exclusiveMaximum, minimum, exclusiveMinimum, maxLength, minLength, pattern,
|
||||
maxItems, minItems.
|
||||
By default, the validation is performed for data generated locally by the client
|
||||
and data received from the server, independent of any validation performed by
|
||||
the server side. If the input data does not satisfy the JSON schema validation
|
||||
rules specified in the OpenAPI document, an exception is raised.
|
||||
If disabled_client_side_validations is set, structural validation is
|
||||
disabled. This can be useful to troubleshoot data validation problem, such as
|
||||
when the OpenAPI document validation rules do not match the actual API data
|
||||
received by the server.
|
||||
{{#if hasHttpSignatureMethods}}
|
||||
:param signing_info: Configuration parameters for the HTTP signature security scheme.
|
||||
Must be an instance of {{{packageName}}}.signing.HttpSigningConfiguration
|
||||
{{/if}}
|
||||
:param server_index: Index to servers configuration.
|
||||
:param server_variables: Mapping with string values to replace variables in
|
||||
templated server configuration. The validation of enums is performed for
|
||||
variables with defined enum values before.
|
||||
:param server_operation_index: Mapping from operation ID to an index to server
|
||||
configuration.
|
||||
:param server_operation_variables: Mapping from operation ID to a mapping with
|
||||
string values to replace variables in templated server configuration.
|
||||
The validation of enums is performed for variables with defined enum values before.
|
||||
|
||||
{{#if hasAuthMethods}}
|
||||
:Example:
|
||||
{{#if hasApiKeyMethods}}
|
||||
|
||||
API Key Authentication Example.
|
||||
Given the following security scheme in the OpenAPI specification:
|
||||
components:
|
||||
securitySchemes:
|
||||
cookieAuth: # name for the security scheme
|
||||
type: apiKey
|
||||
in: cookie
|
||||
name: JSESSIONID # cookie name
|
||||
|
||||
You can programmatically set the cookie:
|
||||
|
||||
conf = {{{packageName}}}.Configuration(
|
||||
api_key={'cookieAuth': 'abc123'}
|
||||
api_key_prefix={'cookieAuth': 'JSESSIONID'}
|
||||
)
|
||||
|
||||
The following cookie will be added to the HTTP request:
|
||||
Cookie: JSESSIONID abc123
|
||||
{{/if}}
|
||||
{{#if hasHttpBasicMethods}}
|
||||
|
||||
HTTP Basic Authentication Example.
|
||||
Given the following security scheme in the OpenAPI specification:
|
||||
components:
|
||||
securitySchemes:
|
||||
http_basic_auth:
|
||||
type: http
|
||||
scheme: basic
|
||||
|
||||
Configure API client with HTTP basic authentication:
|
||||
|
||||
conf = {{{packageName}}}.Configuration(
|
||||
username='the-user',
|
||||
password='the-password',
|
||||
)
|
||||
|
||||
{{/if}}
|
||||
{{#if hasHttpSignatureMethods}}
|
||||
|
||||
HTTP Signature Authentication Example.
|
||||
Given the following security scheme in the OpenAPI specification:
|
||||
components:
|
||||
securitySchemes:
|
||||
http_basic_auth:
|
||||
type: http
|
||||
scheme: signature
|
||||
|
||||
Configure API client with HTTP signature authentication. Use the 'hs2019' signature scheme,
|
||||
sign the HTTP requests with the RSA-SSA-PSS signature algorithm, and set the expiration time
|
||||
of the signature to 5 minutes after the signature has been created.
|
||||
Note you can use the constants defined in the {{{packageName}}}.signing module, and you can
|
||||
also specify arbitrary HTTP headers to be included in the HTTP signature, except for the
|
||||
'Authorization' header, which is used to carry the signature.
|
||||
|
||||
One may be tempted to sign all headers by default, but in practice it rarely works.
|
||||
This is beccause explicit proxies, transparent proxies, TLS termination endpoints or
|
||||
load balancers may add/modify/remove headers. Include the HTTP headers that you know
|
||||
are not going to be modified in transit.
|
||||
|
||||
conf = {{{packageName}}}.Configuration(
|
||||
signing_info = {{{packageName}}}.signing.HttpSigningConfiguration(
|
||||
key_id = 'my-key-id',
|
||||
private_key_path = 'rsa.pem',
|
||||
signing_scheme = {{{packageName}}}.signing.SCHEME_HS2019,
|
||||
signing_algorithm = {{{packageName}}}.signing.ALGORITHM_RSASSA_PSS,
|
||||
signed_headers = [{{{packageName}}}.signing.HEADER_REQUEST_TARGET,
|
||||
{{{packageName}}}.signing.HEADER_CREATED,
|
||||
{{{packageName}}}.signing.HEADER_EXPIRES,
|
||||
{{{packageName}}}.signing.HEADER_HOST,
|
||||
{{{packageName}}}.signing.HEADER_DATE,
|
||||
{{{packageName}}}.signing.HEADER_DIGEST,
|
||||
'Content-Type',
|
||||
'User-Agent'
|
||||
],
|
||||
signature_max_validity = datetime.timedelta(minutes=5)
|
||||
)
|
||||
)
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
"""
|
||||
|
||||
_default = None
|
||||
|
||||
def __init__(self, host=None,
|
||||
api_key=None, api_key_prefix=None,
|
||||
username=None, password=None,
|
||||
discard_unknown_keys=False,
|
||||
disabled_client_side_validations="",
|
||||
{{#if hasHttpSignatureMethods}}
|
||||
signing_info=None,
|
||||
{{/if}}
|
||||
server_index=None, server_variables=None,
|
||||
server_operation_index=None, server_operation_variables=None,
|
||||
):
|
||||
"""Constructor
|
||||
"""
|
||||
self._base_path = "{{{basePath}}}" if host is None else host
|
||||
"""Default Base url
|
||||
"""
|
||||
self.server_index = 0 if server_index is None and host is None else server_index
|
||||
self.server_operation_index = server_operation_index or {}
|
||||
"""Default server index
|
||||
"""
|
||||
self.server_variables = server_variables or {}
|
||||
self.server_operation_variables = server_operation_variables or {}
|
||||
"""Default server variables
|
||||
"""
|
||||
self.temp_folder_path = None
|
||||
"""Temp file folder for downloading files
|
||||
"""
|
||||
# Authentication Settings
|
||||
self.api_key = {}
|
||||
if api_key:
|
||||
self.api_key = api_key
|
||||
"""dict to store API key(s)
|
||||
"""
|
||||
self.api_key_prefix = {}
|
||||
if api_key_prefix:
|
||||
self.api_key_prefix = api_key_prefix
|
||||
"""dict to store API prefix (e.g. Bearer)
|
||||
"""
|
||||
self.refresh_api_key_hook = None
|
||||
"""function hook to refresh API key if expired
|
||||
"""
|
||||
self.username = username
|
||||
"""Username for HTTP basic authentication
|
||||
"""
|
||||
self.password = password
|
||||
"""Password for HTTP basic authentication
|
||||
"""
|
||||
self.discard_unknown_keys = discard_unknown_keys
|
||||
self.disabled_client_side_validations = disabled_client_side_validations
|
||||
{{#if hasHttpSignatureMethods}}
|
||||
if signing_info is not None:
|
||||
signing_info.host = host
|
||||
self.signing_info = signing_info
|
||||
"""The HTTP signing configuration
|
||||
"""
|
||||
{{/if}}
|
||||
{{#if hasOAuthMethods}}
|
||||
self.access_token = None
|
||||
"""access token for OAuth/Bearer
|
||||
"""
|
||||
{{/if}}
|
||||
{{#unless hasOAuthMethods}}
|
||||
{{#if hasBearerMethods}}
|
||||
self.access_token = None
|
||||
"""access token for OAuth/Bearer
|
||||
"""
|
||||
{{/if}}
|
||||
{{/unless}}
|
||||
self.logger = {}
|
||||
"""Logging Settings
|
||||
"""
|
||||
self.logger["package_logger"] = logging.getLogger("{{packageName}}")
|
||||
self.logger["urllib3_logger"] = logging.getLogger("urllib3")
|
||||
self.logger_format = '%(asctime)s %(levelname)s %(message)s'
|
||||
"""Log format
|
||||
"""
|
||||
self.logger_stream_handler = None
|
||||
"""Log stream handler
|
||||
"""
|
||||
self.logger_file_handler = None
|
||||
"""Log file handler
|
||||
"""
|
||||
self.logger_file = None
|
||||
"""Debug file location
|
||||
"""
|
||||
self.debug = False
|
||||
"""Debug switch
|
||||
"""
|
||||
|
||||
self.verify_ssl = True
|
||||
"""SSL/TLS verification
|
||||
Set this to false to skip verifying SSL certificate when calling API
|
||||
from https server.
|
||||
"""
|
||||
self.ssl_ca_cert = None
|
||||
"""Set this to customize the certificate file to verify the peer.
|
||||
"""
|
||||
self.cert_file = None
|
||||
"""client certificate file
|
||||
"""
|
||||
self.key_file = None
|
||||
"""client key file
|
||||
"""
|
||||
self.assert_hostname = None
|
||||
"""Set this to True/False to enable/disable SSL hostname verification.
|
||||
"""
|
||||
|
||||
{{#if asyncio}}
|
||||
self.connection_pool_maxsize = 100
|
||||
"""This value is passed to the aiohttp to limit simultaneous connections.
|
||||
Default values is 100, None means no-limit.
|
||||
"""
|
||||
{{/if}}
|
||||
{{#unless asyncio}}
|
||||
self.connection_pool_maxsize = multiprocessing.cpu_count() * 5
|
||||
"""urllib3 connection pool's maximum number of connections saved
|
||||
per pool. urllib3 uses 1 connection as default value, but this is
|
||||
not the best value when you are making a lot of possibly parallel
|
||||
requests to the same host, which is often the case here.
|
||||
cpu_count * 5 is used as default value to increase performance.
|
||||
"""
|
||||
{{/unless}}
|
||||
|
||||
self.proxy = None
|
||||
"""Proxy URL
|
||||
"""
|
||||
self.proxy_headers = None
|
||||
"""Proxy headers
|
||||
"""
|
||||
self.safe_chars_for_path_param = ''
|
||||
"""Safe chars for path_param
|
||||
"""
|
||||
self.retries = None
|
||||
"""Adding retries to override urllib3 default value 3
|
||||
"""
|
||||
# Enable client side validation
|
||||
self.client_side_validation = True
|
||||
|
||||
# Options to pass down to the underlying urllib3 socket
|
||||
self.socket_options = None
|
||||
|
||||
def __deepcopy__(self, memo):
|
||||
cls = self.__class__
|
||||
result = cls.__new__(cls)
|
||||
memo[id(self)] = result
|
||||
for k, v in self.__dict__.items():
|
||||
if k not in ('logger', 'logger_file_handler'):
|
||||
setattr(result, k, copy.deepcopy(v, memo))
|
||||
# shallow copy of loggers
|
||||
result.logger = copy.copy(self.logger)
|
||||
# use setters to configure loggers
|
||||
result.logger_file = self.logger_file
|
||||
result.debug = self.debug
|
||||
return result
|
||||
|
||||
def __setattr__(self, name, value):
|
||||
object.__setattr__(self, name, value)
|
||||
if name == 'disabled_client_side_validations':
|
||||
s = set(filter(None, value.split(',')))
|
||||
for v in s:
|
||||
if v not in JSON_SCHEMA_VALIDATION_KEYWORDS:
|
||||
raise ApiValueError(
|
||||
"Invalid keyword: '{0}''".format(v))
|
||||
self._disabled_client_side_validations = s
|
||||
{{#if hasHttpSignatureMethods}}
|
||||
if name == "signing_info" and value is not None:
|
||||
# Ensure the host paramater from signing info is the same as
|
||||
# Configuration.host.
|
||||
value.host = self.host
|
||||
{{/if}}
|
||||
|
||||
@classmethod
|
||||
def set_default(cls, default):
|
||||
"""Set default instance of configuration.
|
||||
|
||||
It stores default configuration, which can be
|
||||
returned by get_default_copy method.
|
||||
|
||||
:param default: object of Configuration
|
||||
"""
|
||||
cls._default = copy.deepcopy(default)
|
||||
|
||||
@classmethod
|
||||
def get_default_copy(cls):
|
||||
"""Return new instance of configuration.
|
||||
|
||||
This method returns newly created, based on default constructor,
|
||||
object of Configuration class or returns a copy of default
|
||||
configuration passed by the set_default method.
|
||||
|
||||
:return: The configuration object.
|
||||
"""
|
||||
if cls._default is not None:
|
||||
return copy.deepcopy(cls._default)
|
||||
return Configuration()
|
||||
|
||||
@property
|
||||
def logger_file(self):
|
||||
"""The logger file.
|
||||
|
||||
If the logger_file is None, then add stream handler and remove file
|
||||
handler. Otherwise, add file handler and remove stream handler.
|
||||
|
||||
:param value: The logger_file path.
|
||||
:type: str
|
||||
"""
|
||||
return self.__logger_file
|
||||
|
||||
@logger_file.setter
|
||||
def logger_file(self, value):
|
||||
"""The logger file.
|
||||
|
||||
If the logger_file is None, then add stream handler and remove file
|
||||
handler. Otherwise, add file handler and remove stream handler.
|
||||
|
||||
:param value: The logger_file path.
|
||||
:type: str
|
||||
"""
|
||||
self.__logger_file = value
|
||||
if self.__logger_file:
|
||||
# If set logging file,
|
||||
# then add file handler and remove stream handler.
|
||||
self.logger_file_handler = logging.FileHandler(self.__logger_file)
|
||||
self.logger_file_handler.setFormatter(self.logger_formatter)
|
||||
for _, logger in self.logger.items():
|
||||
logger.addHandler(self.logger_file_handler)
|
||||
|
||||
@property
|
||||
def debug(self):
|
||||
"""Debug status
|
||||
|
||||
:param value: The debug status, True or False.
|
||||
:type: bool
|
||||
"""
|
||||
return self.__debug
|
||||
|
||||
@debug.setter
|
||||
def debug(self, value):
|
||||
"""Debug status
|
||||
|
||||
:param value: The debug status, True or False.
|
||||
:type: bool
|
||||
"""
|
||||
self.__debug = value
|
||||
if self.__debug:
|
||||
# if debug status is True, turn on debug logging
|
||||
for _, logger in self.logger.items():
|
||||
logger.setLevel(logging.DEBUG)
|
||||
# turn on http_client debug
|
||||
http_client.HTTPConnection.debuglevel = 1
|
||||
else:
|
||||
# if debug status is False, turn off debug logging,
|
||||
# setting log level to default `logging.WARNING`
|
||||
for _, logger in self.logger.items():
|
||||
logger.setLevel(logging.WARNING)
|
||||
# turn off http_client debug
|
||||
http_client.HTTPConnection.debuglevel = 0
|
||||
|
||||
@property
|
||||
def logger_format(self):
|
||||
"""The logger format.
|
||||
|
||||
The logger_formatter will be updated when sets logger_format.
|
||||
|
||||
:param value: The format string.
|
||||
:type: str
|
||||
"""
|
||||
return self.__logger_format
|
||||
|
||||
@logger_format.setter
|
||||
def logger_format(self, value):
|
||||
"""The logger format.
|
||||
|
||||
The logger_formatter will be updated when sets logger_format.
|
||||
|
||||
:param value: The format string.
|
||||
:type: str
|
||||
"""
|
||||
self.__logger_format = value
|
||||
self.logger_formatter = logging.Formatter(self.__logger_format)
|
||||
|
||||
def get_api_key_with_prefix(self, identifier, alias=None):
|
||||
"""Gets API key (with prefix if set).
|
||||
|
||||
:param identifier: The identifier of apiKey.
|
||||
:param alias: The alternative identifier of apiKey.
|
||||
:return: The token for api key authentication.
|
||||
"""
|
||||
if self.refresh_api_key_hook is not None:
|
||||
self.refresh_api_key_hook(self)
|
||||
key = self.api_key.get(identifier, self.api_key.get(alias) if alias is not None else None)
|
||||
if key:
|
||||
prefix = self.api_key_prefix.get(identifier)
|
||||
if prefix:
|
||||
return "%s %s" % (prefix, key)
|
||||
else:
|
||||
return key
|
||||
|
||||
def get_basic_auth_token(self):
|
||||
"""Gets HTTP basic authentication header (string).
|
||||
|
||||
:return: The token for basic HTTP authentication.
|
||||
"""
|
||||
username = ""
|
||||
if self.username is not None:
|
||||
username = self.username
|
||||
password = ""
|
||||
if self.password is not None:
|
||||
password = self.password
|
||||
return urllib3.util.make_headers(
|
||||
basic_auth=username + ':' + password
|
||||
).get('authorization')
|
||||
|
||||
def auth_settings(self):
|
||||
"""Gets Auth Settings dict for api client.
|
||||
|
||||
:return: The Auth Settings information dict.
|
||||
"""
|
||||
auth = {}
|
||||
{{#each authMethods}}
|
||||
{{#if isApiKey}}
|
||||
if '{{name}}' in self.api_key{{#each vendorExtensions.x-auth-id-alias}} or '{{.}}' in self.api_key{{/each}}:
|
||||
auth['{{name}}'] = {
|
||||
'type': 'api_key',
|
||||
'in': {{#if isKeyInCookie}}'cookie'{{/if}}{{#if isKeyInHeader}}'header'{{/if}}{{#if isKeyInQuery}}'query'{{/if}},
|
||||
'key': '{{keyParamName}}',
|
||||
'value': self.get_api_key_with_prefix(
|
||||
'{{name}}',{{#each vendorExtensions.x-auth-id-alias}}
|
||||
alias='{{.}}',{{/each}}
|
||||
),
|
||||
}
|
||||
{{/if}}
|
||||
{{#if isBasic}}
|
||||
{{#if isBasicBasic}}
|
||||
if self.username is not None and self.password is not None:
|
||||
auth['{{name}}'] = {
|
||||
'type': 'basic',
|
||||
'in': 'header',
|
||||
'key': 'Authorization',
|
||||
'value': self.get_basic_auth_token()
|
||||
}
|
||||
{{/if}}
|
||||
{{#if isBasicBearer}}
|
||||
if self.access_token is not None:
|
||||
auth['{{name}}'] = {
|
||||
'type': 'bearer',
|
||||
'in': 'header',
|
||||
{{#if bearerFormat}}
|
||||
'format': '{{{bearerFormat}}}',
|
||||
{{/if}}
|
||||
'key': 'Authorization',
|
||||
'value': 'Bearer ' + self.access_token
|
||||
}
|
||||
{{/if}}
|
||||
{{#if isHttpSignature}}
|
||||
if self.signing_info is not None:
|
||||
auth['{{name}}'] = {
|
||||
'type': 'http-signature',
|
||||
'in': 'header',
|
||||
'key': 'Authorization',
|
||||
'value': None # Signature headers are calculated for every HTTP request
|
||||
}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{#if isOAuth}}
|
||||
if self.access_token is not None:
|
||||
auth['{{name}}'] = {
|
||||
'type': 'oauth2',
|
||||
'in': 'header',
|
||||
'key': 'Authorization',
|
||||
'value': 'Bearer ' + self.access_token
|
||||
}
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
return auth
|
||||
|
||||
def to_debug_report(self):
|
||||
"""Gets the essential information for debugging.
|
||||
|
||||
:return: The report for debugging.
|
||||
"""
|
||||
return "Python SDK Debug Report:\n"\
|
||||
"OS: {env}\n"\
|
||||
"Python Version: {pyversion}\n"\
|
||||
"Version of the API: {{version}}\n"\
|
||||
"SDK Package Version: {{packageVersion}}".\
|
||||
format(env=sys.platform, pyversion=sys.version)
|
||||
|
||||
def get_host_settings(self):
|
||||
"""Gets an array of host settings
|
||||
|
||||
:return: An array of host settings
|
||||
"""
|
||||
return [
|
||||
{{#each servers}}
|
||||
{
|
||||
'url': "{{{url}}}",
|
||||
'description': "{{{description}}}{{#unless description}}No description provided{{/unless}}",
|
||||
{{#each variables}}
|
||||
{{#if @first}}
|
||||
'variables': {
|
||||
{{/if}}
|
||||
'{{{name}}}': {
|
||||
'description': "{{{description}}}{{#unless description}}No description provided{{/unless}}",
|
||||
'default_value': "{{{defaultValue}}}",
|
||||
{{#each enumValues}}
|
||||
{{#if @first}}
|
||||
'enum_values': [
|
||||
{{/if}}
|
||||
"{{{.}}}"{{#unless @last}},{{/unless}}
|
||||
{{#if @last}}
|
||||
]
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
}{{#unless @last}},{{/unless}}
|
||||
{{#if @last}}
|
||||
}
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
}{{#unless @last}},{{/unless}}
|
||||
{{/each}}
|
||||
]
|
||||
|
||||
def get_host_from_settings(self, index, variables=None, servers=None):
|
||||
"""Gets host URL based on the index and variables
|
||||
:param index: array index of the host settings
|
||||
:param variables: hash of variable and the corresponding value
|
||||
:param servers: an array of host settings or None
|
||||
:return: URL based on host settings
|
||||
"""
|
||||
if index is None:
|
||||
return self._base_path
|
||||
|
||||
variables = {} if variables is None else variables
|
||||
servers = self.get_host_settings() if servers is None else servers
|
||||
|
||||
try:
|
||||
server = servers[index]
|
||||
except IndexError:
|
||||
raise ValueError(
|
||||
"Invalid index {0} when selecting the host settings. "
|
||||
"Must be less than {1}".format(index, len(servers)))
|
||||
|
||||
url = server['url']
|
||||
|
||||
# go through variables and replace placeholders
|
||||
for variable_name, variable in server.get('variables', {}).items():
|
||||
used_value = variables.get(
|
||||
variable_name, variable['default_value'])
|
||||
|
||||
if 'enum_values' in variable \
|
||||
and used_value not in variable['enum_values']:
|
||||
raise ValueError(
|
||||
"The variable `{0}` in the host URL has invalid value "
|
||||
"{1}. Must be {2}.".format(
|
||||
variable_name, variables[variable_name],
|
||||
variable['enum_values']))
|
||||
|
||||
url = url.replace("{" + variable_name + "}", used_value)
|
||||
|
||||
return url
|
||||
|
||||
@property
|
||||
def host(self):
|
||||
"""Return generated host."""
|
||||
return self.get_host_from_settings(self.server_index, variables=self.server_variables)
|
||||
|
||||
@host.setter
|
||||
def host(self, value):
|
||||
"""Fix base path."""
|
||||
self._base_path = value
|
||||
self.server_index = None
|
@ -0,0 +1,109 @@
|
||||
# Defining the host is optional and defaults to {{{basePath}}}
|
||||
# See configuration.py for a list of all supported configuration parameters.
|
||||
configuration = {{{packageName}}}.Configuration(
|
||||
host = "{{{basePath}}}"
|
||||
)
|
||||
|
||||
{{#if hasAuthMethods}}
|
||||
# The client must configure the authentication and authorization parameters
|
||||
# in accordance with the API server security policy.
|
||||
# Examples for each auth method are provided below, use the example that
|
||||
# satisfies your auth use case.
|
||||
{{#each authMethods}}
|
||||
{{#if isBasic}}
|
||||
{{#if isBasicBasic}}
|
||||
|
||||
# Configure HTTP basic authorization: {{{name}}}
|
||||
configuration = {{{packageName}}}.Configuration(
|
||||
username = 'YOUR_USERNAME',
|
||||
password = 'YOUR_PASSWORD'
|
||||
)
|
||||
{{/if}}
|
||||
{{#if isBasicBearer}}
|
||||
|
||||
# Configure Bearer authorization{{#if bearerFormat}} ({{{bearerFormat}}}){{/if}}: {{{name}}}
|
||||
configuration = {{{packageName}}}.Configuration(
|
||||
access_token = 'YOUR_BEARER_TOKEN'
|
||||
)
|
||||
{{/if}}
|
||||
{{#if isHttpSignature}}
|
||||
|
||||
# Configure HTTP message signature: {{{name}}}
|
||||
# The HTTP Signature Header mechanism that can be used by a client to
|
||||
# authenticate the sender of a message and ensure that particular headers
|
||||
# have not been modified in transit.
|
||||
#
|
||||
# You can specify the signing key-id, private key path, signing scheme,
|
||||
# signing algorithm, list of signed headers and signature max validity.
|
||||
# The 'key_id' parameter is an opaque string that the API server can use
|
||||
# to lookup the client and validate the signature.
|
||||
# The 'private_key_path' parameter should be the path to a file that
|
||||
# contains a DER or base-64 encoded private key.
|
||||
# The 'private_key_passphrase' parameter is optional. Set the passphrase
|
||||
# if the private key is encrypted.
|
||||
# The 'signed_headers' parameter is used to specify the list of
|
||||
# HTTP headers included when generating the signature for the message.
|
||||
# You can specify HTTP headers that you want to protect with a cryptographic
|
||||
# signature. Note that proxies may add, modify or remove HTTP headers
|
||||
# for legitimate reasons, so you should only add headers that you know
|
||||
# will not be modified. For example, if you want to protect the HTTP request
|
||||
# body, you can specify the Digest header. In that case, the client calculates
|
||||
# the digest of the HTTP request body and includes the digest in the message
|
||||
# signature.
|
||||
# The 'signature_max_validity' parameter is optional. It is configured as a
|
||||
# duration to express when the signature ceases to be valid. The client calculates
|
||||
# the expiration date every time it generates the cryptographic signature
|
||||
# of an HTTP request. The API server may have its own security policy
|
||||
# that controls the maximum validity of the signature. The client max validity
|
||||
# must be lower than the server max validity.
|
||||
# The time on the client and server must be synchronized, otherwise the
|
||||
# server may reject the client signature.
|
||||
#
|
||||
# The client must use a combination of private key, signing scheme,
|
||||
# signing algorithm and hash algorithm that matches the security policy of
|
||||
# the API server.
|
||||
#
|
||||
# See {{{packageName}}}.signing for a list of all supported parameters.
|
||||
configuration = {{{packageName}}}.Configuration(
|
||||
host = "{{{basePath}}}",
|
||||
signing_info = {{{packageName}}}.signing.HttpSigningConfiguration(
|
||||
key_id = 'my-key-id',
|
||||
private_key_path = 'private_key.pem',
|
||||
private_key_passphrase = 'YOUR_PASSPHRASE',
|
||||
signing_scheme = {{{packageName}}}.signing.SCHEME_HS2019,
|
||||
signing_algorithm = {{{packageName}}}.signing.ALGORITHM_ECDSA_MODE_FIPS_186_3,
|
||||
hash_algorithm = {{{packageName}}}.signing.SCHEME_RSA_SHA256,
|
||||
signed_headers = [
|
||||
{{{packageName}}}.signing.HEADER_REQUEST_TARGET,
|
||||
{{{packageName}}}.signing.HEADER_CREATED,
|
||||
{{{packageName}}}.signing.HEADER_EXPIRES,
|
||||
{{{packageName}}}.signing.HEADER_HOST,
|
||||
{{{packageName}}}.signing.HEADER_DATE,
|
||||
{{{packageName}}}.signing.HEADER_DIGEST,
|
||||
'Content-Type',
|
||||
'Content-Length',
|
||||
'User-Agent'
|
||||
],
|
||||
signature_max_validity = datetime.timedelta(minutes=5)
|
||||
)
|
||||
)
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{#if isApiKey}}
|
||||
|
||||
# Configure API key authorization: {{{name}}}
|
||||
configuration.api_key['{{{name}}}'] = 'YOUR_API_KEY'
|
||||
|
||||
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
|
||||
# configuration.api_key_prefix['{{name}}'] = 'Bearer'
|
||||
{{/if}}
|
||||
{{#if isOAuth}}
|
||||
|
||||
# Configure OAuth2 access token for authorization: {{{name}}}
|
||||
configuration = {{{packageName}}}.Configuration(
|
||||
host = "{{{basePath}}}"
|
||||
)
|
||||
configuration.access_token = 'YOUR_ACCESS_TOKEN'
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
{{/if}}
|
@ -0,0 +1,549 @@
|
||||
# coding: utf-8
|
||||
|
||||
{{>partial_header}}
|
||||
|
||||
from dataclasses import dataclass
|
||||
import re # noqa: F401
|
||||
import sys # noqa: F401
|
||||
import typing
|
||||
import urllib3
|
||||
{{#with operation}}
|
||||
{{#or headerParams bodyParam produces}}
|
||||
from urllib3._collections import HTTPHeaderDict
|
||||
{{/or}}
|
||||
{{/with}}
|
||||
|
||||
from {{packageName}} import api_client, exceptions
|
||||
{{> model_templates/imports_schema_types }}
|
||||
{{> model_templates/imports_schemas }}
|
||||
|
||||
{{#with operation}}
|
||||
{{#if queryParams}}
|
||||
# query params
|
||||
{{#each queryParams}}
|
||||
{{#with schema}}
|
||||
{{> model_templates/schema }}
|
||||
{{/with}}
|
||||
{{/each}}
|
||||
RequestRequiredQueryParams = typing.TypedDict(
|
||||
'RequestRequiredQueryParams',
|
||||
{
|
||||
{{#each queryParams}}
|
||||
{{#if required}}
|
||||
'{{baseName}}': {{#with schema}}{{baseName}},{{/with}}
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
}
|
||||
)
|
||||
RequestOptionalQueryParams = typing.TypedDict(
|
||||
'RequestOptionalQueryParams',
|
||||
{
|
||||
{{#each queryParams}}
|
||||
{{#unless required}}
|
||||
'{{baseName}}': {{#with schema}}{{baseName}},{{/with}}
|
||||
{{/unless}}
|
||||
{{/each}}
|
||||
},
|
||||
total=False
|
||||
)
|
||||
|
||||
|
||||
class RequestQueryParams(RequestRequiredQueryParams, RequestOptionalQueryParams):
|
||||
pass
|
||||
|
||||
|
||||
{{#each queryParams}}
|
||||
{{> endpoint_parameter }}
|
||||
{{/each}}
|
||||
{{/if}}
|
||||
{{#if headerParams}}
|
||||
# header params
|
||||
{{#each headerParams}}
|
||||
{{#with schema}}
|
||||
{{> model_templates/schema }}
|
||||
{{/with}}
|
||||
{{/each}}
|
||||
RequestRequiredHeaderParams = typing.TypedDict(
|
||||
'RequestRequiredHeaderParams',
|
||||
{
|
||||
{{#each headerParams}}
|
||||
{{#if required}}
|
||||
'{{baseName}}': {{#with schema}}{{baseName}},{{/with}}
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
}
|
||||
)
|
||||
RequestOptionalHeaderParams = typing.TypedDict(
|
||||
'RequestOptionalHeaderParams',
|
||||
{
|
||||
{{#each headerParams}}
|
||||
{{#unless required}}
|
||||
'{{baseName}}': {{#with schema}}{{baseName}},{{/with}}
|
||||
{{/unless}}
|
||||
{{/each}}
|
||||
},
|
||||
total=False
|
||||
)
|
||||
|
||||
|
||||
class RequestHeaderParams(RequestRequiredHeaderParams, RequestOptionalHeaderParams):
|
||||
pass
|
||||
|
||||
|
||||
{{#each headerParams}}
|
||||
{{> endpoint_parameter }}
|
||||
{{/each}}
|
||||
{{/if}}
|
||||
{{#if pathParams}}
|
||||
# path params
|
||||
{{#each pathParams}}
|
||||
{{#with schema}}
|
||||
{{> model_templates/schema }}
|
||||
{{/with}}
|
||||
{{/each}}
|
||||
RequestRequiredPathParams = typing.TypedDict(
|
||||
'RequestRequiredPathParams',
|
||||
{
|
||||
{{#each pathParams}}
|
||||
{{#if required}}
|
||||
'{{baseName}}': {{#with schema}}{{baseName}},{{/with}}
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
}
|
||||
)
|
||||
RequestOptionalPathParams = typing.TypedDict(
|
||||
'RequestOptionalPathParams',
|
||||
{
|
||||
{{#each pathParams}}
|
||||
{{#unless required}}
|
||||
'{{baseName}}': {{#with schema}}{{baseName}},{{/with}}
|
||||
{{/unless}}
|
||||
{{/each}}
|
||||
},
|
||||
total=False
|
||||
)
|
||||
|
||||
|
||||
class RequestPathParams(RequestRequiredPathParams, RequestOptionalPathParams):
|
||||
pass
|
||||
|
||||
|
||||
{{#each pathParams}}
|
||||
{{> endpoint_parameter }}
|
||||
{{/each}}
|
||||
{{/if}}
|
||||
{{#if cookieParams}}
|
||||
# cookie params
|
||||
{{#each cookieParams}}
|
||||
{{#with schema}}
|
||||
{{> model_templates/schema }}
|
||||
{{/with}}
|
||||
{{/each}}
|
||||
RequestRequiredCookieParams = typing.TypedDict(
|
||||
'RequestRequiredCookieParams',
|
||||
{
|
||||
{{#each cookieParams}}
|
||||
{{#if required}}
|
||||
'{{baseName}}': {{#with schema}}{{baseName}},{{/with}}
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
}
|
||||
)
|
||||
RequestOptionalCookieParams = typing.TypedDict(
|
||||
'RequestOptionalCookieParams',
|
||||
{
|
||||
{{#each cookieParams}}
|
||||
{{#unless required}}
|
||||
'{{baseName}}': {{#with schema}}{{baseName}},{{/with}}
|
||||
{{/unless}}
|
||||
{{/each}}
|
||||
},
|
||||
total=False
|
||||
)
|
||||
|
||||
|
||||
class RequestCookieParams(RequestRequiredCookieParams, RequestOptionalCookieParams):
|
||||
pass
|
||||
|
||||
|
||||
{{#each cookieParams}}
|
||||
{{> endpoint_parameter }}
|
||||
{{/each}}
|
||||
{{/if}}
|
||||
{{#with bodyParam}}
|
||||
# body param
|
||||
{{#each content}}
|
||||
{{#with this.schema}}
|
||||
{{> model_templates/schema }}
|
||||
{{/with}}
|
||||
{{/each}}
|
||||
|
||||
|
||||
request_body_{{paramName}} = api_client.RequestBody(
|
||||
content={
|
||||
{{#each content}}
|
||||
'{{@key}}': api_client.MediaType(
|
||||
schema={{this.schema.baseName}}),
|
||||
{{/each}}
|
||||
},
|
||||
{{#if required}}
|
||||
required=True,
|
||||
{{/if}}
|
||||
)
|
||||
{{/with}}
|
||||
_path = '{{{path}}}'
|
||||
_method = '{{httpMethod}}'
|
||||
{{#each authMethods}}
|
||||
{{#if @first}}
|
||||
_auth = [
|
||||
{{/if}}
|
||||
'{{name}}',
|
||||
{{#if @last}}
|
||||
]
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
{{#each servers}}
|
||||
{{#if @first}}
|
||||
_servers = (
|
||||
{{/if}}
|
||||
{
|
||||
'url': "{{{url}}}",
|
||||
'description': "{{{description}}}{{#unless description}}No description provided{{/unless}}",
|
||||
{{#each variables}}
|
||||
{{#if @first}}
|
||||
'variables': {
|
||||
{{/if}}
|
||||
'{{{name}}}': {
|
||||
'description': "{{{description}}}{{#unless description}}No description provided{{/unless}}",
|
||||
'default_value': "{{{defaultValue}}}",
|
||||
{{#each enumValues}}
|
||||
{{#if @first}}
|
||||
'enum_values': [
|
||||
{{/if}}
|
||||
"{{{.}}}"{{#unless @last}},{{/unless}}
|
||||
{{#if @last}}
|
||||
]
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
}{{#unless @last}},{{/unless}}
|
||||
{{#if @last}}
|
||||
}
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
},
|
||||
{{#if @last}}
|
||||
)
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
{{#each responses}}
|
||||
{{#each responseHeaders}}
|
||||
{{#with schema}}
|
||||
{{> model_templates/schema }}
|
||||
{{/with}}
|
||||
{{paramName}}_parameter = api_client.HeaderParameter(
|
||||
name="{{baseName}}",
|
||||
{{#if style}}
|
||||
style=api_client.ParameterStyle.{{style}},
|
||||
{{/if}}
|
||||
{{#if schema}}
|
||||
{{#with schema}}
|
||||
schema={{baseName}},
|
||||
{{/with}}
|
||||
{{/if}}
|
||||
{{#if required}}
|
||||
required=True,
|
||||
{{/if}}
|
||||
{{#if isExplode}}
|
||||
explode=True,
|
||||
{{/if}}
|
||||
)
|
||||
{{/each}}
|
||||
{{#each content}}
|
||||
{{#with this.schema}}
|
||||
{{> model_templates/schema }}
|
||||
{{/with}}
|
||||
{{/each}}
|
||||
{{#if responseHeaders}}
|
||||
ResponseHeadersFor{{code}} = typing.TypedDict(
|
||||
'ResponseHeadersFor{{code}}',
|
||||
{
|
||||
{{#each responseHeaders}}
|
||||
'{{baseName}}': {{#with schema}}{{baseName}},{{/with}}
|
||||
{{/each}}
|
||||
}
|
||||
)
|
||||
{{/if}}
|
||||
|
||||
|
||||
@dataclass
|
||||
{{#if isDefault}}
|
||||
class ApiResponseForDefault(api_client.ApiResponse):
|
||||
{{else}}
|
||||
class ApiResponseFor{{code}}(api_client.ApiResponse):
|
||||
{{/if}}
|
||||
response: urllib3.HTTPResponse
|
||||
{{#and responseHeaders content}}
|
||||
body: typing.Union[
|
||||
{{#each content}}
|
||||
{{this.schema.baseName}},
|
||||
{{/each}}
|
||||
]
|
||||
headers: ResponseHeadersFor{{code}}
|
||||
{{else}}
|
||||
{{#or responseHeaders content}}
|
||||
{{#if responseHeaders}}
|
||||
headers: ResponseHeadersFor{{code}}
|
||||
body: Unset = unset
|
||||
{{else}}
|
||||
body: typing.Union[
|
||||
{{#each content}}
|
||||
{{this.schema.baseName}},
|
||||
{{/each}}
|
||||
]
|
||||
headers: Unset = unset
|
||||
{{/if}}
|
||||
{{/or}}
|
||||
{{/and}}
|
||||
{{#unless responseHeaders}}
|
||||
{{#unless content}}
|
||||
body: Unset = unset
|
||||
headers: Unset = unset
|
||||
{{/unless}}
|
||||
{{/unless}}
|
||||
|
||||
|
||||
{{#if isDefault}}
|
||||
_response_for_default = api_client.OpenApiResponse(
|
||||
response_cls=ApiResponseForDefault,
|
||||
{{else}}
|
||||
_response_for_{{code}} = api_client.OpenApiResponse(
|
||||
response_cls=ApiResponseFor{{code}},
|
||||
{{/if}}
|
||||
{{#each content}}
|
||||
{{#if @first}}
|
||||
content={
|
||||
{{/if}}
|
||||
'{{@key}}': api_client.MediaType(
|
||||
schema={{this.schema.baseName}}),
|
||||
{{#if @last}}
|
||||
},
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
{{#if responseHeaders}}
|
||||
headers=[
|
||||
{{#each responseHeaders}}
|
||||
{{paramName}}_parameter,
|
||||
{{/each}}
|
||||
]
|
||||
{{/if}}
|
||||
)
|
||||
{{/each}}
|
||||
_status_code_to_response = {
|
||||
{{#each responses}}
|
||||
{{#if isDefault}}
|
||||
'default': _response_for_default,
|
||||
{{else}}
|
||||
'{{code}}': _response_for_{{code}},
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
}
|
||||
{{#each produces}}
|
||||
{{#if @first}}
|
||||
_all_accept_content_types = (
|
||||
{{/if}}
|
||||
'{{this.mediaType}}',
|
||||
{{#if @last}}
|
||||
)
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
|
||||
|
||||
class {{operationIdCamelCase}}(api_client.Api):
|
||||
|
||||
def {{operationId}}(
|
||||
self: api_client.Api,
|
||||
{{#if bodyParam}}
|
||||
{{#with bodyParam}}
|
||||
{{baseName}}: typing.Union[{{#each content}}{{#unless @first}}, {{/unless}}{{this.schema.baseName}}{{/each}}{{#unless required}}, Unset] = unset{{else}}]{{/unless}},
|
||||
{{/with}}
|
||||
{{/if}}
|
||||
{{#if queryParams}}
|
||||
query_params: RequestQueryParams = frozendict(),
|
||||
{{/if}}
|
||||
{{#if headerParams}}
|
||||
header_params: RequestHeaderParams = frozendict(),
|
||||
{{/if}}
|
||||
{{#if pathParams}}
|
||||
path_params: RequestPathParams = frozendict(),
|
||||
{{/if}}
|
||||
{{#if cookieParams}}
|
||||
cookie_params: RequestCookieParams = frozendict(),
|
||||
{{/if}}
|
||||
{{#with bodyParam}}
|
||||
{{#each content}}
|
||||
{{#if @first}}
|
||||
content_type: str = '{{@key}}',
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
{{/with}}
|
||||
{{#if produces}}
|
||||
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
|
||||
{{/if}}
|
||||
{{#if servers}}
|
||||
host_index: typing.Optional[int] = None,
|
||||
{{/if}}
|
||||
stream: bool = False,
|
||||
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
|
||||
skip_deserialization: bool = False,
|
||||
) -> typing.Union[
|
||||
{{#each responses}}
|
||||
{{#if isDefault}}
|
||||
ApiResponseForDefault,
|
||||
{{else}}
|
||||
{{#if is2xx}}
|
||||
ApiResponseFor{{code}},
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
api_client.ApiResponseWithoutDeserialization
|
||||
]:
|
||||
"""
|
||||
{{#if summary}}
|
||||
{{summary}}
|
||||
{{/if}}
|
||||
:param skip_deserialization: If true then api_response.response will be set but
|
||||
api_response.body and api_response.headers will not be deserialized into schema
|
||||
class instances
|
||||
"""
|
||||
{{#if queryParams}}
|
||||
self._verify_typed_dict_inputs(RequestQueryParams, query_params)
|
||||
{{/if}}
|
||||
{{#if headerParams}}
|
||||
self._verify_typed_dict_inputs(RequestHeaderParams, header_params)
|
||||
{{/if}}
|
||||
{{#if pathParams}}
|
||||
self._verify_typed_dict_inputs(RequestPathParams, path_params)
|
||||
{{/if}}
|
||||
{{#if cookieParams}}
|
||||
self._verify_typed_dict_inputs(RequestCookieParams, cookie_params)
|
||||
{{/if}}
|
||||
{{#if pathParams}}
|
||||
|
||||
_path_params = {}
|
||||
for parameter in (
|
||||
{{#each pathParams}}
|
||||
request_path_{{paramName}},
|
||||
{{/each}}
|
||||
):
|
||||
parameter_data = path_params.get(parameter.name, unset)
|
||||
if parameter_data is unset:
|
||||
continue
|
||||
serialized_data = parameter.serialize(parameter_data)
|
||||
_path_params.update(serialized_data)
|
||||
{{/if}}
|
||||
{{#if queryParams}}
|
||||
|
||||
_query_params = []
|
||||
for parameter in (
|
||||
{{#each queryParams}}
|
||||
request_query_{{paramName}},
|
||||
{{/each}}
|
||||
):
|
||||
parameter_data = query_params.get(parameter.name, unset)
|
||||
if parameter_data is unset:
|
||||
continue
|
||||
serialized_data = parameter.serialize(parameter_data)
|
||||
_query_params.extend(serialized_data)
|
||||
{{/if}}
|
||||
{{#or headerParams bodyParam produces}}
|
||||
|
||||
_headers = HTTPHeaderDict()
|
||||
{{else}}
|
||||
{{/or}}
|
||||
{{#if headerParams}}
|
||||
for parameter in (
|
||||
{{#each headerParams}}
|
||||
request_header_{{paramName}},
|
||||
{{/each}}
|
||||
):
|
||||
parameter_data = header_params.get(parameter.name, unset)
|
||||
if parameter_data is unset:
|
||||
continue
|
||||
serialized_data = parameter.serialize(parameter_data)
|
||||
_headers.extend(serialized_data)
|
||||
{{/if}}
|
||||
# TODO add cookie handling
|
||||
{{#if produces}}
|
||||
if accept_content_types:
|
||||
for accept_content_type in accept_content_types:
|
||||
_headers.add('Accept', accept_content_type)
|
||||
{{/if}}
|
||||
{{#with bodyParam}}
|
||||
|
||||
{{#if required}}
|
||||
if body is unset:
|
||||
raise exceptions.ApiValueError(
|
||||
'The required body parameter has an invalid value of: unset. Set a valid value instead')
|
||||
{{/if}}
|
||||
_fields = None
|
||||
_body = None
|
||||
{{#if required}}
|
||||
{{> endpoint_body_serialization }}
|
||||
{{else}}
|
||||
if body is not unset:
|
||||
{{> endpoint_body_serialization }}
|
||||
{{/if}}
|
||||
{{/with}}
|
||||
{{#if servers}}
|
||||
|
||||
host = self.get_host('{{operationId}}', _servers, host_index)
|
||||
{{/if}}
|
||||
|
||||
response = self.api_client.call_api(
|
||||
resource_path=_path,
|
||||
method=_method,
|
||||
{{#if pathParams}}
|
||||
path_params=_path_params,
|
||||
{{/if}}
|
||||
{{#if queryParams}}
|
||||
query_params=tuple(_query_params),
|
||||
{{/if}}
|
||||
{{#or headerParams bodyParam produces}}
|
||||
headers=_headers,
|
||||
{{/or}}
|
||||
{{#if bodyParam}}
|
||||
fields=_fields,
|
||||
body=_body,
|
||||
{{/if}}
|
||||
{{#if hasAuthMethods}}
|
||||
auth_settings=_auth,
|
||||
{{/if}}
|
||||
{{#if servers}}
|
||||
host=host,
|
||||
{{/if}}
|
||||
stream=stream,
|
||||
timeout=timeout,
|
||||
)
|
||||
|
||||
if skip_deserialization:
|
||||
api_response = api_client.ApiResponseWithoutDeserialization(response=response)
|
||||
else:
|
||||
response_for_status = _status_code_to_response.get(str(response.status))
|
||||
if response_for_status:
|
||||
api_response = response_for_status.deserialize(response, self.api_client.configuration)
|
||||
else:
|
||||
{{#if hasDefaultResponse}}
|
||||
default_response = _status_code_to_response.get('default')
|
||||
if default_response:
|
||||
api_response = default_response.deserialize(response, self.api_client.configuration)
|
||||
else:
|
||||
api_response = api_client.ApiResponseWithoutDeserialization(response=response)
|
||||
{{else}}
|
||||
api_response = api_client.ApiResponseWithoutDeserialization(response=response)
|
||||
{{/if}}
|
||||
|
||||
if not 200 <= response.status <= 299:
|
||||
raise exceptions.ApiException(api_response=api_response)
|
||||
|
||||
return api_response
|
||||
{{/with}}
|
@ -0,0 +1,6 @@
|
||||
serialized_data = request_body_{{paramName}}.serialize(body, content_type)
|
||||
_headers.add('Content-Type', content_type)
|
||||
if 'fields' in serialized_data:
|
||||
_fields = serialized_data['fields']
|
||||
elif 'body' in serialized_data:
|
||||
_body = serialized_data['body']
|
@ -0,0 +1,17 @@
|
||||
request_{{#if isQueryParam}}query{{/if}}{{#if isPathParam}}path{{/if}}{{#if isHeaderParam}}header{{/if}}{{#if isCookieParam}}cookie{{/if}}_{{paramName}} = api_client.{{#if isQueryParam}}Query{{/if}}{{#if isPathParam}}Path{{/if}}{{#if isHeaderParam}}Header{{/if}}{{#if isCookieParam}}Cookie{{/if}}Parameter(
|
||||
name="{{baseName}}",
|
||||
{{#if style}}
|
||||
style=api_client.ParameterStyle.{{style}},
|
||||
{{/if}}
|
||||
{{#if schema}}
|
||||
{{#with schema}}
|
||||
schema={{baseName}},
|
||||
{{/with}}
|
||||
{{/if}}
|
||||
{{#if required}}
|
||||
required=True,
|
||||
{{/if}}
|
||||
{{#if isExplode}}
|
||||
explode=True,
|
||||
{{/if}}
|
||||
)
|
@ -0,0 +1,129 @@
|
||||
# coding: utf-8
|
||||
|
||||
{{>partial_header}}
|
||||
|
||||
|
||||
class OpenApiException(Exception):
|
||||
"""The base exception class for all OpenAPIExceptions"""
|
||||
|
||||
|
||||
class ApiTypeError(OpenApiException, TypeError):
|
||||
def __init__(self, msg, path_to_item=None, valid_classes=None,
|
||||
key_type=None):
|
||||
""" Raises an exception for TypeErrors
|
||||
|
||||
Args:
|
||||
msg (str): the exception message
|
||||
|
||||
Keyword Args:
|
||||
path_to_item (list): a list of keys an indices to get to the
|
||||
current_item
|
||||
None if unset
|
||||
valid_classes (tuple): the primitive classes that current item
|
||||
should be an instance of
|
||||
None if unset
|
||||
key_type (bool): False if our value is a value in a dict
|
||||
True if it is a key in a dict
|
||||
False if our item is an item in a list
|
||||
None if unset
|
||||
"""
|
||||
self.path_to_item = path_to_item
|
||||
self.valid_classes = valid_classes
|
||||
self.key_type = key_type
|
||||
full_msg = msg
|
||||
if path_to_item:
|
||||
full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
|
||||
super(ApiTypeError, self).__init__(full_msg)
|
||||
|
||||
|
||||
class ApiValueError(OpenApiException, ValueError):
|
||||
def __init__(self, msg, path_to_item=None):
|
||||
"""
|
||||
Args:
|
||||
msg (str): the exception message
|
||||
|
||||
Keyword Args:
|
||||
path_to_item (list) the path to the exception in the
|
||||
received_data dict. None if unset
|
||||
"""
|
||||
|
||||
self.path_to_item = path_to_item
|
||||
full_msg = msg
|
||||
if path_to_item:
|
||||
full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
|
||||
super(ApiValueError, self).__init__(full_msg)
|
||||
|
||||
|
||||
class ApiAttributeError(OpenApiException, AttributeError):
|
||||
def __init__(self, msg, path_to_item=None):
|
||||
"""
|
||||
Raised when an attribute reference or assignment fails.
|
||||
|
||||
Args:
|
||||
msg (str): the exception message
|
||||
|
||||
Keyword Args:
|
||||
path_to_item (None/list) the path to the exception in the
|
||||
received_data dict
|
||||
"""
|
||||
self.path_to_item = path_to_item
|
||||
full_msg = msg
|
||||
if path_to_item:
|
||||
full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
|
||||
super(ApiAttributeError, self).__init__(full_msg)
|
||||
|
||||
|
||||
class ApiKeyError(OpenApiException, KeyError):
|
||||
def __init__(self, msg, path_to_item=None):
|
||||
"""
|
||||
Args:
|
||||
msg (str): the exception message
|
||||
|
||||
Keyword Args:
|
||||
path_to_item (None/list) the path to the exception in the
|
||||
received_data dict
|
||||
"""
|
||||
self.path_to_item = path_to_item
|
||||
full_msg = msg
|
||||
if path_to_item:
|
||||
full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
|
||||
super(ApiKeyError, self).__init__(full_msg)
|
||||
|
||||
|
||||
class ApiException(OpenApiException):
|
||||
|
||||
def __init__(self, status=None, reason=None, api_response: '{{packageName}}.api_client.ApiResponse' = None):
|
||||
if api_response:
|
||||
self.status = api_response.response.status
|
||||
self.reason = api_response.response.reason
|
||||
self.body = api_response.response.data
|
||||
self.headers = api_response.response.getheaders()
|
||||
else:
|
||||
self.status = status
|
||||
self.reason = reason
|
||||
self.body = None
|
||||
self.headers = None
|
||||
|
||||
def __str__(self):
|
||||
"""Custom error messages for exception"""
|
||||
error_message = "({0})\n"\
|
||||
"Reason: {1}\n".format(self.status, self.reason)
|
||||
if self.headers:
|
||||
error_message += "HTTP response headers: {0}\n".format(
|
||||
self.headers)
|
||||
|
||||
if self.body:
|
||||
error_message += "HTTP response body: {0}\n".format(self.body)
|
||||
|
||||
return error_message
|
||||
|
||||
|
||||
def render_path(path_to_item):
|
||||
"""Returns a string representation of a path"""
|
||||
result = ""
|
||||
for pth in path_to_item:
|
||||
if isinstance(pth, int):
|
||||
result += "[{0}]".format(pth)
|
||||
else:
|
||||
result += "['{0}']".format(pth)
|
||||
return result
|
@ -0,0 +1,58 @@
|
||||
#!/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-pestore-perl "minor update" "gitlab.com"
|
||||
|
||||
git_user_id=$1
|
||||
git_repo_id=$2
|
||||
release_note=$3
|
||||
git_host=$4
|
||||
|
||||
if [ "$git_host" = "" ]; then
|
||||
git_host="{{{gitHost}}}"
|
||||
echo "[INFO] No command line input provided. Set \$git_host to $git_host"
|
||||
fi
|
||||
|
||||
if [ "$git_user_id" = "" ]; then
|
||||
git_user_id="{{{gitUserId}}}"
|
||||
echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
|
||||
fi
|
||||
|
||||
if [ "$git_repo_id" = "" ]; then
|
||||
git_repo_id="{{{gitRepoId}}}"
|
||||
echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
|
||||
fi
|
||||
|
||||
if [ "$release_note" = "" ]; then
|
||||
release_note="{{{releaseNote}}}"
|
||||
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://${git_host}/${git_user_id}/${git_repo_id}.git
|
||||
else
|
||||
git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${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://${git_host}/${git_user_id}/${git_repo_id}.git"
|
||||
git push origin master 2>&1 | grep -v 'To https'
|
||||
|
@ -0,0 +1,67 @@
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
|
||||
# C extensions
|
||||
*.so
|
||||
|
||||
# Distribution / packaging
|
||||
.Python
|
||||
env/
|
||||
build/
|
||||
develop-eggs/
|
||||
dist/
|
||||
downloads/
|
||||
eggs/
|
||||
.eggs/
|
||||
lib/
|
||||
lib64/
|
||||
parts/
|
||||
sdist/
|
||||
var/
|
||||
*.egg-info/
|
||||
.installed.cfg
|
||||
*.egg
|
||||
|
||||
# PyInstaller
|
||||
# Usually these files are written by a python script from a template
|
||||
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||
*.manifest
|
||||
*.spec
|
||||
|
||||
# Installer logs
|
||||
pip-log.txt
|
||||
pip-delete-this-directory.txt
|
||||
dev-requirements.txt.log
|
||||
|
||||
# Unit test / coverage reports
|
||||
htmlcov/
|
||||
.tox/
|
||||
.coverage
|
||||
.coverage.*
|
||||
.cache
|
||||
nosetests.xml
|
||||
coverage.xml
|
||||
*,cover
|
||||
.hypothesis/
|
||||
venv/
|
||||
.venv/
|
||||
.python-version
|
||||
.pytest_cache
|
||||
|
||||
# Translations
|
||||
*.mo
|
||||
*.pot
|
||||
|
||||
# Django stuff:
|
||||
*.log
|
||||
|
||||
# Sphinx documentation
|
||||
docs/_build/
|
||||
|
||||
# PyBuilder
|
||||
target/
|
||||
|
||||
#Ipython Notebook
|
||||
.ipynb_checkpoints
|
@ -0,0 +1,29 @@
|
||||
# ref: https://docs.gitlab.com/ee/ci/README.html
|
||||
|
||||
stages:
|
||||
- test
|
||||
|
||||
.tests:
|
||||
stage: test
|
||||
script:
|
||||
- pip install -r requirements.txt
|
||||
- pip install -r test-requirements.txt
|
||||
{{#if useNose}}
|
||||
- nosetests
|
||||
{{/if}}
|
||||
{{#unless useNose}}
|
||||
- pytest --cov={{{packageName}}}
|
||||
{{/unless}}
|
||||
|
||||
test-3.5:
|
||||
extends: .tests
|
||||
image: python:3.5-alpine
|
||||
test-3.6:
|
||||
extends: .tests
|
||||
image: python:3.6-alpine
|
||||
test-3.7:
|
||||
extends: .tests
|
||||
image: python:3.7-alpine
|
||||
test-3.8:
|
||||
extends: .tests
|
||||
image: python:3.8-alpine
|
@ -0,0 +1,17 @@
|
||||
# coding: utf-8
|
||||
|
||||
{{>partial_header}}
|
||||
|
||||
import re # noqa: F401
|
||||
import sys # noqa: F401
|
||||
import typing # noqa: F401
|
||||
|
||||
from frozendict import frozendict # noqa: F401
|
||||
|
||||
{{#each models}}
|
||||
{{#with model}}
|
||||
{{> model_templates/imports_schema_types }}
|
||||
{{> model_templates/schema }}
|
||||
{{> model_templates/imports_schemas }}
|
||||
{{/with}}
|
||||
{{/each}}
|
@ -0,0 +1,9 @@
|
||||
{{#each models}}
|
||||
{{#with model}}
|
||||
# {{classname}}
|
||||
{{> schema_doc }}
|
||||
{{/with}}
|
||||
{{/each}}
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
@ -0,0 +1,86 @@
|
||||
@classmethod
|
||||
@property
|
||||
def _composed_schemas(cls):
|
||||
# we need this here to make our import statements work
|
||||
# we must store _composed_schemas in here so the code is only run
|
||||
# when we invoke this method. If we kept this at the class
|
||||
# level we would get an error because the class level
|
||||
# code would be run when this module is imported, and these composed
|
||||
# classes don't exist yet because their module has not finished
|
||||
# loading
|
||||
{{#with composedSchemas}}
|
||||
{{#each allOf}}
|
||||
{{#unless complexType}}
|
||||
{{#unless isAnyType}}
|
||||
{{> model_templates/schema }}
|
||||
{{/unless}}
|
||||
{{/unless}}
|
||||
{{#if isAnyType}}
|
||||
{{#if this.classname}}{{classname}}{{else}}{{#if nameInSnakeCase}}{{name}}{{else}}{{baseName}}{{/if}}{{/if}} = AnyTypeSchema
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
{{#each oneOf}}
|
||||
{{#unless complexType}}
|
||||
{{#unless isAnyType}}
|
||||
{{> model_templates/schema }}
|
||||
{{/unless}}
|
||||
{{/unless}}
|
||||
{{#if isAnyType}}
|
||||
{{#if this.classname}}{{classname}}{{else}}{{#if nameInSnakeCase}}{{name}}{{else}}{{baseName}}{{/if}}{{/if}} = AnyTypeSchema
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
{{#each anyOf}}
|
||||
{{#unless complexType}}
|
||||
{{#unless isAnyType}}
|
||||
{{> model_templates/schema }}
|
||||
{{/unless}}
|
||||
{{/unless}}
|
||||
{{#if isAnyType}}
|
||||
{{#if this.classname}}{{classname}}{{else}}{{#if nameInSnakeCase}}{{name}}{{else}}{{baseName}}{{/if}}{{/if}} = AnyTypeSchema
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
{{/with}}
|
||||
return {
|
||||
'allOf': [
|
||||
{{#with composedSchemas}}
|
||||
{{#each allOf}}
|
||||
{{#if complexType}}
|
||||
{{complexType}},
|
||||
{{/if}}
|
||||
{{#unless complexType}}
|
||||
{{#if nameInSnakeCase}}{{name}}{{/if}}{{#unless nameInSnakeCase}}{{baseName}}{{/unless}},
|
||||
{{/unless}}
|
||||
{{/each}}
|
||||
],
|
||||
'oneOf': [
|
||||
{{#each oneOf}}
|
||||
{{#if complexType}}
|
||||
{{complexType}},
|
||||
{{/if}}
|
||||
{{#unless complexType}}
|
||||
{{#if isAnyType}}
|
||||
AnyTypeSchema,
|
||||
{{/if}}
|
||||
{{#unless isAnyType}}
|
||||
{{#if nameInSnakeCase}}{{name}}{{/if}}{{#unless nameInSnakeCase}}{{baseName}}{{/unless}},
|
||||
{{/unless}}
|
||||
{{/unless}}
|
||||
{{/each}}
|
||||
],
|
||||
'anyOf': [
|
||||
{{#each anyOf}}
|
||||
{{#if complexType}}
|
||||
{{complexType}},
|
||||
{{/if}}
|
||||
{{#unless complexType}}
|
||||
{{#if isAnyType}}
|
||||
AnyTypeSchema,
|
||||
{{/if}}
|
||||
{{#unless isAnyType}}
|
||||
{{#if nameInSnakeCase}}{{name}}{{/if}}{{#unless nameInSnakeCase}}{{baseName}}{{/unless}},
|
||||
{{/unless}}
|
||||
{{/unless}}
|
||||
{{/each}}
|
||||
{{/with}}
|
||||
],
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
{{#if getHasRequired}}
|
||||
_required_property_names = set((
|
||||
{{#each requiredVars}}
|
||||
'{{baseName}}',
|
||||
{{/each}}
|
||||
))
|
||||
{{/if}}
|
||||
{{#each vars}}
|
||||
{{#if complexType}}
|
||||
|
||||
@classmethod
|
||||
@property
|
||||
def {{baseName}}(cls) -> typing.Type['{{complexType}}']:
|
||||
return {{complexType}}
|
||||
{{else}}
|
||||
{{> model_templates/schema }}
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
{{#if getHasDiscriminatorWithNonEmptyMapping}}
|
||||
{{#with discriminator}}
|
||||
{{#each mappedModels}}
|
||||
{{#if @first}}
|
||||
|
||||
@classmethod
|
||||
@property
|
||||
def _discriminator(cls):
|
||||
return {
|
||||
'{{{propertyBaseName}}}': {
|
||||
{{/if}}
|
||||
'{{mappingName}}': {{{modelName}}},
|
||||
{{#if @last}}
|
||||
}
|
||||
}
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
{{/with}}
|
||||
{{/if}}
|
||||
{{#with additionalProperties}}
|
||||
{{#if complexType}}
|
||||
|
||||
@classmethod
|
||||
@property
|
||||
def _additional_properties(cls) -> typing.Type['{{complexType}}']:
|
||||
return {{complexType}}
|
||||
{{/if}}
|
||||
{{#unless complexType}}
|
||||
{{#unless isAnyType}}
|
||||
{{> model_templates/schema }}
|
||||
{{/unless}}
|
||||
{{/unless}}
|
||||
{{/with}}
|
||||
{{#unless additionalProperties}}
|
||||
_additional_properties = None
|
||||
{{/unless}}
|
@ -0,0 +1,12 @@
|
||||
_SchemaEnumMaker(
|
||||
enum_value_to_name={
|
||||
{{#if isNull}}
|
||||
None: "NONE",
|
||||
{{/if}}
|
||||
{{#with allowableValues}}
|
||||
{{#each enumVars}}
|
||||
{{{value}}}: "{{name}}",
|
||||
{{/each}}
|
||||
{{/with}}
|
||||
}
|
||||
),
|
@ -0,0 +1,16 @@
|
||||
{{#if isNull}}
|
||||
|
||||
@classmethod
|
||||
@property
|
||||
def NONE(cls):
|
||||
return cls._enum_by_value[None](None)
|
||||
{{/if}}
|
||||
{{#with allowableValues}}
|
||||
{{#each enumVars}}
|
||||
|
||||
@classmethod
|
||||
@property
|
||||
def {{name}}(cls):
|
||||
return cls._enum_by_value[{{{value}}}]({{{value}}})
|
||||
{{/each}}
|
||||
{{/with}}
|
@ -0,0 +1,41 @@
|
||||
from decimal import Decimal # noqa: F401
|
||||
from datetime import date, datetime # noqa: F401
|
||||
from frozendict import frozendict # noqa: F401
|
||||
|
||||
from {{packageName}}.schemas import ( # noqa: F401
|
||||
AnyTypeSchema,
|
||||
ComposedSchema,
|
||||
DictSchema,
|
||||
ListSchema,
|
||||
StrSchema,
|
||||
IntSchema,
|
||||
Int32Schema,
|
||||
Int64Schema,
|
||||
Float32Schema,
|
||||
Float64Schema,
|
||||
NumberSchema,
|
||||
DateSchema,
|
||||
DateTimeSchema,
|
||||
BoolSchema,
|
||||
BinarySchema,
|
||||
NoneSchema,
|
||||
none_type,
|
||||
InstantiationMetadata,
|
||||
Unset,
|
||||
unset,
|
||||
ComposedBase,
|
||||
ListBase,
|
||||
DictBase,
|
||||
NoneBase,
|
||||
StrBase,
|
||||
IntBase,
|
||||
NumberBase,
|
||||
DateBase,
|
||||
DateTimeBase,
|
||||
BoolBase,
|
||||
BinaryBase,
|
||||
Schema,
|
||||
_SchemaValidator,
|
||||
_SchemaTypeChecker,
|
||||
_SchemaEnumMaker
|
||||
)
|
@ -0,0 +1,6 @@
|
||||
{{#each imports}}
|
||||
{{#if @first}}
|
||||
|
||||
{{/if}}
|
||||
{{{.}}}
|
||||
{{/each}}
|
@ -0,0 +1,53 @@
|
||||
def __new__(
|
||||
cls,
|
||||
*args: typing.Union[{{#if isAnyType}}dict, frozendict, str, date, datetime, int, float, Decimal, None, list, tuple, bytes{{/if}}{{#if isUnboundedInteger}}int, {{/if}}{{#if isNumber}}float, {{/if}}{{#if isBoolean}}bool, {{/if}}{{#if isArray}}list, tuple, {{/if}}{{#if isMap}}dict, frozendict, {{/if}}{{#if isString}}str, {{/if}}{{#if isNull}}None, {{/if}}],
|
||||
{{#unless isNull}}
|
||||
{{#if getHasRequired}}
|
||||
{{#each requiredVars}}
|
||||
{{#unless nameInSnakeCase}}
|
||||
{{baseName}}: {{baseName}},
|
||||
{{/unless}}
|
||||
{{/each}}
|
||||
{{/if}}
|
||||
{{/unless}}
|
||||
{{#each vars}}
|
||||
{{#unless nameInSnakeCase}}
|
||||
{{#unless getRequired}}
|
||||
{{#unless complexType}}
|
||||
{{baseName}}: typing.Union[{{baseName}}, Unset] = unset,
|
||||
{{/unless}}
|
||||
{{#if complexType}}
|
||||
{{baseName}}: typing.Union['{{complexType}}', Unset] = unset,
|
||||
{{/if}}
|
||||
{{/unless}}
|
||||
{{/unless}}
|
||||
{{/each}}
|
||||
_instantiation_metadata: typing.Optional[InstantiationMetadata] = None,
|
||||
{{#with additionalProperties}}
|
||||
**kwargs: typing.Type[Schema],
|
||||
{{/with}}
|
||||
):
|
||||
return super().__new__(
|
||||
cls,
|
||||
*args,
|
||||
{{#unless isNull}}
|
||||
{{#if getHasRequired}}
|
||||
{{#each requiredVars}}
|
||||
{{#unless nameInSnakeCase}}
|
||||
{{baseName}}={{baseName}},
|
||||
{{/unless}}
|
||||
{{/each}}
|
||||
{{/if}}
|
||||
{{/unless}}
|
||||
{{#each vars}}
|
||||
{{#unless getRequired}}
|
||||
{{#unless nameInSnakeCase}}
|
||||
{{baseName}}={{baseName}},
|
||||
{{/unless}}
|
||||
{{/unless}}
|
||||
{{/each}}
|
||||
_instantiation_metadata=_instantiation_metadata,
|
||||
{{#with additionalProperties}}
|
||||
**kwargs,
|
||||
{{/with}}
|
||||
)
|
@ -0,0 +1,46 @@
|
||||
{{#if composedSchemas}}
|
||||
{{> model_templates/schema_composed_or_anytype }}
|
||||
{{/if}}
|
||||
{{#unless composedSchemas}}
|
||||
{{#if getHasMultipleTypes}}
|
||||
{{> model_templates/schema_composed_or_anytype }}
|
||||
{{else}}
|
||||
{{#or isMap isArray isAnyType}}
|
||||
{{#if isMap}}
|
||||
{{#or hasVars hasValidation hasRequiredVars getHasDiscriminatorWithNonEmptyMapping}}
|
||||
{{> model_templates/schema_dict }}
|
||||
{{else}}
|
||||
{{#if additionalPropertiesIsAnyType}}
|
||||
{{> model_templates/var_equals_cls }}
|
||||
{{else}}
|
||||
{{> model_templates/schema_dict }}
|
||||
{{/if}}
|
||||
{{/or}}
|
||||
{{/if}}
|
||||
{{#if isArray}}
|
||||
{{#or hasItems hasValidation}}
|
||||
{{> model_templates/schema_list }}
|
||||
{{else}}
|
||||
{{> model_templates/var_equals_cls }}
|
||||
{{/or}}
|
||||
{{/if}}
|
||||
{{#if isAnyType}}
|
||||
{{#or isEnum hasVars hasValidation hasRequiredVars getHasDiscriminatorWithNonEmptyMapping items}}
|
||||
{{> model_templates/schema_composed_or_anytype }}
|
||||
{{else}}
|
||||
{{> model_templates/var_equals_cls }}
|
||||
{{/or}}
|
||||
{{/if}}
|
||||
{{else}}
|
||||
{{#or isEnum hasValidation}}
|
||||
{{> model_templates/schema_simple }}
|
||||
{{else}}
|
||||
{{> model_templates/var_equals_cls }}
|
||||
{{/or}}
|
||||
{{/or}}
|
||||
{{#if nameInSnakeCase}}
|
||||
locals()['{{baseName}}'] = {{name}}
|
||||
del locals()['{{name}}']
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{/unless}}
|
@ -0,0 +1,67 @@
|
||||
|
||||
|
||||
class {{#if this.classname}}{{classname}}{{else}}{{#if nameInSnakeCase}}{{name}}{{else}}{{baseName}}{{/if}}{{/if}}(
|
||||
{{#if hasValidation}}
|
||||
{{> model_templates/validations }}
|
||||
{{/if}}
|
||||
{{#if getIsAnyType}}
|
||||
{{#if composedSchemas}}
|
||||
ComposedSchema
|
||||
{{else}}
|
||||
AnyTypeSchema
|
||||
{{/if}}
|
||||
{{else}}
|
||||
{{#if getHasMultipleTypes}}
|
||||
_SchemaTypeChecker(typing.Union[{{#if isArray}}tuple, {{/if}}{{#if isMap}}frozendict, {{/if}}{{#if isNull}}none_type, {{/if}}{{#if isString}}str, {{/if}}{{#if isByteArray}}str, {{/if}}{{#if isUnboundedInteger}}Decimal, {{/if}}{{#if isShort}}Decimal, {{/if}}{{#if isLong}}Decimal, {{/if}}{{#if isFloat}}Decimal, {{/if}}{{#if isDouble}}Decimal, {{/if}}{{#if isNumber}}Decimal, {{/if}}{{#if isDate}}str, {{/if}}{{#if isDateTime}}str, {{/if}}{{#if isBoolean}}bool, {{/if}}]),
|
||||
{{/if}}
|
||||
{{#if composedSchemas}}
|
||||
ComposedBase,
|
||||
{{/if}}
|
||||
{{#if isEnum}}
|
||||
{{> model_templates/enum_value_to_name }}
|
||||
{{/if}}
|
||||
{{> model_templates/xbase_schema }}
|
||||
{{/if}}
|
||||
):
|
||||
{{#if this.classname}}
|
||||
"""NOTE: This class is auto generated by OpenAPI Generator.
|
||||
Ref: https://openapi-generator.tech
|
||||
|
||||
Do not edit the class manually.
|
||||
{{#if description}}
|
||||
|
||||
{{{unescapedDescription}}}
|
||||
{{/if}}
|
||||
|
||||
Attributes:
|
||||
{{#each vars}}
|
||||
{{baseName}} ({{#if isArray}}tuple,{{/if}}{{#if isBoolean}}bool,{{/if}}{{#if isDate}}date,{{/if}}{{#if isDateTime}}datetime,{{/if}}{{#if isMap}}dict,{{/if}}{{#if isFloat}}float,{{/if}}{{#if isNumber}}float,{{/if}}{{#if isUnboundedInteger}}int,{{/if}}{{#if isShort}}int,{{/if}}{{#if isLong}}int,{{/if}}{{#if isString}}str,{{/if}}{{#if isByteArray}}str,{{/if}}{{#if isNull}} none_type,{{/if}}): {{#if description}}{{description}}{{/if}}
|
||||
{{/each}}
|
||||
{{#if hasValidation}}
|
||||
_validations (dict): the validations which apply to the current Schema
|
||||
The value is a dict that stores validations for max_length, min_length, max_items,
|
||||
min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum,
|
||||
inclusive_minimum, and regex.
|
||||
{{/if}}
|
||||
{{#with additionalProperties}}
|
||||
_additional_properties (Schema): the definition used for additional properties
|
||||
that are not defined in _properties
|
||||
{{/with}}
|
||||
{{#if getHasDiscriminatorWithNonEmptyMapping}}
|
||||
_discriminator(cls) -> dict: the key is the required discriminator propertyName
|
||||
the value is a dict mapping from a string name to the corresponding Schema class
|
||||
{{/if}}
|
||||
"""
|
||||
{{/if}}
|
||||
{{#or isMap isAnyType}}
|
||||
{{> model_templates/dict_partial }}
|
||||
{{/or}}
|
||||
{{#if composedSchemas}}
|
||||
|
||||
{{> model_templates/composed_schemas }}
|
||||
{{/if}}
|
||||
{{#if isEnum}}
|
||||
{{> model_templates/enums }}
|
||||
{{/if}}
|
||||
|
||||
{{> model_templates/new }}
|
@ -0,0 +1,42 @@
|
||||
|
||||
|
||||
class {{#if this.classname}}{{classname}}{{else}}{{#if nameInSnakeCase}}{{name}}{{else}}{{baseName}}{{/if}}{{/if}}(
|
||||
{{#if hasValidation}}
|
||||
{{> model_templates/validations }}
|
||||
{{/if}}
|
||||
DictSchema
|
||||
):
|
||||
{{#if this.classname}}
|
||||
"""NOTE: This class is auto generated by OpenAPI Generator.
|
||||
Ref: https://openapi-generator.tech
|
||||
|
||||
Do not edit the class manually.
|
||||
{{#if description}}
|
||||
|
||||
{{{unescapedDescription}}}
|
||||
{{/if}}
|
||||
|
||||
Attributes:
|
||||
{{#each vars}}
|
||||
{{baseName}} ({{#if isArray}}tuple,{{/if}}{{#if isBoolean}}bool,{{/if}}{{#if isDate}}date,{{/if}}{{#if isDateTime}}datetime,{{/if}}{{#if isMap}}dict,{{/if}}{{#if isFloat}}float,{{/if}}{{#if isDouble}}float,{{/if}}{{#if isNumber}}int, float,{{/if}}{{#if isUnboundedInteger}}int,{{/if}}{{#if isShort}}int,{{/if}}{{#if isLong}}int,{{/if}}{{#if isString}}str,{{/if}}{{#if isByteArray}}str,{{/if}}{{#if isNull}} none_type,{{/if}}): {{#if description}}{{description}}{{/if}}
|
||||
{{/each}}
|
||||
{{#if hasValidation}}
|
||||
_validations (dict): the validations which apply to the current Schema
|
||||
The value is a dict that stores validations for max_length, min_length, max_items,
|
||||
min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum,
|
||||
inclusive_minimum, and regex.
|
||||
{{/if}}
|
||||
{{#with additionalProperties}}
|
||||
_additional_properties (Schema): the definition used for additional properties
|
||||
that are not defined in _properties
|
||||
{{/with}}
|
||||
{{#if getHasDiscriminatorWithNonEmptyMapping}}
|
||||
_discriminator(cls) -> dict: the key is the required discriminator propertyName
|
||||
the value is a dict mapping from a string name to the corresponding Schema class
|
||||
{{/if}}
|
||||
"""
|
||||
{{/if}}
|
||||
{{> model_templates/dict_partial }}
|
||||
|
||||
|
||||
{{> model_templates/new }}
|
@ -0,0 +1,39 @@
|
||||
|
||||
|
||||
class {{#if this.classname}}{{classname}}{{else}}{{#if nameInSnakeCase}}{{name}}{{else}}{{baseName}}{{/if}}{{/if}}(
|
||||
{{#if hasValidation}}
|
||||
{{> model_templates/validations }}
|
||||
{{/if}}
|
||||
ListSchema
|
||||
):
|
||||
{{#if this.classname}}
|
||||
"""NOTE: This class is auto generated by OpenAPI Generator.
|
||||
Ref: https://openapi-generator.tech
|
||||
|
||||
Do not edit the class manually.
|
||||
{{#if description}}
|
||||
|
||||
{{{unescapedDescription}}}
|
||||
{{/if}}
|
||||
|
||||
Attributes:
|
||||
_items (Schema): the schema definition of the array items
|
||||
{{#if hasValidation}}
|
||||
_validations (dict): the validations which apply to the current Schema
|
||||
The value is a dict that stores validations for max_length, min_length, max_items,
|
||||
min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum,
|
||||
inclusive_minimum, and regex.
|
||||
{{/if}}
|
||||
"""
|
||||
{{/if}}
|
||||
{{#with items}}
|
||||
{{#if complexType}}
|
||||
|
||||
@classmethod
|
||||
@property
|
||||
def _items(cls) -> typing.Type['{{complexType}}']:
|
||||
return {{complexType}}
|
||||
{{else}}
|
||||
{{> model_templates/schema }}
|
||||
{{/if}}
|
||||
{{/with}}
|
@ -0,0 +1,35 @@
|
||||
|
||||
|
||||
class {{#if this.classname}}{{classname}}{{else}}{{#if nameInSnakeCase}}{{name}}{{else}}{{baseName}}{{/if}}{{/if}}(
|
||||
{{#if hasValidation}}
|
||||
{{> model_templates/validations }}
|
||||
{{/if}}
|
||||
{{#if isEnum}}
|
||||
{{> model_templates/enum_value_to_name }}
|
||||
{{/if}}
|
||||
{{> model_templates/xbase_schema }}
|
||||
):
|
||||
{{#if this.classname}}
|
||||
"""NOTE: This class is auto generated by OpenAPI Generator.
|
||||
Ref: https://openapi-generator.tech
|
||||
|
||||
Do not edit the class manually.
|
||||
{{#if description}}
|
||||
|
||||
{{{unescapedDescription}}}
|
||||
{{/if}}
|
||||
|
||||
Attributes:
|
||||
{{#if hasValidation}}
|
||||
_validations (dict): the validations which apply to the current Schema
|
||||
The value is a dict that stores validations for max_length, min_length, max_items,
|
||||
min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum,
|
||||
inclusive_minimum, and regex.
|
||||
{{/if}}
|
||||
"""
|
||||
{{/if}}
|
||||
{{#if isEnum}}
|
||||
{{> model_templates/enums }}
|
||||
{{else}}
|
||||
pass
|
||||
{{/if}}
|
@ -0,0 +1,50 @@
|
||||
_SchemaValidator(
|
||||
{{#if getUniqueItems}}
|
||||
unique_items=True,
|
||||
{{/if}}
|
||||
{{#if maxLength}}
|
||||
max_length={{maxLength}},
|
||||
{{/if}}
|
||||
{{#if minLength}}
|
||||
min_length={{minLength}},
|
||||
{{/if}}
|
||||
{{#if maxItems}}
|
||||
max_items={{maxItems}},
|
||||
{{/if}}
|
||||
{{#if minItems}}
|
||||
min_items={{minItems}},
|
||||
{{/if}}
|
||||
{{#if maxProperties}}
|
||||
max_properties={{maxProperties}},
|
||||
{{/if}}
|
||||
{{#if minProperties}}
|
||||
min_properties={{minProperties}},
|
||||
{{/if}}
|
||||
{{#if maximum}}
|
||||
{{#if exclusiveMaximum}}exclusive_maximum{{/if}}inclusive_maximum{{#unless exclusiveMaximum}}{{/unless}}={{maximum}},
|
||||
{{/if}}
|
||||
{{#if minimum}}
|
||||
{{#if exclusiveMinimum}}exclusive_minimum{{/if}}inclusive_minimum{{#unless exclusiveMinimum}}{{/unless}}={{minimum}},
|
||||
{{/if}}
|
||||
{{#if pattern}}
|
||||
regex=[{
|
||||
{{#if vendorExtensions.x-regex}}
|
||||
'pattern': r'{{{vendorExtensions.x-regex}}}', # noqa: E501
|
||||
{{else}}
|
||||
'pattern': r'{{{pattern}}}', # noqa: E501
|
||||
{{/if}}
|
||||
{{#each vendorExtensions.x-modifiers}}
|
||||
{{#if @first}}
|
||||
'flags': (
|
||||
{{/if}}
|
||||
{{#unless @first}}| {{/unless}}re.{{.}}
|
||||
{{#if @last}}
|
||||
)
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
}],
|
||||
{{/if}}
|
||||
{{#if multipleOf}}
|
||||
multiple_of=[{{multipleOf}}],
|
||||
{{/if}}
|
||||
),
|
@ -0,0 +1 @@
|
||||
{{#if this.classname}}{{classname}}{{else}}{{#if nameInSnakeCase}}{{name}}{{else}}{{baseName}}{{/if}}{{/if}} = {{#if complexType}}{{complexType}}{{else}}{{#if isNullable}}Nullable{{/if}}{{#if getIsNull}}None{{/if}}{{#if isAnyType}}AnyType{{/if}}{{#if isMap}}Dict{{/if}}{{#if isArray}}List{{/if}}{{#if isString}}Str{{/if}}{{#if isByteArray}}Str{{/if}}{{#if isUnboundedInteger}}Int{{/if}}{{#if isShort}}Int32{{/if}}{{#if isLong}}Int64{{/if}}{{#if isFloat}}Float32{{/if}}{{#if isDouble}}Float64{{/if}}{{#if isNumber}}Number{{/if}}{{#if isDate}}Date{{/if}}{{#if isDateTime}}DateTime{{/if}}{{#if isBoolean}}Bool{{/if}}{{#if isBinary}}Binary{{/if}}Schema{{/if}}
|
@ -0,0 +1,48 @@
|
||||
{{#if isArray}}
|
||||
List{{#if getHasMultipleTypes}}Base,{{else}}Schema{{/if}}
|
||||
{{/if}}
|
||||
{{#if isMap}}
|
||||
Dict{{#if getHasMultipleTypes}}Base,{{else}}Schema{{/if}}
|
||||
{{/if}}
|
||||
{{#if isString}}
|
||||
Str{{#if getHasMultipleTypes}}Base,{{else}}Schema{{/if}}
|
||||
{{/if}}
|
||||
{{#if isByteArray}}
|
||||
Str{{#if getHasMultipleTypes}}Base,{{else}}Schema{{/if}}
|
||||
{{/if}}
|
||||
{{#if isUnboundedInteger}}
|
||||
Int{{#if getHasMultipleTypes}}Base,{{else}}Schema{{/if}}
|
||||
{{/if}}
|
||||
{{#if isNumber}}
|
||||
Number{{#if getHasMultipleTypes}}Base,{{else}}Schema{{/if}}
|
||||
{{/if}}
|
||||
{{#isShort}}
|
||||
Int32{{#if getHasMultipleTypes}}Base,{{else}}Schema{{/if}}
|
||||
{{/isShort}}
|
||||
{{#isLong}}
|
||||
Int64{{#if getHasMultipleTypes}}Base,{{else}}Schema{{/if}}
|
||||
{{/isLong}}
|
||||
{{#isFloat}}
|
||||
Float32{{#if getHasMultipleTypes}}Base,{{else}}Schema{{/if}}
|
||||
{{/isFloat}}
|
||||
{{#isDouble}}
|
||||
Float64{{#if getHasMultipleTypes}}Base,{{else}}Schema{{/if}}
|
||||
{{/isDouble}}
|
||||
{{#if isDate}}
|
||||
Date{{#if getHasMultipleTypes}}Base,{{else}}Schema{{/if}}
|
||||
{{/if}}
|
||||
{{#if isDateTime}}
|
||||
DateTime{{#if getHasMultipleTypes}}Base,{{else}}Schema{{/if}}
|
||||
{{/if}}
|
||||
{{#if isBoolean}}
|
||||
Bool{{#if getHasMultipleTypes}}Base,{{else}}Schema{{/if}}
|
||||
{{/if}}
|
||||
{{#if isBinary}}
|
||||
Binary{{#if getHasMultipleTypes}}Base,{{else}}Schema{{/if}}
|
||||
{{/if}}
|
||||
{{#if isNull}}
|
||||
None{{#if getHasMultipleTypes}}Base,{{else}}Schema{{/if}}
|
||||
{{/if}}
|
||||
{{#if getHasMultipleTypes}}
|
||||
Schema
|
||||
{{/if}}
|
@ -0,0 +1,33 @@
|
||||
# coding: utf-8
|
||||
|
||||
{{>partial_header}}
|
||||
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
import {{packageName}}
|
||||
{{#each models}}
|
||||
{{#with model}}
|
||||
from {{modelPackage}}.{{classFilename}} import {{classname}}
|
||||
|
||||
|
||||
class Test{{classname}}(unittest.TestCase):
|
||||
"""{{classname}} unit test stubs"""
|
||||
|
||||
def setUp(self):
|
||||
pass
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
||||
def test_{{classname}}(self):
|
||||
"""Test {{classname}}"""
|
||||
# FIXME: construct object with mandatory attributes with example values
|
||||
# model = {{classname}}() # noqa: E501
|
||||
pass
|
||||
|
||||
{{/with}}
|
||||
{{/each}}
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
@ -0,0 +1,17 @@
|
||||
"""
|
||||
{{#if appName}}
|
||||
{{{appName}}}
|
||||
{{/if}}
|
||||
|
||||
{{#if appDescription}}
|
||||
{{{appDescription}}} # noqa: E501
|
||||
{{/if}}
|
||||
|
||||
{{#if version}}
|
||||
The version of the OpenAPI document: {{{version}}}
|
||||
{{/if}}
|
||||
{{#if infoEmail}}
|
||||
Contact: {{{infoEmail}}}
|
||||
{{/if}}
|
||||
Generated by: https://openapi-generator.tech
|
||||
"""
|
@ -0,0 +1,5 @@
|
||||
certifi >= 14.05.14
|
||||
frozendict >= 2.0.3
|
||||
python_dateutil >= 2.5.3
|
||||
setuptools >= 21.0.0
|
||||
urllib3 >= 1.15.1
|
@ -0,0 +1,251 @@
|
||||
# coding: utf-8
|
||||
|
||||
{{>partial_header}}
|
||||
|
||||
import logging
|
||||
import ssl
|
||||
from urllib.parse import urlencode
|
||||
import typing
|
||||
|
||||
import certifi
|
||||
import urllib3
|
||||
from urllib3._collections import HTTPHeaderDict
|
||||
|
||||
from {{packageName}}.exceptions import ApiException, ApiValueError
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class RESTClientObject(object):
|
||||
|
||||
def __init__(self, configuration, pools_size=4, maxsize=None):
|
||||
# urllib3.PoolManager will pass all kw parameters to connectionpool
|
||||
# https://github.com/shazow/urllib3/blob/f9409436f83aeb79fbaf090181cd81b784f1b8ce/urllib3/poolmanager.py#L75 # noqa: E501
|
||||
# https://github.com/shazow/urllib3/blob/f9409436f83aeb79fbaf090181cd81b784f1b8ce/urllib3/connectionpool.py#L680 # noqa: E501
|
||||
# maxsize is the number of requests to host that are allowed in parallel # noqa: E501
|
||||
# Custom SSL certificates and client certificates: http://urllib3.readthedocs.io/en/latest/advanced-usage.html # noqa: E501
|
||||
|
||||
# cert_reqs
|
||||
if configuration.verify_ssl:
|
||||
cert_reqs = ssl.CERT_REQUIRED
|
||||
else:
|
||||
cert_reqs = ssl.CERT_NONE
|
||||
|
||||
# ca_certs
|
||||
if configuration.ssl_ca_cert:
|
||||
ca_certs = configuration.ssl_ca_cert
|
||||
else:
|
||||
# if not set certificate file, use Mozilla's root certificates.
|
||||
ca_certs = certifi.where()
|
||||
|
||||
addition_pool_args = {}
|
||||
if configuration.assert_hostname is not None:
|
||||
addition_pool_args['assert_hostname'] = configuration.assert_hostname # noqa: E501
|
||||
|
||||
if configuration.retries is not None:
|
||||
addition_pool_args['retries'] = configuration.retries
|
||||
|
||||
if configuration.socket_options is not None:
|
||||
addition_pool_args['socket_options'] = configuration.socket_options
|
||||
|
||||
if maxsize is None:
|
||||
if configuration.connection_pool_maxsize is not None:
|
||||
maxsize = configuration.connection_pool_maxsize
|
||||
else:
|
||||
maxsize = 4
|
||||
|
||||
# https pool manager
|
||||
if configuration.proxy:
|
||||
self.pool_manager = urllib3.ProxyManager(
|
||||
num_pools=pools_size,
|
||||
maxsize=maxsize,
|
||||
cert_reqs=cert_reqs,
|
||||
ca_certs=ca_certs,
|
||||
cert_file=configuration.cert_file,
|
||||
key_file=configuration.key_file,
|
||||
proxy_url=configuration.proxy,
|
||||
proxy_headers=configuration.proxy_headers,
|
||||
**addition_pool_args
|
||||
)
|
||||
else:
|
||||
self.pool_manager = urllib3.PoolManager(
|
||||
num_pools=pools_size,
|
||||
maxsize=maxsize,
|
||||
cert_reqs=cert_reqs,
|
||||
ca_certs=ca_certs,
|
||||
cert_file=configuration.cert_file,
|
||||
key_file=configuration.key_file,
|
||||
**addition_pool_args
|
||||
)
|
||||
|
||||
def request(
|
||||
self,
|
||||
method: str,
|
||||
url: str,
|
||||
query_params: typing.Optional[typing.Tuple[typing.Tuple[str, str], ...]] = None,
|
||||
headers: typing.Optional[HTTPHeaderDict] = None,
|
||||
fields: typing.Optional[typing.Tuple[typing.Tuple[str, typing.Any], ...]] = None,
|
||||
body: typing.Optional[typing.Union[str, bytes]] = None,
|
||||
stream: bool = False,
|
||||
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
|
||||
) -> urllib3.HTTPResponse:
|
||||
"""Perform requests.
|
||||
|
||||
:param method: http request method
|
||||
:param url: http request url
|
||||
:param query_params: query parameters in the url
|
||||
:param headers: http request headers
|
||||
:param body: request body, for other types
|
||||
:param fields: request parameters for
|
||||
`application/x-www-form-urlencoded`
|
||||
or `multipart/form-data`
|
||||
:param stream: if True, the urllib3.HTTPResponse object will
|
||||
be returned without reading/decoding response
|
||||
data. Default is False.
|
||||
:param timeout: timeout setting for this request. If one
|
||||
number provided, it will be total request
|
||||
timeout. It can also be a pair (tuple) of
|
||||
(connection, read) timeouts.
|
||||
"""
|
||||
method = method.upper()
|
||||
assert method in ['GET', 'HEAD', 'DELETE', 'POST', 'PUT',
|
||||
'PATCH', 'OPTIONS']
|
||||
|
||||
if fields and body:
|
||||
raise ApiValueError(
|
||||
"body parameter cannot be used with fields parameter."
|
||||
)
|
||||
|
||||
fields = fields or {}
|
||||
headers = headers or {}
|
||||
|
||||
if timeout:
|
||||
if isinstance(timeout, (int, float)): # noqa: E501,F821
|
||||
timeout = urllib3.Timeout(total=timeout)
|
||||
elif (isinstance(timeout, tuple) and
|
||||
len(timeout) == 2):
|
||||
timeout = urllib3.Timeout(connect=timeout[0], read=timeout[1])
|
||||
|
||||
if 'Content-Type' not in headers:
|
||||
headers['Content-Type'] = 'application/json'
|
||||
|
||||
try:
|
||||
# For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE`
|
||||
if method in ['POST', 'PUT', 'PATCH', 'OPTIONS', 'DELETE']:
|
||||
if query_params:
|
||||
url += '?' + urlencode(query_params)
|
||||
if headers['Content-Type'] == 'application/x-www-form-urlencoded': # noqa: E501
|
||||
r = self.pool_manager.request(
|
||||
method, url,
|
||||
fields=fields,
|
||||
encode_multipart=False,
|
||||
preload_content=not stream,
|
||||
timeout=timeout,
|
||||
headers=headers)
|
||||
elif headers['Content-Type'] == 'multipart/form-data':
|
||||
# must del headers['Content-Type'], or the correct
|
||||
# Content-Type which generated by urllib3 will be
|
||||
# overwritten.
|
||||
del headers['Content-Type']
|
||||
r = self.pool_manager.request(
|
||||
method, url,
|
||||
fields=fields,
|
||||
encode_multipart=True,
|
||||
preload_content=not stream,
|
||||
timeout=timeout,
|
||||
headers=headers)
|
||||
# Pass a `string` parameter directly in the body to support
|
||||
# other content types than Json when `body` argument is
|
||||
# provided in serialized form
|
||||
elif isinstance(body, str) or isinstance(body, bytes):
|
||||
request_body = body
|
||||
r = self.pool_manager.request(
|
||||
method, url,
|
||||
body=request_body,
|
||||
preload_content=not stream,
|
||||
timeout=timeout,
|
||||
headers=headers)
|
||||
else:
|
||||
# Cannot generate the request from given parameters
|
||||
msg = """Cannot prepare a request message for provided
|
||||
arguments. Please check that your arguments match
|
||||
declared content type."""
|
||||
raise ApiException(status=0, reason=msg)
|
||||
# For `GET`, `HEAD`
|
||||
else:
|
||||
r = self.pool_manager.request(method, url,
|
||||
fields=query_params,
|
||||
preload_content=not stream,
|
||||
timeout=timeout,
|
||||
headers=headers)
|
||||
except urllib3.exceptions.SSLError as e:
|
||||
msg = "{0}\n{1}".format(type(e).__name__, str(e))
|
||||
raise ApiException(status=0, reason=msg)
|
||||
|
||||
if not stream:
|
||||
# log response body
|
||||
logger.debug("response body: %s", r.data)
|
||||
|
||||
return r
|
||||
|
||||
def GET(self, url, headers=None, query_params=None, stream=False,
|
||||
timeout=None, fields=None) -> urllib3.HTTPResponse:
|
||||
return self.request("GET", url,
|
||||
headers=headers,
|
||||
stream=stream,
|
||||
timeout=timeout,
|
||||
query_params=query_params, fields=fields)
|
||||
|
||||
def HEAD(self, url, headers=None, query_params=None, stream=False,
|
||||
timeout=None, fields=None) -> urllib3.HTTPResponse:
|
||||
return self.request("HEAD", url,
|
||||
headers=headers,
|
||||
stream=stream,
|
||||
timeout=timeout,
|
||||
query_params=query_params, fields=fields)
|
||||
|
||||
def OPTIONS(self, url, headers=None, query_params=None,
|
||||
body=None, stream=False, timeout=None, fields=None) -> urllib3.HTTPResponse:
|
||||
return self.request("OPTIONS", url,
|
||||
headers=headers,
|
||||
query_params=query_params,
|
||||
stream=stream,
|
||||
timeout=timeout,
|
||||
body=body, fields=fields)
|
||||
|
||||
def DELETE(self, url, headers=None, query_params=None, body=None,
|
||||
stream=False, timeout=None, fields=None) -> urllib3.HTTPResponse:
|
||||
return self.request("DELETE", url,
|
||||
headers=headers,
|
||||
query_params=query_params,
|
||||
stream=stream,
|
||||
timeout=timeout,
|
||||
body=body, fields=fields)
|
||||
|
||||
def POST(self, url, headers=None, query_params=None,
|
||||
body=None, stream=False, timeout=None, fields=None) -> urllib3.HTTPResponse:
|
||||
return self.request("POST", url,
|
||||
headers=headers,
|
||||
query_params=query_params,
|
||||
stream=stream,
|
||||
timeout=timeout,
|
||||
body=body, fields=fields)
|
||||
|
||||
def PUT(self, url, headers=None, query_params=None,
|
||||
body=None, stream=False, timeout=None, fields=None) -> urllib3.HTTPResponse:
|
||||
return self.request("PUT", url,
|
||||
headers=headers,
|
||||
query_params=query_params,
|
||||
stream=stream,
|
||||
timeout=timeout,
|
||||
body=body, fields=fields)
|
||||
|
||||
def PATCH(self, url, headers=None, query_params=None,
|
||||
body=None, stream=False, timeout=None, fields=None) -> urllib3.HTTPResponse:
|
||||
return self.request("PATCH", url,
|
||||
headers=headers,
|
||||
query_params=query_params,
|
||||
stream=stream,
|
||||
timeout=timeout,
|
||||
body=body, fields=fields)
|
@ -0,0 +1,32 @@
|
||||
|
||||
{{#if description}}
|
||||
{{&description}}
|
||||
|
||||
{{/if}}
|
||||
{{#or vars additionalProperties}}
|
||||
#### Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
{{#each vars}}
|
||||
**{{baseName}}** | {{#unless complexType}}**{{dataType}}**{{/unless}}{{#if complexType}}[**{{dataType}}**]({{complexType}}.md){{/if}} | {{description}} | {{#unless required}}[optional] {{/unless}}{{#if isReadOnly}}[readonly] {{/if}}{{#if defaultValue}} if omitted the server will use the default value of {{{defaultValue}}}{{/if}}
|
||||
{{/each}}
|
||||
{{#with additionalProperties}}
|
||||
**any string name** | **{{dataType}}** | any string name can be used but the value must be the correct type | [optional]
|
||||
{{/with}}
|
||||
{{else}}
|
||||
Type | Description | Notes
|
||||
------------- | ------------- | -------------
|
||||
{{#if isAnyType}}
|
||||
typing.Union[dict, frozendict, str, date, datetime, int, float, bool, Decimal, None, list, tuple, bytes] | |
|
||||
{{else}}
|
||||
{{#if hasMultipleTypes}}
|
||||
typing.Union[{{#if isMap}}dict, frozendict, {{/if}}{{#if isString}}str, {{/if}}{{#if isDate}}date, {{/if}}{{#if isDataTime}}datetime, {{/if}}{{#or isLong isShort isUnboundedInteger}}int, {{/or}}{{#or isFloat isDouble}}float, {{/or}}{{#if isNumber}}Decimal, {{/if}}{{#if isBoolean}}bool, {{/if}}{{#if isNull}}None, {{/if}}{{#if isArray}}list, tuple, {{/if}}{{#if isBinary}}bytes{{/if}}] | | {{#with allowableValues}}{{#if defaultValue}}, {{/if}} must be one of [{{#each enumVars}}{{{value}}}, {{/each}}]{{/with}}
|
||||
{{else}}
|
||||
{{#if isArray}}
|
||||
{{#unless arrayModelType}}**{{dataType}}**{{/unless}}{{#if arrayModelType}}[**{{dataType}}**]({{arrayModelType}}.md){{/if}} | {{description}} | {{#if defaultValue}}{{#if hasRequired}} if omitted the server will use the default value of {{/if}}{{#unless hasRequired}}defaults to {{/unless}}{{{defaultValue}}}{{/if}}
|
||||
{{else}}
|
||||
{{#unless arrayModelType}}**{{dataType}}**{{/unless}} | {{description}} | {{#if defaultValue}}{{#if hasRequired}} if omitted the server will use the default value of {{/if}}{{#unless hasRequired}}defaults to {{/unless}}{{{defaultValue}}}{{/if}}{{#with allowableValues}}{{#if defaultValue}}, {{/if}} must be one of [{{#each enumVars}}{{{value}}}, {{/each}}]{{/with}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{/or}}
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,51 @@
|
||||
# coding: utf-8
|
||||
|
||||
{{>partial_header}}
|
||||
|
||||
from setuptools import setup, find_packages # noqa: H301
|
||||
|
||||
NAME = "{{{projectName}}}"
|
||||
VERSION = "{{packageVersion}}"
|
||||
{{#with apiInfo}}
|
||||
# To install the library, run the following
|
||||
#
|
||||
# python setup.py install
|
||||
#
|
||||
# prerequisite: setuptools
|
||||
# http://pypi.python.org/pypi/setuptools
|
||||
|
||||
REQUIRES = [
|
||||
"urllib3 >= 1.15",
|
||||
"certifi",
|
||||
"python-dateutil",
|
||||
"frozendict >= 2.0.3",
|
||||
{{#if asyncio}}
|
||||
"aiohttp >= 3.0.0",
|
||||
{{/if}}
|
||||
{{#if tornado}}
|
||||
"tornado>=4.2,<5",
|
||||
{{/if}}
|
||||
{{#if hasHttpSignatureMethods}}
|
||||
"pem>=19.3.0",
|
||||
"pycryptodome>=3.9.0",
|
||||
{{/if}}
|
||||
]
|
||||
|
||||
setup(
|
||||
name=NAME,
|
||||
version=VERSION,
|
||||
description="{{appName}}",
|
||||
author="{{#if infoName}}{{infoName}}{{/if}}{{#unless infoName}}OpenAPI Generator community{{/unless}}",
|
||||
author_email="{{#if infoEmail}}{{infoEmail}}{{/if}}{{#unless infoEmail}}team@openapitools.org{{/unless}}",
|
||||
url="{{packageUrl}}",
|
||||
keywords=["OpenAPI", "OpenAPI-Generator", "{{{appName}}}"],
|
||||
python_requires=">=3.9",
|
||||
install_requires=REQUIRES,
|
||||
packages=find_packages(exclude=["test", "tests"]),
|
||||
include_package_data=True,
|
||||
{{#if licenseInfo}}license="{{licenseInfo}}",
|
||||
{{/if}}long_description="""\
|
||||
{{appDescription}} # noqa: E501
|
||||
"""
|
||||
)
|
||||
{{/with}}
|
@ -0,0 +1,13 @@
|
||||
{{#if useNose}}
|
||||
[nosetests]
|
||||
logging-clear-handlers=true
|
||||
verbosity=2
|
||||
randomize=true
|
||||
exe=true
|
||||
with-coverage=true
|
||||
cover-package={{{packageName}}}
|
||||
cover-erase=true
|
||||
|
||||
{{/if}}
|
||||
[flake8]
|
||||
max-line-length=99
|
@ -0,0 +1,409 @@
|
||||
# coding: utf-8
|
||||
{{>partial_header}}
|
||||
|
||||
from base64 import b64encode
|
||||
from Crypto.IO import PEM, PKCS8
|
||||
from Crypto.Hash import SHA256, SHA512
|
||||
from Crypto.PublicKey import RSA, ECC
|
||||
from Crypto.Signature import PKCS1_v1_5, pss, DSS
|
||||
from email.utils import formatdate
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
from time import time
|
||||
from urllib.parse import urlencode, urlparse
|
||||
|
||||
# The constants below define a subset of HTTP headers that can be included in the
|
||||
# HTTP signature scheme. Additional headers may be included in the signature.
|
||||
|
||||
# The '(request-target)' header is a calculated field that includes the HTTP verb,
|
||||
# the URL path and the URL query.
|
||||
HEADER_REQUEST_TARGET = '(request-target)'
|
||||
# The time when the HTTP signature was generated.
|
||||
HEADER_CREATED = '(created)'
|
||||
# The time when the HTTP signature expires. The API server should reject HTTP requests
|
||||
# that have expired.
|
||||
HEADER_EXPIRES = '(expires)'
|
||||
# The 'Host' header.
|
||||
HEADER_HOST = 'Host'
|
||||
# The 'Date' header.
|
||||
HEADER_DATE = 'Date'
|
||||
# When the 'Digest' header is included in the HTTP signature, the client automatically
|
||||
# computes the digest of the HTTP request body, per RFC 3230.
|
||||
HEADER_DIGEST = 'Digest'
|
||||
# The 'Authorization' header is automatically generated by the client. It includes
|
||||
# the list of signed headers and a base64-encoded signature.
|
||||
HEADER_AUTHORIZATION = 'Authorization'
|
||||
|
||||
# The constants below define the cryptographic schemes for the HTTP signature scheme.
|
||||
SCHEME_HS2019 = 'hs2019'
|
||||
SCHEME_RSA_SHA256 = 'rsa-sha256'
|
||||
SCHEME_RSA_SHA512 = 'rsa-sha512'
|
||||
|
||||
# The constants below define the signature algorithms that can be used for the HTTP
|
||||
# signature scheme.
|
||||
ALGORITHM_RSASSA_PSS = 'RSASSA-PSS'
|
||||
ALGORITHM_RSASSA_PKCS1v15 = 'RSASSA-PKCS1-v1_5'
|
||||
|
||||
ALGORITHM_ECDSA_MODE_FIPS_186_3 = 'fips-186-3'
|
||||
ALGORITHM_ECDSA_MODE_DETERMINISTIC_RFC6979 = 'deterministic-rfc6979'
|
||||
ALGORITHM_ECDSA_KEY_SIGNING_ALGORITHMS = {
|
||||
ALGORITHM_ECDSA_MODE_FIPS_186_3,
|
||||
ALGORITHM_ECDSA_MODE_DETERMINISTIC_RFC6979
|
||||
}
|
||||
|
||||
# The cryptographic hash algorithm for the message signature.
|
||||
HASH_SHA256 = 'sha256'
|
||||
HASH_SHA512 = 'sha512'
|
||||
|
||||
|
||||
class HttpSigningConfiguration(object):
|
||||
"""The configuration parameters for the HTTP signature security scheme.
|
||||
The HTTP signature security scheme is used to sign HTTP requests with a private key
|
||||
which is in possession of the API client.
|
||||
An 'Authorization' header is calculated by creating a hash of select headers,
|
||||
and optionally the body of the HTTP request, then signing the hash value using
|
||||
a private key. The 'Authorization' header is added to outbound HTTP requests.
|
||||
|
||||
NOTE: This class is auto generated by OpenAPI Generator
|
||||
|
||||
Ref: https://openapi-generator.tech
|
||||
Do not edit the class manually.
|
||||
|
||||
:param key_id: A string value specifying the identifier of the cryptographic key,
|
||||
when signing HTTP requests.
|
||||
:param signing_scheme: A string value specifying the signature scheme, when
|
||||
signing HTTP requests.
|
||||
Supported value are hs2019, rsa-sha256, rsa-sha512.
|
||||
Avoid using rsa-sha256, rsa-sha512 as they are deprecated. These values are
|
||||
available for server-side applications that only support the older
|
||||
HTTP signature algorithms.
|
||||
:param private_key_path: A string value specifying the path of the file containing
|
||||
a private key. The private key is used to sign HTTP requests.
|
||||
:param private_key_passphrase: A string value specifying the passphrase to decrypt
|
||||
the private key.
|
||||
:param signed_headers: A list of strings. Each value is the name of a HTTP header
|
||||
that must be included in the HTTP signature calculation.
|
||||
The two special signature headers '(request-target)' and '(created)' SHOULD be
|
||||
included in SignedHeaders.
|
||||
The '(created)' header expresses when the signature was created.
|
||||
The '(request-target)' header is a concatenation of the lowercased :method, an
|
||||
ASCII space, and the :path pseudo-headers.
|
||||
When signed_headers is not specified, the client defaults to a single value,
|
||||
'(created)', in the list of HTTP headers.
|
||||
When SignedHeaders contains the 'Digest' value, the client performs the
|
||||
following operations:
|
||||
1. Calculate a digest of request body, as specified in RFC3230, section 4.3.2.
|
||||
2. Set the 'Digest' header in the request body.
|
||||
3. Include the 'Digest' header and value in the HTTP signature.
|
||||
:param signing_algorithm: A string value specifying the signature algorithm, when
|
||||
signing HTTP requests.
|
||||
Supported values are:
|
||||
1. For RSA keys: RSASSA-PSS, RSASSA-PKCS1-v1_5.
|
||||
2. For ECDSA keys: fips-186-3, deterministic-rfc6979.
|
||||
If None, the signing algorithm is inferred from the private key.
|
||||
The default signing algorithm for RSA keys is RSASSA-PSS.
|
||||
The default signing algorithm for ECDSA keys is fips-186-3.
|
||||
:param hash_algorithm: The hash algorithm for the signature. Supported values are
|
||||
sha256 and sha512.
|
||||
If the signing_scheme is rsa-sha256, the hash algorithm must be set
|
||||
to None or sha256.
|
||||
If the signing_scheme is rsa-sha512, the hash algorithm must be set
|
||||
to None or sha512.
|
||||
:param signature_max_validity: The signature max validity, expressed as
|
||||
a datetime.timedelta value. It must be a positive value.
|
||||
"""
|
||||
def __init__(self, key_id, signing_scheme, private_key_path,
|
||||
private_key_passphrase=None,
|
||||
signed_headers=None,
|
||||
signing_algorithm=None,
|
||||
hash_algorithm=None,
|
||||
signature_max_validity=None):
|
||||
self.key_id = key_id
|
||||
if signing_scheme not in {SCHEME_HS2019, SCHEME_RSA_SHA256, SCHEME_RSA_SHA512}:
|
||||
raise Exception("Unsupported security scheme: {0}".format(signing_scheme))
|
||||
self.signing_scheme = signing_scheme
|
||||
if not os.path.exists(private_key_path):
|
||||
raise Exception("Private key file does not exist")
|
||||
self.private_key_path = private_key_path
|
||||
self.private_key_passphrase = private_key_passphrase
|
||||
self.signing_algorithm = signing_algorithm
|
||||
self.hash_algorithm = hash_algorithm
|
||||
if signing_scheme == SCHEME_RSA_SHA256:
|
||||
if self.hash_algorithm is None:
|
||||
self.hash_algorithm = HASH_SHA256
|
||||
elif self.hash_algorithm != HASH_SHA256:
|
||||
raise Exception("Hash algorithm must be sha256 when security scheme is %s" %
|
||||
SCHEME_RSA_SHA256)
|
||||
elif signing_scheme == SCHEME_RSA_SHA512:
|
||||
if self.hash_algorithm is None:
|
||||
self.hash_algorithm = HASH_SHA512
|
||||
elif self.hash_algorithm != HASH_SHA512:
|
||||
raise Exception("Hash algorithm must be sha512 when security scheme is %s" %
|
||||
SCHEME_RSA_SHA512)
|
||||
elif signing_scheme == SCHEME_HS2019:
|
||||
if self.hash_algorithm is None:
|
||||
self.hash_algorithm = HASH_SHA256
|
||||
elif self.hash_algorithm not in {HASH_SHA256, HASH_SHA512}:
|
||||
raise Exception("Invalid hash algorithm")
|
||||
if signature_max_validity is not None and signature_max_validity.total_seconds() < 0:
|
||||
raise Exception("The signature max validity must be a positive value")
|
||||
self.signature_max_validity = signature_max_validity
|
||||
# If the user has not provided any signed_headers, the default must be set to '(created)',
|
||||
# as specified in the 'HTTP signature' standard.
|
||||
if signed_headers is None or len(signed_headers) == 0:
|
||||
signed_headers = [HEADER_CREATED]
|
||||
if self.signature_max_validity is None and HEADER_EXPIRES in signed_headers:
|
||||
raise Exception(
|
||||
"Signature max validity must be set when "
|
||||
"'(expires)' signature parameter is specified")
|
||||
if len(signed_headers) != len(set(signed_headers)):
|
||||
raise Exception("Cannot have duplicates in the signed_headers parameter")
|
||||
if HEADER_AUTHORIZATION in signed_headers:
|
||||
raise Exception("'Authorization' header cannot be included in signed headers")
|
||||
self.signed_headers = signed_headers
|
||||
self.private_key = None
|
||||
"""The private key used to sign HTTP requests.
|
||||
Initialized when the PEM-encoded private key is loaded from a file.
|
||||
"""
|
||||
self.host = None
|
||||
"""The host name, optionally followed by a colon and TCP port number.
|
||||
"""
|
||||
self._load_private_key()
|
||||
|
||||
def get_http_signature_headers(self, resource_path, method, headers, body, query_params):
|
||||
"""Create a cryptographic message signature for the HTTP request and add the signed headers.
|
||||
|
||||
:param resource_path : A string representation of the HTTP request resource path.
|
||||
:param method: A string representation of the HTTP request method, e.g. GET, POST.
|
||||
:param headers: A dict containing the HTTP request headers.
|
||||
:param body: The object representing the HTTP request body.
|
||||
:param query_params: A string representing the HTTP request query parameters.
|
||||
:return: A dict of HTTP headers that must be added to the outbound HTTP request.
|
||||
"""
|
||||
if method is None:
|
||||
raise Exception("HTTP method must be set")
|
||||
if resource_path is None:
|
||||
raise Exception("Resource path must be set")
|
||||
|
||||
signed_headers_list, request_headers_dict = self._get_signed_header_info(
|
||||
resource_path, method, headers, body, query_params)
|
||||
|
||||
header_items = [
|
||||
"{0}: {1}".format(key.lower(), value) for key, value in signed_headers_list]
|
||||
string_to_sign = "\n".join(header_items)
|
||||
|
||||
digest, digest_prefix = self._get_message_digest(string_to_sign.encode())
|
||||
b64_signed_msg = self._sign_digest(digest)
|
||||
|
||||
request_headers_dict[HEADER_AUTHORIZATION] = self._get_authorization_header(
|
||||
signed_headers_list, b64_signed_msg)
|
||||
|
||||
return request_headers_dict
|
||||
|
||||
def get_public_key(self):
|
||||
"""Returns the public key object associated with the private key.
|
||||
"""
|
||||
pubkey = None
|
||||
if isinstance(self.private_key, RSA.RsaKey):
|
||||
pubkey = self.private_key.publickey()
|
||||
elif isinstance(self.private_key, ECC.EccKey):
|
||||
pubkey = self.private_key.public_key()
|
||||
return pubkey
|
||||
|
||||
def _load_private_key(self):
|
||||
"""Load the private key used to sign HTTP requests.
|
||||
The private key is used to sign HTTP requests as defined in
|
||||
https://datatracker.ietf.org/doc/draft-cavage-http-signatures/.
|
||||
"""
|
||||
if self.private_key is not None:
|
||||
return
|
||||
with open(self.private_key_path, 'r') as f:
|
||||
pem_data = f.read()
|
||||
# Verify PEM Pre-Encapsulation Boundary
|
||||
r = re.compile(r"\s*-----BEGIN (.*)-----\s+")
|
||||
m = r.match(pem_data)
|
||||
if not m:
|
||||
raise ValueError("Not a valid PEM pre boundary")
|
||||
pem_header = m.group(1)
|
||||
if pem_header == 'RSA PRIVATE KEY':
|
||||
self.private_key = RSA.importKey(pem_data, self.private_key_passphrase)
|
||||
elif pem_header == 'EC PRIVATE KEY':
|
||||
self.private_key = ECC.import_key(pem_data, self.private_key_passphrase)
|
||||
elif pem_header in {'PRIVATE KEY', 'ENCRYPTED PRIVATE KEY'}:
|
||||
# Key is in PKCS8 format, which is capable of holding many different
|
||||
# types of private keys, not just EC keys.
|
||||
(key_binary, pem_header, is_encrypted) = \
|
||||
PEM.decode(pem_data, self.private_key_passphrase)
|
||||
(oid, privkey, params) = \
|
||||
PKCS8.unwrap(key_binary, passphrase=self.private_key_passphrase)
|
||||
if oid == '1.2.840.10045.2.1':
|
||||
self.private_key = ECC.import_key(pem_data, self.private_key_passphrase)
|
||||
else:
|
||||
raise Exception("Unsupported key: {0}. OID: {1}".format(pem_header, oid))
|
||||
else:
|
||||
raise Exception("Unsupported key: {0}".format(pem_header))
|
||||
# Validate the specified signature algorithm is compatible with the private key.
|
||||
if self.signing_algorithm is not None:
|
||||
supported_algs = None
|
||||
if isinstance(self.private_key, RSA.RsaKey):
|
||||
supported_algs = {ALGORITHM_RSASSA_PSS, ALGORITHM_RSASSA_PKCS1v15}
|
||||
elif isinstance(self.private_key, ECC.EccKey):
|
||||
supported_algs = ALGORITHM_ECDSA_KEY_SIGNING_ALGORITHMS
|
||||
if supported_algs is not None and self.signing_algorithm not in supported_algs:
|
||||
raise Exception(
|
||||
"Signing algorithm {0} is not compatible with private key".format(
|
||||
self.signing_algorithm))
|
||||
|
||||
def _get_signed_header_info(self, resource_path, method, headers, body, query_params):
|
||||
"""Build the HTTP headers (name, value) that need to be included in
|
||||
the HTTP signature scheme.
|
||||
|
||||
:param resource_path : A string representation of the HTTP request resource path.
|
||||
:param method: A string representation of the HTTP request method, e.g. GET, POST.
|
||||
:param headers: A dict containing the HTTP request headers.
|
||||
:param body: The object (e.g. a dict) representing the HTTP request body.
|
||||
:param query_params: A string representing the HTTP request query parameters.
|
||||
:return: A tuple containing two dict objects:
|
||||
The first dict contains the HTTP headers that are used to calculate
|
||||
the HTTP signature.
|
||||
The second dict contains the HTTP headers that must be added to
|
||||
the outbound HTTP request.
|
||||
"""
|
||||
|
||||
if body is None:
|
||||
body = ''
|
||||
else:
|
||||
body = json.dumps(body)
|
||||
|
||||
# Build the '(request-target)' HTTP signature parameter.
|
||||
target_host = urlparse(self.host).netloc
|
||||
target_path = urlparse(self.host).path
|
||||
request_target = method.lower() + " " + target_path + resource_path
|
||||
if query_params:
|
||||
request_target += "?" + urlencode(query_params)
|
||||
|
||||
# Get UNIX time, e.g. seconds since epoch, not including leap seconds.
|
||||
now = time()
|
||||
# Format date per RFC 7231 section-7.1.1.2. An example is:
|
||||
# Date: Wed, 21 Oct 2015 07:28:00 GMT
|
||||
cdate = formatdate(timeval=now, localtime=False, usegmt=True)
|
||||
# The '(created)' value MUST be a Unix timestamp integer value.
|
||||
# Subsecond precision is not supported.
|
||||
created = int(now)
|
||||
if self.signature_max_validity is not None:
|
||||
expires = now + self.signature_max_validity.total_seconds()
|
||||
|
||||
signed_headers_list = []
|
||||
request_headers_dict = {}
|
||||
for hdr_key in self.signed_headers:
|
||||
hdr_key = hdr_key.lower()
|
||||
if hdr_key == HEADER_REQUEST_TARGET:
|
||||
value = request_target
|
||||
elif hdr_key == HEADER_CREATED:
|
||||
value = '{0}'.format(created)
|
||||
elif hdr_key == HEADER_EXPIRES:
|
||||
value = '{0}'.format(expires)
|
||||
elif hdr_key == HEADER_DATE.lower():
|
||||
value = cdate
|
||||
request_headers_dict[HEADER_DATE] = '{0}'.format(cdate)
|
||||
elif hdr_key == HEADER_DIGEST.lower():
|
||||
request_body = body.encode()
|
||||
body_digest, digest_prefix = self._get_message_digest(request_body)
|
||||
b64_body_digest = b64encode(body_digest.digest())
|
||||
value = digest_prefix + b64_body_digest.decode('ascii')
|
||||
request_headers_dict[HEADER_DIGEST] = '{0}{1}'.format(
|
||||
digest_prefix, b64_body_digest.decode('ascii'))
|
||||
elif hdr_key == HEADER_HOST.lower():
|
||||
value = target_host
|
||||
request_headers_dict[HEADER_HOST] = '{0}'.format(target_host)
|
||||
else:
|
||||
value = next((v for k, v in headers.items() if k.lower() == hdr_key), None)
|
||||
if value is None:
|
||||
raise Exception(
|
||||
"Cannot sign HTTP request. "
|
||||
"Request does not contain the '{0}' header".format(hdr_key))
|
||||
signed_headers_list.append((hdr_key, value))
|
||||
|
||||
return signed_headers_list, request_headers_dict
|
||||
|
||||
def _get_message_digest(self, data):
|
||||
"""Calculates and returns a cryptographic digest of a specified HTTP request.
|
||||
|
||||
:param data: The string representation of the date to be hashed with a cryptographic hash.
|
||||
:return: A tuple of (digest, prefix).
|
||||
The digest is a hashing object that contains the cryptographic digest of
|
||||
the HTTP request.
|
||||
The prefix is a string that identifies the cryptographc hash. It is used
|
||||
to generate the 'Digest' header as specified in RFC 3230.
|
||||
"""
|
||||
if self.hash_algorithm == HASH_SHA512:
|
||||
digest = SHA512.new()
|
||||
prefix = 'SHA-512='
|
||||
elif self.hash_algorithm == HASH_SHA256:
|
||||
digest = SHA256.new()
|
||||
prefix = 'SHA-256='
|
||||
else:
|
||||
raise Exception("Unsupported hash algorithm: {0}".format(self.hash_algorithm))
|
||||
digest.update(data)
|
||||
return digest, prefix
|
||||
|
||||
def _sign_digest(self, digest):
|
||||
"""Signs a message digest with a private key specified in the signing_info.
|
||||
|
||||
:param digest: A hashing object that contains the cryptographic digest of the HTTP request.
|
||||
:return: A base-64 string representing the cryptographic signature of the input digest.
|
||||
"""
|
||||
sig_alg = self.signing_algorithm
|
||||
if isinstance(self.private_key, RSA.RsaKey):
|
||||
if sig_alg is None or sig_alg == ALGORITHM_RSASSA_PSS:
|
||||
# RSASSA-PSS in Section 8.1 of RFC8017.
|
||||
signature = pss.new(self.private_key).sign(digest)
|
||||
elif sig_alg == ALGORITHM_RSASSA_PKCS1v15:
|
||||
# RSASSA-PKCS1-v1_5 in Section 8.2 of RFC8017.
|
||||
signature = PKCS1_v1_5.new(self.private_key).sign(digest)
|
||||
else:
|
||||
raise Exception("Unsupported signature algorithm: {0}".format(sig_alg))
|
||||
elif isinstance(self.private_key, ECC.EccKey):
|
||||
if sig_alg is None:
|
||||
sig_alg = ALGORITHM_ECDSA_MODE_FIPS_186_3
|
||||
if sig_alg in ALGORITHM_ECDSA_KEY_SIGNING_ALGORITHMS:
|
||||
# draft-ietf-httpbis-message-signatures-00 does not specify the ECDSA encoding.
|
||||
# Issue: https://github.com/w3c-ccg/http-signatures/issues/107
|
||||
signature = DSS.new(key=self.private_key, mode=sig_alg,
|
||||
encoding='der').sign(digest)
|
||||
else:
|
||||
raise Exception("Unsupported signature algorithm: {0}".format(sig_alg))
|
||||
else:
|
||||
raise Exception("Unsupported private key: {0}".format(type(self.private_key)))
|
||||
return b64encode(signature)
|
||||
|
||||
def _get_authorization_header(self, signed_headers, signed_msg):
|
||||
"""Calculates and returns the value of the 'Authorization' header when signing HTTP requests.
|
||||
|
||||
:param signed_headers : A list of tuples. Each value is the name of a HTTP header that
|
||||
must be included in the HTTP signature calculation.
|
||||
:param signed_msg: A base-64 encoded string representation of the signature.
|
||||
:return: The string value of the 'Authorization' header, representing the signature
|
||||
of the HTTP request.
|
||||
"""
|
||||
created_ts = None
|
||||
expires_ts = None
|
||||
for k, v in signed_headers:
|
||||
if k == HEADER_CREATED:
|
||||
created_ts = v
|
||||
elif k == HEADER_EXPIRES:
|
||||
expires_ts = v
|
||||
lower_keys = [k.lower() for k, v in signed_headers]
|
||||
headers_value = " ".join(lower_keys)
|
||||
|
||||
auth_str = "Signature keyId=\"{0}\",algorithm=\"{1}\",".format(
|
||||
self.key_id, self.signing_scheme)
|
||||
if created_ts is not None:
|
||||
auth_str = auth_str + "created={0},".format(created_ts)
|
||||
if expires_ts is not None:
|
||||
auth_str = auth_str + "expires={0},".format(expires_ts)
|
||||
auth_str = auth_str + "headers=\"{0}\",signature=\"{1}\"".format(
|
||||
headers_value, signed_msg.decode('ascii'))
|
||||
|
||||
return auth_str
|
@ -0,0 +1,15 @@
|
||||
{{#if useNose}}
|
||||
coverage>=4.0.3
|
||||
nose>=1.3.7
|
||||
pluggy>=0.3.1
|
||||
py>=1.4.31
|
||||
randomize>=0.13
|
||||
{{/if}}
|
||||
{{#unless useNose}}
|
||||
pytest~=4.6.7 # needed for python 3.4
|
||||
pytest-cov>=2.8.1
|
||||
pytest-randomly==1.2.3 # needed for python 3.4
|
||||
{{/unless}}
|
||||
{{#if hasHttpSignatureMethods}}
|
||||
pycryptodome>=3.9.0
|
||||
{{/if}}
|
@ -0,0 +1,9 @@
|
||||
[tox]
|
||||
envlist = py3
|
||||
|
||||
[testenv]
|
||||
deps=-r{toxinidir}/requirements.txt
|
||||
-r{toxinidir}/test-requirements.txt
|
||||
|
||||
commands=
|
||||
{{#unless useNose}}pytest --cov={{{packageName}}}{{/unless}}{{#if useNose}}nosetests{{/if}}
|
@ -0,0 +1,18 @@
|
||||
# ref: https://docs.travis-ci.com/user/languages/python
|
||||
language: python
|
||||
python:
|
||||
- "3.5"
|
||||
- "3.6"
|
||||
- "3.7"
|
||||
- "3.8"
|
||||
# command to install dependencies
|
||||
install:
|
||||
- "pip install -r requirements.txt"
|
||||
- "pip install -r test-requirements.txt"
|
||||
# command to run tests
|
||||
{{#if useNose}}
|
||||
script: nosetests
|
||||
{{/if}}
|
||||
{{#unless useNose}}
|
||||
script: pytest --cov={{{packageName}}}
|
||||
{{/unless}}
|
File diff suppressed because it is too large
Load Diff
67
samples/openapi3/client/petstore/python-experimental/.gitignore
vendored
Normal file
67
samples/openapi3/client/petstore/python-experimental/.gitignore
vendored
Normal file
@ -0,0 +1,67 @@
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
|
||||
# C extensions
|
||||
*.so
|
||||
|
||||
# Distribution / packaging
|
||||
.Python
|
||||
env/
|
||||
build/
|
||||
develop-eggs/
|
||||
dist/
|
||||
downloads/
|
||||
eggs/
|
||||
.eggs/
|
||||
lib/
|
||||
lib64/
|
||||
parts/
|
||||
sdist/
|
||||
var/
|
||||
*.egg-info/
|
||||
.installed.cfg
|
||||
*.egg
|
||||
|
||||
# PyInstaller
|
||||
# Usually these files are written by a python script from a template
|
||||
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||
*.manifest
|
||||
*.spec
|
||||
|
||||
# Installer logs
|
||||
pip-log.txt
|
||||
pip-delete-this-directory.txt
|
||||
dev-requirements.txt.log
|
||||
|
||||
# Unit test / coverage reports
|
||||
htmlcov/
|
||||
.tox/
|
||||
.coverage
|
||||
.coverage.*
|
||||
.cache
|
||||
nosetests.xml
|
||||
coverage.xml
|
||||
*,cover
|
||||
.hypothesis/
|
||||
venv/
|
||||
.venv/
|
||||
.python-version
|
||||
.pytest_cache
|
||||
|
||||
# Translations
|
||||
*.mo
|
||||
*.pot
|
||||
|
||||
# Django stuff:
|
||||
*.log
|
||||
|
||||
# Sphinx documentation
|
||||
docs/_build/
|
||||
|
||||
# PyBuilder
|
||||
target/
|
||||
|
||||
#Ipython Notebook
|
||||
.ipynb_checkpoints
|
@ -0,0 +1,24 @@
|
||||
# ref: https://docs.gitlab.com/ee/ci/README.html
|
||||
|
||||
stages:
|
||||
- test
|
||||
|
||||
.tests:
|
||||
stage: test
|
||||
script:
|
||||
- pip install -r requirements.txt
|
||||
- pip install -r test-requirements.txt
|
||||
- pytest --cov=petstore_api
|
||||
|
||||
test-3.5:
|
||||
extends: .tests
|
||||
image: python:3.5-alpine
|
||||
test-3.6:
|
||||
extends: .tests
|
||||
image: python:3.6-alpine
|
||||
test-3.7:
|
||||
extends: .tests
|
||||
image: python:3.7-alpine
|
||||
test-3.8:
|
||||
extends: .tests
|
||||
image: python:3.8-alpine
|
@ -0,0 +1,23 @@
|
||||
# OpenAPI Generator Ignore
|
||||
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
|
||||
|
||||
# Use this file to prevent files from being overwritten by the generator.
|
||||
# The patterns follow closely to .gitignore or .dockerignore.
|
||||
|
||||
# As an example, the C# client generator defines ApiClient.cs.
|
||||
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
|
||||
#ApiClient.cs
|
||||
|
||||
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
|
||||
#foo/*/qux
|
||||
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
|
||||
|
||||
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
|
||||
#foo/**/qux
|
||||
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
|
||||
|
||||
# You can also negate patterns with an exclamation (!).
|
||||
# For example, you can ignore all files in a docs folder with the file extension .md:
|
||||
#docs/*.md
|
||||
# Then explicitly reverse the ignore rule for a single file:
|
||||
#!docs/README.md
|
@ -0,0 +1,262 @@
|
||||
.gitignore
|
||||
.gitlab-ci.yml
|
||||
.travis.yml
|
||||
README.md
|
||||
docs/AdditionalPropertiesClass.md
|
||||
docs/AdditionalPropertiesWithArrayOfEnums.md
|
||||
docs/Address.md
|
||||
docs/Animal.md
|
||||
docs/AnimalFarm.md
|
||||
docs/AnotherFakeApi.md
|
||||
docs/ApiResponse.md
|
||||
docs/Apple.md
|
||||
docs/AppleReq.md
|
||||
docs/ArrayHoldingAnyType.md
|
||||
docs/ArrayOfArrayOfNumberOnly.md
|
||||
docs/ArrayOfEnums.md
|
||||
docs/ArrayOfNumberOnly.md
|
||||
docs/ArrayTest.md
|
||||
docs/ArrayWithValidationsInItems.md
|
||||
docs/Banana.md
|
||||
docs/BananaReq.md
|
||||
docs/Bar.md
|
||||
docs/BasquePig.md
|
||||
docs/Boolean.md
|
||||
docs/BooleanEnum.md
|
||||
docs/Capitalization.md
|
||||
docs/Cat.md
|
||||
docs/CatAllOf.md
|
||||
docs/Category.md
|
||||
docs/ChildCat.md
|
||||
docs/ChildCatAllOf.md
|
||||
docs/ClassModel.md
|
||||
docs/Client.md
|
||||
docs/ComplexQuadrilateral.md
|
||||
docs/ComplexQuadrilateralAllOf.md
|
||||
docs/ComposedAnyOfDifferentTypesNoValidations.md
|
||||
docs/ComposedArray.md
|
||||
docs/ComposedBool.md
|
||||
docs/ComposedNone.md
|
||||
docs/ComposedNumber.md
|
||||
docs/ComposedObject.md
|
||||
docs/ComposedOneOfDifferentTypes.md
|
||||
docs/ComposedString.md
|
||||
docs/DanishPig.md
|
||||
docs/DateTimeTest.md
|
||||
docs/DateTimeWithValidations.md
|
||||
docs/DateWithValidations.md
|
||||
docs/DefaultApi.md
|
||||
docs/Dog.md
|
||||
docs/DogAllOf.md
|
||||
docs/Drawing.md
|
||||
docs/EnumArrays.md
|
||||
docs/EnumClass.md
|
||||
docs/EnumTest.md
|
||||
docs/EquilateralTriangle.md
|
||||
docs/EquilateralTriangleAllOf.md
|
||||
docs/FakeApi.md
|
||||
docs/FakeClassnameTags123Api.md
|
||||
docs/File.md
|
||||
docs/FileSchemaTestClass.md
|
||||
docs/Foo.md
|
||||
docs/FormatTest.md
|
||||
docs/Fruit.md
|
||||
docs/FruitReq.md
|
||||
docs/GmFruit.md
|
||||
docs/GrandparentAnimal.md
|
||||
docs/HasOnlyReadOnly.md
|
||||
docs/HealthCheckResult.md
|
||||
docs/InlineResponseDefault.md
|
||||
docs/IntegerEnum.md
|
||||
docs/IntegerEnumBig.md
|
||||
docs/IntegerEnumOneValue.md
|
||||
docs/IntegerEnumWithDefaultValue.md
|
||||
docs/IntegerMax10.md
|
||||
docs/IntegerMin15.md
|
||||
docs/IsoscelesTriangle.md
|
||||
docs/IsoscelesTriangleAllOf.md
|
||||
docs/Mammal.md
|
||||
docs/MapTest.md
|
||||
docs/MixedPropertiesAndAdditionalPropertiesClass.md
|
||||
docs/Model200Response.md
|
||||
docs/ModelReturn.md
|
||||
docs/Name.md
|
||||
docs/NoAdditionalProperties.md
|
||||
docs/NullableClass.md
|
||||
docs/NullableShape.md
|
||||
docs/NullableString.md
|
||||
docs/Number.md
|
||||
docs/NumberOnly.md
|
||||
docs/NumberWithValidations.md
|
||||
docs/ObjectInterface.md
|
||||
docs/ObjectModelWithRefProps.md
|
||||
docs/ObjectWithDifficultlyNamedProps.md
|
||||
docs/ObjectWithValidations.md
|
||||
docs/Order.md
|
||||
docs/ParentPet.md
|
||||
docs/Pet.md
|
||||
docs/PetApi.md
|
||||
docs/Pig.md
|
||||
docs/Player.md
|
||||
docs/Quadrilateral.md
|
||||
docs/QuadrilateralInterface.md
|
||||
docs/ReadOnlyFirst.md
|
||||
docs/ScaleneTriangle.md
|
||||
docs/ScaleneTriangleAllOf.md
|
||||
docs/Shape.md
|
||||
docs/ShapeOrNull.md
|
||||
docs/SimpleQuadrilateral.md
|
||||
docs/SimpleQuadrilateralAllOf.md
|
||||
docs/SomeObject.md
|
||||
docs/SpecialModelName.md
|
||||
docs/StoreApi.md
|
||||
docs/String.md
|
||||
docs/StringBooleanMap.md
|
||||
docs/StringEnum.md
|
||||
docs/StringEnumWithDefaultValue.md
|
||||
docs/StringWithValidation.md
|
||||
docs/Tag.md
|
||||
docs/Triangle.md
|
||||
docs/TriangleInterface.md
|
||||
docs/User.md
|
||||
docs/UserApi.md
|
||||
docs/Whale.md
|
||||
docs/Zebra.md
|
||||
git_push.sh
|
||||
petstore_api/__init__.py
|
||||
petstore_api/api/__init__.py
|
||||
petstore_api/api/another_fake_api.py
|
||||
petstore_api/api/default_api.py
|
||||
petstore_api/api/fake_api.py
|
||||
petstore_api/api/fake_classname_tags_123_api.py
|
||||
petstore_api/api/pet_api.py
|
||||
petstore_api/api/store_api.py
|
||||
petstore_api/api/user_api.py
|
||||
petstore_api/api_client.py
|
||||
petstore_api/apis/__init__.py
|
||||
petstore_api/configuration.py
|
||||
petstore_api/exceptions.py
|
||||
petstore_api/model/__init__.py
|
||||
petstore_api/model/additional_properties_class.py
|
||||
petstore_api/model/additional_properties_with_array_of_enums.py
|
||||
petstore_api/model/address.py
|
||||
petstore_api/model/animal.py
|
||||
petstore_api/model/animal_farm.py
|
||||
petstore_api/model/api_response.py
|
||||
petstore_api/model/apple.py
|
||||
petstore_api/model/apple_req.py
|
||||
petstore_api/model/array_holding_any_type.py
|
||||
petstore_api/model/array_of_array_of_number_only.py
|
||||
petstore_api/model/array_of_enums.py
|
||||
petstore_api/model/array_of_number_only.py
|
||||
petstore_api/model/array_test.py
|
||||
petstore_api/model/array_with_validations_in_items.py
|
||||
petstore_api/model/banana.py
|
||||
petstore_api/model/banana_req.py
|
||||
petstore_api/model/bar.py
|
||||
petstore_api/model/basque_pig.py
|
||||
petstore_api/model/boolean.py
|
||||
petstore_api/model/boolean_enum.py
|
||||
petstore_api/model/capitalization.py
|
||||
petstore_api/model/cat.py
|
||||
petstore_api/model/cat_all_of.py
|
||||
petstore_api/model/category.py
|
||||
petstore_api/model/child_cat.py
|
||||
petstore_api/model/child_cat_all_of.py
|
||||
petstore_api/model/class_model.py
|
||||
petstore_api/model/client.py
|
||||
petstore_api/model/complex_quadrilateral.py
|
||||
petstore_api/model/complex_quadrilateral_all_of.py
|
||||
petstore_api/model/composed_any_of_different_types_no_validations.py
|
||||
petstore_api/model/composed_array.py
|
||||
petstore_api/model/composed_bool.py
|
||||
petstore_api/model/composed_none.py
|
||||
petstore_api/model/composed_number.py
|
||||
petstore_api/model/composed_object.py
|
||||
petstore_api/model/composed_one_of_different_types.py
|
||||
petstore_api/model/composed_string.py
|
||||
petstore_api/model/danish_pig.py
|
||||
petstore_api/model/date_time_test.py
|
||||
petstore_api/model/date_time_with_validations.py
|
||||
petstore_api/model/date_with_validations.py
|
||||
petstore_api/model/dog.py
|
||||
petstore_api/model/dog_all_of.py
|
||||
petstore_api/model/drawing.py
|
||||
petstore_api/model/enum_arrays.py
|
||||
petstore_api/model/enum_class.py
|
||||
petstore_api/model/enum_test.py
|
||||
petstore_api/model/equilateral_triangle.py
|
||||
petstore_api/model/equilateral_triangle_all_of.py
|
||||
petstore_api/model/file.py
|
||||
petstore_api/model/file_schema_test_class.py
|
||||
petstore_api/model/foo.py
|
||||
petstore_api/model/format_test.py
|
||||
petstore_api/model/fruit.py
|
||||
petstore_api/model/fruit_req.py
|
||||
petstore_api/model/gm_fruit.py
|
||||
petstore_api/model/grandparent_animal.py
|
||||
petstore_api/model/has_only_read_only.py
|
||||
petstore_api/model/health_check_result.py
|
||||
petstore_api/model/inline_response_default.py
|
||||
petstore_api/model/integer_enum.py
|
||||
petstore_api/model/integer_enum_big.py
|
||||
petstore_api/model/integer_enum_one_value.py
|
||||
petstore_api/model/integer_enum_with_default_value.py
|
||||
petstore_api/model/integer_max10.py
|
||||
petstore_api/model/integer_min15.py
|
||||
petstore_api/model/isosceles_triangle.py
|
||||
petstore_api/model/isosceles_triangle_all_of.py
|
||||
petstore_api/model/mammal.py
|
||||
petstore_api/model/map_test.py
|
||||
petstore_api/model/mixed_properties_and_additional_properties_class.py
|
||||
petstore_api/model/model200_response.py
|
||||
petstore_api/model/model_return.py
|
||||
petstore_api/model/name.py
|
||||
petstore_api/model/no_additional_properties.py
|
||||
petstore_api/model/nullable_class.py
|
||||
petstore_api/model/nullable_shape.py
|
||||
petstore_api/model/nullable_string.py
|
||||
petstore_api/model/number.py
|
||||
petstore_api/model/number_only.py
|
||||
petstore_api/model/number_with_validations.py
|
||||
petstore_api/model/object_interface.py
|
||||
petstore_api/model/object_model_with_ref_props.py
|
||||
petstore_api/model/object_with_difficultly_named_props.py
|
||||
petstore_api/model/object_with_validations.py
|
||||
petstore_api/model/order.py
|
||||
petstore_api/model/parent_pet.py
|
||||
petstore_api/model/pet.py
|
||||
petstore_api/model/pig.py
|
||||
petstore_api/model/player.py
|
||||
petstore_api/model/quadrilateral.py
|
||||
petstore_api/model/quadrilateral_interface.py
|
||||
petstore_api/model/read_only_first.py
|
||||
petstore_api/model/scalene_triangle.py
|
||||
petstore_api/model/scalene_triangle_all_of.py
|
||||
petstore_api/model/shape.py
|
||||
petstore_api/model/shape_or_null.py
|
||||
petstore_api/model/simple_quadrilateral.py
|
||||
petstore_api/model/simple_quadrilateral_all_of.py
|
||||
petstore_api/model/some_object.py
|
||||
petstore_api/model/special_model_name.py
|
||||
petstore_api/model/string.py
|
||||
petstore_api/model/string_boolean_map.py
|
||||
petstore_api/model/string_enum.py
|
||||
petstore_api/model/string_enum_with_default_value.py
|
||||
petstore_api/model/string_with_validation.py
|
||||
petstore_api/model/tag.py
|
||||
petstore_api/model/triangle.py
|
||||
petstore_api/model/triangle_interface.py
|
||||
petstore_api/model/user.py
|
||||
petstore_api/model/whale.py
|
||||
petstore_api/model/zebra.py
|
||||
petstore_api/models/__init__.py
|
||||
petstore_api/rest.py
|
||||
petstore_api/schemas.py
|
||||
petstore_api/signing.py
|
||||
requirements.txt
|
||||
setup.cfg
|
||||
setup.py
|
||||
test-requirements.txt
|
||||
test/__init__.py
|
||||
tox.ini
|
@ -0,0 +1 @@
|
||||
5.4.0-SNAPSHOT
|
@ -0,0 +1,13 @@
|
||||
# ref: https://docs.travis-ci.com/user/languages/python
|
||||
language: python
|
||||
python:
|
||||
- "3.5"
|
||||
- "3.6"
|
||||
- "3.7"
|
||||
- "3.8"
|
||||
# command to install dependencies
|
||||
install:
|
||||
- "pip install -r requirements.txt"
|
||||
- "pip install -r test-requirements.txt"
|
||||
# command to run tests
|
||||
script: pytest --cov=petstore_api
|
@ -0,0 +1,16 @@
|
||||
REQUIREMENTS_FILE=dev-requirements.txt
|
||||
REQUIREMENTS_OUT=dev-requirements.txt.log
|
||||
SETUP_OUT=*.egg-info
|
||||
VENV=venv
|
||||
|
||||
clean:
|
||||
rm -rf $(REQUIREMENTS_OUT)
|
||||
rm -rf $(SETUP_OUT)
|
||||
rm -rf $(VENV)
|
||||
rm -rf .tox
|
||||
rm -rf .coverage
|
||||
find . -name "*.py[oc]" -delete
|
||||
find . -name "__pycache__" -delete
|
||||
|
||||
test: clean
|
||||
bash ./test_python.sh
|
320
samples/openapi3/client/petstore/python-experimental/README.md
Normal file
320
samples/openapi3/client/petstore/python-experimental/README.md
Normal file
@ -0,0 +1,320 @@
|
||||
# petstore-api
|
||||
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
|
||||
This Python package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:
|
||||
|
||||
- API version: 1.0.0
|
||||
- Package version: 1.0.0
|
||||
- Build package: org.openapitools.codegen.languages.PythonExperimentalClientCodegen
|
||||
|
||||
## Requirements.
|
||||
|
||||
Python >= 3.9
|
||||
v3.9 is needed so one can combine classmethod and property decorators to define
|
||||
object schema properties as classes
|
||||
|
||||
## Installation & Usage
|
||||
### pip install
|
||||
|
||||
If the python package is hosted on a repository, you can install directly using:
|
||||
|
||||
```sh
|
||||
pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git
|
||||
```
|
||||
(you may need to run `pip` with root permission: `sudo pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git`)
|
||||
|
||||
Then import the package:
|
||||
```python
|
||||
import petstore_api
|
||||
```
|
||||
|
||||
### Setuptools
|
||||
|
||||
Install via [Setuptools](http://pypi.python.org/pypi/setuptools).
|
||||
|
||||
```sh
|
||||
python setup.py install --user
|
||||
```
|
||||
(or `sudo python setup.py install` to install the package for all users)
|
||||
|
||||
Then import the package:
|
||||
```python
|
||||
import petstore_api
|
||||
```
|
||||
|
||||
## Getting Started
|
||||
|
||||
Please follow the [installation procedure](#installation--usage) and then run the following:
|
||||
|
||||
```python
|
||||
import datetimeimport datetimeimport datetimeimport datetimeimport datetimeimport datetimeimport datetime
|
||||
import time
|
||||
import petstore_api
|
||||
from pprint import pprint
|
||||
from petstore_api.api import another_fake_api
|
||||
from petstore_api.model.client import Client
|
||||
# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2
|
||||
# See configuration.py for a list of all supported configuration parameters.
|
||||
configuration = petstore_api.Configuration(
|
||||
host = "http://petstore.swagger.io:80/v2"
|
||||
)
|
||||
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = another_fake_api.AnotherFakeApi(api_client)
|
||||
client = Client(
|
||||
client="client_example",
|
||||
) # Client | client model
|
||||
|
||||
try:
|
||||
# To test special tags
|
||||
api_response = api_instance.call_123_test_special_tags(client)
|
||||
pprint(api_response)
|
||||
except petstore_api.ApiException as e:
|
||||
print("Exception when calling AnotherFakeApi->call_123_test_special_tags: %s\n" % e)
|
||||
```
|
||||
|
||||
## Documentation for API Endpoints
|
||||
|
||||
All URIs are relative to *http://petstore.swagger.io:80/v2*
|
||||
|
||||
Class | Method | HTTP request | Description
|
||||
------------ | ------------- | ------------- | -------------
|
||||
*AnotherFakeApi* | [**call_123_test_special_tags**](docs/AnotherFakeApi.md#call_123_test_special_tags) | **PATCH** /another-fake/dummy | To test special tags
|
||||
*DefaultApi* | [**foo_get**](docs/DefaultApi.md#foo_get) | **GET** /foo |
|
||||
*FakeApi* | [**additional_properties_with_array_of_enums**](docs/FakeApi.md#additional_properties_with_array_of_enums) | **GET** /fake/additional-properties-with-array-of-enums | Additional Properties with Array of Enums
|
||||
*FakeApi* | [**array_model**](docs/FakeApi.md#array_model) | **POST** /fake/refs/arraymodel |
|
||||
*FakeApi* | [**array_of_enums**](docs/FakeApi.md#array_of_enums) | **POST** /fake/refs/array-of-enums | Array of Enums
|
||||
*FakeApi* | [**body_with_file_schema**](docs/FakeApi.md#body_with_file_schema) | **PUT** /fake/body-with-file-schema |
|
||||
*FakeApi* | [**body_with_query_params**](docs/FakeApi.md#body_with_query_params) | **PUT** /fake/body-with-query-params |
|
||||
*FakeApi* | [**boolean**](docs/FakeApi.md#boolean) | **POST** /fake/refs/boolean |
|
||||
*FakeApi* | [**case_sensitive_params**](docs/FakeApi.md#case_sensitive_params) | **PUT** /fake/case-sensitive-params |
|
||||
*FakeApi* | [**client_model**](docs/FakeApi.md#client_model) | **PATCH** /fake | To test \"client\" model
|
||||
*FakeApi* | [**composed_one_of_different_types**](docs/FakeApi.md#composed_one_of_different_types) | **POST** /fake/refs/composed_one_of_number_with_validations |
|
||||
*FakeApi* | [**endpoint_parameters**](docs/FakeApi.md#endpoint_parameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
||||
*FakeApi* | [**enum_parameters**](docs/FakeApi.md#enum_parameters) | **GET** /fake | To test enum parameters
|
||||
*FakeApi* | [**fake_health_get**](docs/FakeApi.md#fake_health_get) | **GET** /fake/health | Health check endpoint
|
||||
*FakeApi* | [**group_parameters**](docs/FakeApi.md#group_parameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional)
|
||||
*FakeApi* | [**inline_additional_properties**](docs/FakeApi.md#inline_additional_properties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties
|
||||
*FakeApi* | [**json_form_data**](docs/FakeApi.md#json_form_data) | **GET** /fake/jsonFormData | test json serialization of form data
|
||||
*FakeApi* | [**mammal**](docs/FakeApi.md#mammal) | **POST** /fake/refs/mammal |
|
||||
*FakeApi* | [**number_with_validations**](docs/FakeApi.md#number_with_validations) | **POST** /fake/refs/number |
|
||||
*FakeApi* | [**object_model_with_ref_props**](docs/FakeApi.md#object_model_with_ref_props) | **POST** /fake/refs/object_model_with_ref_props |
|
||||
*FakeApi* | [**parameter_collisions**](docs/FakeApi.md#parameter_collisions) | **POST** /fake/parameterCollisions/{1}/{aB}/{Ab}/{self}/{A-B}/ | parameter collision case
|
||||
*FakeApi* | [**query_parameter_collection_format**](docs/FakeApi.md#query_parameter_collection_format) | **PUT** /fake/test-query-paramters |
|
||||
*FakeApi* | [**string**](docs/FakeApi.md#string) | **POST** /fake/refs/string |
|
||||
*FakeApi* | [**string_enum**](docs/FakeApi.md#string_enum) | **POST** /fake/refs/enum |
|
||||
*FakeApi* | [**upload_download_file**](docs/FakeApi.md#upload_download_file) | **POST** /fake/uploadDownloadFile | uploads a file and downloads a file using application/octet-stream
|
||||
*FakeApi* | [**upload_file**](docs/FakeApi.md#upload_file) | **POST** /fake/uploadFile | uploads a file using multipart/form-data
|
||||
*FakeApi* | [**upload_files**](docs/FakeApi.md#upload_files) | **POST** /fake/uploadFiles | uploads files using multipart/form-data
|
||||
*FakeClassnameTags123Api* | [**classname**](docs/FakeClassnameTags123Api.md#classname) | **PATCH** /fake_classname_test | To test class name in snake case
|
||||
*PetApi* | [**add_pet**](docs/PetApi.md#add_pet) | **POST** /pet | Add a new pet to the store
|
||||
*PetApi* | [**delete_pet**](docs/PetApi.md#delete_pet) | **DELETE** /pet/{petId} | Deletes a pet
|
||||
*PetApi* | [**find_pets_by_status**](docs/PetApi.md#find_pets_by_status) | **GET** /pet/findByStatus | Finds Pets by status
|
||||
*PetApi* | [**find_pets_by_tags**](docs/PetApi.md#find_pets_by_tags) | **GET** /pet/findByTags | Finds Pets by tags
|
||||
*PetApi* | [**get_pet_by_id**](docs/PetApi.md#get_pet_by_id) | **GET** /pet/{petId} | Find pet by ID
|
||||
*PetApi* | [**update_pet**](docs/PetApi.md#update_pet) | **PUT** /pet | Update an existing pet
|
||||
*PetApi* | [**update_pet_with_form**](docs/PetApi.md#update_pet_with_form) | **POST** /pet/{petId} | Updates a pet in the store with form data
|
||||
*PetApi* | [**upload_file_with_required_file**](docs/PetApi.md#upload_file_with_required_file) | **POST** /fake/{petId}/uploadImageWithRequiredFile | uploads an image (required)
|
||||
*PetApi* | [**upload_image**](docs/PetApi.md#upload_image) | **POST** /pet/{petId}/uploadImage | uploads an image
|
||||
*StoreApi* | [**delete_order**](docs/StoreApi.md#delete_order) | **DELETE** /store/order/{order_id} | Delete purchase order by ID
|
||||
*StoreApi* | [**get_inventory**](docs/StoreApi.md#get_inventory) | **GET** /store/inventory | Returns pet inventories by status
|
||||
*StoreApi* | [**get_order_by_id**](docs/StoreApi.md#get_order_by_id) | **GET** /store/order/{order_id} | Find purchase order by ID
|
||||
*StoreApi* | [**place_order**](docs/StoreApi.md#place_order) | **POST** /store/order | Place an order for a pet
|
||||
*UserApi* | [**create_user**](docs/UserApi.md#create_user) | **POST** /user | Create user
|
||||
*UserApi* | [**create_users_with_array_input**](docs/UserApi.md#create_users_with_array_input) | **POST** /user/createWithArray | Creates list of users with given input array
|
||||
*UserApi* | [**create_users_with_list_input**](docs/UserApi.md#create_users_with_list_input) | **POST** /user/createWithList | Creates list of users with given input array
|
||||
*UserApi* | [**delete_user**](docs/UserApi.md#delete_user) | **DELETE** /user/{username} | Delete user
|
||||
*UserApi* | [**get_user_by_name**](docs/UserApi.md#get_user_by_name) | **GET** /user/{username} | Get user by user name
|
||||
*UserApi* | [**login_user**](docs/UserApi.md#login_user) | **GET** /user/login | Logs user into the system
|
||||
*UserApi* | [**logout_user**](docs/UserApi.md#logout_user) | **GET** /user/logout | Logs out current logged in user session
|
||||
*UserApi* | [**update_user**](docs/UserApi.md#update_user) | **PUT** /user/{username} | Updated user
|
||||
|
||||
## Documentation For Models
|
||||
|
||||
- [AdditionalPropertiesClass](docs/AdditionalPropertiesClass.md)
|
||||
- [AdditionalPropertiesWithArrayOfEnums](docs/AdditionalPropertiesWithArrayOfEnums.md)
|
||||
- [Address](docs/Address.md)
|
||||
- [Animal](docs/Animal.md)
|
||||
- [AnimalFarm](docs/AnimalFarm.md)
|
||||
- [ApiResponse](docs/ApiResponse.md)
|
||||
- [Apple](docs/Apple.md)
|
||||
- [AppleReq](docs/AppleReq.md)
|
||||
- [ArrayHoldingAnyType](docs/ArrayHoldingAnyType.md)
|
||||
- [ArrayOfArrayOfNumberOnly](docs/ArrayOfArrayOfNumberOnly.md)
|
||||
- [ArrayOfEnums](docs/ArrayOfEnums.md)
|
||||
- [ArrayOfNumberOnly](docs/ArrayOfNumberOnly.md)
|
||||
- [ArrayTest](docs/ArrayTest.md)
|
||||
- [ArrayWithValidationsInItems](docs/ArrayWithValidationsInItems.md)
|
||||
- [Banana](docs/Banana.md)
|
||||
- [BananaReq](docs/BananaReq.md)
|
||||
- [Bar](docs/Bar.md)
|
||||
- [BasquePig](docs/BasquePig.md)
|
||||
- [Boolean](docs/Boolean.md)
|
||||
- [BooleanEnum](docs/BooleanEnum.md)
|
||||
- [Capitalization](docs/Capitalization.md)
|
||||
- [Cat](docs/Cat.md)
|
||||
- [CatAllOf](docs/CatAllOf.md)
|
||||
- [Category](docs/Category.md)
|
||||
- [ChildCat](docs/ChildCat.md)
|
||||
- [ChildCatAllOf](docs/ChildCatAllOf.md)
|
||||
- [ClassModel](docs/ClassModel.md)
|
||||
- [Client](docs/Client.md)
|
||||
- [ComplexQuadrilateral](docs/ComplexQuadrilateral.md)
|
||||
- [ComplexQuadrilateralAllOf](docs/ComplexQuadrilateralAllOf.md)
|
||||
- [ComposedAnyOfDifferentTypesNoValidations](docs/ComposedAnyOfDifferentTypesNoValidations.md)
|
||||
- [ComposedArray](docs/ComposedArray.md)
|
||||
- [ComposedBool](docs/ComposedBool.md)
|
||||
- [ComposedNone](docs/ComposedNone.md)
|
||||
- [ComposedNumber](docs/ComposedNumber.md)
|
||||
- [ComposedObject](docs/ComposedObject.md)
|
||||
- [ComposedOneOfDifferentTypes](docs/ComposedOneOfDifferentTypes.md)
|
||||
- [ComposedString](docs/ComposedString.md)
|
||||
- [DanishPig](docs/DanishPig.md)
|
||||
- [DateTimeTest](docs/DateTimeTest.md)
|
||||
- [DateTimeWithValidations](docs/DateTimeWithValidations.md)
|
||||
- [DateWithValidations](docs/DateWithValidations.md)
|
||||
- [Dog](docs/Dog.md)
|
||||
- [DogAllOf](docs/DogAllOf.md)
|
||||
- [Drawing](docs/Drawing.md)
|
||||
- [EnumArrays](docs/EnumArrays.md)
|
||||
- [EnumClass](docs/EnumClass.md)
|
||||
- [EnumTest](docs/EnumTest.md)
|
||||
- [EquilateralTriangle](docs/EquilateralTriangle.md)
|
||||
- [EquilateralTriangleAllOf](docs/EquilateralTriangleAllOf.md)
|
||||
- [File](docs/File.md)
|
||||
- [FileSchemaTestClass](docs/FileSchemaTestClass.md)
|
||||
- [Foo](docs/Foo.md)
|
||||
- [FormatTest](docs/FormatTest.md)
|
||||
- [Fruit](docs/Fruit.md)
|
||||
- [FruitReq](docs/FruitReq.md)
|
||||
- [GmFruit](docs/GmFruit.md)
|
||||
- [GrandparentAnimal](docs/GrandparentAnimal.md)
|
||||
- [HasOnlyReadOnly](docs/HasOnlyReadOnly.md)
|
||||
- [HealthCheckResult](docs/HealthCheckResult.md)
|
||||
- [InlineResponseDefault](docs/InlineResponseDefault.md)
|
||||
- [IntegerEnum](docs/IntegerEnum.md)
|
||||
- [IntegerEnumBig](docs/IntegerEnumBig.md)
|
||||
- [IntegerEnumOneValue](docs/IntegerEnumOneValue.md)
|
||||
- [IntegerEnumWithDefaultValue](docs/IntegerEnumWithDefaultValue.md)
|
||||
- [IntegerMax10](docs/IntegerMax10.md)
|
||||
- [IntegerMin15](docs/IntegerMin15.md)
|
||||
- [IsoscelesTriangle](docs/IsoscelesTriangle.md)
|
||||
- [IsoscelesTriangleAllOf](docs/IsoscelesTriangleAllOf.md)
|
||||
- [Mammal](docs/Mammal.md)
|
||||
- [MapTest](docs/MapTest.md)
|
||||
- [MixedPropertiesAndAdditionalPropertiesClass](docs/MixedPropertiesAndAdditionalPropertiesClass.md)
|
||||
- [Model200Response](docs/Model200Response.md)
|
||||
- [ModelReturn](docs/ModelReturn.md)
|
||||
- [Name](docs/Name.md)
|
||||
- [NoAdditionalProperties](docs/NoAdditionalProperties.md)
|
||||
- [NullableClass](docs/NullableClass.md)
|
||||
- [NullableShape](docs/NullableShape.md)
|
||||
- [NullableString](docs/NullableString.md)
|
||||
- [Number](docs/Number.md)
|
||||
- [NumberOnly](docs/NumberOnly.md)
|
||||
- [NumberWithValidations](docs/NumberWithValidations.md)
|
||||
- [ObjectInterface](docs/ObjectInterface.md)
|
||||
- [ObjectModelWithRefProps](docs/ObjectModelWithRefProps.md)
|
||||
- [ObjectWithDifficultlyNamedProps](docs/ObjectWithDifficultlyNamedProps.md)
|
||||
- [ObjectWithValidations](docs/ObjectWithValidations.md)
|
||||
- [Order](docs/Order.md)
|
||||
- [ParentPet](docs/ParentPet.md)
|
||||
- [Pet](docs/Pet.md)
|
||||
- [Pig](docs/Pig.md)
|
||||
- [Player](docs/Player.md)
|
||||
- [Quadrilateral](docs/Quadrilateral.md)
|
||||
- [QuadrilateralInterface](docs/QuadrilateralInterface.md)
|
||||
- [ReadOnlyFirst](docs/ReadOnlyFirst.md)
|
||||
- [ScaleneTriangle](docs/ScaleneTriangle.md)
|
||||
- [ScaleneTriangleAllOf](docs/ScaleneTriangleAllOf.md)
|
||||
- [Shape](docs/Shape.md)
|
||||
- [ShapeOrNull](docs/ShapeOrNull.md)
|
||||
- [SimpleQuadrilateral](docs/SimpleQuadrilateral.md)
|
||||
- [SimpleQuadrilateralAllOf](docs/SimpleQuadrilateralAllOf.md)
|
||||
- [SomeObject](docs/SomeObject.md)
|
||||
- [SpecialModelName](docs/SpecialModelName.md)
|
||||
- [String](docs/String.md)
|
||||
- [StringBooleanMap](docs/StringBooleanMap.md)
|
||||
- [StringEnum](docs/StringEnum.md)
|
||||
- [StringEnumWithDefaultValue](docs/StringEnumWithDefaultValue.md)
|
||||
- [StringWithValidation](docs/StringWithValidation.md)
|
||||
- [Tag](docs/Tag.md)
|
||||
- [Triangle](docs/Triangle.md)
|
||||
- [TriangleInterface](docs/TriangleInterface.md)
|
||||
- [User](docs/User.md)
|
||||
- [Whale](docs/Whale.md)
|
||||
- [Zebra](docs/Zebra.md)
|
||||
|
||||
## Documentation For Authorization
|
||||
|
||||
|
||||
## api_key
|
||||
|
||||
- **Type**: API key
|
||||
- **API key parameter name**: api_key
|
||||
- **Location**: HTTP header
|
||||
|
||||
|
||||
## api_key_query
|
||||
|
||||
- **Type**: API key
|
||||
- **API key parameter name**: api_key_query
|
||||
- **Location**: URL query string
|
||||
|
||||
|
||||
## bearer_test
|
||||
|
||||
- **Type**: Bearer authentication (JWT)
|
||||
|
||||
|
||||
## http_basic_test
|
||||
|
||||
- **Type**: HTTP basic authentication
|
||||
|
||||
|
||||
## http_signature_test
|
||||
|
||||
- **Type**: HTTP signature authentication
|
||||
|
||||
Authentication schemes defined for the API:
|
||||
## petstore_auth
|
||||
|
||||
- **Type**: OAuth
|
||||
- **Flow**: implicit
|
||||
- **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog
|
||||
- **Scopes**:
|
||||
- **write:pets**: modify pets in your account
|
||||
- **read:pets**: read your pets
|
||||
|
||||
|
||||
## Author
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## Notes for Large OpenAPI documents
|
||||
If the OpenAPI document is large, imports in petstore_api.apis and petstore_api.models may fail with a
|
||||
RecursionError indicating the maximum recursion limit has been exceeded. In that case, there are a couple of solutions:
|
||||
|
||||
Solution 1:
|
||||
Use specific imports for apis and models like:
|
||||
- `from petstore_api.api.default_api import DefaultApi`
|
||||
- `from petstore_api.model.pet import Pet`
|
||||
|
||||
Solution 1:
|
||||
Before importing the package, adjust the maximum recursion limit as shown below:
|
||||
```
|
||||
import sys
|
||||
sys.setrecursionlimit(1500)
|
||||
import petstore_api
|
||||
from petstore_api.apis import *
|
||||
from petstore_api.models import *
|
||||
```
|
@ -0,0 +1,2 @@
|
||||
tox
|
||||
flake8
|
@ -0,0 +1,17 @@
|
||||
# AdditionalPropertiesClass
|
||||
|
||||
#### Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**map_property** | **{str: (str,)}** | | [optional]
|
||||
**map_of_map_property** | **{str: ({str: (str,)},)}** | | [optional]
|
||||
**anytype_1** | **bool, date, datetime, dict, float, int, list, str, none_type** | | [optional]
|
||||
**map_with_undeclared_properties_anytype_1** | **{str: (bool, date, datetime, dict, float, int, list, str, none_type)}** | | [optional]
|
||||
**map_with_undeclared_properties_anytype_2** | **{str: (bool, date, datetime, dict, float, int, list, str, none_type)}** | | [optional]
|
||||
**map_with_undeclared_properties_anytype_3** | **{str: (bool, date, datetime, dict, float, int, list, str, none_type)}** | | [optional]
|
||||
**empty_map** | **bool, date, datetime, dict, float, int, list, str** | an object with no declared properties and no undeclared properties, hence it's an empty map. | [optional]
|
||||
**map_with_undeclared_properties_string** | **{str: (str,)}** | | [optional]
|
||||
**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
@ -0,0 +1,9 @@
|
||||
# AdditionalPropertiesWithArrayOfEnums
|
||||
|
||||
#### Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**any string name** | **[EnumClass]** | any string name can be used but the value must be the correct type | [optional]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
@ -0,0 +1,9 @@
|
||||
# Address
|
||||
|
||||
#### Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**any string name** | **int** | any string name can be used but the value must be the correct type | [optional]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
@ -0,0 +1,11 @@
|
||||
# Animal
|
||||
|
||||
#### Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**className** | **str** | |
|
||||
**color** | **str** | | [optional] if omitted the server will use the default value of "red"
|
||||
**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
@ -0,0 +1,8 @@
|
||||
# AnimalFarm
|
||||
|
||||
Type | Description | Notes
|
||||
------------- | ------------- | -------------
|
||||
**[Animal]** | |
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
@ -0,0 +1,94 @@
|
||||
# petstore_api.AnotherFakeApi
|
||||
|
||||
All URIs are relative to *http://petstore.swagger.io:80/v2*
|
||||
|
||||
Method | HTTP request | Description
|
||||
------------- | ------------- | -------------
|
||||
[**call_123_test_special_tags**](AnotherFakeApi.md#call_123_test_special_tags) | **PATCH** /another-fake/dummy | To test special tags
|
||||
|
||||
# **call_123_test_special_tags**
|
||||
> Client call_123_test_special_tags(client)
|
||||
|
||||
To test special tags
|
||||
|
||||
To test special tags and operation ID starting with number
|
||||
|
||||
### Example
|
||||
|
||||
```python
|
||||
import petstore_api
|
||||
from petstore_api.api import another_fake_api
|
||||
from petstore_api.model.client import Client
|
||||
from pprint import pprint
|
||||
# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2
|
||||
# See configuration.py for a list of all supported configuration parameters.
|
||||
configuration = petstore_api.Configuration(
|
||||
host = "http://petstore.swagger.io:80/v2"
|
||||
)
|
||||
|
||||
# Enter a context with an instance of the API client
|
||||
with petstore_api.ApiClient(configuration) as api_client:
|
||||
# Create an instance of the API class
|
||||
api_instance = another_fake_api.AnotherFakeApi(api_client)
|
||||
|
||||
# example passing only required values which don't have defaults set
|
||||
body = Client(
|
||||
client="client_example",
|
||||
)
|
||||
try:
|
||||
# To test special tags
|
||||
api_response = api_instance.call_123_test_special_tags(
|
||||
body=body,
|
||||
)
|
||||
pprint(api_response)
|
||||
except petstore_api.ApiException as e:
|
||||
print("Exception when calling AnotherFakeApi->call_123_test_special_tags: %s\n" % e)
|
||||
```
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
body | typing.Union[SchemaForRequestBodyApplicationJson] | required |
|
||||
content_type | str | optional, default is 'application/json' | Selects the schema and serialization of the request body
|
||||
accept_content_types | typing.Tuple[str] | default is ('application/json', ) | Tells the server the content type(s) that are accepted by the client
|
||||
stream | bool | default is False | if True then the response.content will be streamed and loaded from a file like object. When downloading a file, set this to True to force the code to deserialize the content to a FileSchema file
|
||||
timeout | typing.Optional[typing.Union[int, typing.Tuple]] | default is None | the timeout used by the rest client
|
||||
skip_deserialization | bool | default is False | when True, headers and body will be unset and an instance of api_client.ApiResponseWithoutDeserialization will be returned
|
||||
|
||||
### body
|
||||
|
||||
#### SchemaForRequestBodyApplicationJson
|
||||
Type | Description | Notes
|
||||
------------- | ------------- | -------------
|
||||
[**Client**](Client.md) | |
|
||||
|
||||
|
||||
### Return Types, Responses
|
||||
|
||||
Code | Class | Description
|
||||
------------- | ------------- | -------------
|
||||
n/a | api_client.ApiResponseWithoutDeserialization | When skip_deserialization is True this response is returned
|
||||
200 | ApiResponseFor200 | successful operation
|
||||
|
||||
#### ApiResponseFor200
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
response | urllib3.HTTPResponse | Raw response |
|
||||
body | typing.Union[SchemaFor200ResponseBodyApplicationJson, ] | |
|
||||
headers | Unset | headers were not defined |
|
||||
|
||||
#### SchemaFor200ResponseBodyApplicationJson
|
||||
Type | Description | Notes
|
||||
------------- | ------------- | -------------
|
||||
[**Client**](Client.md) | |
|
||||
|
||||
|
||||
|
||||
[**Client**](Client.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
@ -0,0 +1,12 @@
|
||||
# ApiResponse
|
||||
|
||||
#### Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**code** | **int** | | [optional]
|
||||
**type** | **str** | | [optional]
|
||||
**message** | **str** | | [optional]
|
||||
**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
@ -0,0 +1,11 @@
|
||||
# Apple
|
||||
|
||||
#### Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**cultivar** | **str** | |
|
||||
**origin** | **str** | | [optional]
|
||||
**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
@ -0,0 +1,10 @@
|
||||
# AppleReq
|
||||
|
||||
#### Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**cultivar** | **str** | |
|
||||
**mealy** | **bool** | | [optional]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
@ -0,0 +1,8 @@
|
||||
# ArrayHoldingAnyType
|
||||
|
||||
Type | Description | Notes
|
||||
------------- | ------------- | -------------
|
||||
**[bool, date, datetime, dict, float, int, list, str, none_type]** | |
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
@ -0,0 +1,10 @@
|
||||
# ArrayOfArrayOfNumberOnly
|
||||
|
||||
#### Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**ArrayArrayNumber** | **[[int, float]]** | | [optional]
|
||||
**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
@ -0,0 +1,8 @@
|
||||
# ArrayOfEnums
|
||||
|
||||
Type | Description | Notes
|
||||
------------- | ------------- | -------------
|
||||
**[StringEnum]** | |
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
@ -0,0 +1,10 @@
|
||||
# ArrayOfNumberOnly
|
||||
|
||||
#### Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**ArrayNumber** | **[int, float]** | | [optional]
|
||||
**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
@ -0,0 +1,12 @@
|
||||
# ArrayTest
|
||||
|
||||
#### Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**array_of_string** | **[str]** | | [optional]
|
||||
**array_array_of_integer** | **[[int]]** | | [optional]
|
||||
**array_array_of_model** | **[[ReadOnlyFirst]]** | | [optional]
|
||||
**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
@ -0,0 +1,8 @@
|
||||
# ArrayWithValidationsInItems
|
||||
|
||||
Type | Description | Notes
|
||||
------------- | ------------- | -------------
|
||||
**[int]** | |
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
@ -0,0 +1,10 @@
|
||||
# Banana
|
||||
|
||||
#### Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**lengthCm** | **int, float** | |
|
||||
**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
@ -0,0 +1,10 @@
|
||||
# BananaReq
|
||||
|
||||
#### Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**lengthCm** | **int, float** | |
|
||||
**sweet** | **bool** | | [optional]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
@ -0,0 +1,8 @@
|
||||
# Bar
|
||||
|
||||
Type | Description | Notes
|
||||
------------- | ------------- | -------------
|
||||
**str** | | defaults to "bar"
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
@ -0,0 +1,10 @@
|
||||
# BasquePig
|
||||
|
||||
#### Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**className** | **str** | |
|
||||
**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
@ -0,0 +1,8 @@
|
||||
# Boolean
|
||||
|
||||
Type | Description | Notes
|
||||
------------- | ------------- | -------------
|
||||
**bool** | |
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
@ -0,0 +1,8 @@
|
||||
# BooleanEnum
|
||||
|
||||
Type | Description | Notes
|
||||
------------- | ------------- | -------------
|
||||
**bool** | | must be one of [True, ]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
@ -0,0 +1,15 @@
|
||||
# Capitalization
|
||||
|
||||
#### Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**smallCamel** | **str** | | [optional]
|
||||
**CapitalCamel** | **str** | | [optional]
|
||||
**small_Snake** | **str** | | [optional]
|
||||
**Capital_Snake** | **str** | | [optional]
|
||||
**SCA_ETH_Flow_Points** | **str** | | [optional]
|
||||
**ATT_NAME** | **str** | Name of the pet | [optional]
|
||||
**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
@ -0,0 +1,9 @@
|
||||
# Cat
|
||||
|
||||
#### Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
@ -0,0 +1,10 @@
|
||||
# CatAllOf
|
||||
|
||||
#### Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**declawed** | **bool** | | [optional]
|
||||
**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
@ -0,0 +1,11 @@
|
||||
# Category
|
||||
|
||||
#### Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**id** | **int** | | [optional]
|
||||
**name** | **str** | | if omitted the server will use the default value of "default-name"
|
||||
**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
@ -0,0 +1,9 @@
|
||||
# ChildCat
|
||||
|
||||
#### Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
@ -0,0 +1,10 @@
|
||||
# ChildCatAllOf
|
||||
|
||||
#### Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**name** | **str** | | [optional]
|
||||
**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
@ -0,0 +1,12 @@
|
||||
# ClassModel
|
||||
|
||||
Model for testing model with \"_class\" property
|
||||
|
||||
#### Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**_class** | **str** | | [optional]
|
||||
**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user