[python] Add field as a reserved word (#18279)

* add field as a reserved word

* remove tabs

* update
This commit is contained in:
William Cheng
2024-04-03 16:43:51 +08:00
committed by GitHub
parent 88204b247a
commit 2a39b29684
34 changed files with 692 additions and 0 deletions

View File

@@ -43,6 +43,7 @@ docs/EnumTest.md
docs/FakeApi.md
docs/FakeClassnameTags123Api.md
docs/Feeding.md
docs/Field.md
docs/File.md
docs/FileSchemaTestClass.md
docs/FirstRef.md
@@ -156,6 +157,7 @@ petstore_api/models/enum_string1.py
petstore_api/models/enum_string2.py
petstore_api/models/enum_test.py
petstore_api/models/feeding.py
petstore_api/models/field.py
petstore_api/models/file.py
petstore_api/models/file_schema_test_class.py
petstore_api/models/first_ref.py

View File

@@ -187,6 +187,7 @@ Class | Method | HTTP request | Description
- [EnumString2](docs/EnumString2.md)
- [EnumTest](docs/EnumTest.md)
- [Feeding](docs/Feeding.md)
- [Field](docs/Field.md)
- [File](docs/File.md)
- [FileSchemaTestClass](docs/FileSchemaTestClass.md)
- [FirstRef](docs/FirstRef.md)

View File

@@ -0,0 +1,28 @@
# Field
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**field** | **str** | | [optional]
## Example
```python
from petstore_api.models.field import Field
# TODO update the JSON string below
json = "{}"
# create an instance of Field from a JSON string
field_instance = Field.from_json(json)
# print the JSON string representation of the object
print Field.to_json()
# convert the object into a dict
field_dict = field_instance.to_dict()
# create an instance of Field from a dict
field_form_dict = field.from_dict(field_dict)
```
[[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

@@ -75,6 +75,7 @@ from petstore_api.models.enum_string1 import EnumString1
from petstore_api.models.enum_string2 import EnumString2
from petstore_api.models.enum_test import EnumTest
from petstore_api.models.feeding import Feeding
from petstore_api.models.field import Field
from petstore_api.models.file import File
from petstore_api.models.file_schema_test_class import FileSchemaTestClass
from petstore_api.models.first_ref import FirstRef

View File

@@ -50,6 +50,7 @@ from petstore_api.models.enum_string1 import EnumString1
from petstore_api.models.enum_string2 import EnumString2
from petstore_api.models.enum_test import EnumTest
from petstore_api.models.feeding import Feeding
from petstore_api.models.field import Field
from petstore_api.models.file import File
from petstore_api.models.file_schema_test_class import FileSchemaTestClass
from petstore_api.models.first_ref import FirstRef

View File

@@ -0,0 +1,71 @@
# 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: \" \\
The version of the OpenAPI document: 1.0.0
Generated by OpenAPI Generator (https://openapi-generator.tech)
Do not edit the class manually.
""" # noqa: E501
from __future__ import annotations
import pprint
import re # noqa: F401
import json
from typing import Optional
from pydantic import BaseModel, StrictStr
class Field(BaseModel):
"""
Field
"""
field: Optional[StrictStr] = None
__properties = ["field"]
class Config:
"""Pydantic configuration"""
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) -> Field:
"""Create an instance of Field 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) -> Field:
"""Create an instance of Field from a dict"""
if obj is None:
return None
if not isinstance(obj, dict):
return Field.parse_obj(obj)
_obj = Field.parse_obj({
"field": obj.get("field")
})
return _obj

View File

@@ -0,0 +1,52 @@
# 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: \" \\
The version of the OpenAPI document: 1.0.0
Generated by OpenAPI Generator (https://openapi-generator.tech)
Do not edit the class manually.
""" # noqa: E501
import unittest
import datetime
from petstore_api.models.field import Field # noqa: E501
class TestField(unittest.TestCase):
"""Field unit test stubs"""
def setUp(self):
pass
def tearDown(self):
pass
def make_instance(self, include_optional) -> Field:
"""Test Field
include_option is a boolean, when False only required
params are included, when True both required and
optional params are included """
# uncomment below to create an instance of `Field`
"""
model = Field() # noqa: E501
if include_optional:
return Field(
dummy = ''
)
else:
return Field(
)
"""
def testField(self):
"""Test Field"""
# inst_req_only = self.make_instance(include_optional=False)
# inst_req_and_optional = self.make_instance(include_optional=True)
if __name__ == '__main__':
unittest.main()