[python-nextgen] better datetime support in parameters (#14621)

* add allowStringInDateTimeParameters option

* add tests

* add files

* add tests for datetime query parameters

* fix file anme

* trigger build

* fix pytest

* install test requirement

* trigger build

* break build

* add new files

* fix Locale.ROOT

* update doc
This commit is contained in:
William Cheng
2023-02-12 21:11:29 +08:00
committed by GitHub
parent 72c02e4bc1
commit 110460b71a
97 changed files with 8482 additions and 1 deletions

View File

@@ -0,0 +1,28 @@
# coding: utf-8
# flake8: noqa
"""
Echo Server API
Echo Server API # noqa: E501
The version of the OpenAPI document: 0.1.0
Contact: team@openapitools.org
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
# import models into model package
from openapi_client.models.bird import Bird
from openapi_client.models.category import Category
from openapi_client.models.data_query import DataQuery
from openapi_client.models.data_query_all_of import DataQueryAllOf
from openapi_client.models.default_value import DefaultValue
from openapi_client.models.pet import Pet
from openapi_client.models.query import Query
from openapi_client.models.string_enum_ref import StringEnumRef
from openapi_client.models.tag import Tag
from openapi_client.models.test_query_style_deep_object_explode_true_object_all_of_query_object_parameter import TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter
from openapi_client.models.test_query_style_form_explode_true_array_string_query_object_parameter import TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter

View File

@@ -0,0 +1,73 @@
# coding: utf-8
"""
Echo Server API
Echo Server API # noqa: E501
The version of the OpenAPI document: 0.1.0
Contact: team@openapitools.org
Generated by: https://openapi-generator.tech
"""
from __future__ import annotations
from inspect import getfullargspec
import pprint
import re # noqa: F401
import json
from typing import Optional
from pydantic import BaseModel, StrictStr
class Bird(BaseModel):
"""NOTE: This class is auto generated by OpenAPI Generator.
Ref: https://openapi-generator.tech
Do not edit the class manually.
"""
size: Optional[StrictStr] = None
color: Optional[StrictStr] = None
__properties = ["size", "color"]
class Config:
allow_population_by_field_name = True
validate_assignment = True
def to_str(self) -> str:
"""Returns the string representation of the model using alias"""
return pprint.pformat(self.dict(by_alias=True))
def to_json(self) -> str:
"""Returns the JSON representation of the model using alias"""
return json.dumps(self.to_dict())
@classmethod
def from_json(cls, json_str: str) -> Bird:
"""Create an instance of Bird from a JSON string"""
return cls.from_dict(json.loads(json_str))
def to_dict(self):
"""Returns the dictionary representation of the model using alias"""
_dict = self.dict(by_alias=True,
exclude={
},
exclude_none=True)
return _dict
@classmethod
def from_dict(cls, obj: dict) -> Bird:
"""Create an instance of Bird from a dict"""
if obj is None:
return None
if type(obj) is not dict:
return Bird.parse_obj(obj)
_obj = Bird.parse_obj({
"size": obj.get("size"),
"color": obj.get("color")
})
return _obj

View File

@@ -0,0 +1,73 @@
# coding: utf-8
"""
Echo Server API
Echo Server API # noqa: E501
The version of the OpenAPI document: 0.1.0
Contact: team@openapitools.org
Generated by: https://openapi-generator.tech
"""
from __future__ import annotations
from inspect import getfullargspec
import pprint
import re # noqa: F401
import json
from typing import Optional
from pydantic import BaseModel, StrictInt, StrictStr
class Category(BaseModel):
"""NOTE: This class is auto generated by OpenAPI Generator.
Ref: https://openapi-generator.tech
Do not edit the class manually.
"""
id: Optional[StrictInt] = None
name: Optional[StrictStr] = None
__properties = ["id", "name"]
class Config:
allow_population_by_field_name = True
validate_assignment = True
def to_str(self) -> str:
"""Returns the string representation of the model using alias"""
return pprint.pformat(self.dict(by_alias=True))
def to_json(self) -> str:
"""Returns the JSON representation of the model using alias"""
return json.dumps(self.to_dict())
@classmethod
def from_json(cls, json_str: str) -> Category:
"""Create an instance of Category from a JSON string"""
return cls.from_dict(json.loads(json_str))
def to_dict(self):
"""Returns the dictionary representation of the model using alias"""
_dict = self.dict(by_alias=True,
exclude={
},
exclude_none=True)
return _dict
@classmethod
def from_dict(cls, obj: dict) -> Category:
"""Create an instance of Category from a dict"""
if obj is None:
return None
if type(obj) is not dict:
return Category.parse_obj(obj)
_obj = Category.parse_obj({
"id": obj.get("id"),
"name": obj.get("name")
})
return _obj

View File

@@ -0,0 +1,78 @@
# coding: utf-8
"""
Echo Server API
Echo Server API # noqa: E501
The version of the OpenAPI document: 0.1.0
Contact: team@openapitools.org
Generated by: https://openapi-generator.tech
"""
from __future__ import annotations
from inspect import getfullargspec
import pprint
import re # noqa: F401
import json
from datetime import datetime
from typing import Optional
from pydantic import BaseModel, Field, StrictStr
from openapi_client.models.query import Query
class DataQuery(Query):
"""NOTE: This class is auto generated by OpenAPI Generator.
Ref: https://openapi-generator.tech
Do not edit the class manually.
"""
suffix: Optional[StrictStr] = Field(None, description="test suffix")
text: Optional[StrictStr] = Field(None, description="Some text containing white spaces")
var_date: Optional[datetime] = Field(None, alias="date", description="A date")
__properties = ["suffix", "text", "date", "id", "outcomes"]
class Config:
allow_population_by_field_name = True
validate_assignment = True
def to_str(self) -> str:
"""Returns the string representation of the model using alias"""
return pprint.pformat(self.dict(by_alias=True))
def to_json(self) -> str:
"""Returns the JSON representation of the model using alias"""
return json.dumps(self.to_dict())
@classmethod
def from_json(cls, json_str: str) -> DataQuery:
"""Create an instance of DataQuery from a JSON string"""
return cls.from_dict(json.loads(json_str))
def to_dict(self):
"""Returns the dictionary representation of the model using alias"""
_dict = self.dict(by_alias=True,
exclude={
},
exclude_none=True)
return _dict
@classmethod
def from_dict(cls, obj: dict) -> DataQuery:
"""Create an instance of DataQuery from a dict"""
if obj is None:
return None
if type(obj) is not dict:
return DataQuery.parse_obj(obj)
_obj = DataQuery.parse_obj({
"suffix": obj.get("suffix"),
"text": obj.get("text"),
"var_date": obj.get("date"),
"id": obj.get("id"),
"outcomes": obj.get("outcomes")
})
return _obj

View File

@@ -0,0 +1,75 @@
# coding: utf-8
"""
Echo Server API
Echo Server API # noqa: E501
The version of the OpenAPI document: 0.1.0
Contact: team@openapitools.org
Generated by: https://openapi-generator.tech
"""
from __future__ import annotations
from inspect import getfullargspec
import pprint
import re # noqa: F401
import json
from datetime import datetime
from typing import Optional
from pydantic import BaseModel, Field, StrictStr
class DataQueryAllOf(BaseModel):
"""NOTE: This class is auto generated by OpenAPI Generator.
Ref: https://openapi-generator.tech
Do not edit the class manually.
"""
suffix: Optional[StrictStr] = Field(None, description="test suffix")
text: Optional[StrictStr] = Field(None, description="Some text containing white spaces")
var_date: Optional[datetime] = Field(None, alias="date", description="A date")
__properties = ["suffix", "text", "date"]
class Config:
allow_population_by_field_name = True
validate_assignment = True
def to_str(self) -> str:
"""Returns the string representation of the model using alias"""
return pprint.pformat(self.dict(by_alias=True))
def to_json(self) -> str:
"""Returns the JSON representation of the model using alias"""
return json.dumps(self.to_dict())
@classmethod
def from_json(cls, json_str: str) -> DataQueryAllOf:
"""Create an instance of DataQueryAllOf from a JSON string"""
return cls.from_dict(json.loads(json_str))
def to_dict(self):
"""Returns the dictionary representation of the model using alias"""
_dict = self.dict(by_alias=True,
exclude={
},
exclude_none=True)
return _dict
@classmethod
def from_dict(cls, obj: dict) -> DataQueryAllOf:
"""Create an instance of DataQueryAllOf from a dict"""
if obj is None:
return None
if type(obj) is not dict:
return DataQueryAllOf.parse_obj(obj)
_obj = DataQueryAllOf.parse_obj({
"suffix": obj.get("suffix"),
"text": obj.get("text"),
"var_date": obj.get("date")
})
return _obj

View File

@@ -0,0 +1,101 @@
# coding: utf-8
"""
Echo Server API
Echo Server API # noqa: E501
The version of the OpenAPI document: 0.1.0
Contact: team@openapitools.org
Generated by: https://openapi-generator.tech
"""
from __future__ import annotations
from inspect import getfullargspec
import pprint
import re # noqa: F401
import json
from typing import List, Optional
from pydantic import BaseModel, StrictInt, StrictStr, validator
from openapi_client.models.string_enum_ref import StringEnumRef
class DefaultValue(BaseModel):
"""NOTE: This class is auto generated by OpenAPI Generator.
Ref: https://openapi-generator.tech
Do not edit the class manually.
"""
array_string_enum_ref_default: Optional[List[StringEnumRef]] = None
array_string_enum_default: Optional[List[StrictStr]] = None
array_string_default: Optional[List[StrictStr]] = None
array_integer_default: Optional[List[StrictInt]] = None
array_string: Optional[List[StrictStr]] = None
array_string_nullable: Optional[List[StrictStr]] = None
string_nullable: Optional[StrictStr] = None
__properties = ["array_string_enum_ref_default", "array_string_enum_default", "array_string_default", "array_integer_default", "array_string", "array_string_nullable", "string_nullable"]
@validator('array_string_enum_default')
def array_string_enum_default_validate_enum(cls, v):
if v is None:
return v
if v not in ('success', 'failure', 'unclassified'):
raise ValueError("must validate the enum values ('success', 'failure', 'unclassified')")
return v
class Config:
allow_population_by_field_name = True
validate_assignment = True
def to_str(self) -> str:
"""Returns the string representation of the model using alias"""
return pprint.pformat(self.dict(by_alias=True))
def to_json(self) -> str:
"""Returns the JSON representation of the model using alias"""
return json.dumps(self.to_dict())
@classmethod
def from_json(cls, json_str: str) -> DefaultValue:
"""Create an instance of DefaultValue from a JSON string"""
return cls.from_dict(json.loads(json_str))
def to_dict(self):
"""Returns the dictionary representation of the model using alias"""
_dict = self.dict(by_alias=True,
exclude={
},
exclude_none=True)
# set to None if array_string_nullable (nullable) is None
if self.array_string_nullable is None:
_dict['array_string_nullable'] = None
# set to None if string_nullable (nullable) is None
if self.string_nullable is None:
_dict['string_nullable'] = None
return _dict
@classmethod
def from_dict(cls, obj: dict) -> DefaultValue:
"""Create an instance of DefaultValue from a dict"""
if obj is None:
return None
if type(obj) is not dict:
return DefaultValue.parse_obj(obj)
_obj = DefaultValue.parse_obj({
"array_string_enum_ref_default": obj.get("array_string_enum_ref_default"),
"array_string_enum_default": obj.get("array_string_enum_default"),
"array_string_default": obj.get("array_string_default"),
"array_integer_default": obj.get("array_integer_default"),
"array_string": obj.get("array_string"),
"array_string_nullable": obj.get("array_string_nullable"),
"string_nullable": obj.get("string_nullable")
})
return _obj

View File

@@ -0,0 +1,102 @@
# coding: utf-8
"""
Echo Server API
Echo Server API # noqa: E501
The version of the OpenAPI document: 0.1.0
Contact: team@openapitools.org
Generated by: https://openapi-generator.tech
"""
from __future__ import annotations
from inspect import getfullargspec
import pprint
import re # noqa: F401
import json
from typing import List, Optional
from pydantic import BaseModel, Field, StrictInt, StrictStr, validator
from openapi_client.models.category import Category
from openapi_client.models.tag import Tag
class Pet(BaseModel):
"""NOTE: This class is auto generated by OpenAPI Generator.
Ref: https://openapi-generator.tech
Do not edit the class manually.
"""
id: Optional[StrictInt] = None
name: StrictStr = ...
category: Optional[Category] = None
photo_urls: List[StrictStr] = Field(..., alias="photoUrls")
tags: Optional[List[Tag]] = None
status: Optional[StrictStr] = Field(None, description="pet status in the store")
__properties = ["id", "name", "category", "photoUrls", "tags", "status"]
@validator('status')
def status_validate_enum(cls, v):
if v is None:
return v
if v not in ('available', 'pending', 'sold'):
raise ValueError("must validate the enum values ('available', 'pending', 'sold')")
return v
class Config:
allow_population_by_field_name = True
validate_assignment = True
def to_str(self) -> str:
"""Returns the string representation of the model using alias"""
return pprint.pformat(self.dict(by_alias=True))
def to_json(self) -> str:
"""Returns the JSON representation of the model using alias"""
return json.dumps(self.to_dict())
@classmethod
def from_json(cls, json_str: str) -> Pet:
"""Create an instance of Pet from a JSON string"""
return cls.from_dict(json.loads(json_str))
def to_dict(self):
"""Returns the dictionary representation of the model using alias"""
_dict = self.dict(by_alias=True,
exclude={
},
exclude_none=True)
# override the default output from pydantic by calling `to_dict()` of category
if self.category:
_dict['category'] = self.category.to_dict()
# override the default output from pydantic by calling `to_dict()` of each item in tags (list)
_items = []
if self.tags:
for _item in self.tags:
if _item:
_items.append(_item.to_dict())
_dict['tags'] = _items
return _dict
@classmethod
def from_dict(cls, obj: dict) -> Pet:
"""Create an instance of Pet from a dict"""
if obj is None:
return None
if type(obj) is not dict:
return Pet.parse_obj(obj)
_obj = Pet.parse_obj({
"id": obj.get("id"),
"name": obj.get("name"),
"category": Category.from_dict(obj.get("category")) if obj.get("category") is not None else None,
"photo_urls": obj.get("photoUrls"),
"tags": [Tag.from_dict(_item) for _item in obj.get("tags")] if obj.get("tags") is not None else None,
"status": obj.get("status")
})
return _obj

View File

@@ -0,0 +1,71 @@
# coding: utf-8
"""
Echo Server API
Echo Server API # noqa: E501
The version of the OpenAPI document: 0.1.0
Contact: team@openapitools.org
Generated by: https://openapi-generator.tech
"""
from __future__ import annotations
from inspect import getfullargspec
import pprint
import re # noqa: F401
import json
from typing import List, Optional
from pydantic import BaseModel, Field, StrictInt, StrictStr, validator
class Query(BaseModel):
"""NOTE: This class is auto generated by OpenAPI Generator.
Ref: https://openapi-generator.tech
Do not edit the class manually.
"""
id: Optional[StrictInt] = Field(None, description="Query")
outcomes: Optional[List[StrictStr]] = None
__properties = ["id", "outcomes"]
@validator('outcomes')
def outcomes_validate_enum(cls, v):
if v is None:
return v
if v not in ('SUCCESS', 'FAILURE', 'SKIPPED'):
raise ValueError("must validate the enum values ('SUCCESS', 'FAILURE', 'SKIPPED')")
return v
class Config:
allow_population_by_field_name = True
validate_assignment = True
def to_str(self) -> str:
"""Returns the string representation of the model using alias"""
return pprint.pformat(self.dict(by_alias=True))
def to_json(self) -> str:
"""Returns the JSON representation of the model using alias"""
return json.dumps(self.to_dict())
@classmethod
def from_json(cls, json_str: str) -> Query:
"""Create an instance of Query from a JSON string"""
return cls.from_dict(json.loads(json_str))
def to_dict(self):
"""Returns the dictionary representation of the model using alias"""
_dict = self.dict(by_alias=True,
exclude={
},
exclude_none=True)
return _dict
@classmethod
def from_dict(cls, obj: dict) -> Query:
"""Create an instance of Query from a dict"""

View File

@@ -0,0 +1,37 @@
# coding: utf-8
"""
Echo Server API
Echo Server API # noqa: E501
The version of the OpenAPI document: 0.1.0
Contact: team@openapitools.org
Generated by: https://openapi-generator.tech
"""
from inspect import getfullargspec
import pprint
import re # noqa: F401
from aenum import Enum, no_arg
class StringEnumRef(str, Enum):
"""NOTE: This class is auto generated by OpenAPI Generator.
Ref: https://openapi-generator.tech
Do not edit the class manually.
"""
"""
allowed enum values
"""
SUCCESS = 'success'
FAILURE = 'failure'
UNCLASSIFIED = 'unclassified'

View File

@@ -0,0 +1,73 @@
# coding: utf-8
"""
Echo Server API
Echo Server API # noqa: E501
The version of the OpenAPI document: 0.1.0
Contact: team@openapitools.org
Generated by: https://openapi-generator.tech
"""
from __future__ import annotations
from inspect import getfullargspec
import pprint
import re # noqa: F401
import json
from typing import Optional
from pydantic import BaseModel, StrictInt, StrictStr
class Tag(BaseModel):
"""NOTE: This class is auto generated by OpenAPI Generator.
Ref: https://openapi-generator.tech
Do not edit the class manually.
"""
id: Optional[StrictInt] = None
name: Optional[StrictStr] = None
__properties = ["id", "name"]
class Config:
allow_population_by_field_name = True
validate_assignment = True
def to_str(self) -> str:
"""Returns the string representation of the model using alias"""
return pprint.pformat(self.dict(by_alias=True))
def to_json(self) -> str:
"""Returns the JSON representation of the model using alias"""
return json.dumps(self.to_dict())
@classmethod
def from_json(cls, json_str: str) -> Tag:
"""Create an instance of Tag from a JSON string"""
return cls.from_dict(json.loads(json_str))
def to_dict(self):
"""Returns the dictionary representation of the model using alias"""
_dict = self.dict(by_alias=True,
exclude={
},
exclude_none=True)
return _dict
@classmethod
def from_dict(cls, obj: dict) -> Tag:
"""Create an instance of Tag from a dict"""
if obj is None:
return None
if type(obj) is not dict:
return Tag.parse_obj(obj)
_obj = Tag.parse_obj({
"id": obj.get("id"),
"name": obj.get("name")
})
return _obj

View File

@@ -0,0 +1,77 @@
# coding: utf-8
"""
Echo Server API
Echo Server API # noqa: E501
The version of the OpenAPI document: 0.1.0
Contact: team@openapitools.org
Generated by: https://openapi-generator.tech
"""
from __future__ import annotations
from inspect import getfullargspec
import pprint
import re # noqa: F401
import json
from typing import Optional
from pydantic import BaseModel, StrictInt, StrictStr
class TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter(BaseModel):
"""NOTE: This class is auto generated by OpenAPI Generator.
Ref: https://openapi-generator.tech
Do not edit the class manually.
"""
size: Optional[StrictStr] = None
color: Optional[StrictStr] = None
id: Optional[StrictInt] = None
name: Optional[StrictStr] = None
__properties = ["size", "color", "id", "name"]
class Config:
allow_population_by_field_name = True
validate_assignment = True
def to_str(self) -> str:
"""Returns the string representation of the model using alias"""
return pprint.pformat(self.dict(by_alias=True))
def to_json(self) -> str:
"""Returns the JSON representation of the model using alias"""
return json.dumps(self.to_dict())
@classmethod
def from_json(cls, json_str: str) -> TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter:
"""Create an instance of TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter from a JSON string"""
return cls.from_dict(json.loads(json_str))
def to_dict(self):
"""Returns the dictionary representation of the model using alias"""
_dict = self.dict(by_alias=True,
exclude={
},
exclude_none=True)
return _dict
@classmethod
def from_dict(cls, obj: dict) -> TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter:
"""Create an instance of TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter from a dict"""
if obj is None:
return None
if type(obj) is not dict:
return TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.parse_obj(obj)
_obj = TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.parse_obj({
"size": obj.get("size"),
"color": obj.get("color"),
"id": obj.get("id"),
"name": obj.get("name")
})
return _obj

View File

@@ -0,0 +1,71 @@
# coding: utf-8
"""
Echo Server API
Echo Server API # noqa: E501
The version of the OpenAPI document: 0.1.0
Contact: team@openapitools.org
Generated by: https://openapi-generator.tech
"""
from __future__ import annotations
from inspect import getfullargspec
import pprint
import re # noqa: F401
import json
from typing import List, Optional
from pydantic import BaseModel, StrictStr
class TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter(BaseModel):
"""NOTE: This class is auto generated by OpenAPI Generator.
Ref: https://openapi-generator.tech
Do not edit the class manually.
"""
values: Optional[List[StrictStr]] = None
__properties = ["values"]
class Config:
allow_population_by_field_name = True
validate_assignment = True
def to_str(self) -> str:
"""Returns the string representation of the model using alias"""
return pprint.pformat(self.dict(by_alias=True))
def to_json(self) -> str:
"""Returns the JSON representation of the model using alias"""
return json.dumps(self.to_dict())
@classmethod
def from_json(cls, json_str: str) -> TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter:
"""Create an instance of TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter from a JSON string"""
return cls.from_dict(json.loads(json_str))
def to_dict(self):
"""Returns the dictionary representation of the model using alias"""
_dict = self.dict(by_alias=True,
exclude={
},
exclude_none=True)
return _dict
@classmethod
def from_dict(cls, obj: dict) -> TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter:
"""Create an instance of TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter from a dict"""
if obj is None:
return None
if type(obj) is not dict:
return TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.parse_obj(obj)
_obj = TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.parse_obj({
"values": obj.get("values")
})
return _obj