Skip to content
This repository was archived by the owner on Dec 25, 2024. It is now read-only.

Adds tests of securitySchemes in endpoints #68

Merged
merged 4 commits into from
Nov 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,6 @@ class Configuration(object):
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,
Expand Down Expand Up @@ -162,17 +151,29 @@ conf = {{{packageName}}}.Configuration(

_default = None

def __init__(self, host=None,
api_key=None, api_key_prefix=None,
username=None, password=None,
discard_unknown_keys=False,
disabled_client_side_validations="",
def __init__(
self,
host=None,
{{#if hasApiKeyMethods}}
api_key=None,
api_key_prefix=None,
{{/if}}
{{#if hasHttpBasicMethods}}
username=None,
password=None,
{{/if}}
disabled_client_side_validations="",
{{#if hasHttpSignatureMethods}}
signing_info=None,
signing_info=None,
{{/if}}
server_index=None, server_variables=None,
server_operation_index=None, server_operation_variables=None,
):
server_index=None,
server_variables=None,
server_operation_index=None,
server_operation_variables=None,
{{#or hasOAuthMethods hasBearerMethods}}
access_token=None,
{{/or}}
):
"""Constructor
"""
self._base_path = "{{{basePath}}}" if host is None else host
Expand All @@ -190,6 +191,7 @@ conf = {{{packageName}}}.Configuration(
"""Temp file folder for downloading files
"""
# Authentication Settings
{{#if hasApiKeyMethods}}
self.api_key = {}
if api_key:
self.api_key = api_key
Expand All @@ -203,13 +205,15 @@ conf = {{{packageName}}}.Configuration(
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:
Expand All @@ -218,18 +222,11 @@ conf = {{{packageName}}}.Configuration(
"""The HTTP signing configuration
"""
{{/if}}
{{#if hasOAuthMethods}}
self.access_token = None
"""access token for OAuth/Bearer
"""
{{/if}}
{{#unless hasOAuthMethods}}
{{#if hasBearerMethods}}
self.access_token = None
{{#or hasOAuthMethods hasBearerMethods}}
self.access_token = access_token
"""access token for OAuth/Bearer
"""
{{/if}}
{{/unless}}
{{/or}}
self.logger = {}
"""Logging Settings
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ configuration.api_key['{{{name}}}'] = 'YOUR_API_KEY'

# Configure OAuth2 access token for authorization: {{{name}}}
configuration = {{{packageName}}}.Configuration(
host = "{{{basePath}}}"
host = "{{{basePath}}}",
access_token = 'YOUR_ACCESS_TOKEN'
)
configuration.access_token = 'YOUR_ACCESS_TOKEN'
{{/if}}
{{/each}}
{{/if}}
Original file line number Diff line number Diff line change
Expand Up @@ -791,13 +791,16 @@ paths:
description: Required String in group parameters
required: true
schema:
type: integer
type: string
- name: required_boolean_group
in: header
description: Required Boolean in group parameters
required: true
schema:
type: boolean
type: string
enum:
- true
- false
- name: required_int64_group
in: query
description: Required Integer in group parameters
Expand All @@ -809,12 +812,15 @@ paths:
in: query
description: String in group parameters
schema:
type: integer
type: string
- name: boolean_group
in: header
description: Boolean in group parameters
schema:
type: boolean
type: string
enum:
- true
- false
- name: int64_group
in: query
description: Integer in group parameters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,6 @@ class Configuration(object):
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,
Expand Down Expand Up @@ -80,14 +69,15 @@ class Configuration(object):

_default = None

def __init__(self, host=None,
api_key=None, api_key_prefix=None,
username=None, password=None,
discard_unknown_keys=False,
disabled_client_side_validations="",
server_index=None, server_variables=None,
server_operation_index=None, server_operation_variables=None,
):
def __init__(
self,
host=None,
disabled_client_side_validations="",
server_index=None,
server_variables=None,
server_operation_index=None,
server_operation_variables=None,
):
"""Constructor
"""
self._base_path = "https://someserver.com/v1" if host is None else host
Expand All @@ -105,26 +95,6 @@ def __init__(self, host=None,
"""Temp file folder for downloading files
"""
# Authentication Settings
self.api_key = {}
if api_key:
self.api_key = api_key
"""dict to store API key(s)
"""
self.api_key_prefix = {}
if api_key_prefix:
self.api_key_prefix = api_key_prefix
"""dict to store API prefix (e.g. Bearer)
"""
self.refresh_api_key_hook = None
"""function hook to refresh API key if expired
"""
self.username = username
"""Username for HTTP basic authentication
"""
self.password = password
"""Password for HTTP basic authentication
"""
self.discard_unknown_keys = discard_unknown_keys
self.disabled_client_side_validations = disabled_client_side_validations
self.logger = {}
"""Logging Settings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,6 @@ class Configuration(object):
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,
Expand Down Expand Up @@ -80,14 +69,15 @@ class Configuration(object):

_default = None

def __init__(self, host=None,
api_key=None, api_key_prefix=None,
username=None, password=None,
discard_unknown_keys=False,
disabled_client_side_validations="",
server_index=None, server_variables=None,
server_operation_index=None, server_operation_variables=None,
):
def __init__(
self,
host=None,
disabled_client_side_validations="",
server_index=None,
server_variables=None,
server_operation_index=None,
server_operation_variables=None,
):
"""Constructor
"""
self._base_path = "http://localhost:3000" if host is None else host
Expand All @@ -105,26 +95,6 @@ def __init__(self, host=None,
"""Temp file folder for downloading files
"""
# Authentication Settings
self.api_key = {}
if api_key:
self.api_key = api_key
"""dict to store API key(s)
"""
self.api_key_prefix = {}
if api_key_prefix:
self.api_key_prefix = api_key_prefix
"""dict to store API prefix (e.g. Bearer)
"""
self.refresh_api_key_hook = None
"""function hook to refresh API key if expired
"""
self.username = username
"""Username for HTTP basic authentication
"""
self.password = password
"""Password for HTTP basic authentication
"""
self.discard_unknown_keys = discard_unknown_keys
self.disabled_client_side_validations = disabled_client_side_validations
self.logger = {}
"""Logging Settings
Expand Down
20 changes: 10 additions & 10 deletions samples/openapi3/client/petstore/python/docs/apis/tags/FakeApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -1328,11 +1328,11 @@ with petstore_api.ApiClient(configuration) as api_client:

# example passing only required values which don't have defaults set
query_params = {
'required_string_group': 1,
'required_string_group': "required_string_group_example",
'required_int64_group': 1,
}
header_params = {
'required_boolean_group': True,
'required_boolean_group': "true",
}
try:
# Fake endpoint to test group parameters (optional)
Expand All @@ -1345,14 +1345,14 @@ with petstore_api.ApiClient(configuration) as api_client:

# example passing only optional values
query_params = {
'required_string_group': 1,
'required_string_group': "required_string_group_example",
'required_int64_group': 1,
'string_group': 1,
'string_group': "string_group_example",
'int64_group': 1,
}
header_params = {
'required_boolean_group': True,
'boolean_group': True,
'required_boolean_group': "true",
'boolean_group': "true",
}
try:
# Fake endpoint to test group parameters (optional)
Expand Down Expand Up @@ -1389,7 +1389,7 @@ int64_group | Int64GroupSchema | | optional
## Model Type Info
Input Type | Accessed Type | Description | Notes
------------ | ------------- | ------------- | -------------
decimal.Decimal, int, | decimal.Decimal, | |
str, | str, | |

# RequiredInt64GroupSchema

Expand All @@ -1403,7 +1403,7 @@ decimal.Decimal, int, | decimal.Decimal, | | value must be a 64 bit integer
## Model Type Info
Input Type | Accessed Type | Description | Notes
------------ | ------------- | ------------- | -------------
decimal.Decimal, int, | decimal.Decimal, | |
str, | str, | |

# Int64GroupSchema

Expand All @@ -1425,14 +1425,14 @@ boolean_group | BooleanGroupSchema | | optional
## Model Type Info
Input Type | Accessed Type | Description | Notes
------------ | ------------- | ------------- | -------------
bool, | BoolClass, | |
str, | str, | | must be one of ["true", "false", ]

# BooleanGroupSchema

## Model Type Info
Input Type | Accessed Type | Description | Notes
------------ | ------------- | ------------- | -------------
bool, | BoolClass, | |
str, | str, | | must be one of ["true", "false", ]

### Return Types, Responses

Expand Down
Loading