def test_path_params_no_style(self): name = 'color' test_cases = ( ParamTestCase( None, dict(color='') ), ParamTestCase( 1, dict(color='1') ), ParamTestCase( 3.14, dict(color='3.14') ), ParamTestCase( 'blue', dict(color='blue') ), ParamTestCase( 'hello world', dict(color='hello%20world') ), ParamTestCase( '', dict(color='') ), ParamTestCase( True, dict(color='true') ), ParamTestCase( False, dict(color='false') ), ParamTestCase( [], dict(color='') ), ParamTestCase( ['blue', 'black', 'brown'], dict(color='blue,black,brown') ), ParamTestCase( {}, dict(color='') ), ParamTestCase( dict(R=100, G=200, B=150), dict(color='R,100,G,200,B,150') ), ) for test_case in test_cases: parameter = api_client.PathParameter( name=name, schema=schemas.AnyTypeSchema, ) serialization = parameter.serialize(test_case.payload) self.assertEqual(serialization, test_case.expected_serialization)
# path params PetIdSchema = Int64Schema RequestRequiredPathParams = typing.TypedDict('RequestRequiredPathParams', { 'petId': PetIdSchema, }) RequestOptionalPathParams = typing.TypedDict('RequestOptionalPathParams', {}, total=False) class RequestPathParams(RequestRequiredPathParams, RequestOptionalPathParams): pass request_path_pet_id = api_client.PathParameter( name="petId", style=api_client.ParameterStyle.SIMPLE, schema=PetIdSchema, required=True, ) # body param class SchemaForRequestBodyMultipartFormData(DictSchema): additionalMetadata = StrSchema file = BinarySchema def __new__( cls, *args: typing.Union[dict, frozendict, ], additionalMetadata: typing.Union[additionalMetadata, Unset] = unset, _configuration: typing.Optional[Configuration] = None, **kwargs: typing.Type[Schema],
) RequestOptionalPathParams = typing.TypedDict( 'RequestOptionalPathParams', { }, total=False ) class RequestPathParams(RequestRequiredPathParams, RequestOptionalPathParams): pass request_path_username = api_client.PathParameter( name="username", style=api_client.ParameterStyle.SIMPLE, schema=UsernameSchema, required=True, ) # body param SchemaForRequestBodyApplicationJson = User request_body_user = api_client.RequestBody( content={ 'application/json': api_client.MediaType( schema=SchemaForRequestBodyApplicationJson), }, required=True, ) _path = '/user/{username}' _method = 'PUT'
) RequestOptionalPathParams = typing.TypedDict( 'RequestOptionalPathParams', { }, total=False ) class RequestPathParams(RequestRequiredPathParams, RequestOptionalPathParams): pass request_path_order_id = api_client.PathParameter( name="order_id", style=api_client.ParameterStyle.SIMPLE, schema=OrderIdSchema, required=True, ) _path = '/store/order/{order_id}' _method = 'GET' SchemaFor200ResponseBodyApplicationXml = Order SchemaFor200ResponseBodyApplicationJson = Order @dataclass class ApiResponseFor200(api_client.ApiResponse): response: urllib3.HTTPResponse body: typing.Union[ SchemaFor200ResponseBodyApplicationXml, SchemaFor200ResponseBodyApplicationJson, ]
'aB': ABSchema, 'Ab': AbSchema, 'self': ModelSelfSchema, 'A-B': ABSchema, }) RequestOptionalPathParams = typing.TypedDict('RequestOptionalPathParams', {}, total=False) class RequestPathParams(RequestRequiredPathParams, RequestOptionalPathParams): pass request_path__3 = api_client.PathParameter( name="1", style=api_client.ParameterStyle.SIMPLE, schema=Model1Schema, required=True, ) request_path_a_b5 = api_client.PathParameter( name="aB", style=api_client.ParameterStyle.SIMPLE, schema=ABSchema, required=True, ) request_path_ab2 = api_client.PathParameter( name="Ab", style=api_client.ParameterStyle.SIMPLE, schema=AbSchema, required=True, ) request_path__self3 = api_client.PathParameter(
def test_style_matrix_in_path_serialization(self): name = 'color' test_cases = ( ParamTestCase( None, dict(color='') ), ParamTestCase( 1, dict(color=';color=1') ), ParamTestCase( 3.14, dict(color=';color=3.14') ), ParamTestCase( 'blue', dict(color=';color=blue') ), ParamTestCase( 'hello world', dict(color=';color=hello%20world') ), ParamTestCase( '', dict(color=';color') ), ParamTestCase( True, dict(color=';color=true') ), ParamTestCase( False, dict(color=';color=false') ), ParamTestCase( [], dict(color='') ), ParamTestCase( ['blue', 'black', 'brown'], dict(color=';color=blue,black,brown') ), ParamTestCase( ['blue', 'black', 'brown'], dict(color=';color=blue;color=black;color=brown'), explode=True ), ParamTestCase( {}, dict(color='') ), ParamTestCase( dict(R=100, G=200, B=150), dict(color=';color=R,100,G,200,B,150') ), ParamTestCase( dict(R=100, G=200, B=150), dict(color=';R=100;G=200;B=150'), explode=True ), ) for test_case in test_cases: parameter = api_client.PathParameter( name=name, style=api_client.ParameterStyle.MATRIX, schema=schemas.AnyTypeSchema, explode=test_case.explode, ) serialization = parameter.serialize(test_case.payload) self.assertEqual(serialization, test_case.expected_serialization)
def test_style_label_in_path_serialization(self): name = 'color' test_cases = ( ParamTestCase( None, dict(color='') ), ParamTestCase( 1, dict(color='.1') ), ParamTestCase( 3.14, dict(color='.3.14') ), ParamTestCase( 'blue', dict(color='.blue') ), ParamTestCase( 'hello world', dict(color='.hello%20world') ), ParamTestCase( '', dict(color='.') ), ParamTestCase( True, dict(color='.true') ), ParamTestCase( False, dict(color='.false') ), ParamTestCase( [], dict(color='') ), ParamTestCase( ['blue', 'black', 'brown'], dict(color='.blue.black.brown') ), ParamTestCase( ['blue', 'black', 'brown'], dict(color='.blue.black.brown'), explode=True ), ParamTestCase( {}, dict(color='') ), ParamTestCase( dict(R=100, G=200, B=150), dict(color='.R.100.G.200.B.150') ), ParamTestCase( dict(R=100, G=200, B=150), dict(color='.R=100.G=200.B=150'), explode=True ), ) for test_case in test_cases: parameter = api_client.PathParameter( name=name, style=api_client.ParameterStyle.LABEL, schema=schemas.AnyTypeSchema, explode=test_case.explode, ) serialization = parameter.serialize(test_case.payload) self.assertEqual(serialization, test_case.expected_serialization)