[python-experimental] adds new json content type (#13356)

* Adds json detection for application/json-patch+json

* Adds jsonPatch route and schemas

* Adds test_json_patch

* Unit test sample updated

* Reverts version files
This commit is contained in:
Justin Black
2022-09-05 09:37:01 -07:00
committed by GitHub
parent 2a8ea162d7
commit cb8d9d5bfe
34 changed files with 1580 additions and 24 deletions

View File

@@ -797,12 +797,17 @@ class ApiResponseWithoutDeserialization(ApiResponse):
class JSONDetector:
@staticmethod
def content_type_is_json(content_type: str) -> bool:
"""
for when content_type strings also include charset info like:
application/json; charset=UTF-8
"""
content_type_piece = content_type.split(';')[0]
def _content_type_is_json(content_type: str) -> bool:
content_type_piece = content_type
if ';' in content_type:
# application/json; charset=UTF-8
content_type_piece = content_type.split(';')[0]
elif '-' in content_type:
"""
application/json-patch+json
application/json-seq
"""
content_type_piece = content_type.split('-')[0]
if content_type_piece == 'application/json':
return True
return False
@@ -905,7 +910,7 @@ class OpenApiResponse(JSONDetector):
body=unset
)
if self.content_type_is_json(content_type):
if self._content_type_is_json(content_type):
body_data = self.__deserialize_json(response)
elif content_type == 'application/octet-stream':
body_data = self.__deserialize_application_octet_stream(response)
@@ -1463,7 +1468,7 @@ class RequestBody(StyleFormSerializer, JSONDetector):
cast_in_data = media_type.schema(in_data)
# TODO check for and use encoding if it exists
# and content_type is multipart or application/x-www-form-urlencoded
if self.content_type_is_json(content_type):
if self._content_type_is_json(content_type):
return self.__serialize_json(cast_in_data)
elif content_type == 'text/plain':
return self.__serialize_text_plain(cast_in_data)

View File

@@ -1558,6 +1558,21 @@ paths:
content:
application/json: {}
application/xml: {}
/fake/jsonPatch:
patch:
summary: json patch
description: json patch route with a requestBody
operationId: jsonPatch
tags:
- fake
requestBody:
content:
application/json-patch+json:
schema:
$ref: '#/components/schemas/JSONPatchRequest'
responses:
'200':
description: OK
/fake/deleteCoffee/{id}:
delete:
operationId: deleteCoffee
@@ -2832,3 +2847,62 @@ components:
AnyTypeNotString:
not:
type: string
JSONPatchRequest:
type: array
items:
oneOf:
- $ref: '#/components/schemas/JSONPatchRequestAddReplaceTest'
- $ref: '#/components/schemas/JSONPatchRequestRemove'
- $ref: '#/components/schemas/JSONPatchRequestMoveCopy'
JSONPatchRequestAddReplaceTest:
type: object
additionalProperties: false
required:
- value
- op
- path
properties:
path:
description: A JSON Pointer path.
type: string
value:
description: The value to add, replace or test.
op:
description: The operation to perform.
type: string
enum:
- add
- replace
- test
JSONPatchRequestRemove:
type: object
additionalProperties: false
required:
- op
- path
properties:
path:
description: A JSON Pointer path.
type: string
op:
description: The operation to perform.
type: string
enum:
- remove
JSONPatchRequestMoveCopy:
type: object
additionalProperties: false
required:
- from
- op
- path
properties:
path:
description: A JSON Pointer path.
type: string
op:
description: The operation to perform.
type: string
enum:
- move
- copy

View File

@@ -801,12 +801,17 @@ class ApiResponseWithoutDeserialization(ApiResponse):
class JSONDetector:
@staticmethod
def content_type_is_json(content_type: str) -> bool:
"""
for when content_type strings also include charset info like:
application/json; charset=UTF-8
"""
content_type_piece = content_type.split(';')[0]
def _content_type_is_json(content_type: str) -> bool:
content_type_piece = content_type
if ';' in content_type:
# application/json; charset=UTF-8
content_type_piece = content_type.split(';')[0]
elif '-' in content_type:
"""
application/json-patch+json
application/json-seq
"""
content_type_piece = content_type.split('-')[0]
if content_type_piece == 'application/json':
return True
return False
@@ -909,7 +914,7 @@ class OpenApiResponse(JSONDetector):
body=unset
)
if self.content_type_is_json(content_type):
if self._content_type_is_json(content_type):
body_data = self.__deserialize_json(response)
elif content_type == 'application/octet-stream':
body_data = self.__deserialize_application_octet_stream(response)
@@ -1453,7 +1458,7 @@ class RequestBody(StyleFormSerializer, JSONDetector):
cast_in_data = media_type.schema(in_data)
# TODO check for and use encoding if it exists
# and content_type is multipart or application/x-www-form-urlencoded
if self.content_type_is_json(content_type):
if self._content_type_is_json(content_type):
return self.__serialize_json(cast_in_data)
elif content_type == 'text/plain':
return self.__serialize_text_plain(cast_in_data)

View File

@@ -74,6 +74,10 @@ docs/models/IntegerEnumWithDefaultValue.md
docs/models/IntegerMax10.md
docs/models/IntegerMin15.md
docs/models/IsoscelesTriangle.md
docs/models/JSONPatchRequest.md
docs/models/JSONPatchRequestAddReplaceTest.md
docs/models/JSONPatchRequestMoveCopy.md
docs/models/JSONPatchRequestRemove.md
docs/models/Mammal.md
docs/models/MapTest.md
docs/models/MixedPropertiesAndAdditionalPropertiesClass.md
@@ -264,6 +268,14 @@ petstore_api/model/integer_min15.py
petstore_api/model/integer_min15.pyi
petstore_api/model/isosceles_triangle.py
petstore_api/model/isosceles_triangle.pyi
petstore_api/model/json_patch_request.py
petstore_api/model/json_patch_request.pyi
petstore_api/model/json_patch_request_add_replace_test.py
petstore_api/model/json_patch_request_add_replace_test.pyi
petstore_api/model/json_patch_request_move_copy.py
petstore_api/model/json_patch_request_move_copy.pyi
petstore_api/model/json_patch_request_remove.py
petstore_api/model/json_patch_request_remove.pyi
petstore_api/model/mammal.py
petstore_api/model/mammal.pyi
petstore_api/model/map_test.py

View File

@@ -182,6 +182,7 @@ Class | Method | HTTP request | Description
*FakeApi* | [**inline_additional_properties**](docs/apis/tags/FakeApi.md#inline_additional_properties) | **post** /fake/inline-additionalProperties | test inline additionalProperties
*FakeApi* | [**inline_composition**](docs/apis/tags/FakeApi.md#inline_composition) | **post** /fake/inlineComposition/ | testing composed schemas at inline locations
*FakeApi* | [**json_form_data**](docs/apis/tags/FakeApi.md#json_form_data) | **get** /fake/jsonFormData | test json serialization of form data
*FakeApi* | [**json_patch**](docs/apis/tags/FakeApi.md#json_patch) | **patch** /fake/jsonPatch | json patch
*FakeApi* | [**json_with_charset**](docs/apis/tags/FakeApi.md#json_with_charset) | **post** /fake/jsonWithCharset | json with charset tx and rx
*FakeApi* | [**mammal**](docs/apis/tags/FakeApi.md#mammal) | **post** /fake/refs/mammal |
*FakeApi* | [**number_with_validations**](docs/apis/tags/FakeApi.md#number_with_validations) | **post** /fake/refs/number |
@@ -286,6 +287,10 @@ Class | Method | HTTP request | Description
- [IntegerMax10](docs/models/IntegerMax10.md)
- [IntegerMin15](docs/models/IntegerMin15.md)
- [IsoscelesTriangle](docs/models/IsoscelesTriangle.md)
- [JSONPatchRequest](docs/models/JSONPatchRequest.md)
- [JSONPatchRequestAddReplaceTest](docs/models/JSONPatchRequestAddReplaceTest.md)
- [JSONPatchRequestMoveCopy](docs/models/JSONPatchRequestMoveCopy.md)
- [JSONPatchRequestRemove](docs/models/JSONPatchRequestRemove.md)
- [Mammal](docs/models/Mammal.md)
- [MapTest](docs/models/MapTest.md)
- [MixedPropertiesAndAdditionalPropertiesClass](docs/models/MixedPropertiesAndAdditionalPropertiesClass.md)

View File

@@ -22,6 +22,7 @@ Method | HTTP request | Description
[**inline_additional_properties**](#inline_additional_properties) | **post** /fake/inline-additionalProperties | test inline additionalProperties
[**inline_composition**](#inline_composition) | **post** /fake/inlineComposition/ | testing composed schemas at inline locations
[**json_form_data**](#json_form_data) | **get** /fake/jsonFormData | test json serialization of form data
[**json_patch**](#json_patch) | **patch** /fake/jsonPatch | json patch
[**json_with_charset**](#json_with_charset) | **post** /fake/jsonWithCharset | json with charset tx and rx
[**mammal**](#mammal) | **post** /fake/refs/mammal |
[**number_with_validations**](#number_with_validations) | **post** /fake/refs/number |
@@ -1719,6 +1720,85 @@ body | Unset | body was not defined |
headers | Unset | headers were not defined |
void (empty response body)
### Authorization
No authorization required
[[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)
# **json_patch**
<a name="json_patch"></a>
> json_patch()
json patch
json patch route with a requestBody
### Example
```python
import petstore_api
from petstore_api.apis.tags import fake_api
from petstore_api.model.json_patch_request import JSONPatchRequest
from pprint import pprint
# Defining the host is optional and defaults to http://petstore.swagger.io:80/v2
# See configuration.py for a list of all supported configuration parameters.
configuration = petstore_api.Configuration(
host = "http://petstore.swagger.io:80/v2"
)
# Enter a context with an instance of the API client
with petstore_api.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = fake_api.FakeApi(api_client)
# example passing only optional values
body = JSONPatchRequest([
None
])
try:
# json patch
api_response = api_instance.json_patch(
body=body,
)
except petstore_api.ApiException as e:
print("Exception when calling FakeApi->json_patch: %s\n" % e)
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
body | typing.Union[SchemaForRequestBodyApplicationJsonPatchjson, Unset] | optional, default is unset |
content_type | str | optional, default is 'application/json-patch+json' | Selects the schema and serialization of the request body
stream | bool | default is False | if True then the response.content will be streamed and loaded from a file like object. When downloading a file, set this to True to force the code to deserialize the content to a FileSchema file
timeout | typing.Optional[typing.Union[int, typing.Tuple]] | default is None | the timeout used by the rest client
skip_deserialization | bool | default is False | when True, headers and body will be unset and an instance of api_client.ApiResponseWithoutDeserialization will be returned
### body
#### SchemaForRequestBodyApplicationJsonPatchjson
Type | Description | Notes
------------- | ------------- | -------------
[**JSONPatchRequest**](JSONPatchRequest.md) | |
### Return Types, Responses
Code | Class | Description
------------- | ------------- | -------------
n/a | api_client.ApiResponseWithoutDeserialization | When skip_deserialization is True this response is returned
200 | ApiResponseFor200 | OK
#### ApiResponseFor200
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
response | urllib3.HTTPResponse | Raw response |
body | Unset | body was not defined |
headers | Unset | headers were not defined |
void (empty response body)
### Authorization

View File

@@ -0,0 +1,8 @@
# petstore_api.model.json_patch_request.JSONPatchRequest
Type | Description | Notes
------------- | ------------- | -------------
**[bool, date, datetime, dict, float, int, list, str, none_type]** | |
[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md)

View File

@@ -0,0 +1,11 @@
# petstore_api.model.json_patch_request_add_replace_test.JSONPatchRequestAddReplaceTest
#### Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**op** | **str** | The operation to perform. |
**path** | **str** | A JSON Pointer path. |
**value** | **bool, date, datetime, dict, float, int, list, str, none_type** | The value to add, replace or test. |
[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md)

View File

@@ -0,0 +1,11 @@
# petstore_api.model.json_patch_request_move_copy.JSONPatchRequestMoveCopy
#### Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**op** | **str** | The operation to perform. |
**path** | **str** | A JSON Pointer path. |
**from** |
[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md)

View File

@@ -0,0 +1,10 @@
# petstore_api.model.json_patch_request_remove.JSONPatchRequestRemove
#### Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**op** | **str** | The operation to perform. |
**path** | **str** | A JSON Pointer path. |
[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md)

View File

@@ -801,12 +801,17 @@ class ApiResponseWithoutDeserialization(ApiResponse):
class JSONDetector:
@staticmethod
def content_type_is_json(content_type: str) -> bool:
"""
for when content_type strings also include charset info like:
application/json; charset=UTF-8
"""
content_type_piece = content_type.split(';')[0]
def _content_type_is_json(content_type: str) -> bool:
content_type_piece = content_type
if ';' in content_type:
# application/json; charset=UTF-8
content_type_piece = content_type.split(';')[0]
elif '-' in content_type:
"""
application/json-patch+json
application/json-seq
"""
content_type_piece = content_type.split('-')[0]
if content_type_piece == 'application/json':
return True
return False
@@ -909,7 +914,7 @@ class OpenApiResponse(JSONDetector):
body=unset
)
if self.content_type_is_json(content_type):
if self._content_type_is_json(content_type):
body_data = self.__deserialize_json(response)
elif content_type == 'application/octet-stream':
body_data = self.__deserialize_application_octet_stream(response)
@@ -1462,7 +1467,7 @@ class RequestBody(StyleFormSerializer, JSONDetector):
cast_in_data = media_type.schema(in_data)
# TODO check for and use encoding if it exists
# and content_type is multipart or application/x-www-form-urlencoded
if self.content_type_is_json(content_type):
if self._content_type_is_json(content_type):
return self.__serialize_json(cast_in_data)
elif content_type == 'text/plain':
return self.__serialize_text_plain(cast_in_data)

View File

@@ -46,6 +46,7 @@ from petstore_api.apis.paths.fake_obj_in_query import FakeObjInQuery
from petstore_api.apis.paths.fake_ref_obj_in_query import FakeRefObjInQuery
from petstore_api.apis.paths.fake_json_with_charset import FakeJsonWithCharset
from petstore_api.apis.paths.fake_response_without_schema import FakeResponseWithoutSchema
from petstore_api.apis.paths.fake_json_patch import FakeJsonPatch
from petstore_api.apis.paths.fake_delete_coffee_id import FakeDeleteCoffeeId
PathToApi = typing.TypedDict(
@@ -96,6 +97,7 @@ PathToApi = typing.TypedDict(
PathValues.FAKE_REF_OBJ_IN_QUERY: FakeRefObjInQuery,
PathValues.FAKE_JSON_WITH_CHARSET: FakeJsonWithCharset,
PathValues.FAKE_RESPONSE_WITHOUT_SCHEMA: FakeResponseWithoutSchema,
PathValues.FAKE_JSON_PATCH: FakeJsonPatch,
PathValues.FAKE_DELETE_COFFEE_ID: FakeDeleteCoffeeId,
}
)
@@ -147,6 +149,7 @@ path_to_api = PathToApi(
PathValues.FAKE_REF_OBJ_IN_QUERY: FakeRefObjInQuery,
PathValues.FAKE_JSON_WITH_CHARSET: FakeJsonWithCharset,
PathValues.FAKE_RESPONSE_WITHOUT_SCHEMA: FakeResponseWithoutSchema,
PathValues.FAKE_JSON_PATCH: FakeJsonPatch,
PathValues.FAKE_DELETE_COFFEE_ID: FakeDeleteCoffeeId,
}
)

View File

@@ -0,0 +1,7 @@
from petstore_api.paths.fake_json_patch.patch import ApiForpatch
class FakeJsonPatch(
ApiForpatch,
):
pass

View File

@@ -26,6 +26,7 @@ from petstore_api.paths.fake_3.delete import GroupParameters
from petstore_api.paths.fake_inline_additional_properties.post import InlineAdditionalProperties
from petstore_api.paths.fake_inline_composition_.post import InlineComposition
from petstore_api.paths.fake_json_form_data.get import JsonFormData
from petstore_api.paths.fake_json_patch.patch import JsonPatch
from petstore_api.paths.fake_json_with_charset.post import JsonWithCharset
from petstore_api.paths.fake_refs_mammal.post import Mammal
from petstore_api.paths.fake_refs_number.post import NumberWithValidations
@@ -60,6 +61,7 @@ class FakeApi(
InlineAdditionalProperties,
InlineComposition,
JsonFormData,
JsonPatch,
JsonWithCharset,
Mammal,
NumberWithValidations,

View File

@@ -0,0 +1,92 @@
# coding: utf-8
"""
OpenAPI Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
"""
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 uuid # noqa: F401
import frozendict # noqa: F401
from petstore_api import schemas # noqa: F401
class JSONPatchRequest(
schemas.ListSchema
):
"""NOTE: This class is auto generated by OpenAPI Generator.
Ref: https://openapi-generator.tech
Do not edit the class manually.
"""
class MetaOapg:
class items(
schemas.ComposedSchema,
):
class MetaOapg:
@classmethod
@property
@functools.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 [
JSONPatchRequestAddReplaceTest,
JSONPatchRequestRemove,
JSONPatchRequestMoveCopy,
]
def __new__(
cls,
*args: typing.Union[dict, frozendict.frozendict, str, date, datetime, uuid.UUID, int, float, decimal.Decimal, None, list, tuple, bytes, ],
_configuration: typing.Optional[schemas.Configuration] = None,
**kwargs: typing.Union[schemas.AnyTypeSchema, dict, frozendict.frozendict, str, date, datetime, uuid.UUID, int, float, decimal.Decimal, None, list, tuple, bytes],
) -> 'items':
return super().__new__(
cls,
*args,
_configuration=_configuration,
**kwargs,
)
def __new__(
cls,
arg: typing.Union[typing.Tuple[typing.Union[MetaOapg.items, dict, frozendict.frozendict, str, date, datetime, uuid.UUID, int, float, decimal.Decimal, None, list, tuple, bytes, ]], typing.List[typing.Union[MetaOapg.items, dict, frozendict.frozendict, str, date, datetime, uuid.UUID, int, float, decimal.Decimal, None, list, tuple, bytes, ]]],
_configuration: typing.Optional[schemas.Configuration] = None,
) -> 'JSONPatchRequest':
return super().__new__(
cls,
arg,
_configuration=_configuration,
)
def __getitem__(self, i: int) -> MetaOapg.items:
return super().__getitem__(i)
from petstore_api.model.json_patch_request_add_replace_test import JSONPatchRequestAddReplaceTest
from petstore_api.model.json_patch_request_move_copy import JSONPatchRequestMoveCopy
from petstore_api.model.json_patch_request_remove import JSONPatchRequestRemove

View File

@@ -0,0 +1,92 @@
# coding: utf-8
"""
OpenAPI Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
"""
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 uuid # noqa: F401
import frozendict # noqa: F401
from petstore_api import schemas # noqa: F401
class JSONPatchRequest(
schemas.ListSchema
):
"""NOTE: This class is auto generated by OpenAPI Generator.
Ref: https://openapi-generator.tech
Do not edit the class manually.
"""
class MetaOapg:
class items(
schemas.ComposedSchema,
):
class MetaOapg:
@classmethod
@property
@functools.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 [
JSONPatchRequestAddReplaceTest,
JSONPatchRequestRemove,
JSONPatchRequestMoveCopy,
]
def __new__(
cls,
*args: typing.Union[dict, frozendict.frozendict, str, date, datetime, uuid.UUID, int, float, decimal.Decimal, None, list, tuple, bytes, ],
_configuration: typing.Optional[schemas.Configuration] = None,
**kwargs: typing.Union[schemas.AnyTypeSchema, dict, frozendict.frozendict, str, date, datetime, uuid.UUID, int, float, decimal.Decimal, None, list, tuple, bytes],
) -> 'items':
return super().__new__(
cls,
*args,
_configuration=_configuration,
**kwargs,
)
def __new__(
cls,
arg: typing.Union[typing.Tuple[typing.Union[MetaOapg.items, dict, frozendict.frozendict, str, date, datetime, uuid.UUID, int, float, decimal.Decimal, None, list, tuple, bytes, ]], typing.List[typing.Union[MetaOapg.items, dict, frozendict.frozendict, str, date, datetime, uuid.UUID, int, float, decimal.Decimal, None, list, tuple, bytes, ]]],
_configuration: typing.Optional[schemas.Configuration] = None,
) -> 'JSONPatchRequest':
return super().__new__(
cls,
arg,
_configuration=_configuration,
)
def __getitem__(self, i: int) -> MetaOapg.items:
return super().__getitem__(i)
from petstore_api.model.json_patch_request_add_replace_test import JSONPatchRequestAddReplaceTest
from petstore_api.model.json_patch_request_move_copy import JSONPatchRequestMoveCopy
from petstore_api.model.json_patch_request_remove import JSONPatchRequestRemove

View File

@@ -0,0 +1,122 @@
# coding: utf-8
"""
OpenAPI Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
"""
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 uuid # noqa: F401
import frozendict # noqa: F401
from petstore_api import schemas # noqa: F401
class JSONPatchRequestAddReplaceTest(
schemas.DictSchema
):
"""NOTE: This class is auto generated by OpenAPI Generator.
Ref: https://openapi-generator.tech
Do not edit the class manually.
"""
class MetaOapg:
required = {
"op",
"path",
"value",
}
class properties:
path = schemas.StrSchema
value = schemas.AnyTypeSchema
class op(
schemas.SchemaEnumMakerClsFactory(
enum_value_to_name={
"add": "ADD",
"replace": "REPLACE",
"test": "TEST",
}
),
schemas.StrSchema
):
@classmethod
@property
def ADD(cls):
return cls("add")
@classmethod
@property
def REPLACE(cls):
return cls("replace")
@classmethod
@property
def TEST(cls):
return cls("test")
__annotations__ = {
"path": path,
"value": value,
"op": op,
}
additional_properties = schemas.NotAnyTypeSchema
op: MetaOapg.properties.op
path: MetaOapg.properties.path
value: MetaOapg.properties.value
@typing.overload
def __getitem__(self, name: typing.Literal["op"]) -> MetaOapg.properties.op: ...
@typing.overload
def __getitem__(self, name: typing.Literal["path"]) -> MetaOapg.properties.path: ...
@typing.overload
def __getitem__(self, name: typing.Literal["value"]) -> MetaOapg.properties.value: ...
def __getitem__(self, name: typing.Union[typing.Literal["op"], typing.Literal["path"], typing.Literal["value"], ]):
# dict_instance[name] accessor
return super().__getitem__(name)
@typing.overload
def get_item_oapg(self, name: typing.Literal["op"]) -> MetaOapg.properties.op: ...
@typing.overload
def get_item_oapg(self, name: typing.Literal["path"]) -> MetaOapg.properties.path: ...
@typing.overload
def get_item_oapg(self, name: typing.Literal["value"]) -> MetaOapg.properties.value: ...
def get_item_oapg(self, name: typing.Union[typing.Literal["op"], typing.Literal["path"], typing.Literal["value"], ]):
return super().get_item_oapg(name)
def __new__(
cls,
*args: typing.Union[dict, frozendict.frozendict, ],
op: typing.Union[MetaOapg.properties.op, str, ],
path: typing.Union[MetaOapg.properties.path, str, ],
value: typing.Union[MetaOapg.properties.value, dict, frozendict.frozendict, str, date, datetime, uuid.UUID, int, float, decimal.Decimal, None, list, tuple, bytes, ],
_configuration: typing.Optional[schemas.Configuration] = None,
) -> 'JSONPatchRequestAddReplaceTest':
return super().__new__(
cls,
*args,
op=op,
path=path,
value=value,
_configuration=_configuration,
)

View File

@@ -0,0 +1,122 @@
# coding: utf-8
"""
OpenAPI Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
"""
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 uuid # noqa: F401
import frozendict # noqa: F401
from petstore_api import schemas # noqa: F401
class JSONPatchRequestAddReplaceTest(
schemas.DictSchema
):
"""NOTE: This class is auto generated by OpenAPI Generator.
Ref: https://openapi-generator.tech
Do not edit the class manually.
"""
class MetaOapg:
required = {
"op",
"path",
"value",
}
class properties:
path = schemas.StrSchema
value = schemas.AnyTypeSchema
class op(
schemas.SchemaEnumMakerClsFactory(
enum_value_to_name={
"add": "ADD",
"replace": "REPLACE",
"test": "TEST",
}
),
schemas.StrSchema
):
@classmethod
@property
def ADD(cls):
return cls("add")
@classmethod
@property
def REPLACE(cls):
return cls("replace")
@classmethod
@property
def TEST(cls):
return cls("test")
__annotations__ = {
"path": path,
"value": value,
"op": op,
}
additional_properties = schemas.NotAnyTypeSchema
op: MetaOapg.properties.op
path: MetaOapg.properties.path
value: MetaOapg.properties.value
@typing.overload
def __getitem__(self, name: typing.Literal["op"]) -> MetaOapg.properties.op: ...
@typing.overload
def __getitem__(self, name: typing.Literal["path"]) -> MetaOapg.properties.path: ...
@typing.overload
def __getitem__(self, name: typing.Literal["value"]) -> MetaOapg.properties.value: ...
def __getitem__(self, name: typing.Union[typing.Literal["op"], typing.Literal["path"], typing.Literal["value"], ]):
# dict_instance[name] accessor
return super().__getitem__(name)
@typing.overload
def get_item_oapg(self, name: typing.Literal["op"]) -> MetaOapg.properties.op: ...
@typing.overload
def get_item_oapg(self, name: typing.Literal["path"]) -> MetaOapg.properties.path: ...
@typing.overload
def get_item_oapg(self, name: typing.Literal["value"]) -> MetaOapg.properties.value: ...
def get_item_oapg(self, name: typing.Union[typing.Literal["op"], typing.Literal["path"], typing.Literal["value"], ]):
return super().get_item_oapg(name)
def __new__(
cls,
*args: typing.Union[dict, frozendict.frozendict, ],
op: typing.Union[MetaOapg.properties.op, str, ],
path: typing.Union[MetaOapg.properties.path, str, ],
value: typing.Union[MetaOapg.properties.value, dict, frozendict.frozendict, str, date, datetime, uuid.UUID, int, float, decimal.Decimal, None, list, tuple, bytes, ],
_configuration: typing.Optional[schemas.Configuration] = None,
) -> 'JSONPatchRequestAddReplaceTest':
return super().__new__(
cls,
*args,
op=op,
path=path,
value=value,
_configuration=_configuration,
)

View File

@@ -0,0 +1,105 @@
# coding: utf-8
"""
OpenAPI Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
"""
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 uuid # noqa: F401
import frozendict # noqa: F401
from petstore_api import schemas # noqa: F401
class JSONPatchRequestMoveCopy(
schemas.DictSchema
):
"""NOTE: This class is auto generated by OpenAPI Generator.
Ref: https://openapi-generator.tech
Do not edit the class manually.
"""
class MetaOapg:
required = {
"op",
"path",
"from",
}
class properties:
path = schemas.StrSchema
class op(
schemas.SchemaEnumMakerClsFactory(
enum_value_to_name={
"move": "MOVE",
"copy": "COPY",
}
),
schemas.StrSchema
):
@classmethod
@property
def MOVE(cls):
return cls("move")
@classmethod
@property
def COPY(cls):
return cls("copy")
__annotations__ = {
"path": path,
"op": op,
}
additional_properties = schemas.NotAnyTypeSchema
op: MetaOapg.properties.op
path: MetaOapg.properties.path
@typing.overload
def __getitem__(self, name: typing.Literal["op"]) -> MetaOapg.properties.op: ...
@typing.overload
def __getitem__(self, name: typing.Literal["path"]) -> MetaOapg.properties.path: ...
def __getitem__(self, name: typing.Union[typing.Literal["op"], typing.Literal["path"], ]):
# dict_instance[name] accessor
return super().__getitem__(name)
@typing.overload
def get_item_oapg(self, name: typing.Literal["op"]) -> MetaOapg.properties.op: ...
@typing.overload
def get_item_oapg(self, name: typing.Literal["path"]) -> MetaOapg.properties.path: ...
def get_item_oapg(self, name: typing.Union[typing.Literal["op"], typing.Literal["path"], ]):
return super().get_item_oapg(name)
def __new__(
cls,
*args: typing.Union[dict, frozendict.frozendict, ],
op: typing.Union[MetaOapg.properties.op, str, ],
path: typing.Union[MetaOapg.properties.path, str, ],
_configuration: typing.Optional[schemas.Configuration] = None,
) -> 'JSONPatchRequestMoveCopy':
return super().__new__(
cls,
*args,
op=op,
path=path,
_configuration=_configuration,
)

View File

@@ -0,0 +1,105 @@
# coding: utf-8
"""
OpenAPI Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
"""
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 uuid # noqa: F401
import frozendict # noqa: F401
from petstore_api import schemas # noqa: F401
class JSONPatchRequestMoveCopy(
schemas.DictSchema
):
"""NOTE: This class is auto generated by OpenAPI Generator.
Ref: https://openapi-generator.tech
Do not edit the class manually.
"""
class MetaOapg:
required = {
"op",
"path",
"from",
}
class properties:
path = schemas.StrSchema
class op(
schemas.SchemaEnumMakerClsFactory(
enum_value_to_name={
"move": "MOVE",
"copy": "COPY",
}
),
schemas.StrSchema
):
@classmethod
@property
def MOVE(cls):
return cls("move")
@classmethod
@property
def COPY(cls):
return cls("copy")
__annotations__ = {
"path": path,
"op": op,
}
additional_properties = schemas.NotAnyTypeSchema
op: MetaOapg.properties.op
path: MetaOapg.properties.path
@typing.overload
def __getitem__(self, name: typing.Literal["op"]) -> MetaOapg.properties.op: ...
@typing.overload
def __getitem__(self, name: typing.Literal["path"]) -> MetaOapg.properties.path: ...
def __getitem__(self, name: typing.Union[typing.Literal["op"], typing.Literal["path"], ]):
# dict_instance[name] accessor
return super().__getitem__(name)
@typing.overload
def get_item_oapg(self, name: typing.Literal["op"]) -> MetaOapg.properties.op: ...
@typing.overload
def get_item_oapg(self, name: typing.Literal["path"]) -> MetaOapg.properties.path: ...
def get_item_oapg(self, name: typing.Union[typing.Literal["op"], typing.Literal["path"], ]):
return super().get_item_oapg(name)
def __new__(
cls,
*args: typing.Union[dict, frozendict.frozendict, ],
op: typing.Union[MetaOapg.properties.op, str, ],
path: typing.Union[MetaOapg.properties.path, str, ],
_configuration: typing.Optional[schemas.Configuration] = None,
) -> 'JSONPatchRequestMoveCopy':
return super().__new__(
cls,
*args,
op=op,
path=path,
_configuration=_configuration,
)

View File

@@ -0,0 +1,98 @@
# coding: utf-8
"""
OpenAPI Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
"""
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 uuid # noqa: F401
import frozendict # noqa: F401
from petstore_api import schemas # noqa: F401
class JSONPatchRequestRemove(
schemas.DictSchema
):
"""NOTE: This class is auto generated by OpenAPI Generator.
Ref: https://openapi-generator.tech
Do not edit the class manually.
"""
class MetaOapg:
required = {
"op",
"path",
}
class properties:
path = schemas.StrSchema
class op(
schemas.SchemaEnumMakerClsFactory(
enum_value_to_name={
"remove": "REMOVE",
}
),
schemas.StrSchema
):
@classmethod
@property
def REMOVE(cls):
return cls("remove")
__annotations__ = {
"path": path,
"op": op,
}
additional_properties = schemas.NotAnyTypeSchema
op: MetaOapg.properties.op
path: MetaOapg.properties.path
@typing.overload
def __getitem__(self, name: typing.Literal["op"]) -> MetaOapg.properties.op: ...
@typing.overload
def __getitem__(self, name: typing.Literal["path"]) -> MetaOapg.properties.path: ...
def __getitem__(self, name: typing.Union[typing.Literal["op"], typing.Literal["path"], ]):
# dict_instance[name] accessor
return super().__getitem__(name)
@typing.overload
def get_item_oapg(self, name: typing.Literal["op"]) -> MetaOapg.properties.op: ...
@typing.overload
def get_item_oapg(self, name: typing.Literal["path"]) -> MetaOapg.properties.path: ...
def get_item_oapg(self, name: typing.Union[typing.Literal["op"], typing.Literal["path"], ]):
return super().get_item_oapg(name)
def __new__(
cls,
*args: typing.Union[dict, frozendict.frozendict, ],
op: typing.Union[MetaOapg.properties.op, str, ],
path: typing.Union[MetaOapg.properties.path, str, ],
_configuration: typing.Optional[schemas.Configuration] = None,
) -> 'JSONPatchRequestRemove':
return super().__new__(
cls,
*args,
op=op,
path=path,
_configuration=_configuration,
)

View File

@@ -0,0 +1,98 @@
# coding: utf-8
"""
OpenAPI Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
"""
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 uuid # noqa: F401
import frozendict # noqa: F401
from petstore_api import schemas # noqa: F401
class JSONPatchRequestRemove(
schemas.DictSchema
):
"""NOTE: This class is auto generated by OpenAPI Generator.
Ref: https://openapi-generator.tech
Do not edit the class manually.
"""
class MetaOapg:
required = {
"op",
"path",
}
class properties:
path = schemas.StrSchema
class op(
schemas.SchemaEnumMakerClsFactory(
enum_value_to_name={
"remove": "REMOVE",
}
),
schemas.StrSchema
):
@classmethod
@property
def REMOVE(cls):
return cls("remove")
__annotations__ = {
"path": path,
"op": op,
}
additional_properties = schemas.NotAnyTypeSchema
op: MetaOapg.properties.op
path: MetaOapg.properties.path
@typing.overload
def __getitem__(self, name: typing.Literal["op"]) -> MetaOapg.properties.op: ...
@typing.overload
def __getitem__(self, name: typing.Literal["path"]) -> MetaOapg.properties.path: ...
def __getitem__(self, name: typing.Union[typing.Literal["op"], typing.Literal["path"], ]):
# dict_instance[name] accessor
return super().__getitem__(name)
@typing.overload
def get_item_oapg(self, name: typing.Literal["op"]) -> MetaOapg.properties.op: ...
@typing.overload
def get_item_oapg(self, name: typing.Literal["path"]) -> MetaOapg.properties.path: ...
def get_item_oapg(self, name: typing.Union[typing.Literal["op"], typing.Literal["path"], ]):
return super().get_item_oapg(name)
def __new__(
cls,
*args: typing.Union[dict, frozendict.frozendict, ],
op: typing.Union[MetaOapg.properties.op, str, ],
path: typing.Union[MetaOapg.properties.path, str, ],
_configuration: typing.Optional[schemas.Configuration] = None,
) -> 'JSONPatchRequestRemove':
return super().__new__(
cls,
*args,
op=op,
path=path,
_configuration=_configuration,
)

View File

@@ -76,6 +76,10 @@ from petstore_api.model.integer_enum_with_default_value import IntegerEnumWithDe
from petstore_api.model.integer_max10 import IntegerMax10
from petstore_api.model.integer_min15 import IntegerMin15
from petstore_api.model.isosceles_triangle import IsoscelesTriangle
from petstore_api.model.json_patch_request import JSONPatchRequest
from petstore_api.model.json_patch_request_add_replace_test import JSONPatchRequestAddReplaceTest
from petstore_api.model.json_patch_request_move_copy import JSONPatchRequestMoveCopy
from petstore_api.model.json_patch_request_remove import JSONPatchRequestRemove
from petstore_api.model.mammal import Mammal
from petstore_api.model.map_test import MapTest
from petstore_api.model.mixed_properties_and_additional_properties_class import MixedPropertiesAndAdditionalPropertiesClass

View File

@@ -51,4 +51,5 @@ class PathValues(str, enum.Enum):
FAKE_REF_OBJ_IN_QUERY = "/fake/refObjInQuery"
FAKE_JSON_WITH_CHARSET = "/fake/jsonWithCharset"
FAKE_RESPONSE_WITHOUT_SCHEMA = "/fake/responseWithoutSchema"
FAKE_JSON_PATCH = "/fake/jsonPatch"
FAKE_DELETE_COFFEE_ID = "/fake/deleteCoffee/{id}"

View File

@@ -0,0 +1,7 @@
# 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 petstore_api.paths.fake_json_patch import Api
from petstore_api.paths import PathValues
path = PathValues.FAKE_JSON_PATCH

View File

@@ -0,0 +1,160 @@
# coding: utf-8
"""
Generated by: https://openapi-generator.tech
"""
from dataclasses import dataclass
import urllib3
from urllib3._collections import HTTPHeaderDict
from petstore_api import api_client, exceptions
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 uuid # noqa: F401
import frozendict # noqa: F401
from petstore_api import schemas # noqa: F401
from petstore_api.model.json_patch_request import JSONPatchRequest
from . import path
# body param
SchemaForRequestBodyApplicationJsonPatchjson = JSONPatchRequest
request_body_json_patch_request = api_client.RequestBody(
content={
'application/json-patch+json': api_client.MediaType(
schema=SchemaForRequestBodyApplicationJsonPatchjson),
},
)
@dataclass
class ApiResponseFor200(api_client.ApiResponse):
response: urllib3.HTTPResponse
body: schemas.Unset = schemas.unset
headers: schemas.Unset = schemas.unset
_response_for_200 = api_client.OpenApiResponse(
response_cls=ApiResponseFor200,
)
_status_code_to_response = {
'200': _response_for_200,
}
class BaseApi(api_client.Api):
def _json_patch_oapg(
self: api_client.Api,
body: typing.Union[SchemaForRequestBodyApplicationJsonPatchjson, schemas.Unset] = schemas.unset,
content_type: str = 'application/json-patch+json',
stream: bool = False,
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
skip_deserialization: bool = False,
) -> typing.Union[
ApiResponseFor200,
api_client.ApiResponseWithoutDeserialization
]:
"""
json patch
: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
"""
used_path = path.value
_headers = HTTPHeaderDict()
# TODO add cookie handling
_fields = None
_body = None
if body is not schemas.unset:
serialized_data = request_body_json_patch_request.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']
response = self.api_client.call_api(
resource_path=used_path,
method='patch'.upper(),
headers=_headers,
fields=_fields,
body=_body,
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:
api_response = api_client.ApiResponseWithoutDeserialization(response=response)
if not 200 <= response.status <= 299:
raise exceptions.ApiException(api_response=api_response)
return api_response
class JsonPatch(BaseApi):
# this class is used by api classes that refer to endpoints with operationId fn names
def json_patch(
self: BaseApi,
body: typing.Union[SchemaForRequestBodyApplicationJsonPatchjson, schemas.Unset] = schemas.unset,
content_type: str = 'application/json-patch+json',
stream: bool = False,
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
skip_deserialization: bool = False,
) -> typing.Union[
ApiResponseFor200,
api_client.ApiResponseWithoutDeserialization
]:
return self._json_patch_oapg(
body=body,
content_type=content_type,
stream=stream,
timeout=timeout,
skip_deserialization=skip_deserialization
)
class ApiForpatch(BaseApi):
# this class is used by api classes that refer to endpoints by path and http method names
def patch(
self: BaseApi,
body: typing.Union[SchemaForRequestBodyApplicationJsonPatchjson, schemas.Unset] = schemas.unset,
content_type: str = 'application/json-patch+json',
stream: bool = False,
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
skip_deserialization: bool = False,
) -> typing.Union[
ApiResponseFor200,
api_client.ApiResponseWithoutDeserialization
]:
return self._json_patch_oapg(
body=body,
content_type=content_type,
stream=stream,
timeout=timeout,
skip_deserialization=skip_deserialization
)

View File

@@ -0,0 +1,135 @@
# coding: utf-8
"""
Generated by: https://openapi-generator.tech
"""
from dataclasses import dataclass
import urllib3
from urllib3._collections import HTTPHeaderDict
from petstore_api import api_client, exceptions
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 uuid # noqa: F401
import frozendict # noqa: F401
from petstore_api import schemas # noqa: F401
from petstore_api.model.json_patch_request import JSONPatchRequest
# body param
SchemaForRequestBodyApplicationJsonPatchjson = JSONPatchRequest
class BaseApi(api_client.Api):
def _json_patch_oapg(
self: api_client.Api,
body: typing.Union[SchemaForRequestBodyApplicationJsonPatchjson, schemas.Unset] = schemas.unset,
content_type: str = 'application/json-patch+json',
stream: bool = False,
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
skip_deserialization: bool = False,
) -> typing.Union[
ApiResponseFor200,
api_client.ApiResponseWithoutDeserialization
]:
"""
json patch
: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
"""
used_path = path.value
_headers = HTTPHeaderDict()
# TODO add cookie handling
_fields = None
_body = None
if body is not schemas.unset:
serialized_data = request_body_json_patch_request.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']
response = self.api_client.call_api(
resource_path=used_path,
method='patch'.upper(),
headers=_headers,
fields=_fields,
body=_body,
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:
api_response = api_client.ApiResponseWithoutDeserialization(response=response)
if not 200 <= response.status <= 299:
raise exceptions.ApiException(api_response=api_response)
return api_response
class JsonPatch(BaseApi):
# this class is used by api classes that refer to endpoints with operationId fn names
def json_patch(
self: BaseApi,
body: typing.Union[SchemaForRequestBodyApplicationJsonPatchjson, schemas.Unset] = schemas.unset,
content_type: str = 'application/json-patch+json',
stream: bool = False,
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
skip_deserialization: bool = False,
) -> typing.Union[
ApiResponseFor200,
api_client.ApiResponseWithoutDeserialization
]:
return self._json_patch_oapg(
body=body,
content_type=content_type,
stream=stream,
timeout=timeout,
skip_deserialization=skip_deserialization
)
class ApiForpatch(BaseApi):
# this class is used by api classes that refer to endpoints by path and http method names
def patch(
self: BaseApi,
body: typing.Union[SchemaForRequestBodyApplicationJsonPatchjson, schemas.Unset] = schemas.unset,
content_type: str = 'application/json-patch+json',
stream: bool = False,
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
skip_deserialization: bool = False,
) -> typing.Union[
ApiResponseFor200,
api_client.ApiResponseWithoutDeserialization
]:
return self._json_patch_oapg(
body=body,
content_type=content_type,
stream=stream,
timeout=timeout,
skip_deserialization=skip_deserialization
)

View File

@@ -0,0 +1,25 @@
# coding: utf-8
"""
OpenAPI Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
"""
import unittest
import petstore_api
from petstore_api.model.json_patch_request import JSONPatchRequest
from petstore_api import configuration
class TestJSONPatchRequest(unittest.TestCase):
"""JSONPatchRequest unit test stubs"""
_configuration = configuration.Configuration()
if __name__ == '__main__':
unittest.main()

View File

@@ -0,0 +1,25 @@
# coding: utf-8
"""
OpenAPI Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
"""
import unittest
import petstore_api
from petstore_api.model.json_patch_request_add_replace_test import JSONPatchRequestAddReplaceTest
from petstore_api import configuration
class TestJSONPatchRequestAddReplaceTest(unittest.TestCase):
"""JSONPatchRequestAddReplaceTest unit test stubs"""
_configuration = configuration.Configuration()
if __name__ == '__main__':
unittest.main()

View File

@@ -0,0 +1,25 @@
# coding: utf-8
"""
OpenAPI Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
"""
import unittest
import petstore_api
from petstore_api.model.json_patch_request_move_copy import JSONPatchRequestMoveCopy
from petstore_api import configuration
class TestJSONPatchRequestMoveCopy(unittest.TestCase):
"""JSONPatchRequestMoveCopy unit test stubs"""
_configuration = configuration.Configuration()
if __name__ == '__main__':
unittest.main()

View File

@@ -0,0 +1,25 @@
# coding: utf-8
"""
OpenAPI Petstore
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ # noqa: E501
The version of the OpenAPI document: 1.0.0
Generated by: https://openapi-generator.tech
"""
import unittest
import petstore_api
from petstore_api.model.json_patch_request_remove import JSONPatchRequestRemove
from petstore_api import configuration
class TestJSONPatchRequestRemove(unittest.TestCase):
"""JSONPatchRequestRemove unit test stubs"""
_configuration = configuration.Configuration()
if __name__ == '__main__':
unittest.main()

View File

@@ -0,0 +1,40 @@
# coding: utf-8
"""
Generated by: https://openapi-generator.tech
"""
import unittest
from unittest.mock import patch
import urllib3
import petstore_api
from petstore_api.paths.fake_json_patch import patch # noqa: E501
from petstore_api import configuration, schemas, api_client
from .. import ApiTestMixin
class TestFakeJsonPatch(ApiTestMixin, unittest.TestCase):
"""
FakeJsonPatch unit test stubs
json patch # noqa: E501
"""
_configuration = configuration.Configuration()
def setUp(self):
used_api_client = api_client.ApiClient(configuration=self._configuration)
self.api = patch.ApiForpatch(api_client=used_api_client) # noqa: E501
def tearDown(self):
pass
response_status = 200
response_body = ''
if __name__ == '__main__':
unittest.main()

View File

@@ -727,6 +727,43 @@ class TestFakeApi(ApiTestMixin):
assert isinstance(api_response.body, schemas.Unset)
assert isinstance(api_response.headers, schemas.Unset)
def test_json_patch(self):
with patch.object(urllib3.PoolManager, 'request') as mock_request:
from petstore_api.model import json_patch_request
from petstore_api.model import json_patch_request_add_replace_test
mock_request.return_value = self.response("")
body = json_patch_request.JSONPatchRequest(
[
json_patch_request_add_replace_test.JSONPatchRequestAddReplaceTest(
op='add',
path='/a/b/c',
value='foo',
)
]
)
api_response = self.api.json_patch(body)
json_body = [
{
'op': 'add',
'path': '/a/b/c',
'value': 'foo'
}
]
self.assert_pool_manager_request_called_with(
mock_request,
'http://petstore.swagger.io:80/v2/fake/jsonPatch',
body=self.json_bytes(json_body),
method='PATCH',
content_type='application/json-patch+json',
accept_content_type=None,
)
assert isinstance(api_response.response, urllib3.HTTPResponse)
assert isinstance(api_response.body, schemas.Unset)
assert isinstance(api_response.headers, schemas.Unset)
assert api_response.response.status == 200
if __name__ == '__main__':
unittest.main()