[Python] refactor pydantic model methods into abstract python codegen (#16279)

* refactor methods from python client to abstract python codegen

* refactor regular expression methods

* more refactoring

* more refactoring
This commit is contained in:
William Cheng 2023-08-08 20:42:43 +08:00 committed by GitHub
parent f3b930c48c
commit 3d064c6115
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 1201 additions and 1197 deletions

View File

@ -321,12 +321,6 @@ public class PythonFastAPIServerCodegen extends AbstractPythonCodegen {
System.out.println("################################################################################");
}
@Override
public String toRegularExpression(String pattern) {
String regex = super.toRegularExpression(pattern);
return StringUtils.substring(regex, 1, -1);
}
@Override
public String generatorLanguageVersion() { return "3.7"; };
}

View File

@ -138,7 +138,7 @@ async def get_user_by_name(
response_model_by_alias=True,
)
async def login_user(
username: str = Query(None, description="The user name for login", regex=r"^[a-zA-Z0-9]+[a-zA-Z0-9\.\-_]*[a-zA-Z0-9]+$"),
username: str = Query(None, description="The user name for login", regex=r"/^[a-zA-Z0-9]+[a-zA-Z0-9\.\-_]*[a-zA-Z0-9]+$/"),
password: str = Query(None, description="The password for login in clear text"),
) -> str:
""""""

View File

@ -25,7 +25,7 @@ class Category(BaseModel):
@validator("name")
def name_pattern(cls, value):
assert value is not None and re.match(r"^[a-zA-Z0-9]+[a-zA-Z0-9\.\-_]*[a-zA-Z0-9]+$", value)
assert value is not None and re.match(r"/^[a-zA-Z0-9]+[a-zA-Z0-9\.\-_]*[a-zA-Z0-9]+$/", value)
return value
Category.update_forward_refs()