forked from loafle/openapi-generator-original
rename python-nextgen to python (#15504)
This commit is contained in:
parent
dd6ccaa84f
commit
01ed5975e1
@ -3,10 +3,10 @@ name: Python Client (Echo API)
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- samples/client/echo_api/python-nextgen/**
|
||||
- samples/client/echo_api/python/**
|
||||
pull_request:
|
||||
paths:
|
||||
- samples/client/echo_api/python-nextgen/**
|
||||
- samples/client/echo_api/python/**
|
||||
jobs:
|
||||
build:
|
||||
name: Test Python client
|
||||
@ -16,7 +16,7 @@ jobs:
|
||||
matrix:
|
||||
sample:
|
||||
# clients
|
||||
- samples/client/echo_api/python-nextgen
|
||||
- samples/client/echo_api/python
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-python@v4
|
||||
|
@ -1,4 +1,8 @@
|
||||
generatorName: python-aiohttp
|
||||
outputDir: samples/server/petstore/python-aiohttp
|
||||
inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/python-aiohttp
|
||||
generatorName: python
|
||||
outputDir: samples/openapi3/client/petstore/python-aiohttp
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/python/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/python
|
||||
library: asyncio
|
||||
additionalProperties:
|
||||
packageName: petstore_api
|
||||
mapNumberTo: float
|
||||
|
@ -1,6 +1,6 @@
|
||||
generatorName: python-nextgen
|
||||
outputDir: samples/client/echo_api/python-nextgen
|
||||
generatorName: python
|
||||
outputDir: samples/client/echo_api/python
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/echo_api.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/python-nextgen
|
||||
templateDir: modules/openapi-generator/src/main/resources/python
|
||||
additionalProperties:
|
||||
hideGenerationTimestamp: "true"
|
@ -1,8 +0,0 @@
|
||||
generatorName: python-nextgen
|
||||
outputDir: samples/openapi3/client/petstore/python-nextgen-aiohttp
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/python/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/python-nextgen
|
||||
library: asyncio
|
||||
additionalProperties:
|
||||
packageName: petstore_api
|
||||
mapNumberTo: float
|
@ -1,7 +1,7 @@
|
||||
generatorName: python-nextgen
|
||||
outputDir: samples/openapi3/client/petstore/python-nextgen
|
||||
generatorName: python
|
||||
outputDir: samples/openapi3/client/petstore/python
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/python/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/python-nextgen
|
||||
templateDir: modules/openapi-generator/src/main/resources/python
|
||||
additionalProperties:
|
||||
packageName: petstore_api
|
||||
useOneOfDiscriminatorLookup: "true"
|
@ -52,7 +52,7 @@ The following generators are available:
|
||||
* [php](generators/php.md)
|
||||
* [php-dt (beta)](generators/php-dt.md)
|
||||
* [powershell (beta)](generators/powershell.md)
|
||||
* [python-nextgen](generators/python-nextgen.md)
|
||||
* [python](generators/python.md)
|
||||
* [r](generators/r.md)
|
||||
* [ruby](generators/ruby.md)
|
||||
* [rust](generators/rust.md)
|
||||
|
@ -1,230 +0,0 @@
|
||||
---
|
||||
title: Documentation for the python-nextgen Generator
|
||||
---
|
||||
|
||||
## METADATA
|
||||
|
||||
| Property | Value | Notes |
|
||||
| -------- | ----- | ----- |
|
||||
| generator name | python-nextgen | pass this to the generate command after -g |
|
||||
| generator stability | STABLE | |
|
||||
| generator type | CLIENT | |
|
||||
| generator language | Python | |
|
||||
| generator language version | 3.7+ | |
|
||||
| generator default templating engine | mustache | |
|
||||
| helpTxt | Generates a Python client library. | |
|
||||
|
||||
## CONFIG OPTIONS
|
||||
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 |
|
||||
| ------ | ----------- | ------ | ------- |
|
||||
|dateFormat|date format for query parameters| |%Y-%m-%d|
|
||||
|datetimeFormat|datetime format for query parameters| |%Y-%m-%dT%H:%M:%S%z|
|
||||
|disallowAdditionalPropertiesIfNotPresent|If false, the 'additionalProperties' implementation (set to true by default) is compliant with the OAS and JSON schema specifications. If true (default), keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.|<dl><dt>**false**</dt><dd>The 'additionalProperties' implementation is compliant with the OAS and JSON schema specifications.</dd><dt>**true**</dt><dd>Keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.</dd></dl>|true|
|
||||
|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 (deprecated), urllib3| |urllib3|
|
||||
|mapNumberTo|Map number to Union[StrictFloat, StrictInt], StrictStr or float.| |Union[StrictFloat, StrictInt]|
|
||||
|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|
|
||||
|
||||
## IMPORT MAPPING
|
||||
|
||||
| Type/Alias | Imports |
|
||||
| ---------- | ------- |
|
||||
|
||||
|
||||
## INSTANTIATION TYPES
|
||||
|
||||
| Type/Alias | Instantiated By |
|
||||
| ---------- | --------------- |
|
||||
|
||||
|
||||
## LANGUAGE PRIMITIVES
|
||||
|
||||
<ul class="column-ul">
|
||||
<li>Dict</li>
|
||||
<li>List</li>
|
||||
<li>bool</li>
|
||||
<li>bytearray</li>
|
||||
<li>bytes</li>
|
||||
<li>date</li>
|
||||
<li>datetime</li>
|
||||
<li>decimal.Decimal</li>
|
||||
<li>dict</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>and</li>
|
||||
<li>as</li>
|
||||
<li>assert</li>
|
||||
<li>async</li>
|
||||
<li>await</li>
|
||||
<li>base64</li>
|
||||
<li>break</li>
|
||||
<li>class</li>
|
||||
<li>continue</li>
|
||||
<li>date</li>
|
||||
<li>def</li>
|
||||
<li>del</li>
|
||||
<li>elif</li>
|
||||
<li>else</li>
|
||||
<li>except</li>
|
||||
<li>exec</li>
|
||||
<li>false</li>
|
||||
<li>finally</li>
|
||||
<li>for</li>
|
||||
<li>from</li>
|
||||
<li>global</li>
|
||||
<li>if</li>
|
||||
<li>import</li>
|
||||
<li>in</li>
|
||||
<li>is</li>
|
||||
<li>json</li>
|
||||
<li>lambda</li>
|
||||
<li>none</li>
|
||||
<li>nonlocal</li>
|
||||
<li>not</li>
|
||||
<li>or</li>
|
||||
<li>pass</li>
|
||||
<li>print</li>
|
||||
<li>property</li>
|
||||
<li>raise</li>
|
||||
<li>return</li>
|
||||
<li>schema</li>
|
||||
<li>self</li>
|
||||
<li>true</li>
|
||||
<li>try</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
|
||||
|Uuid|✗|
|
||||
|Array|✓|OAS2,OAS3
|
||||
|Null|✗|OAS3
|
||||
|AnyType|✗|OAS2,OAS3
|
||||
|Object|✓|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
|
||||
|allOf|✓|OAS2,OAS3
|
||||
|anyOf|✓|OAS3
|
||||
|oneOf|✓|OAS3
|
||||
|not|✗|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
|
@ -10,26 +10,27 @@ title: Documentation for the python Generator
|
||||
| generator stability | STABLE | |
|
||||
| generator type | CLIENT | |
|
||||
| generator language | Python | |
|
||||
| generator language version | >=3.7 | |
|
||||
| generator default templating engine | handlebars | |
|
||||
| helpTxt | Generates a Python client library<br /><br />Features in this generator:<br />- type hints on endpoints and model creation<br />- model parameter names use the spec defined keys and cases<br />- robust composition (oneOf/anyOf/allOf/not) where payload data is stored in one instance only<br />- endpoint parameter names use the spec defined keys and cases<br />- inline schemas are supported at any location including composition<br />- multiple content types supported in request body and response bodies<br />- run time type checking<br />- Sending/receiving decimals as strings supported with type:string format: number -> DecimalSchema<br />- Sending/receiving uuids as strings supported with type:string format: uuid -> UUIDSchema<br />- quicker load time for python modules (a single endpoint can be imported and used without loading others)<br />- all instances of schemas dynamically inherit from all matching schemas so one can use isinstance to check if validation passed<br />- composed schemas with type constraints supported (type:object + oneOf/anyOf/allOf)<br />- schemas are not coerced/cast. For example string + date are both stored as string, and there is a date accessor<br /> - Exceptions: int/float is stored as Decimal, When receiving data from headers it will start as str and may need to be cast for example to int | |
|
||||
| generator language version | 3.7+ | |
|
||||
| generator default templating engine | mustache | |
|
||||
| helpTxt | Generates a Python client library. | |
|
||||
|
||||
## CONFIG OPTIONS
|
||||
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 |
|
||||
| ------ | ----------- | ------ | ------- |
|
||||
|dateFormat|date format for query parameters| |%Y-%m-%d|
|
||||
|datetimeFormat|datetime format for query parameters| |%Y-%m-%dT%H:%M:%S%z|
|
||||
|disallowAdditionalPropertiesIfNotPresent|If false, the 'additionalProperties' implementation (set to true by default) is compliant with the OAS and JSON schema specifications. If true (default), keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.|<dl><dt>**false**</dt><dd>The 'additionalProperties' implementation is compliant with the OAS and JSON schema specifications.</dd><dt>**true**</dt><dd>Keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.</dd></dl>|true|
|
||||
|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: urllib3| |urllib3|
|
||||
|nonCompliantUseDiscriminatorIfCompositionFails|When true, If the payload fails to validate against composed schemas (allOf/anyOf/oneOf/not) and a discriminator is present, then ignore the composition validation errors and attempt to use the discriminator to validate the payload.<br />Note: setting this to true makes the generated client not comply with json schema because it ignores composition validation errors. Please consider making your schemas more restrictive rather than setting this to true. You can do that by:<ul><li>defining the propertyName as an enum with only one value in the schemas that are in your discriminator map</li><li>setting additionalProperties: false in your schemas</li></ul>|<dl><dt>**true**</dt><dd>If composition fails and a discriminator exists, the composition errors will be ignored and validation will be attempted with the discriminator</dd><dt>**false**</dt><dd>Composition validation must succeed. Discriminator validation must succeed.</dd></dl>|false|
|
||||
|library|library template (sub-template) to use: asyncio, tornado (deprecated), urllib3| |urllib3|
|
||||
|mapNumberTo|Map number to Union[StrictFloat, StrictInt], StrictStr or float.| |Union[StrictFloat, StrictInt]|
|
||||
|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|
|
||||
|useInlineModelResolver|use the inline model resolver, if true inline complex models will be extracted into components and $refs to them will be used| |false|
|
||||
|useNose|use the nose test framework| |false|
|
||||
|
||||
## IMPORT MAPPING
|
||||
|
||||
@ -41,7 +42,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|
||||
| Type/Alias | Instantiated By |
|
||||
| ---------- | --------------- |
|
||||
|map|dict|
|
||||
|
||||
|
||||
## LANGUAGE PRIMITIVES
|
||||
@ -50,12 +50,12 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
<li>Dict</li>
|
||||
<li>List</li>
|
||||
<li>bool</li>
|
||||
<li>bytearray</li>
|
||||
<li>bytes</li>
|
||||
<li>date</li>
|
||||
<li>datetime</li>
|
||||
<li>decimal.Decimal</li>
|
||||
<li>dict</li>
|
||||
<li>file</li>
|
||||
<li>file_type</li>
|
||||
<li>float</li>
|
||||
<li>int</li>
|
||||
<li>list</li>
|
||||
@ -67,61 +67,46 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
## 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>base64</li>
|
||||
<li>break</li>
|
||||
<li>class</li>
|
||||
<li>continue</li>
|
||||
<li>date</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>json</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>schema</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>
|
||||
@ -155,10 +140,10 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|DateTime|✓|OAS2,OAS3
|
||||
|Password|✓|OAS2,OAS3
|
||||
|File|✓|OAS2
|
||||
|Uuid|✓|
|
||||
|Uuid|✗|
|
||||
|Array|✓|OAS2,OAS3
|
||||
|Null|✓|OAS3
|
||||
|AnyType|✓|OAS2,OAS3
|
||||
|Null|✗|OAS3
|
||||
|AnyType|✗|OAS2,OAS3
|
||||
|Object|✓|OAS2,OAS3
|
||||
|Maps|✓|ToolingExtension
|
||||
|CollectionFormat|✓|OAS2
|
||||
@ -196,8 +181,8 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|Examples|✓|OAS2,OAS3
|
||||
|XMLStructureDefinitions|✗|OAS2,OAS3
|
||||
|MultiServer|✗|OAS3
|
||||
|ParameterizedServer|✓|OAS3
|
||||
|ParameterStyling|✓|OAS3
|
||||
|ParameterizedServer|✗|OAS3
|
||||
|ParameterStyling|✗|OAS3
|
||||
|Callbacks|✗|OAS3
|
||||
|LinkObjects|✗|OAS3
|
||||
|
||||
@ -218,11 +203,11 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|Simple|✓|OAS2,OAS3
|
||||
|Composite|✓|OAS2,OAS3
|
||||
|Polymorphism|✓|OAS2,OAS3
|
||||
|Union|✓|OAS3
|
||||
|Union|✗|OAS3
|
||||
|allOf|✓|OAS2,OAS3
|
||||
|anyOf|✓|OAS3
|
||||
|oneOf|✓|OAS3
|
||||
|not|✓|OAS3
|
||||
|not|✗|OAS3
|
||||
|
||||
### Security Feature
|
||||
| Name | Supported | Defined By |
|
||||
@ -240,6 +225,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
| Name | Supported | Defined By |
|
||||
| ---- | --------- | ---------- |
|
||||
|JSON|✓|OAS2,OAS3
|
||||
|XML|✗|OAS2,OAS3
|
||||
|XML|✓|OAS2,OAS3
|
||||
|PROTOBUF|✗|ToolingExtension
|
||||
|Custom|✓|OAS2,OAS3
|
||||
|
@ -41,8 +41,8 @@ import java.util.*;
|
||||
import static org.openapitools.codegen.utils.StringUtils.escape;
|
||||
import static org.openapitools.codegen.utils.StringUtils.underscore;
|
||||
|
||||
public class PythonNextgenClientCodegen extends AbstractPythonCodegen implements CodegenConfig {
|
||||
private final Logger LOGGER = LoggerFactory.getLogger(PythonNextgenClientCodegen.class);
|
||||
public class PythonClientCodegen extends AbstractPythonCodegen implements CodegenConfig {
|
||||
private final Logger LOGGER = LoggerFactory.getLogger(PythonClientCodegen.class);
|
||||
|
||||
public static final String PACKAGE_URL = "packageUrl";
|
||||
public static final String DEFAULT_LIBRARY = "urllib3";
|
||||
@ -69,7 +69,7 @@ public class PythonNextgenClientCodegen extends AbstractPythonCodegen implements
|
||||
// map of codegen models
|
||||
private HashMap<String, CodegenModel> codegenModelMap = new HashMap<>();
|
||||
|
||||
public PythonNextgenClientCodegen() {
|
||||
public PythonClientCodegen() {
|
||||
super();
|
||||
|
||||
// force sortParamsByRequiredFlag to true to make the api method signature less complicated
|
||||
@ -134,7 +134,7 @@ public class PythonNextgenClientCodegen extends AbstractPythonCodegen implements
|
||||
modelTestTemplateFiles.put("model_test.mustache", ".py");
|
||||
apiTestTemplateFiles.put("api_test.mustache", ".py");
|
||||
|
||||
embeddedTemplateDir = templateDir = "python-nextgen";
|
||||
embeddedTemplateDir = templateDir = "python";
|
||||
|
||||
modelDocTemplateFiles.put("model_doc.mustache", ".md");
|
||||
apiDocTemplateFiles.put("api_doc.mustache", ".md");
|
||||
@ -1420,7 +1420,7 @@ public class PythonNextgenClientCodegen extends AbstractPythonCodegen implements
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "python-nextgen";
|
||||
return "python";
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1428,7 +1428,6 @@ public class PythonNextgenClientCodegen extends AbstractPythonCodegen implements
|
||||
return "Generates a Python client library.";
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String apiDocFileFolder() {
|
||||
return (outputFolder + File.separator + apiDocPath);
|
@ -100,7 +100,7 @@ org.openapitools.codegen.languages.PhpMezzioPathHandlerServerCodegen
|
||||
org.openapitools.codegen.languages.PhpDataTransferClientCodegen
|
||||
org.openapitools.codegen.languages.PowerShellClientCodegen
|
||||
org.openapitools.codegen.languages.ProtobufSchemaCodegen
|
||||
org.openapitools.codegen.languages.PythonNextgenClientCodegen
|
||||
org.openapitools.codegen.languages.PythonClientCodegen
|
||||
org.openapitools.codegen.languages.PythonFastAPIServerCodegen
|
||||
org.openapitools.codegen.languages.PythonFlaskConnexionServerCodegen
|
||||
org.openapitools.codegen.languages.PythonAiohttpConnexionServerCodegen
|
||||
|
@ -1,146 +0,0 @@
|
||||
# {{{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 {{generatorLanguageVersion}}
|
||||
|
||||
## Migration from other generators like python and python-legacy
|
||||
|
||||
### Changes
|
||||
1. This generator uses spec case for all (object) property names and parameter names.
|
||||
- So if the spec has a property name like camelCase, it will use camelCase rather than camel_case
|
||||
- So you will need to update how you input and read properties to use spec case
|
||||
2. Endpoint parameters are stored in dictionaries to prevent collisions (explanation below)
|
||||
- So you will need to update how you pass data in to endpoints
|
||||
3. Endpoint responses now include the original response, the deserialized response body, and (todo)the deserialized headers
|
||||
- So you will need to update your code to use response.body to access deserialized data
|
||||
4. All validated data is instantiated in an instance that subclasses all validated Schema classes and Decimal/str/list/tuple/frozendict/NoneClass/BoolClass/bytes/io.FileIO
|
||||
- This means that you can use isinstance to check if a payload validated against a schema class
|
||||
- This means that no data will be of type None/True/False
|
||||
- ingested None will subclass NoneClass
|
||||
- ingested True will subclass BoolClass
|
||||
- ingested False will subclass BoolClass
|
||||
- So if you need to check is True/False/None, instead use instance.is_true_oapg()/.is_false_oapg()/.is_none_oapg()
|
||||
5. All validated class instances are immutable except for ones based on io.File
|
||||
- This is because if properties were changed after validation, that validation would no longer apply
|
||||
- So no changing values or property values after a class has been instantiated
|
||||
6. String + Number types with formats
|
||||
- String type data is stored as a string and if you need to access types based on its format like date,
|
||||
date-time, uuid, number etc then you will need to use accessor functions on the instance
|
||||
- type string + format: See .as_date_oapg, .as_datetime_oapg, .as_decimal_oapg, .as_uuid_oapg
|
||||
- type number + format: See .as_float_oapg, .as_int_oapg
|
||||
- this was done because openapi/json-schema defines constraints. string data may be type string with no format
|
||||
keyword in one schema, and include a format constraint in another schema
|
||||
- So if you need to access a string format based type, use as_date_oapg/as_datetime_oapg/as_decimal_oapg/as_uuid_oapg
|
||||
- So if you need to access a number format based type, use as_int_oapg/as_float_oapg
|
||||
7. Property access on AnyType(type unset) or object(dict) schemas
|
||||
- Only required keys with valid python names are properties like .someProp and have type hints
|
||||
- All optional keys may not exist, so properties are not defined for them
|
||||
- One can access optional values with dict_instance['optionalProp'] and KeyError will be raised if it does not exist
|
||||
- Use get_item_oapg if you need a way to always get a value whether or not the key exists
|
||||
- If the key does not exist, schemas.unset is returned from calling dict_instance.get_item_oapg('optionalProp')
|
||||
- All required and optional keys have type hints for this method, and @typing.overload is used
|
||||
- A type hint is also generated for additionalProperties accessed using this method
|
||||
- So you will need to update you code to use some_instance['optionalProp'] to access optional property
|
||||
and additionalProperty values
|
||||
8. The location of the api classes has changed
|
||||
- Api classes are located in your_package.apis.tags.some_api
|
||||
- This change was made to eliminate redundant code generation
|
||||
- Legacy generators generated the same endpoint twice if it had > 1 tag on it
|
||||
- This generator defines an endpoint in one class, then inherits that class to generate
|
||||
apis by tags and by paths
|
||||
- This change reduces code and allows quicker run time if you use the path apis
|
||||
- path apis are at your_package.apis.paths.some_path
|
||||
- Those apis will only load their needed models, which is less to load than all of the resources needed in a tag api
|
||||
- So you will need to update your import paths to the api classes
|
||||
|
||||
### Why are Oapg and _oapg used in class and method names?
|
||||
Classes can have arbitrarily named properties set on them
|
||||
Endpoints can have arbitrary operationId method names set
|
||||
For those reasons, I use the prefix Oapg and _oapg to greatly reduce the likelihood of collisions
|
||||
on protected + public classes/methods.
|
||||
oapg stands for OpenApi Python Generator.
|
||||
|
||||
### Object property spec case
|
||||
This was done because when payloads are ingested, they can be validated against N number of schemas.
|
||||
If the input signature used a different property name then that has mutated the payload.
|
||||
So SchemaA and SchemaB must both see the camelCase spec named variable.
|
||||
Also it is possible to send in two properties, named camelCase and camel_case in the same payload.
|
||||
That use case should be support so spec case is used.
|
||||
|
||||
### Parameter spec case
|
||||
Parameters can be included in different locations including:
|
||||
- query
|
||||
- path
|
||||
- header
|
||||
- cookie
|
||||
|
||||
Any of those parameters could use the same parameter names, so if every parameter
|
||||
was included as an endpoint parameter in a function signature, they would collide.
|
||||
For that reason, each of those inputs have been separated out into separate typed dictionaries:
|
||||
- query_params
|
||||
- path_params
|
||||
- header_params
|
||||
- cookie_params
|
||||
|
||||
So when updating your code, you will need to pass endpoint parameters in using those
|
||||
dictionaries.
|
||||
|
||||
### Endpoint responses
|
||||
Endpoint responses have been enriched to now include more information.
|
||||
Any response reom an endpoint will now include the following properties:
|
||||
response: urllib3.HTTPResponse
|
||||
body: typing.Union[Unset, Schema]
|
||||
headers: typing.Union[Unset, TODO]
|
||||
Note: response header deserialization has not yet been added
|
||||
|
||||
|
||||
## 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 }}
|
@ -1,112 +0,0 @@
|
||||
```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}}.tags import {{classFilename}}
|
||||
{{#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 = {{classFilename}}.{{{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#{{operationId}}) | **{{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}}
|
||||
Endpoints do not require authorization.
|
||||
{{/unless}}
|
||||
{{#if hasAuthMethods}}Authentication schemes defined for the API:{{/if}}
|
||||
{{#each authMethods}}
|
||||
<a id="{{name}}"></a>
|
||||
### {{{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}}{{#if infoEmail}}{{infoEmail}}{{/if}}
|
||||
{{/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 *
|
||||
```
|
@ -1,43 +0,0 @@
|
||||
# {{{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 {{generatorLanguageVersion}}
|
||||
|
||||
## 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 }}
|
@ -1,3 +0,0 @@
|
||||
# do not import all endpoints into this module because that uses a lot of memory and stack frames
|
||||
# if you need the ability to import all endpoints then import them from
|
||||
# tags, paths, or path_to_api, or tag_to_api
|
@ -1,11 +0,0 @@
|
||||
# do not import all endpoints into this module because that uses a lot of memory and stack frames
|
||||
# if you need the ability to import all endpoints from this module, import them with
|
||||
# from {{packageName}}.apis.tag_to_api import tag_to_api
|
||||
|
||||
import enum
|
||||
|
||||
|
||||
class TagValues(str, enum.Enum):
|
||||
{{#each enumToTag}}
|
||||
{{@key}} = "{{this}}"
|
||||
{{/each}}
|
@ -1,5 +0,0 @@
|
||||
# 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
|
@ -1,18 +0,0 @@
|
||||
# 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 {{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}}
|
@ -1,28 +0,0 @@
|
||||
# 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}}
|
@ -1,3 +0,0 @@
|
||||
# do not import all endpoints into this module because that uses a lot of memory and stack frames
|
||||
# if you need the ability to import all endpoints from this module, import them with
|
||||
# from {{packageName}}.apis.path_to_api import path_to_api
|
@ -1,11 +0,0 @@
|
||||
# do not import all endpoints into this module because that uses a lot of memory and stack frames
|
||||
# if you need the ability to import all endpoints from this module, import them with
|
||||
# from {{packageName}}.apis.path_to_api import path_to_api
|
||||
|
||||
import enum
|
||||
|
||||
|
||||
class PathValues(str, enum.Enum):
|
||||
{{#each pathValToVar}}
|
||||
{{this}} = "{{@key}}"
|
||||
{{/each}}
|
@ -1,7 +0,0 @@
|
||||
# do not import all endpoints into this module because that uses a lot of memory and stack frames
|
||||
# if you need the ability to import all endpoints from this module, import them with
|
||||
# from {{packageName}}.paths.{{pathModule}} import {{apiClassName}}
|
||||
|
||||
from {{packageName}}.paths import PathValues
|
||||
|
||||
path = PathValues.{{{pathVar}}}
|
@ -1,68 +0,0 @@
|
||||
import json
|
||||
import typing
|
||||
|
||||
import urllib3
|
||||
from urllib3._collections import HTTPHeaderDict
|
||||
|
||||
|
||||
class ApiTestMixin:
|
||||
json_content_type = 'application/json'
|
||||
user_agent = 'OpenAPI-Generator/1.0.0/python'
|
||||
|
||||
@classmethod
|
||||
def assert_pool_manager_request_called_with(
|
||||
cls,
|
||||
mock_request,
|
||||
url: str,
|
||||
method: str = 'POST',
|
||||
body: typing.Optional[bytes] = None,
|
||||
content_type: typing.Optional[str] = None,
|
||||
accept_content_type: typing.Optional[str] = None,
|
||||
stream: bool = False,
|
||||
):
|
||||
headers = {
|
||||
'User-Agent': cls.user_agent
|
||||
}
|
||||
if accept_content_type:
|
||||
headers['Accept'] = accept_content_type
|
||||
if content_type:
|
||||
headers['Content-Type'] = content_type
|
||||
kwargs = dict(
|
||||
headers=HTTPHeaderDict(headers),
|
||||
preload_content=not stream,
|
||||
timeout=None,
|
||||
)
|
||||
if content_type and method != 'GET':
|
||||
kwargs['body'] = body
|
||||
mock_request.assert_called_with(
|
||||
method,
|
||||
url,
|
||||
**kwargs
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def headers_for_content_type(content_type: str) -> typing.Dict[str, str]:
|
||||
return {'content-type': content_type}
|
||||
|
||||
@classmethod
|
||||
def response(
|
||||
cls,
|
||||
body: typing.Union[str, bytes],
|
||||
status: int = 200,
|
||||
content_type: str = json_content_type,
|
||||
headers: typing.Optional[typing.Dict[str, str]] = None,
|
||||
preload_content: bool = True
|
||||
) -> urllib3.HTTPResponse:
|
||||
if headers is None:
|
||||
headers = {}
|
||||
headers.update(cls.headers_for_content_type(content_type))
|
||||
return urllib3.HTTPResponse(
|
||||
body,
|
||||
headers=headers,
|
||||
status=status,
|
||||
preload_content=preload_content
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def json_bytes(in_data: typing.Any) -> bytes:
|
||||
return json.dumps(in_data, separators=(",", ":"), ensure_ascii=False).encode('utf-8')
|
@ -1,24 +0,0 @@
|
||||
# coding: utf-8
|
||||
|
||||
{{>partial_header}}
|
||||
|
||||
{{#with operations}}
|
||||
{{#each operation}}
|
||||
from {{packageName}}.paths.{{nickname}}.{{httpMethod}} import {{operationIdCamelCase}}
|
||||
{{/each}}
|
||||
{{/with}}
|
||||
|
||||
|
||||
{{#with operations}}
|
||||
class {{classname}}(
|
||||
{{#each operation}}
|
||||
{{operationIdCamelCase}},
|
||||
{{/each}}
|
||||
):
|
||||
"""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
@ -1,211 +0,0 @@
|
||||
<a id="__pageTop"></a>
|
||||
# {{packageName}}.{{apiPackage}}.tags.{{classFilename}}.{{classname}}{{#if description}}
|
||||
{{description}}{{/if}}
|
||||
|
||||
All URIs are relative to *{{basePath}}*
|
||||
|
||||
Method | HTTP request | Description
|
||||
------------- | ------------- | -------------
|
||||
{{#with operations}}{{#each operation}}[**{{operationId}}**](#{{operationId}}) | **{{httpMethod}}** {{path}} | {{#if summary}}{{summary}}{{/if}}
|
||||
{{/each}}{{/with}}
|
||||
|
||||
{{#with operations}}
|
||||
{{#each operation}}
|
||||
# **{{{operationId}}}**
|
||||
<a id="{{{operationId}}}"></a>
|
||||
> {{#if returnType}}{{{returnType}}} {{/if}}{{{operationId}}}({{#each requiredParams}}{{#unless defaultValue}}{{paramName}}{{#if hasMore}}, {{/if}}{{/unless}}{{/each}})
|
||||
|
||||
{{#if summary}}{{{summary}}}{{/if}}{{#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 complexTypePrefix="../../models/" }}
|
||||
{{/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 complexTypePrefix="../../models/" }}
|
||||
{{/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 complexTypePrefix="../../models/" }}
|
||||
{{/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 complexTypePrefix="../../models/" }}
|
||||
{{/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 complexTypePrefix="../../models/" }}
|
||||
{{/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](#{{operationId}}.ApiResponseForDefault) | {{message}}
|
||||
{{else}}
|
||||
{{code}} | [ApiResponseFor{{code}}](#{{operationId}}.ApiResponseFor{{code}}) | {{message}}
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
{{#each responses}}
|
||||
{{#if isDefault}}
|
||||
|
||||
#### {{operationId}}.ApiResponseForDefault
|
||||
{{else}}
|
||||
|
||||
#### {{operationId}}.ApiResponseFor{{code}}
|
||||
{{/if}}
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
response | urllib3.HTTPResponse | Raw response |
|
||||
body | {{#unless content}}Unset{{else}}typing.Union[{{#each content}}{{#if this.schema}}{{this.schema.baseName}}{{else}}Unset{{/if}}, {{/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 complexTypePrefix="../../models/" }}
|
||||
{{/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 complexTypePrefix="../../models/" }}
|
||||
{{/with}}
|
||||
{{/each}}
|
||||
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
|
||||
### Authorization
|
||||
|
||||
{{#unless authMethods}}No authorization required{{/unless}}{{#each authMethods}}[{{{name}}}](../../../README.md#{{{name}}}){{#unless @last}}, {{/unless}}{{/each}}
|
||||
|
||||
[[Back to top]](#__pageTop) [[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}}
|
@ -1,163 +0,0 @@
|
||||
```python
|
||||
import {{{packageName}}}
|
||||
from {{packageName}}.{{apiPackage}}.tags import {{classFilename}}
|
||||
{{#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 = {{classFilename}}.{{{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}}
|
||||
```
|
@ -1,10 +0,0 @@
|
||||
|
||||
# {{baseName}}
|
||||
{{#if complexType}}
|
||||
Type | Description | Notes
|
||||
------------- | ------------- | -------------
|
||||
[**{{dataType}}**]({{complexTypePrefix}}{{complexType}}.md) | {{#if description}}{{description}}{{/if}} | {{#if isReadOnly}}[readonly] {{/if}}
|
||||
|
||||
{{else}}
|
||||
{{> schema_doc complexTypePrefix="{{complexTypePrefix}}" }}
|
||||
{{/if}}
|
@ -1,143 +0,0 @@
|
||||
# coding: utf-8
|
||||
|
||||
{{>partial_header}}
|
||||
|
||||
import unittest
|
||||
from unittest.mock import patch
|
||||
|
||||
import urllib3
|
||||
|
||||
import {{packageName}}
|
||||
from {{packageName}}.paths.{{operation.nickname}} import {{operation.httpMethod}} # noqa: E501
|
||||
from {{packageName}} import configuration, schemas, api_client
|
||||
|
||||
from .. import ApiTestMixin
|
||||
|
||||
|
||||
{{#with operation}}
|
||||
class Test{{operationIdSnakeCase}}(ApiTestMixin, unittest.TestCase):
|
||||
"""
|
||||
{{operationIdSnakeCase}} unit test stubs
|
||||
{{#if summary}}
|
||||
{{{summary}}} # noqa: E501
|
||||
{{/if}}
|
||||
"""
|
||||
_configuration = configuration.Configuration()
|
||||
|
||||
def setUp(self):
|
||||
used_api_client = api_client.ApiClient(configuration=self._configuration)
|
||||
self.api = {{httpMethod}}.ApiFor{{httpMethod}}(api_client=used_api_client) # noqa: E501
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
||||
{{#each responses}}
|
||||
{{#if @first}}
|
||||
response_status = {{code}}
|
||||
{{#if content}}
|
||||
{{#each content}}
|
||||
|
||||
{{#if this.testCases}}
|
||||
{{#each testCases}}
|
||||
{{#with this }}
|
||||
def test_{{@key}}_{{#if valid}}passes{{else}}fails{{/if}}(self):
|
||||
# {{description}}
|
||||
accept_content_type = '{{{../@key}}}'
|
||||
|
||||
with patch.object(urllib3.PoolManager, 'request') as mock_request:
|
||||
payload = (
|
||||
{{#with data}}
|
||||
{{> model_templates/payload_renderer endChar='' }}
|
||||
{{/with}}
|
||||
)
|
||||
mock_request.return_value = self.response(
|
||||
self.json_bytes(payload),
|
||||
status=self.response_status
|
||||
)
|
||||
{{#if valid}}
|
||||
{{> api_test_partial }}
|
||||
|
||||
assert isinstance(api_response.response, urllib3.HTTPResponse)
|
||||
assert isinstance(api_response.body, {{httpMethod}}.{{schema.baseName}})
|
||||
deserialized_response_body = {{httpMethod}}.{{schema.baseName}}.from_openapi_data_oapg(
|
||||
payload,
|
||||
_configuration=self._configuration
|
||||
)
|
||||
assert api_response.body == deserialized_response_body
|
||||
{{else}}
|
||||
with self.assertRaises(({{packageName}}.ApiValueError, {{packageName}}.ApiTypeError)):
|
||||
self.api.{{httpMethod}}(
|
||||
accept_content_types=(accept_content_type,)
|
||||
)
|
||||
self.assert_pool_manager_request_called_with(
|
||||
mock_request,
|
||||
self._configuration.host + '{{{path}}}',
|
||||
method='{{httpMethod}}'.upper(),
|
||||
content_type=None,
|
||||
accept_content_type=accept_content_type,
|
||||
)
|
||||
{{/if}}
|
||||
{{/with}}
|
||||
|
||||
{{/each}}
|
||||
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
{{else}}
|
||||
response_body = ''
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
{{#if bodyParam}}
|
||||
{{#with bodyParam}}
|
||||
{{#if required}}
|
||||
{{#each content}}
|
||||
{{#if this.testCases}}
|
||||
|
||||
{{#each testCases}}
|
||||
{{#with this }}
|
||||
def test_{{@key}}_{{#if valid}}passes{{else}}fails{{/if}}(self):
|
||||
content_type = '{{{../@key}}}'
|
||||
# {{description}}
|
||||
with patch.object(urllib3.PoolManager, 'request') as mock_request:
|
||||
payload = (
|
||||
{{#with data}}
|
||||
{{> model_templates/payload_renderer endChar='' }}
|
||||
{{/with}}
|
||||
)
|
||||
{{#if valid}}
|
||||
body = {{httpMethod}}.{{schema.baseName}}.from_openapi_data_oapg(
|
||||
payload,
|
||||
_configuration=self._configuration
|
||||
)
|
||||
mock_request.return_value = self.response(
|
||||
self.json_bytes(self.response_body),
|
||||
status=self.response_status
|
||||
)
|
||||
{{> api_test_partial }}
|
||||
|
||||
assert isinstance(api_response.response, urllib3.HTTPResponse)
|
||||
assert isinstance(api_response.body, schemas.Unset)
|
||||
{{else}}
|
||||
with self.assertRaises(({{packageName}}.ApiValueError, {{packageName}}.ApiTypeError)):
|
||||
body = {{httpMethod}}.{{schema.baseName}}.from_openapi_data_oapg(
|
||||
payload,
|
||||
_configuration=self._configuration
|
||||
)
|
||||
self.api.{{httpMethod}}(body=body)
|
||||
{{/if}}
|
||||
{{/with}}
|
||||
|
||||
{{/each}}
|
||||
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
{{/if}}
|
||||
{{/with}}
|
||||
{{else}}
|
||||
{{/if}}
|
||||
|
||||
{{/with}}
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
@ -1,21 +0,0 @@
|
||||
api_response = self.api.{{httpMethod}}(
|
||||
{{#if bodyParam}}
|
||||
body=body,
|
||||
content_type=content_type
|
||||
{{/if}}
|
||||
{{#if produces}}
|
||||
accept_content_types=(accept_content_type,)
|
||||
{{/if}}
|
||||
)
|
||||
self.assert_pool_manager_request_called_with(
|
||||
mock_request,
|
||||
self._configuration.host + '{{{path}}}',
|
||||
method='{{httpMethod}}'.upper(),
|
||||
{{#if bodyParam}}
|
||||
body=self.json_bytes(payload),
|
||||
content_type=content_type,
|
||||
{{/if}}
|
||||
{{#if produces}}
|
||||
accept_content_type=accept_content_type,
|
||||
{{/if}}
|
||||
)
|
@ -1,52 +0,0 @@
|
||||
{{#if pathItem.get}}
|
||||
from {{packageName}}.paths.{{pathModule}}.get import ApiForget
|
||||
{{/if}}
|
||||
{{#if pathItem.put}}
|
||||
from {{packageName}}.paths.{{pathModule}}.put import ApiForput
|
||||
{{/if}}
|
||||
{{#if pathItem.post}}
|
||||
from {{packageName}}.paths.{{pathModule}}.post import ApiForpost
|
||||
{{/if}}
|
||||
{{#if pathItem.delete}}
|
||||
from {{packageName}}.paths.{{pathModule}}.delete import ApiFordelete
|
||||
{{/if}}
|
||||
{{#if pathItem.options}}
|
||||
from {{packageName}}.paths.{{pathModule}}.options import ApiForoptions
|
||||
{{/if}}
|
||||
{{#if pathItem.head}}
|
||||
from {{packageName}}.paths.{{pathModule}}.head import ApiForhead
|
||||
{{/if}}
|
||||
{{#if pathItem.patch}}
|
||||
from {{packageName}}.paths.{{pathModule}}.patch import ApiForpatch
|
||||
{{/if}}
|
||||
{{#if pathItem.trace}}
|
||||
from {{packageName}}.paths.{{pathModule}}.trace import ApiFortrace
|
||||
{{/if}}
|
||||
|
||||
|
||||
class {{apiClassName}}(
|
||||
{{#if pathItem.get}}
|
||||
ApiForget,
|
||||
{{/if}}
|
||||
{{#if pathItem.put}}
|
||||
ApiForput,
|
||||
{{/if}}
|
||||
{{#if pathItem.post}}
|
||||
ApiForpost,
|
||||
{{/if}}
|
||||
{{#if pathItem.delete}}
|
||||
ApiFordelete,
|
||||
{{/if}}
|
||||
{{#if pathItem.options}}
|
||||
ApiForoptions,
|
||||
{{/if}}
|
||||
{{#if pathItem.head}}
|
||||
ApiForhead,
|
||||
{{/if}}
|
||||
{{#if pathItem.patch}}
|
||||
ApiForpatch,
|
||||
{{/if}}
|
||||
{{#if pathItem.trace}}
|
||||
ApiFortrace,
|
||||
{{/if}}):
|
||||
pass
|
@ -1,23 +0,0 @@
|
||||
import typing_extensions
|
||||
|
||||
from {{packageName}}.paths import PathValues
|
||||
{{#each pathModuleToApiClassname}}
|
||||
from {{packageName}}.apis.paths.{{@key}} import {{this}}
|
||||
{{/each}}
|
||||
|
||||
PathToApi = typing_extensions.TypedDict(
|
||||
'PathToApi',
|
||||
{
|
||||
{{#each pathEnumToApiClassname}}
|
||||
PathValues.{{@key}}: {{this}},
|
||||
{{/each}}
|
||||
}
|
||||
)
|
||||
|
||||
path_to_api = PathToApi(
|
||||
{
|
||||
{{#each pathEnumToApiClassname}}
|
||||
PathValues.{{@key}}: {{this}},
|
||||
{{/each}}
|
||||
}
|
||||
)
|
@ -1,23 +0,0 @@
|
||||
import typing_extensions
|
||||
|
||||
from {{packageName}}.apis.tags import TagValues
|
||||
{{#each tagModuleNameToApiClassname}}
|
||||
from {{packageName}}.apis.tags.{{@key}} import {{this}}
|
||||
{{/each}}
|
||||
|
||||
TagToApi = typing_extensions.TypedDict(
|
||||
'TagToApi',
|
||||
{
|
||||
{{#each tagEnumToApiClassname}}
|
||||
TagValues.{{@key}}: {{this}},
|
||||
{{/each}}
|
||||
}
|
||||
)
|
||||
|
||||
tag_to_api = TagToApi(
|
||||
{
|
||||
{{#each tagEnumToApiClassname}}
|
||||
TagValues.{{@key}}: {{this}},
|
||||
{{/each}}
|
||||
}
|
||||
)
|
@ -1,650 +0,0 @@
|
||||
# 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 because 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,
|
||||
{{#if hasApiKeyMethods}}
|
||||
api_key=None,
|
||||
api_key_prefix=None,
|
||||
{{/if}}
|
||||
{{#if hasHttpBasicMethods}}
|
||||
username=None,
|
||||
password=None,
|
||||
{{/if}}
|
||||
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,
|
||||
{{#or hasOAuthMethods hasHttpBearerMethods}}
|
||||
access_token=None,
|
||||
{{/or}}
|
||||
):
|
||||
"""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
|
||||
{{#if hasApiKeyMethods}}
|
||||
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
|
||||
"""
|
||||
{{/if}}
|
||||
{{#if hasHttpBasicMethods}}
|
||||
self.username = username
|
||||
"""Username for HTTP basic authentication
|
||||
"""
|
||||
self.password = password
|
||||
"""Password for HTTP basic authentication
|
||||
"""
|
||||
self.discard_unknown_keys = discard_unknown_keys
|
||||
{{/if}}
|
||||
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}}
|
||||
{{#or hasOAuthMethods hasHttpBearerMethods}}
|
||||
self.access_token = None
|
||||
"""access token for OAuth/Bearer
|
||||
"""
|
||||
{{/or}}
|
||||
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.
|
||||
"""
|
||||
self.tls_server_name = None
|
||||
"""SSL/TLS Server Name Indication (SNI)
|
||||
Set this to the SNI value expected by the server.
|
||||
"""
|
||||
|
||||
{{#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 parameter 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': "{{#unless description}}No description provided{{else}}{{{description}}}{{/unless}}",
|
||||
{{#each variables}}
|
||||
{{#if @first}}
|
||||
'variables': {
|
||||
{{/if}}
|
||||
'{{{name}}}': {
|
||||
'description': "{{#unless description}}No description provided{{else}}{{{description}}}{{/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
|
@ -1,109 +0,0 @@
|
||||
# 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}}}",
|
||||
access_token = 'YOUR_ACCESS_TOKEN'
|
||||
)
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
{{/if}}
|
@ -1,467 +0,0 @@
|
||||
# coding: utf-8
|
||||
|
||||
{{>partial_header}}
|
||||
|
||||
from dataclasses import dataclass
|
||||
import typing_extensions
|
||||
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 }}
|
||||
|
||||
{{#unless isStub}}
|
||||
from . import path
|
||||
|
||||
{{/unless}}
|
||||
{{#with operation}}
|
||||
{{#if queryParams}}
|
||||
{{> endpoint_parameter_schema_and_def xParams=queryParams xParamsName="Query" }}
|
||||
{{/if}}
|
||||
{{#if headerParams}}
|
||||
{{> endpoint_parameter_schema_and_def xParams=headerParams xParamsName="Header" }}
|
||||
{{/if}}
|
||||
{{#if pathParams}}
|
||||
{{> endpoint_parameter_schema_and_def xParams=pathParams xParamsName="Path" }}
|
||||
{{/if}}
|
||||
{{#if cookieParams}}
|
||||
{{> endpoint_parameter_schema_and_def xParams=cookieParams xParamsName="Cookie" }}
|
||||
{{/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({{#if this.schema}}
|
||||
schema={{this.schema.baseName}}{{/if}}),
|
||||
{{/each}}
|
||||
},
|
||||
{{#if required}}
|
||||
required=True,
|
||||
{{/if}}
|
||||
)
|
||||
{{/with}}
|
||||
{{#unless isStub}}
|
||||
{{#each authMethods}}
|
||||
{{#if @first}}
|
||||
_auth = [
|
||||
{{/if}}
|
||||
'{{name}}',
|
||||
{{#if @last}}
|
||||
]
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
{{#each servers}}
|
||||
{{#if @first}}
|
||||
_servers = (
|
||||
{{/if}}
|
||||
{
|
||||
'url': "{{{url}}}",
|
||||
'description': "{{#unless description}}No description provided{{else}}{{{description}}}{{/unless}}",
|
||||
{{#each variables}}
|
||||
{{#if @first}}
|
||||
'variables': {
|
||||
{{/if}}
|
||||
'{{{name}}}': {
|
||||
'description': "{{#unless description}}No description provided{{else}}{{{description}}}{{/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}}
|
||||
{{/unless}}
|
||||
{{#each responses}}
|
||||
{{#each responseHeaders}}
|
||||
{{#with schema}}
|
||||
{{> model_templates/schema }}
|
||||
{{/with}}
|
||||
{{#unless isStub}}
|
||||
{{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}}
|
||||
)
|
||||
{{/unless}}
|
||||
{{/each}}
|
||||
{{#each content}}
|
||||
{{#with this.schema}}
|
||||
{{> model_templates/schema }}
|
||||
{{/with}}
|
||||
{{/each}}
|
||||
{{#if responseHeaders}}
|
||||
ResponseHeadersFor{{code}} = typing_extensions.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}}
|
||||
{{#if this.schema}}
|
||||
{{this.schema.baseName}},
|
||||
{{else}}
|
||||
schemas.Unset,
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
]
|
||||
headers: ResponseHeadersFor{{code}}
|
||||
{{else}}
|
||||
{{#or responseHeaders content}}
|
||||
{{#if responseHeaders}}
|
||||
headers: ResponseHeadersFor{{code}}
|
||||
body: schemas.Unset = schemas.unset
|
||||
{{else}}
|
||||
body: typing.Union[
|
||||
{{#each content}}
|
||||
{{#if this.schema}}
|
||||
{{this.schema.baseName}},
|
||||
{{else}}
|
||||
schemas.Unset,
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
]
|
||||
headers: schemas.Unset = schemas.unset
|
||||
{{/if}}
|
||||
{{/or}}
|
||||
{{/and}}
|
||||
{{#unless responseHeaders}}
|
||||
{{#unless content}}
|
||||
body: schemas.Unset = schemas.unset
|
||||
headers: schemas.Unset = schemas.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({{#if this.schema}}
|
||||
schema={{this.schema.baseName}}{{/if}}),
|
||||
{{#if @last}}
|
||||
},
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
{{#if responseHeaders}}
|
||||
headers=[
|
||||
{{#each responseHeaders}}
|
||||
{{paramName}}_parameter,
|
||||
{{/each}}
|
||||
]
|
||||
{{/if}}
|
||||
)
|
||||
{{/each}}
|
||||
{{#unless isStub}}
|
||||
_status_code_to_response = {
|
||||
{{#each responses}}
|
||||
{{#if isDefault}}
|
||||
'default': _response_for_default,
|
||||
{{else}}
|
||||
'{{code}}': _response_for_{{code}},
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
}
|
||||
{{/unless}}
|
||||
{{#each produces}}
|
||||
{{#if @first}}
|
||||
_all_accept_content_types = (
|
||||
{{/if}}
|
||||
'{{{this.mediaType}}}',
|
||||
{{#if @last}}
|
||||
)
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
|
||||
|
||||
class BaseApi(api_client.Api):
|
||||
{{#if bodyParam}}
|
||||
{{#each contentTypeToOperation}}
|
||||
{{> endpoint_args_baseapi_wrapper contentType=@key this=this}}
|
||||
|
||||
{{/each}}
|
||||
{{> endpoint_args_baseapi_wrapper contentType="null" this=this}}
|
||||
|
||||
{{else}}
|
||||
@typing.overload
|
||||
def _{{operationId}}_oapg(
|
||||
{{> endpoint_args isOverload=true skipDeserialization="False" contentType="null"}}
|
||||
{{/if}}
|
||||
|
||||
@typing.overload
|
||||
def _{{operationId}}_oapg(
|
||||
{{> endpoint_args isOverload=true skipDeserialization="True" contentType="null"}}
|
||||
|
||||
@typing.overload
|
||||
def _{{operationId}}_oapg(
|
||||
{{> endpoint_args isOverload=true skipDeserialization="null" contentType="null"}}
|
||||
|
||||
def _{{operationId}}_oapg(
|
||||
{{> endpoint_args isOverload=false skipDeserialization="null" contentType="null"}}
|
||||
"""
|
||||
{{#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_oapg(RequestQueryParams, query_params)
|
||||
{{/if}}
|
||||
{{#if headerParams}}
|
||||
self._verify_typed_dict_inputs_oapg(RequestHeaderParams, header_params)
|
||||
{{/if}}
|
||||
{{#if pathParams}}
|
||||
self._verify_typed_dict_inputs_oapg(RequestPathParams, path_params)
|
||||
{{/if}}
|
||||
{{#if cookieParams}}
|
||||
self._verify_typed_dict_inputs_oapg(RequestCookieParams, cookie_params)
|
||||
{{/if}}
|
||||
used_path = path.value
|
||||
{{#if pathParams}}
|
||||
|
||||
_path_params = {}
|
||||
for parameter in (
|
||||
{{#each pathParams}}
|
||||
request_path_{{paramName}},
|
||||
{{/each}}
|
||||
):
|
||||
parameter_data = path_params.get(parameter.name, schemas.unset)
|
||||
if parameter_data is schemas.unset:
|
||||
continue
|
||||
serialized_data = parameter.serialize(parameter_data)
|
||||
_path_params.update(serialized_data)
|
||||
|
||||
for k, v in _path_params.items():
|
||||
used_path = used_path.replace('{%s}' % k, v)
|
||||
{{/if}}
|
||||
{{#if queryParams}}
|
||||
|
||||
prefix_separator_iterator = None
|
||||
for parameter in (
|
||||
{{#each queryParams}}
|
||||
request_query_{{paramName}},
|
||||
{{/each}}
|
||||
):
|
||||
parameter_data = query_params.get(parameter.name, schemas.unset)
|
||||
if parameter_data is schemas.unset:
|
||||
continue
|
||||
if prefix_separator_iterator is None:
|
||||
prefix_separator_iterator = parameter.get_prefix_separator_iterator()
|
||||
serialized_data = parameter.serialize(parameter_data, prefix_separator_iterator)
|
||||
for serialized_value in serialized_data.values():
|
||||
used_path += serialized_value
|
||||
{{/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, schemas.unset)
|
||||
if parameter_data is schemas.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 schemas.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 schemas.unset:
|
||||
{{> endpoint_body_serialization }}
|
||||
{{/if}}
|
||||
{{/with}}
|
||||
{{#if servers}}
|
||||
|
||||
host = self._get_host_oapg('{{operationId}}', _servers, host_index)
|
||||
{{/if}}
|
||||
|
||||
response = self.api_client.call_api(
|
||||
resource_path=used_path,
|
||||
method='{{httpMethod}}'.upper(),
|
||||
{{#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(
|
||||
status=response.status,
|
||||
reason=response.reason,
|
||||
api_response=api_response
|
||||
)
|
||||
|
||||
return api_response
|
||||
|
||||
|
||||
class {{operationIdCamelCase}}(BaseApi):
|
||||
# this class is used by api classes that refer to endpoints with operationId fn names
|
||||
|
||||
{{#if bodyParam}}
|
||||
{{#each contentTypeToOperation}}
|
||||
{{> endpoint_args_operationid_wrapper contentType=@key this=this}}
|
||||
|
||||
{{/each}}
|
||||
{{> endpoint_args_operationid_wrapper contentType="null" this=this}}
|
||||
|
||||
{{else}}
|
||||
@typing.overload
|
||||
def {{operationId}}(
|
||||
{{> endpoint_args isOverload=true skipDeserialization="False" contentType="null"}}
|
||||
{{/if}}
|
||||
|
||||
@typing.overload
|
||||
def {{operationId}}(
|
||||
{{> endpoint_args isOverload=true skipDeserialization="True" contentType="null"}}
|
||||
|
||||
@typing.overload
|
||||
def {{operationId}}(
|
||||
{{> endpoint_args isOverload=true skipDeserialization="null" contentType="null"}}
|
||||
|
||||
def {{operationId}}(
|
||||
{{> endpoint_args isOverload=false skipDeserialization="null" contentType="null"}}
|
||||
return self._{{operationId}}_oapg(
|
||||
{{> endpoint_args_passed }}
|
||||
)
|
||||
|
||||
|
||||
class ApiFor{{httpMethod}}(BaseApi):
|
||||
# this class is used by api classes that refer to endpoints by path and http method names
|
||||
|
||||
{{#if bodyParam}}
|
||||
{{#each contentTypeToOperation}}
|
||||
{{> endpoint_args_httpmethod_wrapper contentType=@key this=this}}
|
||||
|
||||
{{/each}}
|
||||
{{> endpoint_args_httpmethod_wrapper contentType="null" this=this}}
|
||||
|
||||
{{else}}
|
||||
@typing.overload
|
||||
def {{httpMethod}}(
|
||||
{{> endpoint_args isOverload=true skipDeserialization="False" contentType="null"}}
|
||||
{{/if}}
|
||||
|
||||
@typing.overload
|
||||
def {{httpMethod}}(
|
||||
{{> endpoint_args isOverload=true skipDeserialization="True" contentType="null"}}
|
||||
|
||||
@typing.overload
|
||||
def {{httpMethod}}(
|
||||
{{> endpoint_args isOverload=true skipDeserialization="null" contentType="null"}}
|
||||
|
||||
def {{httpMethod}}(
|
||||
{{> endpoint_args isOverload=false skipDeserialization="null" contentType="null"}}
|
||||
return self._{{operationId}}_oapg(
|
||||
{{> endpoint_args_passed }}
|
||||
)
|
||||
|
||||
|
||||
{{/with}}
|
@ -1,147 +0,0 @@
|
||||
self,
|
||||
{{#if bodyParam}}
|
||||
{{#if bodyParam.required}}
|
||||
{{#with bodyParam}}
|
||||
{{#eq ../contentType "null"}}
|
||||
body: typing.Union[{{#each getContent}}{{#with this.schema}}{{baseName}},{{> model_templates/schema_python_types }}{{/with}}{{/each}}],
|
||||
{{else}}
|
||||
body: typing.Union[{{#each getContent}}{{#eq @key ../../contentType }}{{#with this.schema}}{{baseName}},{{> model_templates/schema_python_types }}{{/with}}{{/eq}}{{/each}}],
|
||||
{{/eq}}
|
||||
{{/with}}
|
||||
{{#if isOverload}}
|
||||
{{#eq skipDeserialization "True"}}
|
||||
skip_deserialization: typing_extensions.Literal[True],
|
||||
{{/eq}}
|
||||
{{#neq contentType "null"}}
|
||||
{{#with bodyParam}}
|
||||
{{#each content}}
|
||||
{{#eq @key ../../contentType}}
|
||||
{{#if @first}}
|
||||
content_type: typing_extensions.Literal["{{{@key}}}"] = ...,
|
||||
{{else}}
|
||||
content_type: typing_extensions.Literal["{{{@key}}}"],
|
||||
{{/if}}
|
||||
{{/eq}}
|
||||
{{/each}}
|
||||
{{/with}}
|
||||
{{else}}
|
||||
content_type: str = ...,
|
||||
{{/neq}}
|
||||
{{else}}
|
||||
{{#with bodyParam}}
|
||||
{{#each getContent}}
|
||||
{{#if @first}}
|
||||
content_type: str = '{{{@key}}}',
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
{{/with}}
|
||||
{{/if}}
|
||||
{{else}}
|
||||
{{#if isOverload}}
|
||||
{{#eq skipDeserialization "True"}}
|
||||
skip_deserialization: typing_extensions.Literal[True],
|
||||
{{/eq}}
|
||||
{{#neq contentType "null"}}
|
||||
{{#with bodyParam}}
|
||||
{{#each getContent}}
|
||||
{{#eq @key ../../contentType}}
|
||||
{{#if @first}}
|
||||
content_type: typing_extensions.Literal["{{{@key}}}"] = ...,
|
||||
{{else}}
|
||||
content_type: typing_extensions.Literal["{{{@key}}}"],
|
||||
{{/if}}
|
||||
{{/eq}}
|
||||
{{/each}}
|
||||
{{/with}}
|
||||
{{else}}
|
||||
content_type: str = ...,
|
||||
{{/neq}}
|
||||
{{else}}
|
||||
{{#with bodyParam}}
|
||||
{{#each getContent}}
|
||||
{{#if @first}}
|
||||
content_type: str = '{{{@key}}}',
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
{{/with}}
|
||||
{{/if}}
|
||||
{{#with bodyParam}}
|
||||
{{#eq ../contentType "null"}}
|
||||
body: typing.Union[{{#each getContent}}{{#with this.schema}}{{baseName}}, {{> model_templates/schema_python_types }}{{/with}}{{/each}}schemas.Unset] = schemas.unset,
|
||||
{{else}}
|
||||
body: typing.Union[{{#each getContent}}{{#eq @key ../../contentType }}{{#with this.schema}}{{baseName}}, {{> model_templates/schema_python_types }}{{/with}}{{/eq}}{{/each}}schemas.Unset] = schemas.unset,
|
||||
{{/eq}}
|
||||
{{/with}}
|
||||
{{/if}}
|
||||
{{else}}
|
||||
{{#if isOverload}}
|
||||
{{#eq skipDeserialization "True"}}
|
||||
skip_deserialization: typing_extensions.Literal[True],
|
||||
{{/eq}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{#if queryParams}}
|
||||
query_params: RequestQueryParams = frozendict.frozendict(),
|
||||
{{/if}}
|
||||
{{#if headerParams}}
|
||||
header_params: RequestHeaderParams = frozendict.frozendict(),
|
||||
{{/if}}
|
||||
{{#if pathParams}}
|
||||
path_params: RequestPathParams = frozendict.frozendict(),
|
||||
{{/if}}
|
||||
{{#if cookieParams}}
|
||||
cookie_params: RequestCookieParams = frozendict.frozendict(),
|
||||
{{/if}}
|
||||
{{#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,
|
||||
{{#if isOverload}}
|
||||
{{#eq skipDeserialization "False"}}
|
||||
skip_deserialization: typing_extensions.Literal[False] = ...,
|
||||
{{/eq}}
|
||||
{{#eq skipDeserialization "null"}}
|
||||
skip_deserialization: bool = ...,
|
||||
{{/eq}}
|
||||
{{else}}
|
||||
skip_deserialization: bool = False,
|
||||
{{/if}}
|
||||
{{#eq skipDeserialization "True"}}
|
||||
) -> api_client.ApiResponseWithoutDeserialization: ...
|
||||
{{/eq}}
|
||||
{{#eq skipDeserialization "False"}}
|
||||
) -> {{#if getAllResponsesAreErrors}}api_client.ApiResponseWithoutDeserialization: ...{{else}}typing.Union[
|
||||
{{#each responses}}
|
||||
{{#if isDefault}}
|
||||
ApiResponseForDefault,
|
||||
{{else}}
|
||||
{{#if is2xx}}
|
||||
ApiResponseFor{{code}},
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
]: ...
|
||||
{{/if}}
|
||||
{{/eq}}
|
||||
{{#eq skipDeserialization "null"}}
|
||||
{{#if isOverload}}
|
||||
) -> typing.Union[
|
||||
{{#each responses}}
|
||||
{{#if isDefault}}
|
||||
ApiResponseForDefault,
|
||||
{{else}}
|
||||
{{#if is2xx}}
|
||||
ApiResponseFor{{code}},
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
api_client.ApiResponseWithoutDeserialization,
|
||||
]: ...
|
||||
{{else}}
|
||||
):
|
||||
{{/if}}
|
||||
{{/eq}}
|
@ -1,5 +0,0 @@
|
||||
@typing.overload
|
||||
{{#with this}}
|
||||
def _{{operationId}}_oapg(
|
||||
{{> endpoint_args isOverload=true skipDeserialization="False" contentType=contentType}}
|
||||
{{/with}}
|
@ -1,5 +0,0 @@
|
||||
@typing.overload
|
||||
{{#with this}}
|
||||
def {{httpMethod}}(
|
||||
{{> endpoint_args isOverload=true skipDeserialization="False" contentType=contentType}}
|
||||
{{/with}}
|
@ -1,5 +0,0 @@
|
||||
@typing.overload
|
||||
{{#with this}}
|
||||
def {{operationId}}(
|
||||
{{> endpoint_args isOverload=true skipDeserialization="False" contentType=contentType}}
|
||||
{{/with}}
|
@ -1,33 +0,0 @@
|
||||
{{#if bodyParam}}
|
||||
{{#with bodyParam}}
|
||||
body=body,
|
||||
{{/with}}
|
||||
{{/if}}
|
||||
{{#if queryParams}}
|
||||
query_params=query_params,
|
||||
{{/if}}
|
||||
{{#if headerParams}}
|
||||
header_params=header_params,
|
||||
{{/if}}
|
||||
{{#if pathParams}}
|
||||
path_params=path_params,
|
||||
{{/if}}
|
||||
{{#if cookieParams}}
|
||||
cookie_params=cookie_params,
|
||||
{{/if}}
|
||||
{{#with bodyParam}}
|
||||
{{#each content}}
|
||||
{{#if @first}}
|
||||
content_type=content_type,
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
{{/with}}
|
||||
{{#if produces}}
|
||||
accept_content_types=accept_content_types,
|
||||
{{/if}}
|
||||
{{#if servers}}
|
||||
host_index=host_index,
|
||||
{{/if}}
|
||||
stream=stream,
|
||||
timeout=timeout,
|
||||
skip_deserialization=skip_deserialization
|
@ -1,6 +0,0 @@
|
||||
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']
|
@ -1,24 +0,0 @@
|
||||
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 getContent}}
|
||||
content={
|
||||
{{#each getContent}}
|
||||
"{{@key}}": {{#with this}}{{#with schema}}{{baseName}}{{/with}}{{/with}},
|
||||
{{/each}}
|
||||
},
|
||||
{{/if}}
|
||||
{{#if required}}
|
||||
required=True,
|
||||
{{/if}}
|
||||
{{#if isExplode}}
|
||||
explode=True,
|
||||
{{/if}}
|
||||
)
|
@ -1,56 +0,0 @@
|
||||
# {{xParamsName}} params
|
||||
{{#each xParams}}
|
||||
{{#if schema}}
|
||||
{{#with schema}}
|
||||
{{> model_templates/schema }}
|
||||
{{/with}}
|
||||
{{else}}
|
||||
{{#if getContent}}
|
||||
{{#each getContent}}
|
||||
{{#with this}}
|
||||
{{#with schema}}
|
||||
{{> model_templates/schema }}
|
||||
{{/with}}
|
||||
{{/with}}
|
||||
{{/each}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
RequestRequired{{xParamsName}}Params = typing_extensions.TypedDict(
|
||||
'RequestRequired{{xParamsName}}Params',
|
||||
{
|
||||
{{#each xParams}}
|
||||
{{#if required}}
|
||||
{{#if schema}}
|
||||
'{{baseName}}': {{#with schema}}typing.Union[{{baseName}}, {{> model_templates/schema_python_types }}],{{/with}}
|
||||
{{else}}
|
||||
'{{baseName}}': {{#each getContent}}{{#with this}}{{#with schema}}typing.Union[{{baseName}}, {{> model_templates/schema_python_types }}],{{/with}}{{/with}}{{/each}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
}
|
||||
)
|
||||
RequestOptional{{xParamsName}}Params = typing_extensions.TypedDict(
|
||||
'RequestOptional{{xParamsName}}Params',
|
||||
{
|
||||
{{#each xParams}}
|
||||
{{#unless required}}
|
||||
{{#if schema}}
|
||||
'{{baseName}}': {{#with schema}}typing.Union[{{baseName}}, {{> model_templates/schema_python_types }}],{{/with}}
|
||||
{{else}}
|
||||
'{{baseName}}': {{#each getContent}}{{#with this}}{{#with schema}}typing.Union[{{baseName}}, {{> model_templates/schema_python_types }}],{{/with}}{{/with}}{{/each}}
|
||||
{{/if}}
|
||||
{{/unless}}
|
||||
{{/each}}
|
||||
},
|
||||
total=False
|
||||
)
|
||||
|
||||
|
||||
class Request{{xParamsName}}Params(RequestRequired{{xParamsName}}Params, RequestOptional{{xParamsName}}Params):
|
||||
pass
|
||||
|
||||
|
||||
{{#each xParams}}
|
||||
{{> endpoint_parameter }}
|
||||
{{/each}}
|
@ -1 +0,0 @@
|
||||
{{> endpoint isStub=true }}
|
@ -1,140 +0,0 @@
|
||||
# coding: utf-8
|
||||
|
||||
{{>partial_header}}
|
||||
import dataclasses
|
||||
import typing
|
||||
|
||||
from urllib3._collections import HTTPHeaderDict
|
||||
|
||||
|
||||
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)
|
||||
|
||||
|
||||
T = typing.TypeVar("T")
|
||||
|
||||
|
||||
@dataclasses.dataclass
|
||||
class ApiException(OpenApiException, typing.Generic[T]):
|
||||
status: int
|
||||
reason: str
|
||||
api_response: typing.Optional[T] = None
|
||||
|
||||
@property
|
||||
def body(self) -> typing.Union[str, bytes, None]:
|
||||
if not self.api_response:
|
||||
return None
|
||||
return self.api_response.response.data
|
||||
|
||||
@property
|
||||
def headers(self) -> typing.Optional[HTTPHeaderDict]:
|
||||
if not self.api_response:
|
||||
return None
|
||||
return self.api_response.response.getheaders()
|
||||
|
||||
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
|
@ -1,58 +0,0 @@
|
||||
#!/bin/sh
|
||||
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
|
||||
#
|
||||
# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "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'
|
||||
|
@ -1,67 +0,0 @@
|
||||
# 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
|
@ -1,29 +0,0 @@
|
||||
# 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
|
@ -1,11 +0,0 @@
|
||||
# coding: utf-8
|
||||
|
||||
{{>partial_header}}
|
||||
|
||||
{{#each models}}
|
||||
{{#with model}}
|
||||
{{> model_templates/imports_schema_types }}
|
||||
{{> model_templates/schema }}
|
||||
{{> model_templates/imports_schemas }}
|
||||
{{/with}}
|
||||
{{/each}}
|
@ -1,9 +0,0 @@
|
||||
{{#each models}}
|
||||
{{#with model}}
|
||||
# {{packageName}}.{{modelPackage}}.{{classFilename}}.{{classname}}
|
||||
{{> schema_doc complexTypePrefix="" }}
|
||||
{{/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)
|
||||
|
@ -1 +0,0 @@
|
||||
{{> model isStub=true }}
|
@ -1 +0,0 @@
|
||||
{{#if this.classname}}{{classname}}{{else}}{{#if nameInSnakeCase}}{{name}}{{else}}{{baseName}}{{/if}}{{/if}}
|
@ -1,109 +0,0 @@
|
||||
{{#with composedSchemas}}
|
||||
{{#each allOf}}
|
||||
{{#unless complexType}}
|
||||
{{> model_templates/schema }}
|
||||
{{/unless}}
|
||||
{{/each}}
|
||||
{{#each oneOf}}
|
||||
{{#unless complexType}}
|
||||
{{> model_templates/schema }}
|
||||
{{/unless}}
|
||||
{{/each}}
|
||||
{{#each anyOf}}
|
||||
{{#unless complexType}}
|
||||
{{> model_templates/schema }}
|
||||
{{/unless}}
|
||||
{{/each}}
|
||||
{{/with}}
|
||||
{{#with composedSchemas}}
|
||||
{{#if allOf}}
|
||||
|
||||
@classmethod
|
||||
@functools.lru_cache()
|
||||
def all_of(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
|
||||
return [
|
||||
{{#each allOf}}
|
||||
{{#if complexType}}
|
||||
{{complexType}},
|
||||
{{else}}
|
||||
{{#if nameInSnakeCase}}
|
||||
cls.{{name}},
|
||||
{{else}}
|
||||
cls.{{baseName}},
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
]
|
||||
{{/if}}
|
||||
{{#if oneOf}}
|
||||
|
||||
@classmethod
|
||||
@functools.lru_cache()
|
||||
def one_of(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
|
||||
return [
|
||||
{{#each oneOf}}
|
||||
{{#if complexType}}
|
||||
{{complexType}},
|
||||
{{else}}
|
||||
{{#if nameInSnakeCase}}
|
||||
cls.{{name}},
|
||||
{{else}}
|
||||
cls.{{baseName}},
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
]
|
||||
{{/if}}
|
||||
{{#if anyOf}}
|
||||
|
||||
@classmethod
|
||||
@functools.lru_cache()
|
||||
def any_of(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
|
||||
return [
|
||||
{{#each anyOf}}
|
||||
{{#if complexType}}
|
||||
{{complexType}},
|
||||
{{else}}
|
||||
{{#if nameInSnakeCase}}
|
||||
cls.{{name}},
|
||||
{{else}}
|
||||
cls.{{baseName}},
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
]
|
||||
{{/if}}
|
||||
{{#if not}}
|
||||
{{#with not}}
|
||||
{{#if complexType}}
|
||||
|
||||
@staticmethod
|
||||
def {{#if nameInSnakeCase}}{{name}}{{else}}{{baseName}}{{/if}}() -> typing.Type['{{complexType}}']:
|
||||
return {{complexType}}
|
||||
{{else}}
|
||||
{{> model_templates/schema }}
|
||||
{{/if}}
|
||||
{{/with}}
|
||||
{{/if}}
|
||||
{{/with}}
|
@ -1,58 +0,0 @@
|
||||
{{#if getRequiredVarsMap}}
|
||||
required = {
|
||||
{{#each getRequiredVarsMap}}
|
||||
"{{{@key}}}",
|
||||
{{/each}}
|
||||
}
|
||||
{{/if}}
|
||||
{{#if getHasDiscriminatorWithNonEmptyMapping}}
|
||||
{{#with discriminator}}
|
||||
{{#each mappedModels}}
|
||||
{{#if @first}}
|
||||
|
||||
@staticmethod
|
||||
def discriminator():
|
||||
return {
|
||||
'{{{propertyBaseName}}}': {
|
||||
{{/if}}
|
||||
'{{mappingName}}': {{{modelName}}},
|
||||
{{#if @last}}
|
||||
}
|
||||
}
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
{{/with}}
|
||||
{{/if}}
|
||||
{{#if vars}}
|
||||
|
||||
class properties:
|
||||
{{#each vars}}
|
||||
{{#if complexType}}
|
||||
|
||||
@staticmethod
|
||||
def {{#if nameInSnakeCase}}{{name}}{{else}}{{baseName}}{{/if}}() -> typing.Type['{{complexType}}']:
|
||||
return {{complexType}}
|
||||
{{else}}
|
||||
{{> model_templates/schema }}
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
__annotations__ = {
|
||||
{{#each vars}}
|
||||
{{#if nameInSnakeCase}}
|
||||
"{{{baseName}}}": {{name}},
|
||||
{{else}}
|
||||
"{{{baseName}}}": {{baseName}},
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
}
|
||||
{{/if}}
|
||||
{{#with additionalProperties}}
|
||||
{{#if complexType}}
|
||||
|
||||
@staticmethod
|
||||
def {{baseName}}() -> typing.Type['{{complexType}}']:
|
||||
return {{complexType}}
|
||||
{{else}}
|
||||
{{> model_templates/schema }}
|
||||
{{/if}}
|
||||
{{/with}}
|
@ -1,20 +0,0 @@
|
||||
{{#with allowableValues}}
|
||||
{{#each enumVars}}
|
||||
|
||||
@schemas.classproperty
|
||||
def {{name}}(cls):
|
||||
{{#eq value "schemas.NoneClass.NONE"}}
|
||||
return cls(None)
|
||||
{{else}}
|
||||
{{#eq value "schemas.BoolClass.TRUE"}}
|
||||
return cls(True)
|
||||
{{else}}
|
||||
{{#eq value "schemas.BoolClass.FALSE"}}
|
||||
return cls(False)
|
||||
{{else}}
|
||||
return cls({{{value}}})
|
||||
{{/eq}}
|
||||
{{/eq}}
|
||||
{{/eq}}
|
||||
{{/each}}
|
||||
{{/with}}
|
@ -1,27 +0,0 @@
|
||||
{{#eq getFormat "uuid"}}
|
||||
schemas.UUIDBase,
|
||||
{{/eq}}
|
||||
{{#eq getFormat "date"}}
|
||||
schemas.DateBase,
|
||||
{{/eq}}
|
||||
{{#eq getFormat "date-time"}}
|
||||
schemas.DateTimeBase,
|
||||
{{/eq}}
|
||||
{{#eq getFormat "number"}}
|
||||
schemas.DecimalBase,
|
||||
{{/eq}}
|
||||
{{#eq getFormat "binary"}}
|
||||
schemas.BinaryBase,
|
||||
{{/eq}}
|
||||
{{#eq getFormat "int32"}}
|
||||
schemas.Int32Base,
|
||||
{{/eq}}
|
||||
{{#eq getFormat "int64"}}
|
||||
schemas.Int64Base,
|
||||
{{/eq}}
|
||||
{{#eq getFormat "float"}}
|
||||
schemas.Float32Base,
|
||||
{{/eq}}
|
||||
{{#eq getFormat "double"}}
|
||||
schemas.Float64Base,
|
||||
{{/eq}}
|
@ -1,12 +0,0 @@
|
||||
from datetime import date, datetime # noqa: F401
|
||||
import decimal # noqa: F401
|
||||
import functools # noqa: F401
|
||||
import io # noqa: F401
|
||||
import re # noqa: F401
|
||||
import typing # noqa: F401
|
||||
import typing_extensions # noqa: F401
|
||||
import uuid # noqa: F401
|
||||
|
||||
import frozendict # noqa: F401
|
||||
|
||||
from {{packageName}} import schemas # noqa: F401
|
@ -1,6 +0,0 @@
|
||||
{{#each imports}}
|
||||
{{#if @first}}
|
||||
|
||||
{{/if}}
|
||||
{{{.}}}
|
||||
{{/each}}
|
@ -1,10 +0,0 @@
|
||||
{{#with items}}
|
||||
{{#if complexType}}
|
||||
|
||||
@staticmethod
|
||||
def {{baseName}}() -> typing.Type['{{complexType}}']:
|
||||
return {{complexType}}
|
||||
{{else}}
|
||||
{{> model_templates/schema }}
|
||||
{{/if}}
|
||||
{{/with}}
|
@ -1,100 +0,0 @@
|
||||
def __new__(
|
||||
cls,
|
||||
{{#if getHasMultipleTypes}}
|
||||
*_args: typing.Union[{{> model_templates/schema_python_types }}],
|
||||
{{else}}
|
||||
{{#if isArray }}
|
||||
_arg: typing.Union[typing.Tuple[{{#with items}}{{#if complexType}}'{{complexType}}'{{else}}typing.Union[MetaOapg.{{baseName}}, {{> model_templates/schema_python_types }}]{{/if}}{{/with}}], typing.List[{{#with items}}{{#if complexType}}'{{complexType}}'{{else}}typing.Union[MetaOapg.{{baseName}}, {{> model_templates/schema_python_types }}]{{/if}}{{/with}}]],
|
||||
{{else}}
|
||||
*_args: typing.Union[{{> model_templates/schema_python_types }}],
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{#unless isNull}}
|
||||
{{#if getHasRequired}}
|
||||
{{#each getRequiredVarsMap}}
|
||||
{{#with this}}
|
||||
{{#unless nameInSnakeCase}}
|
||||
{{#if complexType}}
|
||||
{{baseName}}: '{{complexType}}',
|
||||
{{else}}
|
||||
{{#if getSchemaIsFromAdditionalProperties}}
|
||||
{{#if addPropsUnset}}
|
||||
{{baseName}}: typing.Union[schemas.AnyTypeSchema, {{> model_templates/schema_python_types }}],
|
||||
{{else}}
|
||||
{{baseName}}: typing.Union[MetaOapg.additional_properties, {{> model_templates/schema_python_types }}],
|
||||
{{/if}}
|
||||
{{else}}
|
||||
{{baseName}}: typing.Union[MetaOapg.properties.{{baseName}}, {{> model_templates/schema_python_types }}],
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{/unless}}
|
||||
{{/with}}
|
||||
{{/each}}
|
||||
{{/if}}
|
||||
{{/unless}}
|
||||
{{#each vars}}
|
||||
{{#unless nameInSnakeCase}}
|
||||
{{#unless getRequired}}
|
||||
{{#if complexType}}
|
||||
{{baseName}}: typing.Union['{{complexType}}', schemas.Unset] = schemas.unset,
|
||||
{{else}}
|
||||
{{baseName}}: typing.Union[MetaOapg.properties.{{baseName}}, {{> model_templates/schema_python_types }}schemas.Unset] = schemas.unset,
|
||||
{{/if}}
|
||||
{{/unless}}
|
||||
{{/unless}}
|
||||
{{/each}}
|
||||
_configuration: typing.Optional[schemas.Configuration] = None,
|
||||
{{#with additionalProperties}}
|
||||
{{#unless getIsBooleanSchemaFalse}}
|
||||
{{#if complexType}}
|
||||
**kwargs: '{{complexType}}',
|
||||
{{else}}
|
||||
**kwargs: typing.Union[MetaOapg.additional_properties, {{> model_templates/schema_python_types }}],
|
||||
{{/if}}
|
||||
{{/unless}}
|
||||
{{else}}
|
||||
{{#or isMap isAnyType}}
|
||||
**kwargs: typing.Union[schemas.AnyTypeSchema, dict, frozendict.frozendict, str, date, datetime, uuid.UUID, int, float, decimal.Decimal, None, list, tuple, bytes],
|
||||
{{/or}}
|
||||
{{/with}}
|
||||
) -> '{{> model_templates/classname }}':
|
||||
return super().__new__(
|
||||
cls,
|
||||
{{#if getHasMultipleTypes}}
|
||||
*_args,
|
||||
{{else}}
|
||||
{{#if isArray }}
|
||||
_arg,
|
||||
{{else}}
|
||||
*_args,
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{#unless isNull}}
|
||||
{{#if getHasRequired}}
|
||||
{{#each getRequiredVarsMap}}
|
||||
{{#with this}}
|
||||
{{#unless nameInSnakeCase}}
|
||||
{{baseName}}={{baseName}},
|
||||
{{/unless}}
|
||||
{{/with}}
|
||||
{{/each}}
|
||||
{{/if}}
|
||||
{{/unless}}
|
||||
{{#each vars}}
|
||||
{{#unless getRequired}}
|
||||
{{#unless nameInSnakeCase}}
|
||||
{{baseName}}={{baseName}},
|
||||
{{/unless}}
|
||||
{{/unless}}
|
||||
{{/each}}
|
||||
_configuration=_configuration,
|
||||
{{#with additionalProperties}}
|
||||
{{#unless getIsBooleanSchemaFalse}}
|
||||
**kwargs,
|
||||
{{/unless}}
|
||||
{{else}}
|
||||
{{#or isMap isAnyType}}
|
||||
**kwargs,
|
||||
{{/or}}
|
||||
{{/with}}
|
||||
)
|
@ -1 +0,0 @@
|
||||
{{#unless isArray}}{{#unless complexType}}{{#with allowableValues}}must be one of [{{#each enumVars}}{{#eq value "schemas.NoneClass.NONE"}}None{{else}}{{#eq value "schemas.BoolClass.TRUE"}}True{{else}}{{#eq value "schemas.BoolClass.FALSE"}}False{{else}}{{{value}}}{{/eq}}{{/eq}}{{/eq}}, {{/each}}] {{/with}}{{#if defaultValue}}{{#unless hasRequired}}if omitted the server will use the default value of {{{defaultValue}}}{{/unless}}{{/if}}{{#eq getFormat "uuid"}}value must be a uuid{{/eq}}{{#eq getFormat "date"}}value must conform to RFC-3339 full-date YYYY-MM-DD{{/eq}}{{#eq getFormat "date-time"}}value must conform to RFC-3339 date-time{{/eq}}{{#eq getFormat "number"}}value must be numeric and storable in decimal.Decimal{{/eq}}{{#eq getFormat "int32"}}value must be a 32 bit integer{{/eq}}{{#eq getFormat "int64"}}value must be a 64 bit integer{{/eq}}{{#eq getFormat "double"}}value must be a 64 bit float{{/eq}}{{#eq getFormat "float"}}value must be a 32 bit float{{/eq}}{{/unless}}{{/unless}}
|
@ -1,35 +0,0 @@
|
||||
{{#if isMap}}
|
||||
{
|
||||
{{#each value}}
|
||||
{{#with @key}}
|
||||
{{> model_templates/payload_renderer endChar=':'}}
|
||||
{{/with}}
|
||||
{{#with this}}
|
||||
{{> model_templates/payload_renderer endChar=','}}
|
||||
{{/with}}
|
||||
{{/each}}
|
||||
}{{endChar}}
|
||||
{{/if}}
|
||||
{{#if isArray}}
|
||||
[
|
||||
{{#each value}}
|
||||
{{> model_templates/payload_renderer endChar=','}}
|
||||
{{/each}}
|
||||
]{{endChar}}
|
||||
{{/if}}
|
||||
{{#or isNumber isUnboundedInteger}}
|
||||
{{value}}{{endChar}}
|
||||
{{/or}}
|
||||
{{#if isBoolean}}
|
||||
{{#if value}}
|
||||
True{{endChar}}
|
||||
{{else}}
|
||||
False{{endChar}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{#if isNull}}
|
||||
None{{endChar}}
|
||||
{{/if}}
|
||||
{{#if isString}}
|
||||
"{{{value}}}"{{endChar}}
|
||||
{{/if}}
|
@ -1,108 +0,0 @@
|
||||
{{#if getRequiredVarsMap}}
|
||||
{{#each getRequiredVarsMap}}
|
||||
{{#with this}}
|
||||
|
||||
@typing.overload
|
||||
{{#if complexType}}
|
||||
def __getitem__(self, name: typing_extensions.Literal["{{{baseName}}}"]) -> '{{complexType}}': ...
|
||||
{{else}}
|
||||
{{#if schemaIsFromAdditionalProperties}}
|
||||
def __getitem__(self, name: typing_extensions.Literal["{{{baseName}}}"]) -> MetaOapg.additional_properties: ...
|
||||
{{else}}
|
||||
{{#if nameInSnakeCase}}
|
||||
def __getitem__(self, name: typing_extensions.Literal["{{{baseName}}}"]) -> MetaOapg.properties.{{name}}: ...
|
||||
{{else}}
|
||||
def __getitem__(self, name: typing_extensions.Literal["{{{baseName}}}"]) -> MetaOapg.properties.{{baseName}}: ...
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{/with}}
|
||||
{{/each}}
|
||||
{{/if}}
|
||||
{{#if vars}}
|
||||
{{#each vars}}
|
||||
{{#unless required}}
|
||||
|
||||
@typing.overload
|
||||
{{#if complexType}}
|
||||
def __getitem__(self, name: typing_extensions.Literal["{{{baseName}}}"]) -> '{{complexType}}': ...
|
||||
{{else}}
|
||||
{{#if nameInSnakeCase}}
|
||||
def __getitem__(self, name: typing_extensions.Literal["{{{baseName}}}"]) -> MetaOapg.properties.{{name}}: ...
|
||||
{{else}}
|
||||
def __getitem__(self, name: typing_extensions.Literal["{{{baseName}}}"]) -> MetaOapg.properties.{{baseName}}: ...
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{/unless}}
|
||||
{{/each}}
|
||||
{{/if}}
|
||||
{{#or vars getRequiredVarsMap}}
|
||||
{{#with additionalProperties}}
|
||||
{{#unless getIsBooleanSchemaFalse}}
|
||||
|
||||
@typing.overload
|
||||
def __getitem__(self, name: str) -> {{#if complexType}}'{{complexType}}'{{else}}MetaOapg.{{baseName}}{{/if}}: ...
|
||||
{{/unless}}
|
||||
{{/with}}
|
||||
|
||||
{{> model_templates/property_getitems_with_addprops_getitem methodName="__getitem__" }}
|
||||
{{else}}
|
||||
{{#not additionalProperties.getIsBooleanSchemaFalse}}
|
||||
|
||||
{{> model_templates/property_getitems_with_addprops_getitem methodName="__getitem__" }}
|
||||
{{/not}}
|
||||
{{/or}}
|
||||
{{#if getRequiredVarsMap}}
|
||||
{{#each getRequiredVarsMap}}
|
||||
{{#with this}}
|
||||
|
||||
@typing.overload
|
||||
{{#if complexType}}
|
||||
def get_item_oapg(self, name: typing_extensions.Literal["{{{baseName}}}"]) -> '{{complexType}}': ...
|
||||
{{else}}
|
||||
{{#if schemaIsFromAdditionalProperties}}
|
||||
def get_item_oapg(self, name: typing_extensions.Literal["{{{baseName}}}"]) -> MetaOapg.additional_properties: ...
|
||||
{{else}}
|
||||
{{#if nameInSnakeCase}}
|
||||
def get_item_oapg(self, name: typing_extensions.Literal["{{{baseName}}}"]) -> MetaOapg.properties.{{name}}: ...
|
||||
{{else}}
|
||||
def get_item_oapg(self, name: typing_extensions.Literal["{{{baseName}}}"]) -> MetaOapg.properties.{{baseName}}: ...
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{/with}}
|
||||
{{/each}}
|
||||
{{/if}}
|
||||
{{#if vars}}
|
||||
{{#each vars}}
|
||||
{{#unless required}}
|
||||
|
||||
@typing.overload
|
||||
{{#if complexType}}
|
||||
def get_item_oapg(self, name: typing_extensions.Literal["{{{baseName}}}"]) -> typing.Union['{{complexType}}', schemas.Unset]: ...
|
||||
{{else}}
|
||||
{{#if nameInSnakeCase}}
|
||||
def get_item_oapg(self, name: typing_extensions.Literal["{{{baseName}}}"]) -> typing.Union[MetaOapg.properties.{{name}}, schemas.Unset]: ...
|
||||
{{else}}
|
||||
def get_item_oapg(self, name: typing_extensions.Literal["{{{baseName}}}"]) -> typing.Union[MetaOapg.properties.{{baseName}}, schemas.Unset]: ...
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{/unless}}
|
||||
{{/each}}
|
||||
{{/if}}
|
||||
{{#or vars getRequiredVarsMap}}
|
||||
{{#with additionalProperties}}
|
||||
{{#unless getIsBooleanSchemaFalse}}
|
||||
|
||||
@typing.overload
|
||||
def get_item_oapg(self, name: str) -> typing.Union[{{#if complexType}}'{{complexType}}'{{else}}MetaOapg.{{baseName}}{{/if}}, schemas.Unset]: ...
|
||||
{{/unless}}
|
||||
{{/with}}
|
||||
|
||||
{{> model_templates/property_getitems_with_addprops_getitem methodName="get_item_oapg" }}
|
||||
{{else}}
|
||||
{{#not additionalProperties.getIsBooleanSchemaFalse}}
|
||||
|
||||
{{> model_templates/property_getitems_with_addprops_getitem methodName="get_item_oapg" }}
|
||||
{{/not}}
|
||||
{{/or}}
|
@ -1,5 +0,0 @@
|
||||
def {{methodName}}(self, name: typing.Union[{{#each getRequiredVarsMap}}{{#with this}}typing_extensions.Literal["{{{baseName}}}"], {{/with}}{{/each}}{{#each vars}}{{#unless required}}typing_extensions.Literal["{{{baseName}}}"], {{/unless}}{{/each}}{{#with additionalProperties}}{{#unless getIsBooleanSchemaFalse}}str, {{/unless}}{{/with}}]){{#not vars}}{{#not getRequiredVarsMap}}{{#with additionalProperties}}{{#unless getIsBooleanSchemaFalse}} -> {{#if complexType}}'{{complexType}}'{{else}}MetaOapg.{{baseName}}{{/if}}{{/unless}}{{/with}}{{/not}}{{/not}}:
|
||||
{{#eq methodName "__getitem__"}}
|
||||
# dict_instance[name] accessor
|
||||
{{/eq}}
|
||||
return super().{{methodName}}(name)
|
@ -1,45 +0,0 @@
|
||||
{{#if vars}}
|
||||
{{#each vars}}
|
||||
|
||||
@typing.overload
|
||||
{{#if complexType}}
|
||||
def __getitem__(self, name: typing_extensions.Literal["{{{baseName}}}"]) -> '{{complexType}}': ...
|
||||
{{else}}
|
||||
{{#if nameInSnakeCase}}
|
||||
def __getitem__(self, name: typing_extensions.Literal["{{{baseName}}}"]) -> MetaOapg.properties.{{name}}: ...
|
||||
{{else}}
|
||||
def __getitem__(self, name: typing_extensions.Literal["{{{baseName}}}"]) -> MetaOapg.properties.{{baseName}}: ...
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
|
||||
@typing.overload
|
||||
def __getitem__(self, name: str) -> schemas.UnsetAnyTypeSchema: ...
|
||||
|
||||
def __getitem__(self, name: typing.Union[typing_extensions.Literal[{{#each vars}}"{{{baseName}}}", {{/each}}], str]):
|
||||
# dict_instance[name] accessor
|
||||
return super().__getitem__(name)
|
||||
|
||||
{{/if}}
|
||||
{{#if vars}}
|
||||
{{#each vars}}
|
||||
|
||||
@typing.overload
|
||||
{{#if complexType}}
|
||||
def get_item_oapg(self, name: typing_extensions.Literal["{{{baseName}}}"]) -> {{#unless required}}typing.Union[{{/unless}}'{{complexType}}'{{#unless required}}, schemas.Unset]{{/unless}}: ...
|
||||
{{else}}
|
||||
{{#if nameInSnakeCase}}
|
||||
def get_item_oapg(self, name: typing_extensions.Literal["{{{baseName}}}"]) -> {{#unless required}}typing.Union[{{/unless}}MetaOapg.properties.{{name}}{{#unless required}}, schemas.Unset]{{/unless}}: ...
|
||||
{{else}}
|
||||
def get_item_oapg(self, name: typing_extensions.Literal["{{{baseName}}}"]) -> {{#unless required}}typing.Union[{{/unless}}MetaOapg.properties.{{baseName}}{{#unless required}}, schemas.Unset]{{/unless}}: ...
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
|
||||
@typing.overload
|
||||
def get_item_oapg(self, name: str) -> typing.Union[schemas.UnsetAnyTypeSchema, schemas.Unset]: ...
|
||||
|
||||
def get_item_oapg(self, name: typing.Union[typing_extensions.Literal[{{#each vars}}"{{{baseName}}}", {{/each}}], str]):
|
||||
return super().get_item_oapg(name)
|
||||
|
||||
{{/if}}
|
@ -1,13 +0,0 @@
|
||||
{{#if getRequiredVarsMap}}
|
||||
|
||||
{{#if additionalProperties}}
|
||||
{{> model_templates/property_type_hints_required }}
|
||||
{{else}}
|
||||
{{> model_templates/property_type_hints_required addPropsUnset=true }}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{#if additionalProperties}}
|
||||
{{> model_templates/property_getitems_with_addprops }}
|
||||
{{else}}
|
||||
{{> model_templates/property_getitems_without_addprops }}
|
||||
{{/if}}
|
@ -1,19 +0,0 @@
|
||||
{{#each getRequiredVarsMap}}
|
||||
{{#with this}}
|
||||
{{#unless nameInSnakeCase}}
|
||||
{{#if complexType}}
|
||||
{{baseName}}: '{{complexType}}'
|
||||
{{else}}
|
||||
{{#if schemaIsFromAdditionalProperties}}
|
||||
{{#if addPropsUnset}}
|
||||
{{baseName}}: schemas.AnyTypeSchema
|
||||
{{else}}
|
||||
{{baseName}}: MetaOapg.additional_properties
|
||||
{{/if}}
|
||||
{{else}}
|
||||
{{baseName}}: MetaOapg.properties.{{baseName}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{/unless}}
|
||||
{{/with}}
|
||||
{{/each}}
|
@ -1,42 +0,0 @@
|
||||
{{#if composedSchemas}}
|
||||
{{#if getIsBooleanSchemaFalse}}
|
||||
{{> model_templates/var_equals_cls }}
|
||||
{{else}}
|
||||
{{> model_templates/schema_composed_or_anytype }}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{#unless composedSchemas}}
|
||||
{{#if getHasMultipleTypes}}
|
||||
{{> model_templates/schema_composed_or_anytype }}
|
||||
{{else}}
|
||||
{{#or isMap isArray isAnyType}}
|
||||
{{#if isMap}}
|
||||
{{#or hasVars hasValidation getRequiredVarsMap getHasDiscriminatorWithNonEmptyMapping additionalProperties }}
|
||||
{{> model_templates/schema_dict }}
|
||||
{{else}}
|
||||
{{> model_templates/var_equals_cls }}
|
||||
{{/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 getRequiredVarsMap getHasDiscriminatorWithNonEmptyMapping items getFormat}}
|
||||
{{> 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}}
|
||||
{{/unless}}
|
@ -1 +0,0 @@
|
||||
{{#if isAnyType}}frozendict.frozendict, str, decimal.Decimal, BoolClass, NoneClass, tuple, bytes, FileIO{{/if}}{{#if isArray}}tuple, {{/if}}{{#if isMap}}frozendict.frozendict, {{/if}}{{#if isNull}}NoneClass, {{/if}}{{#if isString }}{{#neq format "binary"}}str, {{/neq}}{{#eq format "binary"}}bytes, FileIO, {{/eq}}{{/if}}{{#or isInteger isNumber}}decimal.Decimal, {{/or}}{{#if isBoolean}}BoolClass, {{/if}}
|
@ -1,75 +0,0 @@
|
||||
|
||||
|
||||
class {{#if this.classname}}{{classname}}{{else}}{{#if nameInSnakeCase}}{{name}}{{else}}{{baseName}}{{/if}}{{/if}}(
|
||||
{{#if getIsAnyType}}
|
||||
{{#if getFormat}}
|
||||
{{> model_templates/format_base }}
|
||||
{{/if}}
|
||||
{{#if composedSchemas}}
|
||||
schemas.ComposedSchema,
|
||||
{{else}}
|
||||
schemas.AnyTypeSchema,
|
||||
{{/if}}
|
||||
{{else}}
|
||||
{{#if composedSchemas}}
|
||||
schemas.ComposedBase,
|
||||
{{/if}}
|
||||
{{#if isEnum}}
|
||||
schemas.EnumBase,
|
||||
{{/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}}
|
||||
"""
|
||||
{{/if}}
|
||||
{{#or hasValidation composedSchemas getItems additionalProperties getRequiredVarsMap getHasDiscriminatorWithNonEmptyMapping vars getFormat isEnum}}
|
||||
|
||||
|
||||
class MetaOapg:
|
||||
{{#if getFormat}}
|
||||
format = '{{getFormat}}'
|
||||
{{/if}}
|
||||
{{#if isEnum}}
|
||||
{{#with allowableValues}}
|
||||
enum_value_to_name = {
|
||||
{{#each enumVars}}
|
||||
{{{value}}}: "{{name}}",
|
||||
{{/each}}
|
||||
}
|
||||
{{/with}}
|
||||
{{/if}}
|
||||
{{#if getItems}}
|
||||
{{> model_templates/list_partial }}
|
||||
{{/if}}
|
||||
{{#or additionalProperties getRequiredVarsMap getHasDiscriminatorWithNonEmptyMapping vars}}
|
||||
{{> model_templates/dict_partial }}
|
||||
{{/or}}
|
||||
{{#unless isStub}}
|
||||
{{#if hasValidation}}
|
||||
{{> model_templates/validations }}
|
||||
{{/if}}
|
||||
{{/unless}}
|
||||
{{#if composedSchemas}}
|
||||
{{> model_templates/composed_schemas }}
|
||||
{{/if}}
|
||||
{{/or}}
|
||||
{{#if isEnum}}
|
||||
{{> model_templates/enums }}
|
||||
{{/if}}
|
||||
|
||||
{{> model_templates/property_type_hints }}
|
||||
|
||||
{{#if additionalProperties}}
|
||||
{{> model_templates/new }}
|
||||
{{else}}
|
||||
{{> model_templates/new addPropsUnset=true }}
|
||||
{{/if}}
|
@ -1,39 +0,0 @@
|
||||
|
||||
|
||||
class {{> model_templates/classname }}(
|
||||
schemas.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}}
|
||||
"""
|
||||
{{/if}}
|
||||
{{#if isStub}}
|
||||
{{#or additionalProperties getRequiredVarsMap getHasDiscriminatorWithNonEmptyMapping vars}}
|
||||
|
||||
|
||||
class MetaOapg:
|
||||
{{> model_templates/dict_partial }}
|
||||
{{/or}}
|
||||
{{else}}
|
||||
{{#or additionalProperties getRequiredVarsMap getHasDiscriminatorWithNonEmptyMapping vars hasValidation}}
|
||||
|
||||
|
||||
class MetaOapg:
|
||||
{{> model_templates/dict_partial }}
|
||||
{{> model_templates/validations }}
|
||||
{{/or}}
|
||||
{{/if}}
|
||||
{{> model_templates/property_type_hints }}
|
||||
|
||||
{{#if additionalProperties}}
|
||||
{{> model_templates/new }}
|
||||
{{else}}
|
||||
{{> model_templates/new addPropsUnset=true }}
|
||||
{{/if}}
|
@ -1,39 +0,0 @@
|
||||
|
||||
|
||||
class {{> model_templates/classname }}(
|
||||
schemas.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}}
|
||||
"""
|
||||
{{/if}}
|
||||
{{#if isStub}}
|
||||
{{#if items}}
|
||||
|
||||
|
||||
class MetaOapg:
|
||||
{{> model_templates/list_partial }}
|
||||
{{/if}}
|
||||
{{else}}
|
||||
{{#or getItems hasValidation}}
|
||||
|
||||
|
||||
class MetaOapg:
|
||||
{{#if hasValidation}}
|
||||
{{> model_templates/validations }}
|
||||
{{/if}}
|
||||
{{> model_templates/list_partial }}
|
||||
{{/or}}
|
||||
{{/if}}
|
||||
|
||||
{{> model_templates/new }}
|
||||
|
||||
def __getitem__(self, i: int) -> {{#with items}}{{#if complexType}}'{{complexType}}'{{else}}MetaOapg.items{{/if}}{{/with}}:
|
||||
return super().__getitem__(i)
|
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